本文整理匯總了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();
}
}
示例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;
}
示例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;
}
示例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));
}
}
}
示例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!");
}
示例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");
}
示例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;
}
示例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;
}
示例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();
}
示例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;
}
示例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();
}
示例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)));
}
示例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");
}
示例14: invalidate
import cpw.mods.fml.common.Optional; //導入方法依賴的package包/類
@Optional.Method(modid = "OpenComputers")
@Override
public void invalidate() {
super.invalidate();
if (node != null)
node.remove();
}
示例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;
}