当前位置: 首页>>代码示例>>Java>>正文


Java Optional类代码示例

本文整理汇总了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();
    }
}
 
开发者ID:4Space,项目名称:4Space-5,代码行数:21,代码来源:VersionUtil.java

示例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);
}
 
开发者ID:OreCruncher,项目名称:ThermalRecycling,代码行数:25,代码来源:WailaHandler.java

示例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;
}
 
开发者ID:spacechase0,项目名称:ComponentEquipment,代码行数:22,代码来源:EquipmentItem.java

示例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;
}
 
开发者ID:spacechase0,项目名称:ComponentEquipment,代码行数:21,代码来源:EquipmentItem.java

示例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;
}
 
开发者ID:spacechase0,项目名称:ComponentEquipment,代码行数:17,代码来源:EquipmentItem.java

示例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;
}
 
开发者ID:spacechase0,项目名称:ComponentEquipment,代码行数:19,代码来源:EquipmentItem.java

示例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;
}
 
开发者ID:romelo333,项目名称:notenoughwands,代码行数:20,代码来源:GenericWand.java

示例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;
}
 
开发者ID:romelo333,项目名称:notenoughwands,代码行数:20,代码来源:GenericWand.java

示例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;
	}
}
 
开发者ID:NPException,项目名称:Dimensional-Pockets,代码行数:26,代码来源:TileDimensionalPocket.java

示例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});
}
 
开发者ID:BigRenegade,项目名称:OpenFrames,代码行数:26,代码来源:CarriageControllerEntity.java

示例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];
}
 
开发者ID:Quetzi,项目名称:BluePower,代码行数:27,代码来源:TileSortron.java

示例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());

}
 
开发者ID:MagiciansArtificeTeam,项目名称:Magicians-Artifice,代码行数:26,代码来源:TiConCompat.java

示例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));
        }
    }
}
 
开发者ID:AnDwHaT5,项目名称:PixelUtilities,代码行数:19,代码来源:CustomDrops.java

示例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!");
}
 
开发者ID:XFactHD,项目名称:RFUtilities,代码行数:16,代码来源:TileEntityTransistor.java

示例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");
}
 
开发者ID:XFactHD,项目名称:RFUtilities,代码行数:11,代码来源:TileEntityTransistor.java


注:本文中的cpw.mods.fml.common.Optional类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。