本文整理汇总了Java中cpw.mods.fml.common.Optional类的典型用法代码示例。如果您正苦于以下问题:Java Optional类的具体用法?Java Optional怎么用?Java Optional使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Optional类属于cpw.mods.fml.common包,在下文中一共展示了Optional类的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: callbackRegister
import cpw.mods.fml.common.Optional; //导入依赖的package包/类
@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);
}
示例3: receiveEnergy
import cpw.mods.fml.common.Optional; //导入依赖的package包/类
@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;
}
示例4: extractEnergy
import cpw.mods.fml.common.Optional; //导入依赖的package包/类
@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;
}
示例5: getMaxEnergyStored
import cpw.mods.fml.common.Optional; //导入依赖的package包/类
@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;
}
示例6: getMaxEnergyRate
import cpw.mods.fml.common.Optional; //导入依赖的package包/类
@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;
}
示例7: 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;
}
示例8: 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;
}
示例9: sidedNode
import cpw.mods.fml.common.Optional; //导入依赖的package包/类
@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;
}
}
示例10: callMethod
import cpw.mods.fml.common.Optional; //导入依赖的package包/类
@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});
}
示例11: callMethod
import cpw.mods.fml.common.Optional; //导入依赖的package包/类
@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];
}
示例12: registerStuff
import cpw.mods.fml.common.Optional; //导入依赖的package包/类
@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());
}
示例13: 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));
}
}
}
示例14: 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!");
}
示例15: 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");
}