當前位置: 首頁>>代碼示例>>Java>>正文


Java Optional.Method方法代碼示例

本文整理匯總了Java中cpw.mods.fml.common.Optional.Method方法的典型用法代碼示例。如果您正苦於以下問題:Java Optional.Method方法的具體用法?Java Optional.Method怎麽用?Java Optional.Method使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在cpw.mods.fml.common.Optional的用法示例。


在下文中一共展示了Optional.Method方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setSlimelingOwner

import cpw.mods.fml.common.Optional; //導入方法依賴的package包/類
@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();
    }
}
 
開發者ID:4Space,項目名稱:4Space-5,代碼行數:21,代碼來源:VersionUtil.java

示例2: receiveEnergy

import cpw.mods.fml.common.Optional; //導入方法依賴的package包/類
@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;
}
 
開發者ID:romelo333,項目名稱:notenoughwands,代碼行數:20,代碼來源:GenericWand.java

示例3: extractEnergy

import cpw.mods.fml.common.Optional; //導入方法依賴的package包/類
@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;
}
 
開發者ID:romelo333,項目名稱:notenoughwands,代碼行數:20,代碼來源:GenericWand.java

示例4: eventFired

import cpw.mods.fml.common.Optional; //導入方法依賴的package包/類
@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));
        }
    }
}
 
開發者ID:AnDwHaT5,項目名稱:PixelUtilities,代碼行數:19,代碼來源:CustomDrops.java

示例5: invoke

import cpw.mods.fml.common.Optional; //導入方法依賴的package包/類
@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!");
}
 
開發者ID:XFactHD,項目名稱:RFUtilities,代碼行數:16,代碼來源:TileEntityTransistor.java

示例6: invoke

import cpw.mods.fml.common.Optional; //導入方法依賴的package包/類
@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");
}
 
開發者ID:XFactHD,項目名稱:RFUtilities,代碼行數:11,代碼來源:TileEntityTransistor.java

示例7: isWrench

import cpw.mods.fml.common.Optional; //導入方法依賴的package包/類
@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;
}
 
開發者ID:Quintinity,項目名稱:MobCages,代碼行數:8,代碼來源:IntegrationTE.java

示例8: isWrench

import cpw.mods.fml.common.Optional; //導入方法依賴的package包/類
@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;
}
 
開發者ID:Quintinity,項目名稱:MobCages,代碼行數:11,代碼來源:IntegrationBuildcraft.java

示例9: doWrenchRightClick

import cpw.mods.fml.common.Optional; //導入方法依賴的package包/類
@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();
}
 
開發者ID:Quintinity,項目名稱:MobCages,代碼行數:8,代碼來源:IntegrationForestry.java

示例10: isWrench

import cpw.mods.fml.common.Optional; //導入方法依賴的package包/類
@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;
}
 
開發者ID:Quintinity,項目名稱:MobCages,代碼行數:11,代碼來源:IntegrationIC2.java

示例11: doWrenchRightClick

import cpw.mods.fml.common.Optional; //導入方法依賴的package包/類
@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();
}
 
開發者ID:Quintinity,項目名稱:MobCages,代碼行數:8,代碼來源:IntegrationIC2.java

示例12: loadConfig

import cpw.mods.fml.common.Optional; //導入方法依賴的package包/類
@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)));
}
 
開發者ID:M4thG33k,項目名稱:M4thThings,代碼行數:9,代碼來源:NEIM4thThingsConfig.java

示例13: getEnergyStored

import cpw.mods.fml.common.Optional; //導入方法依賴的package包/類
@Override
@Optional.Method(modid = "CoFHAPI")
public int getEnergyStored(ItemStack container) {
    if (container.stackTagCompound == null || !container.stackTagCompound.hasKey("Energy")) {
        return 0;
    }
    return container.stackTagCompound.getInteger("Energy");
}
 
開發者ID:romelo333,項目名稱:notenoughwands,代碼行數:9,代碼來源:GenericWand.java

示例14: invalidate

import cpw.mods.fml.common.Optional; //導入方法依賴的package包/類
@Optional.Method(modid = "OpenComputers")
@Override
public void invalidate() {
	super.invalidate();
	if (node != null)
		node.remove();
}
 
開發者ID:PC-Logix,項目名稱:OpenFM,代碼行數:8,代碼來源:TileEntitySpeaker.java

示例15: doesCartMatchFilter

import cpw.mods.fml.common.Optional; //導入方法依賴的package包/類
@Optional.Method(modid = "RailcraftAPI|carts")
public boolean doesCartMatchFilter(ItemStack stack, EntityMinecart cart) {
	ItemStack CartStack = new ItemStack(BaseModule.EnderChestCart, 1, 0);
	if (cart instanceof EntityEnderChestCart && stack.getItem() == CartStack.getItem()) {
		return true;
	}
	return false;
}
 
開發者ID:ScottDTA,項目名稱:ExtraCarts-1.7.10,代碼行數:9,代碼來源:EntityEnderChestCart.java


注:本文中的cpw.mods.fml.common.Optional.Method方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。