Java 类cpw.mods.fml.common.Optional.Method 实例源码

项目:enhancedportals    文件:TileDialingDevice.java   
@Override
@Method(modid = ComputerCraft.MOD_ID)
public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws Exception {
    if (method == 0)
        return comp_Dial(arguments);
    else if (method == 1)
        getPortalController().deconstructConnection();
    else if (method == 2)
        return comp_DialStored(arguments);
    else if (method == 3)
        return comp_GetStoredName(arguments);
    else if (method == 4)
        return comp_GetStoredGlyph(arguments);
    else if (method == 5)
        return new Object[] { glyphList.size() };

    return null;
}
项目:vsminecraft    文件:TileEntityElectricBlock.java   
@Override
@Method(modid = "CoFHCore")
public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate)
{
    if(getConsumingSides().contains(from))
    {
        double toAdd = (int)Math.min(getMaxEnergy()-getEnergy(), maxReceive* general.FROM_TE);

        if(!simulate)
        {
            setEnergy(getEnergy() + toAdd);
        }

        return (int)Math.round(toAdd* general.TO_TE);
    }

    return 0;
}
项目:vsminecraft    文件:TileEntityInductionPort.java   
@Method(modid = "IC2")
public void register()
{
    if(!worldObj.isRemote)
    {
        TileEntity registered = EnergyNet.instance.getTileEntity(worldObj, xCoord, yCoord, zCoord);

        if(registered != this)
        {
            if(registered instanceof IEnergyTile)
            {
                MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent((IEnergyTile)registered));
            }
            else if(registered == null)
            {
                MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this));
                ic2Registered = true;
            }
        }
    }
}
项目:vsminecraft    文件:WailaDataProvider.java   
@Override
@Method(modid = "Waila")
public List<String> getWailaHead(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config)
{
    TileEntity tile = accessor.getTileEntity();

    if(tile instanceof TileEntityInductionCell)
    {
        currenttip.set(0, EnumColor.WHITE + ((TileEntityInductionCell)tile).getInventoryName());
    }
    else if(tile instanceof TileEntityInductionProvider)
    {
        currenttip.set(0, EnumColor.WHITE + ((TileEntityInductionProvider)tile).getInventoryName());
    }
    else if(tile instanceof TileEntityFactory)
    {
        currenttip.set(0, EnumColor.WHITE + ((TileEntityFactory)tile).getInventoryName());
    }

    return currenttip;
}
项目:vsminecraft    文件:TileEntityElectricMachine.java   
@Override
@Method(modid = "ComputerCraft")
public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws LuaException, InterruptedException
{
    switch(method)
    {
        case 0:
            return new Object[] {getEnergy()};
        case 1:
            return new Object[] {operatingTicks};
        case 2:
            return new Object[] {isActive};
        case 3:
            return new Object[] {facing};
        case 4:
            return new Object[] {canOperate(getRecipe())};
        case 5:
            return new Object[] {getMaxEnergy()};
        case 6:
            return new Object[] {getMaxEnergy()-getEnergy()};
        default:
            Mekanism.logger.error("Attempted to call unknown method with computer ID " + computer.getID());
            return new Object[] {"Unknown command."};
    }
}
项目:vsminecraft    文件:TileEntityBioGenerator.java   
@Override
@Method(modid = "ComputerCraft")
public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws LuaException, InterruptedException
{
    switch(method)
    {
        case 0:
            return new Object[] {electricityStored};
        case 1:
            return new Object[] {output};
        case 2:
            return new Object[] {BASE_MAX_ENERGY};
        case 3:
            return new Object[] {(BASE_MAX_ENERGY -electricityStored)};
        case 4:
            return new Object[] {bioFuelSlot.fluidStored};
        case 5:
            return new Object[] {bioFuelSlot.MAX_FLUID-bioFuelSlot.fluidStored};
        default:
            Mekanism.logger.error("Attempted to call unknown method with computer ID " + computer.getID());
            return null;
    }
}
项目:vsminecraft    文件:TileEntityAdvancedBoundingBlock.java   
@Override
@Method(modid = "IC2")
public boolean acceptsEnergyFrom(TileEntity emitter, ForgeDirection direction)
{
    if(getInv() == null)
    {
        return false;
    }

    return getInv().acceptsEnergyFrom(emitter, direction);
}
项目:vsminecraft    文件:TileEntityAdvancedBoundingBlock.java   
@Override
@Method(modid = "ComputerCraft")
public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws LuaException, InterruptedException
{
    if(getInv() == null)
    {
        return new Object[] {};
    }

    return getInv().callMethod(computer, context, method, arguments);
}
项目:vsminecraft    文件:TileEntityInductionPort.java   
@Override
@Method(modid = "IC2")
public int addEnergy(int amount)
{
    setEnergy(getEnergy() + amount*general.FROM_IC2);
    return (int)Math.round(getEnergy()*general.TO_IC2);
}
项目:vsminecraft    文件:TileEntityElectricBlock.java   
@Override
@Method(modid = "IC2")
public double injectEnergy(ForgeDirection direction, double amount, double voltage)
{
    if(Coord4D.get(this).getFromSide(direction).getTileEntity(worldObj) instanceof ITransmitterTile)
    {
        return amount;
    }

    return amount-transferEnergyToAcceptor(direction, amount*general.FROM_IC2)*general.TO_IC2;
}
项目:enhancedportals    文件:TileTransferItem.java   
@Override
@Method(modid = ComputerCraft.MOD_ID)
public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws Exception {
    if (method == 0)
        return new Object[] { stack != null ? Item.getIdFromItem(stack.getItem()) : 0 };
    else if (method == 1)
        return new Object[] { stack != null ? stack.stackSize : 0 };
    else if (method == 2)
        return new Object[] { stack != null };
    else if (method == 3)
        return new Object[] { isSending };

    return null;
}
项目:vsminecraft    文件:TileEntityAdvancedBoundingBlock.java   
@Override
@Method(modid = "ComputerCraft")
public String getType()
{
    if(getInv() == null)
    {
        return null;
    }

    return getInv().getType();
}
项目:vsminecraft    文件:TileEntityAdvancedBoundingBlock.java   
@Override
@Method(modid = "CoFHCore")
public boolean canConnectEnergy(ForgeDirection from)
{
    if(getInv() == null)
    {
        return false;
    }

    return getInv().canConnectEnergy(from);
}
项目:vsminecraft    文件:BlockEnergyCube.java   
@Override
@Method(modid = "ComputerCraft")
public IPeripheral getPeripheral(World world, int x, int y, int z, int side)
{
    TileEntity te = world.getTileEntity(x, y, z);

    if(te != null && te instanceof IPeripheral)
    {
        return (IPeripheral)te;
    }

    return null;
}
项目:vsminecraft    文件:TileEntityAdvancedBoundingBlock.java   
@Override
@Method(modid = "ComputerCraft")
public void detach(IComputerAccess computer)
{
    if(getInv() == null)
    {
        return;
    }

    getInv().detach(computer);
}
项目:vsminecraft    文件:TileEntityAdvancedBoundingBlock.java   
@Override
@Method(modid = "IC2")
public double injectEnergy(ForgeDirection directionFrom, double amount, double voltage)
{
    if(getInv() == null)
    {
        return amount;
    }

    return getInv().injectEnergy(directionFrom, amount, voltage);
}
项目:enhancedportals    文件:BlockFrame.java   
@Override
@Method(modid = ComputerCraft.MOD_ID)
public IPeripheral getPeripheral(World world, int x, int y, int z, int side) {
    TileEntity t = world.getTileEntity(x, y, z);

    if (t != null && (t instanceof TileController || t instanceof TileNetworkInterface || t instanceof TileDialingDevice || t instanceof TileTransferEnergy || t instanceof TileTransferFluid || t instanceof TileTransferItem))
        return (IPeripheral) t;

    return null;
}
项目:vsminecraft    文件:OreDictManager.java   
@Method(modid = "IC2")
public static void addIC2BronzeRecipe()
{
    try {
        Recipes.macerator.addRecipe(new RecipeInputOreDict("ingotBronze"), null, StackUtils.size(OreDictionary.getOres("dustBronze").get(0), 1));
    } catch(Exception e) {}
}
项目:vsminecraft    文件:MekanismHooks.java   
@Method(modid = "ComputerCraft")
public void loadCCPeripheralProviders()
{
    try {
        ComputerCraftAPI.registerPeripheralProvider((BlockMachine) MekanismBlocks.MachineBlock);
    } catch(Exception ex) {}
}
项目:vsminecraft    文件:BlockMachine.java   
@Override
@Method(modid = "ComputerCraft")
public IPeripheral getPeripheral(World world, int x, int y, int z, int side)
{
    TileEntity te = world.getTileEntity(x, y, z);

    if(te != null && te instanceof IPeripheral)
    {
        return (IPeripheral)te;
    }

    return null;
}
项目:vsminecraft    文件:TileEntityReactorLogicAdapter.java   
@Override
@Method(modid = "ComputerCraft")
public void detach(IComputerAccess computer) {}
项目:vsminecraft    文件:TileEntityInductionPort.java   
@Override
@Method(modid = "IC2")
public double getDemandedEnergy()
{
    return (getMaxEnergy() - getEnergy())*general.TO_IC2;
}
项目:PowerLines    文件:WailaDataProvider.java   
@Override
@Method(modid = "Waila")
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
    return currenttip;
}
项目:vsminecraft    文件:TileEntityElectricBlock.java   
@Override
@Method(modid = "IC2")
public double getOfferedEnergy()
{
    return Math.min(getEnergy(), getMaxOutput())*general.TO_IC2;
}
项目:vsminecraft    文件:TileEntityReactorLogicAdapter.java   
@Override
@Method(modid = "ComputerCraft")
public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws LuaException, InterruptedException
{
    if(getReactor() == null || !getReactor().isFormed())
    {
        return new Object[] {"Unformed."};
    }

    switch(method)
    {
        case 0:
            return new Object[] {getReactor().isBurning()};
        case 1:
            return new Object[] {getReactor().getPlasmaTemp() >= getReactor().getIgnitionTemperature(activeCooled)};
        case 2:
            return new Object[] {getReactor().getPlasmaTemp()};
        case 3:
            return new Object[] {getReactor().getMaxPlasmaTemperature(activeCooled)};
        case 4:
            return new Object[] {getReactor().getCaseTemp()};
        case 5:
            return new Object[] {getReactor().getMaxCasingTemperature(activeCooled)};
        case 6:
            return new Object[] {getReactor().getInjectionRate()};
        case 7:
            if(arguments[0] instanceof Integer)
            {
                getReactor().setInjectionRate((Integer)arguments[0]);
                return new Object[] {"Injection rate set."};
            }
            else {
                return new Object[] {"Invalid parameters."};
            }
        case 8:
            return new Object[] {(getReactor().getDeuteriumTank().getStored() >= getReactor().getInjectionRate()/2) &&
                    (getReactor().getTritiumTank().getStored() >= getReactor().getInjectionRate()/2)};
        default:
            Mekanism.logger.error("Attempted to call unknown method with computer ID " + computer.getID());
            return new Object[] {"Unknown command."};
    }
}
项目:vsminecraft    文件:TileEntityInductionCasing.java   
@Override
@Method(modid = "ComputerCraft")
public void detach(IComputerAccess computer) {}
项目:Coding    文件:EnchiridionAPI.java   
@Method(modid=REFERENCE.EAPIMODID)
@Override
public void registerRecipeHandler(IRecipeHandler handler) {
       FeatureRecipe.handlers.add(handler);
       LogHelper.info("Registered a new recipe handler: " + handler.getRecipeName());
}
项目:vsminecraft    文件:TileEntityInductionPort.java   
@Override
@Method(modid = "CoFHCore")
public int getEnergyStored(ForgeDirection from)
{
    return (int)Math.round(getEnergy()* general.TO_TE);
}
项目:enhancedportals    文件:TileDialingDevice.java   
@Override
@Method(modid = ComputerCraft.MOD_ID)
public void attach(IComputerAccess computer) {

}
项目:enhancedportals    文件:TileDialingDevice.java   
@Override
@Method(modid = ComputerCraft.MOD_ID)
public void detach(IComputerAccess computer) {

}
项目:vsminecraft    文件:ItemBlockEnergyCube.java   
@Override
@Method(modid = "IC2")
public double getMaxCharge(ItemStack itemStack)
{
    return 0;
}
项目:vsminecraft    文件:TileEntityElectricBlock.java   
@Override
@Method(modid = "IC2")
public boolean isTeleporterCompatible(ForgeDirection side)
{
    return getOutputtingSides().contains(side);
}
项目:enhancedportals    文件:TileDialingDevice.java   
@Override
@Method(modid = ComputerCraft.MOD_ID)
public boolean equals(IPeripheral other) {
    return other == this;
}
项目:vsminecraft    文件:TileEntityElectrolyticSeparator.java   
@Override
@Method(modid = "ComputerCraft")
public void attach(IComputerAccess computer) {}
项目:vsminecraft    文件:TileEntityMetallurgicInfuser.java   
@Override
@Method(modid = "ComputerCraft")
public void detach(IComputerAccess computer) {}
项目:vsminecraft    文件:TileEntityBasicBlock.java   
@Override
@Method(modid = "IC2")
public boolean wrenchCanRemove(EntityPlayer entityPlayer)
{
    return true;
}
项目:Minegate    文件:BlockStargateController.java   
@Override
@Method(modid = "Botania")
public LexiconEntry getEntry(World arg0, int arg1, int arg2, int arg3, EntityPlayer player, ItemStack item) {
    return BotaniaCompatibility.stargate;
}
项目:vsminecraft    文件:ItemFreeRunners.java   
@Override
@Method(modid = "IC2")
public IElectricItemManager getManager(ItemStack itemStack)
{
    return IC2ItemManager.getManager(this);
}
项目:enhancedportals    文件:TileDialingDevice.java   
@Override
@Method(modid = ComputerCraft.MOD_ID)
public String getType() {
    return "ep_dialling_device";
}
项目:enhancedportals    文件:TileDialingDevice.java   
@Callback(doc = "function():boolean -- Terminates any active connection.")
@Method(modid = OpenComputers.MOD_ID)
public Object[] terminate(Context context, Arguments args) {
    getPortalController().deconstructConnection();
    return new Object[] { true };
}