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


Java Optional类代码示例

本文整理汇总了Java中net.minecraftforge.fml.common.Optional的典型用法代码示例。如果您正苦于以下问题:Java Optional类的具体用法?Java Optional怎么用?Java Optional使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Optional类属于net.minecraftforge.fml.common包,在下文中一共展示了Optional类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onIGWAction

import net.minecraftforge.fml.common.Optional; //导入依赖的package包/类
@Optional.Method(modid = ModIds.IGWMOD)
private void onIGWAction() {
    int x = lastMouseX;
    int y = lastMouseY;

    IProgWidget hoveredWidget = programmerUnit.getHoveredWidget(x, y);
    if(hoveredWidget != null) {
        WikiRegistry.getWikiHooks().showWikiGui("pneumaticcraft:progwidget/" + CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, hoveredWidget.getWidgetString()));
    }

    for(IProgWidget widget : visibleSpawnWidgets) {
        if(widget != draggingWidget && x - guiLeft >= widget.getX() && y - guiTop >= widget.getY() && x - guiLeft <= widget.getX() + widget.getWidth() / 2 && y - guiTop <= widget.getY() + widget.getHeight() / 2) {
            WikiRegistry.getWikiHooks().showWikiGui("pneumaticcraft:progwidget/" + CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, widget.getWidgetString()));
        }
    }
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:17,代码来源:GuiProgrammer.java

示例2: equals

import net.minecraftforge.fml.common.Optional; //导入依赖的package包/类
@Override
@Optional.Method(modid = ModIds.COMPUTERCRAFT)
public boolean equals(IPeripheral other) {
    if (other == null) {
        return false;
    }
    if (this == other) {
        return true;
    }
    if (other instanceof TileEntity) {
        TileEntity tother = (TileEntity) other;
        return tother.getWorld().equals(getWorld()) && tother.getPos().equals(getPos());
    }

    return false;
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:17,代码来源:TileEntityDroneInterface.java

示例3: addProbeInfo

import net.minecraftforge.fml.common.Optional; //导入依赖的package包/类
@Override
@Optional.Method(modid = "theoneprobe")
public void addProbeInfo(ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data) {
    TileEntity te = world.getTileEntity(data.getPos());
    if(te instanceof IInfoForwarder){
        te = ((IInfoForwarder)te).getInfoTileEntity();
    }
    
    if (te instanceof IPneumaticMachine) {
        TOPCallback.handlePneumatic(mode, probeInfo, (IPneumaticMachine)te);
    }
    if (te instanceof IHeatExchanger) {
        TOPCallback.handleHeat(mode, probeInfo, (IHeatExchanger) te);
    }
    if (ConfigHandler.client.topShowsFluids && te != null && te.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, data.getSideHit())) {
        IFluidHandler handler = te.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, data.getSideHit());
        TOPCallback.handleFluidTanks(mode, probeInfo, handler);
    }
    if (te instanceof TileEntityBase) {
        TOPCallback.handleRedstoneMode(mode, probeInfo, (TileEntityBase) te);
    }
    if (te instanceof TileEntityPressureTube) {
        TOPCallback.handlePressureTube(mode, probeInfo, (TileEntityPressureTube) te, data.getSideHit());
    }
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:26,代码来源:BlockPneumaticCraft.java

示例4: attemptFERFTransfer

import net.minecraftforge.fml.common.Optional; //导入依赖的package包/类
@Optional.Method(modid = "redstoneflux")
private int attemptFERFTransfer(EnumFacing face, int maxTransferLeft) {
    BlockPos at = this.getPos().offset(face);
    EnumFacing accessingSide = face.getOpposite();

    int receivedEnergy = 0;
    TileEntity te = world.getTileEntity(at);
    if(te != null && !(te instanceof TileEnergyHatch)) {
        if(te instanceof cofh.redstoneflux.api.IEnergyReceiver && ((IEnergyReceiver) te).canConnectEnergy(accessingSide)) {
            receivedEnergy = ((IEnergyReceiver) te).receiveEnergy(accessingSide, maxTransferLeft, false);
        }
        if(receivedEnergy <= 0 && te instanceof IEnergyStorage) {
            receivedEnergy = ((IEnergyStorage) te).receiveEnergy(maxTransferLeft, false);
        }
        if(receivedEnergy <= 0 && te.hasCapability(CapabilityEnergy.ENERGY, accessingSide)) {
            net.minecraftforge.energy.IEnergyStorage ce = te.getCapability(CapabilityEnergy.ENERGY, accessingSide);
            if(ce != null && ce.canReceive()) {
                receivedEnergy = ce.receiveEnergy(maxTransferLeft, false);
            }
        }
    }
    return receivedEnergy;
}
 
开发者ID:HellFirePvP,项目名称:ModularMachinery,代码行数:24,代码来源:TileEnergyOutputHatch.java

示例5: checkForInterface

import net.minecraftforge.fml.common.Optional; //导入依赖的package包/类
@Optional.Method(modid = ModIds.AE2)
private boolean checkForInterface(){
    if(isPlacedOnInterface()) {
        TileEntity te = getTileEntity();
        if(te instanceof IGridHost) {
            if(((IGridHost)te).getGridNode(null) == null) return true;
            if(getGridNode(null) == null) return true;
            try {
                AEApi.instance().grid().createGridConnection(((IGridHost)te).getGridNode(null), getGridNode(null));
            } catch(FailedConnectionException e) {
                Log.error("Couldn't connect to an ME Interface!");
                e.printStackTrace();
            }
        }
    }
    return false;
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:18,代码来源:SemiBlockRequester.java

示例6: onRequestChange

import net.minecraftforge.fml.common.Optional; //导入依赖的package包/类
@Override
@Optional.Method(modid = ModIds.AE2)
public void onRequestChange(ICraftingGrid grid, IAEItemStack aeStack){
    craftingGrid = grid;
    int freeSlot = -1;
    for(int i = 0; i < getFilters().getSlots(); i++) {
        ItemStack s = getFilters().getStackInSlot(i);
        if(!s.isEmpty()) {
            if(aeStack.isSameType(s)) {
                s.setCount( (int) aeStack.getStackSize() );
                return;
            }
        } else if(freeSlot == -1) {
            freeSlot = i;
        }
    }
    if(freeSlot >= 0) {
        getFilters().setStackInSlot(freeSlot, aeStack.createItemStack());
    }
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:21,代码来源:SemiBlockRequester.java

示例7: onStackChange

import net.minecraftforge.fml.common.Optional; //导入依赖的package包/类
@Override
@Optional.Method(modid = ModIds.AE2)
public void onStackChange(IItemList arg0, IAEStack arg1, IAEStack arg2, IActionSource arg3, IStorageChannel arg4){
    if(craftingGrid != null) {
        ICraftingGrid grid = (ICraftingGrid)craftingGrid;
        for(int i = 0; i < getFilters().getSlots(); i++) {
            ItemStack s = getFilters().getStackInSlot(i);
            if(!s.isEmpty()) {
                if(!grid.isRequesting(AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createStack(s))) {
                    getFilters().setStackInSlot(i, ItemStack.EMPTY);
                    notifyNetworkOfCraftingChange();
                }
            }
        }
    }
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:17,代码来源:SemiBlockRequester.java

示例8: onArmorTick

import net.minecraftforge.fml.common.Optional; //导入依赖的package包/类
@Optional.Method(modid = Compats.IC2)
@Override
public void onArmorTick(World world, EntityPlayer player, ItemStack stack)
{
	boolean shouldUpdate = false;
	
	// If we wear some air mask on head.
	if (this.isAirMask && this.armorType == EntityEquipmentSlot.HEAD)
	{
		// Default max value is 300
		
		if ((player.getAir() <= minAirToStartRefil) && (player.inventory.hasItemStack(ItemsCG.ic2AirCell)))
		{
			consumeItemFromInventory(player, ItemsCG.ic2AirCell);
	        player.inventory.addItemStackToInventory(new ItemStack(ItemsCG.ic2EmptyCell.getItem()));
	        player.setAir(300);
	        shouldUpdate = true;
		}
	}
	
	// If we have changed inventory contents then we should sync it on client.
	if (shouldUpdate) {
		player.inventoryContainer.detectAndSendChanges();
	}
}
 
开发者ID:TwilightWingsStudio,项目名称:CompositeGear,代码行数:26,代码来源:ItemCGArmor.java

示例9: invoke

import net.minecraftforge.fml.common.Optional; //导入依赖的package包/类
@Override
@Optional.Method(modid = ModIds.OPEN_COMPUTERS)
public Object[] invoke(String method, Context context, Arguments args) throws Exception {
    if ("greet".equals(method)) return new Object[]{String.format("Hello, %s!", args.checkString(0))};
    for (ILuaMethod m : luaMethods) {
        if (m.getMethodName().equals(method)) {
            return m.call(args.toArray());
        }
    }
    throw new IllegalArgumentException("Can't invoke method with name \"" + method + "\". not registered");
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:12,代码来源:TileEntityDroneInterface.java

示例10: callMethod

import net.minecraftforge.fml.common.Optional; //导入依赖的package包/类
@Override
@Optional.Method(modid = ModIds.COMPUTERCRAFT)
public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws LuaException {
    try {
        return luaMethods.get(method).call(arguments);
    } catch (Exception e) {
        throw new LuaException(e.getMessage());
    }
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:10,代码来源:TileEntityDroneInterface.java

示例11: getPeripheral

import net.minecraftforge.fml.common.Optional; //导入依赖的package包/类
/**
 * Produce an peripheral implementation from a block location.
 *
 * @return a peripheral, or null if there is not a peripheral here you'd like to handle.
 * @see dan200.computercraft.api.ComputerCraftAPI#registerPeripheralProvider(IPeripheralProvider)
 */
@Override
@Optional.Method(modid = ModIds.COMPUTERCRAFT)
public IPeripheral getPeripheral(World world, BlockPos pos, EnumFacing side) {
    TileEntity te = world.getTileEntity(pos);
    return te instanceof IPeripheral ? (IPeripheral) te : null;
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:13,代码来源:BlockPneumaticCraft.java

示例12: addProbeInfo

import net.minecraftforge.fml.common.Optional; //导入依赖的package包/类
@Override
@Optional.Method(modid = "theoneprobe")
public void addProbeInfo(ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data) {
    super.addProbeInfo(mode, probeInfo, player, world, blockState, data);

    IBlockState camo = getCamoState(world, data.getPos());
    if (camo != null) {
        TOPCallback.handleCamo(mode, probeInfo, camo);
    }
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:11,代码来源:BlockPneumaticCraftCamo.java

示例13: callMethod

import net.minecraftforge.fml.common.Optional; //导入依赖的package包/类
@Override
@Optional.Method(modid = ModIds.COMPUTERCRAFT)
public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws LuaException, InterruptedException {
    try {
        return luaMethods.get(method).call(arguments);
    } catch (Exception e) {
        throw new LuaException(e.getMessage());
    }
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:10,代码来源:TileEntityBase.java

示例14: notifyComputers

import net.minecraftforge.fml.common.Optional; //导入依赖的package包/类
/**
 * Called on a event sensor
 *
 * @param arguments
 */
@Optional.Method(modid = ModIds.COMPUTERCRAFT)
private void notifyComputers(Object... arguments) {
    for(IComputerAccess computer : attachedComputers) {
        computer.queueEvent(getType(), arguments);
    }
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:12,代码来源:TileEntityUniversalSensor.java

示例15: handleGUIButtonPress

import net.minecraftforge.fml.common.Optional; //导入依赖的package包/类
@Override
@Optional.Method(modid = ModIds.AE2)
public void handleGUIButtonPress(int guiID, EntityPlayer player){
    if(guiID == 1) {
        aeMode = !aeMode;
        needToCheckForInterface = aeMode;
        if(!aeMode && gridNode != null) {
            disconnectFromInterface();
        }
    }
    super.handleGUIButtonPress(guiID, player);
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:13,代码来源:SemiBlockRequester.java


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