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

项目:4Space-5    文件:VersionUtil.java   
@Optional.Method(modid = Constants.MOD_ID_PLANETS)
public static void setSlimelingOwner(EntitySlimeling slimeling, String ownerName)
{
    try
    {
        Method m = (Method) reflectionCache.get(0);

        if (m == null)
        {
            m = slimeling.getClass().getSuperclass().getMethod(getNameDynamic(KEY_METHOD_SET_OWNER), new Class[] { String.class });
            reflectionCache.put(0, m);
        }

        m.invoke(slimeling, ownerName);
    }
    catch (Throwable t)
    {
        t.printStackTrace();
    }
}
项目:ThermalRecycling    文件:WailaHandler.java   
@Optional.Method(modid = "Waila")
public static void callbackRegister(final IWailaRegistrar register) {

    ModLog.info("Registering Waila handler...");
    final WailaHandler instance = new WailaHandler();

    switch(ModOptions.getWailaDataLocation()) {
    case 0:
        register.registerHeadProvider(instance, Block.class);
        break;
    case 1:
    default:
        register.registerBodyProvider(instance, Block.class);
        break;
    case 2:
        register.registerTailProvider(instance, Block.class);
        break;
    }

    register.registerStackProvider(instance, MachineVendingTop.class);

    // Options
    register.addConfig(ThermalRecycling.MOD_NAME, OPTION_REVEAL_ON_SNEAKING, false);
}
项目:ComponentEquipment    文件:EquipmentItem.java   
@Optional.Method( modid = "CoFHCore" )
@Override
public int receiveEnergy( ItemStack stack, int maxReceive, boolean simulate )
{
    if ( stack.getTagCompound() == null )
    {
        return 0;
    }

    int stored = getEnergyStored( stack );
    int max = getMaxEnergyStored( stack );
    int rate = getMaxEnergyRate( stack );

    int toReceive = Math.min( max - stored, Math.min( rate, maxReceive ) );
    if ( !simulate && toReceive > 0 )
    {
        setEnergyStored( stack, stored + toReceive );
    }

    return toReceive;
}
项目:ComponentEquipment    文件:EquipmentItem.java   
@Optional.Method( modid = "CoFHCore" )
@Override
public int extractEnergy( ItemStack stack, int maxExtract, boolean simulate )
{
    if ( stack.getTagCompound() == null )
    {
        return 0;
    }

    int stored = getEnergyStored( stack );
    int rate = getMaxEnergyRate( stack );

    int toSend = Math.min( stored, Math.min( rate, maxExtract ) );
    if ( !simulate && toSend > 0 )
    {
        setEnergyStored( stack, stored - toSend );
    }

    return toSend;
}
项目:ComponentEquipment    文件:EquipmentItem.java   
@Optional.Method( modid = "CoFHCore" )
@Override
public int getMaxEnergyStored( ItemStack stack )
{
    int level = equipment.getModifierLevel( stack, "fluxEnergy" );
    switch ( level )
    {
        case 1: return 16000;
        case 2: return 80000;
        case 3: return 400000;
        case 4: return 2000000;
        case 5: return 10000000;
    }

    return 0;
}
项目:ComponentEquipment    文件:EquipmentItem.java   
@Optional.Method( modid = "CoFHCore" )
//@Override
public int getMaxEnergyRate( ItemStack stack )
{
    if ( ignoreEnergyRate ) return Integer.MAX_VALUE;

    int level = equipment.getModifierLevel( stack, "fluxEnergy" );
    switch ( level )
    {
        case 1: return 20;
        case 2: return 20;
        case 3: return 100;
        case 4: return 500;
        case 5: return 2500;
    }

    return 0;
}
项目:notenoughwands    文件:GenericWand.java   
@Override
@Optional.Method(modid = "CoFHAPI")
public int extractEnergy(ItemStack container, int maxExtract, boolean simulate) {
    if (maxrf <= 0) {
        return 0;
    }

    if (container.stackTagCompound == null || !container.stackTagCompound.hasKey("Energy")) {
        return 0;
    }
    int energy = container.stackTagCompound.getInteger("Energy");
    int energyExtracted = Math.min(energy, Math.min(this.needsrf, maxExtract));

    if (!simulate) {
        energy -= energyExtracted;
        container.stackTagCompound.setInteger("Energy", energy);
    }
    return energyExtracted;
}
项目:notenoughwands    文件:GenericWand.java   
@Override
@Optional.Method(modid = "CoFHAPI")
public int receiveEnergy(ItemStack container, int maxReceive, boolean simulate) {
    if (maxrf <= 0) {
        return 0;
    }

    if (container.stackTagCompound == null) {
        container.stackTagCompound = new NBTTagCompound();
    }
    int energy = container.stackTagCompound.getInteger("Energy");
    int energyReceived = Math.min(maxrf - energy, Math.min(this.maxrf, maxReceive));

    if (!simulate) {
        energy += energyReceived;
        container.stackTagCompound.setInteger("Energy", energy);
    }
    return energyReceived;
}
项目:Dimensional-Pockets    文件:TileDimensionalPocket.java   
@Optional.Method(modid = "OpenComputers")
@Override
public Node sidedNode(ForgeDirection side) {
    if (worldObj.isRemote) {
        return null;
    }

    Pocket p = getPocket();
    if (p == null) {
        return null;
    }

    switch (p.getFlowState(side)) {
        case ENERGY:
            TileEntity te = getFrameConnectorNeighborTileEntity(side);
            if (te instanceof SidedEnvironment) {
                return ((SidedEnvironment) te).sidedNode(side);
            } else if (te instanceof Environment) {
                return ((Environment) te).node();
            }
            return null;
        default:
            return null;
    }
}
项目:OpenFrames    文件:CarriageControllerEntity.java   
@Optional.Method(modid = "ComputerCraft")
@Override
public Object[] callMethod(IComputerAccess Computer, ILuaContext LuaContext,
                           int MethodIndex, Object[] Arguments) throws Exception {
    callMethod(MethodIndex, Arguments);

    try {
        do {
            wait();
        }
        while (MotionDirection != null);
    } catch (Throwable Throwable) {
        throw (new Exception(Throwable));
    }

    if (Error == null) {
        return (new Object[]{true});
    }

    if (!Obstructed) {
        return (new Object[]{false, Error.getMessage()});
    }

    return (new Object[]{false, Error.getMessage(), ObstructionX, ObstructionY, ObstructionZ});
}
项目:BluePower    文件:TileSortron.java   
@Override
@Optional.Method(modid = Dependencies.COMPUTER_CRAFT)
public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws Exception {

    switch (method) {
        case 0:
            return setAcceptedCol(arguments);
        case 1:
            return getAcceptedCol(arguments);
        case 2:
            return setAcceptedItem(arguments);
        case 3:
            return getAcceptedItem(arguments);
        case 4:
            return getNumSlots(arguments);
        case 5:
            return getSlotContents(arguments);
        case 6:
            return pullFromSlot(arguments);
        case 7:
            return sort(arguments);
        case 8:
            return getStackSizeLeft(arguments);
    }
    return new Object[0];
}
项目:Magicians-Artifice    文件:TiConCompat.java   
@Optional.Method(modid = "TConstruct")
public static void registerStuff() {
    LiquidRegistry.registerTiConFluids();
    TConstructRegistry.addToolMaterial(starsteel_id, "starSteel", 5, 1200, 900, 4, 2.5F, 0, 0f, TextHelper.PURPLE, 0x7338A5);
    TConstructClientRegistry.addMaterialRenderMapping(starsteel_id, ModInfo.MODID, "starsteel", true);
    TConstructRegistry.addBowMaterial(starsteel_id, 1536, 30, 1.2f);
    TConstructRegistry.addArrowMaterial(starsteel_id, 2.25F, 0.1F, 100F);

    castArray = new ItemStack[]{new ItemStack(TinkerSmeltery.metalPattern, 1, 0), new ItemStack(TinkerSmeltery.metalPattern, 1, 1), new ItemStack(TinkerSmeltery.metalPattern, 1, 2)
            , new ItemStack(TinkerSmeltery.metalPattern, 1, 3), new ItemStack(TinkerSmeltery.metalPattern, 1, 4), new ItemStack(TinkerSmeltery.metalPattern, 1, 5), new ItemStack(TinkerSmeltery.metalPattern, 1, 6)
            , new ItemStack(TinkerSmeltery.metalPattern, 1, 7), new ItemStack(TinkerSmeltery.metalPattern, 1, 8), new ItemStack(TinkerSmeltery.metalPattern, 1, 9), new ItemStack(TinkerSmeltery.metalPattern, 1, 10)
            , new ItemStack(TinkerSmeltery.metalPattern, 1, 11), new ItemStack(TinkerSmeltery.metalPattern, 1, 12), new ItemStack(TinkerSmeltery.metalPattern, 1, 13), new ItemStack(TinkerSmeltery.metalPattern, 1, 14)
            , new ItemStack(TinkerSmeltery.metalPattern, 1, 15), new ItemStack(TinkerSmeltery.metalPattern, 1, 16), new ItemStack(TinkerSmeltery.metalPattern, 1, 17), new ItemStack(TinkerSmeltery.metalPattern, 1, 18)
            , new ItemStack(TinkerSmeltery.metalPattern, 1, 19), new ItemStack(TinkerSmeltery.metalPattern, 1, 20), new ItemStack(TinkerSmeltery.metalPattern, 1, 2), new ItemStack(TinkerSmeltery.metalPattern, 1, 21)
            , new ItemStack(TinkerSmeltery.metalPattern, 1, 22), new ItemStack(TinkerSmeltery.metalPattern, 1, 23)};

    starSteelPart = new StarSteelPart();
    addParts();
    addToolCrafting();

    addSmelteryRecipes();
    addCastingBasinRecipes(TConstructRegistry.getBasinCasting());
    addCastingTableRecipes(TConstructRegistry.getTableCasting());

}
项目:PixelUtilities    文件:CustomDrops.java   
@Optional.Method(modid = "pixelmon")
@Override
public void eventFired(EventType eventType, EntityPlayer entityPlayer, Object... objects) {
    if (!pixelConfig.coinDrops) {
        return;
    }

    if(eventType == EventType.BeatWildPokemon) {
        int doDrop = (int) (Math.random() * (pixelConfig.coinDropRate * 25));
        if(doDrop < 25 && doDrop != 10) {
            int amount = random.nextInt(2) + 1;
            entityPlayer.inventory.addItemStackToInventory(new ItemStack(PixelUtilitysItems.PokeCoin1Item, amount));
        }
        if(doDrop == 10) {
            entityPlayer.inventory.addItemStackToInventory(new ItemStack(PixelUtilitysItems.PokeCoin10Item, 1));
        }
    }
}
项目:RFUtilities    文件:TileEntityTransistor.java   
@Optional.Method(modid = "OpenComputers")
@Override
public Object[] invoke(String method, Context context, Arguments arguments) throws Exception
{
    if (("setActive".equals(method) && arguments.count() == 1 && arguments.isBoolean(0)) || ("setMode".equals(method) && arguments.count() == 1 && arguments.isString(0)) || ("getActive".equals(method) && arguments.count() == 0) || ("getMode".equals(method) && arguments.count() == 0))
    {
        Object[] result = call(method, arguments.checkAny(0));
        if (result[0] != null && result[0].equals("Throw!"))
        {
            throw new NoSuchMethodException("Wrong argument!");
        }
        return result;
    }
    throw new NoSuchMethodException("Wrong argument!");
}
项目:RFUtilities    文件:TileEntityTransistor.java   
@Optional.Method(modid = "OpenComputers")
@Override
public Object[] invoke(String method, Context context, Arguments arguments) throws Exception
{
    if (("setActive".equals(method) && arguments.count() == 1 && arguments.isBoolean(0)) || "getActive".equals(method))
    {
        return call(method, arguments.checkBoolean(0));
    }
    throw new Exception("Wrong argument");
}
项目:MobCages    文件:IntegrationTE.java   
@Override
@Optional.Method(modid = "ThermalExpansion")
public boolean isWrench(ItemStack itemstack, EntityPlayer player, int x, int y, int z) 
{
    Item item = itemstack.getItem();
    return item instanceof ItemWrench || item instanceof ItemWrenchBattle;
}
项目:MobCages    文件:IntegrationBuildcraft.java   
@Override
@Optional.Method(modid = "BuildCraft|Core")
public boolean isWrench(ItemStack itemstack, EntityPlayer player, int x, int y, int z) 
{
    if (itemstack.getItem() instanceof IToolWrench) {
        IToolWrench wrench = (IToolWrench)itemstack.getItem();
        return wrench.canWrench(player, x, y, z);
    }
    return false;
}
项目:MobCages    文件:IntegrationForestry.java   
@Override
@Optional.Method(modid = "Forestry")
public void doWrenchRightClick(ItemStack itemstack, EntityPlayer player, int x, int y, int z) 
{
    ((ItemWrench)itemstack.getItem()).wrenchUsed(player, x, y, z);
    player.swingItem();
}
项目:MobCages    文件:IntegrationIC2.java   
@Override
@Optional.Method(modid = "IC2")
public boolean isWrench(ItemStack itemstack, EntityPlayer player, int x, int y, int z) 
{
    Item item = itemstack.getItem();
    if (item instanceof ItemToolWrench) {
        return ((ItemToolWrench)item).canTakeDamage(itemstack, 1);
    }
    return false;
}
项目:MobCages    文件:IntegrationIC2.java   
@Override
@Optional.Method(modid = "IC2")
public void doWrenchRightClick(ItemStack itemstack, EntityPlayer player, int x, int y, int z) 
{
    ((ItemToolWrench)itemstack.getItem()).damage(itemstack, 1, player);
    player.swingItem();
}
项目:MagicBees    文件:ItemThaumiumGrafter.java   
/**
 * Return whether this item is repairable in an anvil.
 */
@Optional.Method(modid = ThaumcraftHelper.Name)
public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack)
{
    return OreDictionary.itemMatches(ThaumcraftApi.toolMatThaumium.getRepairItemStack(), par2ItemStack, true)
            || super.getIsRepairable(par1ItemStack, par2ItemStack);
}
项目:MagicBees    文件:ItemThaumiumScoop.java   
/**
 * Return whether this item is repairable in an anvil.
 */
@Optional.Method(modid = ThaumcraftHelper.Name)
public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack)
{
    return OreDictionary.itemMatches(ThaumcraftApi.toolMatThaumium.getRepairItemStack(), par2ItemStack, true)
            || super.getIsRepairable(par1ItemStack, par2ItemStack);
}
项目:OpenFM    文件:BlockRadio.java   
@Optional.Method(modid = "ComputerCraft")
@Override
public IPeripheral getPeripheral(World world, int x, int y, int z, int side) {
    TileEntity te = world.getTileEntity(x, y, z);

    if(te instanceof TileEntityRadio)
        return (IPeripheral)te;

    return null;
}
项目:OpenFM    文件:TileEntitySpeaker.java   
@Optional.Method(modid = "OpenComputers")
@Override
public void onChunkUnload() {
    super.onChunkUnload();
    if (node != null)
        node.remove();
}
项目:OpenFM    文件:TileEntitySpeaker.java   
@Optional.Method(modid = "OpenComputers")
@Override
public void invalidate() {
    super.invalidate();
    if (node != null)
        node.remove();
}
项目:OpenFM    文件:TileEntitySpeaker.java   
@Optional.Method(modid = "OpenComputers")
@Override
public void readFromNBT(NBTTagCompound nbt) {
    super.readFromNBT(nbt);
    if (node != null && node.host() == this) {
        node.load(nbt.getCompoundTag("oc:node"));
    }
}
项目:OpenFM    文件:TileEntitySpeaker.java   
@Optional.Method(modid = "OpenComputers")
@Override
public void writeToNBT(NBTTagCompound nbt) {
    super.writeToNBT(nbt);
    if (node != null && node.host() == this) {
        final NBTTagCompound nodeNbt = new NBTTagCompound();
        node.save(nodeNbt);
        nbt.setTag("oc:node", nodeNbt);
    }
}
项目:OpenFM    文件:TileEntitySpeaker.java   
@Optional.Method(modid = "OpenComputers")
@Override
public void updateEntity() {
    super.updateEntity();
    if (node != null && node.network() == null) {
        Network.joinOrCreateNetwork(this);
    }
}
项目:OpenFM    文件:TileEntityRadio.java   
@Override
@Optional.Method(modid = "OpenComputers")
public Object[] invoke(final String method, final Context context, final Arguments args) throws Exception {
    final Object[] arguments = new Object[args.count()];
    for (int i = 0; i < args.count(); ++i) {
        arguments[i] = args.checkAny(i);
    }
    final Integer methodId = methodIds.get(method);
    if (methodId == null) {
        throw new NoSuchMethodError();
    }
    return callMethod(methodId, arguments);
}
项目:OpenFM    文件:TileEntityRadio.java   
@Override
@Optional.Method(modid = "ComputerCraft")
public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws LuaException {
    try {
        return callMethod(method, arguments);
    } catch(Exception e) {
        // Rethrow errors as LuaExceptions for CC
        throw new LuaException(e.getMessage());
    }
}
项目:ThermalRecycling    文件:WailaHandler.java   
@Override
@Optional.Method(modid = "Waila")
public List<String> getWailaHead(final ItemStack itemStack,
        final List<String> currenttip, final IWailaDataAccessor accessor,
        final IWailaConfigHandler config) {

    return gatherText(itemStack, currenttip, accessor, config);
}
项目:ThermalRecycling    文件:WailaHandler.java   
@Override
@Optional.Method(modid = "Waila")
public List<String> getWailaBody(final ItemStack itemStack,
        final List<String> currenttip, final IWailaDataAccessor accessor,
        final IWailaConfigHandler config) {

    return gatherText(itemStack, currenttip, accessor, config);
}
项目:ThermalRecycling    文件:WailaHandler.java   
@Override
@Optional.Method(modid = "Waila")
public List<String> getWailaTail(final ItemStack itemStack,
        final List<String> currenttip, final IWailaDataAccessor accessor,
        final IWailaConfigHandler config) {

    return gatherText(itemStack, currenttip, accessor, config);
}
项目:M4thThings    文件:NEIM4thThingsConfig.java   
@Optional.Method(modid="NotEnoughItems")
@Override
public void loadConfig()
{
    LogHelper.info("Adding NEI integration");
    API.hideItem(new ItemStack(Item.getItemFromBlock(ModBlocks.blockQTComponent)));
    API.hideItem(new ItemStack(Item.getItemFromBlock(ModBlocks.blockTextureDummy)));
}
项目:PlayerInterfaceMod    文件:WailaModHelper.java   
@Optional.Method(modid = ModIDs.WAILA)
public static void register(IWailaRegistrar registrar) {
    final IWailaDataProvider tile = new TileWailaDataProvider();

    registrar.registerBodyProvider(tile, TileEntityPlayerInterface.class);
    registrar.registerNBTProvider(tile, TileEntityPlayerInterface.class);
}
项目:ComponentEquipment    文件:ArmorItem.java   
@Optional.Method( modid = "Thaumcraft" )
@Override
public boolean showNodes( ItemStack stack, EntityLivingBase player )
{
    if ( armor.getModifierLevel( stack, "seeAuraNodes" ) > 0 )
    {
        return true;
    }

    return false;
}
项目:ComponentEquipment    文件:ArmorItem.java   
@Optional.Method( modid = "Thaumcraft" )
@Override
public boolean showIngamePopups( ItemStack stack, EntityLivingBase player )
{
    if ( armor.getModifierLevel( stack, "seeAuraNodes" ) > 0 )
    {
        return true;
    }

    return false;
}
项目:ComponentEquipment    文件:ArmorItem.java   
@Optional.Method( modid = "Forestry" )
@Override
public boolean canSeePollination( EntityPlayer player, ItemStack stack, boolean doSee )
{
    if ( armor.getModifierLevel( stack, "natureVisor" ) > 0 )
    {
        return true;
    }

    return false;
}
项目:ComponentEquipment    文件:ArmorItem.java   
@Optional.Method( modid = "Forestry" )
@Override
public boolean protectPlayer( EntityPlayer player, ItemStack stack, String cause, boolean doProtect )
{
    if ( armor.getModifierLevel( stack, "beeSuit" ) > 0 )
    {
        return true;
    }

    return false;
}
项目:ComponentEquipment    文件:EquipmentItem.java   
@Optional.Method( modid = "IC2" )
@Override
public double getMaxCharge( ItemStack stack )
{
    int level = equipment.getModifierLevel( stack, "electric" );
    switch ( level )
    {
        case 1: return 10000;
        case 2: return 100000;
        case 3: return 1000000;
        case 4: return 10000000;
    }

    return 0;
}