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


Java IEnergyProvider类代码示例

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


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

示例1: otherModCanProduce

import cofh.api.energy.IEnergyProvider; //导入依赖的package包/类
/**
   * Test whether a tile can output energy using other mods' energy methods.
   * Currently restricted to IC2 and RF mods - Mekanism tiles do not provide an interface to "output" energy
   * 
   * Parameters:
   * @param tileAdj - the tile under test, it might be an energy tile from another mod
   * @param side - the energy output side for that tile which is under test
   */
public static boolean otherModCanProduce(TileEntity tileAdj, ForgeDirection side)
{
      if (tileAdj instanceof TileBaseConductor || tileAdj instanceof EnergyStorageTile)
      	return false;  //Do not try using other mods' methods to connect to GC's own tiles
      
      if (isIC2Loaded && tileAdj instanceof IEnergyEmitter)
      {
          return ((IEnergyEmitter) tileAdj).emitsEnergyTo(null, side);
      }
      else if (isRF1Loaded && tileAdj instanceof IEnergyHandler || isRF2Loaded && tileAdj instanceof IEnergyProvider)
      {
      	return ((IEnergyConnection)tileAdj).canConnectEnergy(side);
      }
	
      return false;
}
 
开发者ID:4Space,项目名称:4Space-5,代码行数:25,代码来源:EnergyUtil.java

示例2: isBlockPipe

import cofh.api.energy.IEnergyProvider; //导入依赖的package包/类
public static boolean isBlockPipe(TileEntity tileEntity, ForgeDirection direction) {
    if (Loader.isModLoaded(ModIDs.BUILDCRAFT)) {
        if (tileEntity instanceof IPipeTile) {
            if (((IPipeTile) tileEntity).isPipeConnected(direction.getOpposite())) {
                return true;
            }
        }
    }

    if (Loader.isModLoaded(ModIDs.THERMAL_EXPANSION) || Loader.isModLoaded(ModIDs.THERMAL_DYNAMICS)) {

        if (tileEntity instanceof IEnergyProvider) {
            if (((IEnergyProvider) tileEntity).canConnectEnergy(direction.getOpposite())) {
                return true;
            }
        }
    }

    return false;
}
 
开发者ID:Dragon9815,项目名称:PlayerInterfaceMod,代码行数:21,代码来源:BlockHelper.java

示例3: getEnergyInfo

import cofh.api.energy.IEnergyProvider; //导入依赖的package包/类
private Object getEnergyInfo(RelativePos sourcePos, ForgeDirection side) throws Exception {
	TileEntity sourceTile = worldObj.getTileEntity(xCoord + sourcePos.x, yCoord + sourcePos.y, zCoord + sourcePos.z);
	HashMap<String, Integer> result = new HashMap<String, Integer>();
	if (sourceTile instanceof IEnergyProvider) {
		result.put("stored", ((IEnergyProvider) sourceTile).getEnergyStored(side));
		result.put("capacity", ((IEnergyProvider) sourceTile).getMaxEnergyStored(side));
	}
	if (sourceTile instanceof IEnergyReceiver) {
		result.put("stored", ((IEnergyReceiver) sourceTile).getEnergyStored(side));
		result.put("capacity", ((IEnergyReceiver) sourceTile).getMaxEnergyStored(side));
	}

	if (result.size() > 0) {
		return result;
	}

	// TODO: If side is empty, return details about all sides.

	throw new Exception("Source tile is no energy handler.");
}
 
开发者ID:thraaawn,项目名称:CCFactoryManager,代码行数:21,代码来源:TileEntityFactoryController.java

示例4: getTypes

import cofh.api.energy.IEnergyProvider; //导入依赖的package包/类
private ArrayList<String> getTypes(RelativePos pos) throws Exception {
	TileEntity tile = worldObj.getTileEntity(xCoord + pos.x, yCoord + pos.y, zCoord + pos.z);
	if (tile == null) {
		throw new Exception("Not a valid target!");
	}

	ArrayList<String> types = new ArrayList<String>();
	if (tile instanceof IInventory) {
		types.add("item");
	}
	if (tile instanceof IFluidHandler) {
		types.add("fluid");
	}
	if (tile instanceof IEnergyProvider) {
		types.add("energy-provider");
	}
	if (tile instanceof IEnergyReceiver) {
		types.add("energy-receiver");
	}

	return types;
}
 
开发者ID:thraaawn,项目名称:CCFactoryManager,代码行数:23,代码来源:TileEntityFactoryController.java

示例5: getEnergyProvider

import cofh.api.energy.IEnergyProvider; //导入依赖的package包/类
@Optional.Method(modid = Mods.COFH_ENERGY_API_ID)
@Override
public IEnergyProvider getEnergyProvider() {
    TileEntity tile = worldObj.getTileEntity(xConnected, yConnected, zConnected);
    if (tile != null && tile instanceof IEnergyProvider) {
        if (tile != energyProvider) {
            setEnergyProvider((IEnergyProvider) tile);
            worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, worldObj.getBlock(this.xCoord, this.yCoord, this.zCoord));
        }
        return (IEnergyProvider) tile;
    } else {
        if (energyProvider != null) {
            setEnergyProvider(null);
            worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, worldObj.getBlock(this.xCoord, this.yCoord, this.zCoord));
        }
        return null;
    }
}
 
开发者ID:Dynious,项目名称:RefinedRelocation,代码行数:19,代码来源:TileWirelessBlockExtender.java

示例6: takePower

import cofh.api.energy.IEnergyProvider; //导入依赖的package包/类
@Override //Removing from the RF tile
public long takePower(long power, boolean simulated) {
    if(entity instanceof IEnergyProvider){
        return ((IEnergyProvider) entity).extractEnergy(dir, (int) power, simulated);
    }
    return 0;
}
 
开发者ID:modmuss50,项目名称:Tesla-Flux,代码行数:8,代码来源:TeslaRFContainer.java

示例7: setTile

import cofh.api.energy.IEnergyProvider; //导入依赖的package包/类
public void setTile(TileEntity entity){
    if(entity instanceof IEnergyReceiver){
        receiver = (IEnergyReceiver) entity;
    }
    if(entity instanceof IEnergyProvider){
        provider = (IEnergyProvider) entity;
    }
    if(entity instanceof IEnergyHandler){
        handler = (IEnergyHandler) entity;
    }
}
 
开发者ID:modmuss50,项目名称:RF-Bridge,代码行数:12,代码来源:RFContainer.java

示例8: extractEnergy

import cofh.api.energy.IEnergyProvider; //导入依赖的package包/类
/**
 * Redirects the extractEnergy call to the neighboring TileEntity of the
 * corresponding FrameConnector wall block if possible.
 */
@Override
public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate) {
	TileEntity targetTE = getFrameConnectorNeighborTileEntity(from);

	if (targetTE instanceof IEnergyProvider) {
		int extracted = ((IEnergyProvider) targetTE).extractEnergy(from, maxExtract, simulate);
		if (!simulate && !worldObj.isRemote) {
			rfTransferedOut += extracted;
		}
		return extracted;
	}

	return 0;
}
 
开发者ID:NPException,项目名称:Dimensional-Pockets,代码行数:19,代码来源:TileDimensionalPocket.java

示例9: extractEnergy

import cofh.api.energy.IEnergyProvider; //导入依赖的package包/类
/**
 * Redirects the extractEnergy call to the neighboring TileEntity of the
 * DimensionalPocket block if possible.
 */
@Override
public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate) {
	TileEntity targetTE = getDimPocketNeighbourTileEntity(from.getOpposite());

	if (targetTE instanceof IEnergyProvider) {
		int extracted = ((IEnergyProvider) targetTE).extractEnergy(from, maxExtract, simulate);
		if (!simulate && !worldObj.isRemote) {
			rfTransferedIn += extracted;
		}
		return extracted;
	}

	return 0;
}
 
开发者ID:NPException,项目名称:Dimensional-Pockets,代码行数:19,代码来源:TileDimensionalPocketWallConnector.java

示例10: doInteract

import cofh.api.energy.IEnergyProvider; //导入依赖的package包/类
@Override
public boolean doInteract(ChunkPosition pos, IDrone drone, IBlockInteractHandler interactHandler, boolean simulate){
    IEnergyStorage droneEnergy = CoFHCore.getEnergyStorage(drone);
    if(droneEnergy.getEnergyStored() == droneEnergy.getMaxEnergyStored()) {
        interactHandler.abort();
        return false;
    } else {
        TileEntity te = drone.getWorld().getTileEntity(pos.chunkPosX, pos.chunkPosY, pos.chunkPosZ);
        if(te instanceof IEnergyProvider) {
            IEnergyProvider provider = (IEnergyProvider)te;
            for(ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) {
                if(interactHandler.getSides()[d.ordinal()]) {
                    int transferedEnergy = droneEnergy.receiveEnergy(provider.extractEnergy(d, interactHandler.useCount() ? interactHandler.getRemainingCount() : Integer.MAX_VALUE, true), true);
                    if(transferedEnergy > 0) {
                        if(!simulate) {
                            interactHandler.decreaseCount(transferedEnergy);
                            droneEnergy.receiveEnergy(transferedEnergy, false);
                            provider.extractEnergy(d, transferedEnergy, false);
                        }
                        return true;
                    }
                }
            }
        }
        return false;
    }
}
 
开发者ID:MineMaarten,项目名称:PneumaticCraft,代码行数:28,代码来源:DroneInteractRFImport.java

示例11: checkConnectedDirection

import cofh.api.energy.IEnergyProvider; //导入依赖的package包/类
protected void checkConnectedDirection(TileEntity tile) {
    if (tile != null && !LoopHelper.isLooping(this, tile)) {
        boolean updated = false;
        if (tile instanceof IInventory) {
            if (getInventory() == null) {
                updated = true;
            }
            setInventory((IInventory) tile);
        }
        if (tile instanceof IFluidHandler) {
            if (getFluidHandler() == null) {
                updated = true;
            }
            setFluidHandler((IFluidHandler) tile);
        }
        if (Mods.IS_IC2_LOADED && tile instanceof IEnergySink) {
            if (getEnergySink() == null) {
                updated = true;
            }
            setEnergySink((IEnergySink) tile);
        }
        if (Mods.IS_COFH_ENERGY_API_LOADED && tile instanceof IEnergyReceiver) {
            if (getEnergyReceiver() == null) {
                updated = true;
            }
            setEnergyReceiver((IEnergyReceiver) tile);
        }
        if (Mods.IS_COFH_ENERGY_API_LOADED && tile instanceof IEnergyProvider) {
            if (getEnergyProvider() == null) {
                updated = true;
            }
            setEnergyProvider((IEnergyProvider) tile);
        }

        if (updated) {
            worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, worldObj.getBlock(this.xCoord, this.yCoord, this.zCoord));
            worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
        }
    }
}
 
开发者ID:Dynious,项目名称:RefinedRelocation,代码行数:41,代码来源:TileBlockExtender.java

示例12: extractEnergy

import cofh.api.energy.IEnergyProvider; //导入依赖的package包/类
@Override
public int extractEnergy(EnumFacing enumFacing, int amount, boolean simulate)
{
	return ((IEnergyProvider)this.getIEnergyHandler()).extractEnergy(EnumFacing.DOWN, amount, simulate);
}
 
开发者ID:BrassGoggledCoders,项目名称:MoarCarts,代码行数:6,代码来源:EntityMinecartEnergyHandlerTEBase.java

示例13: unLoadCart

import cofh.api.energy.IEnergyProvider; //导入依赖的package包/类
public void unLoadCart(EnumFacing facing, IEnergyProvider provider)
{
	int amountToUnload = this.energyStorage.receiveEnergy(this.energyStorage.getMaxReceive(), true);
	int amountRemovedFromCart = provider.extractEnergy(facing.getOpposite(), amountToUnload, false);
	this.energyStorage.receiveEnergy(amountRemovedFromCart, false);
}
 
开发者ID:BrassGoggledCoders,项目名称:MoarCarts,代码行数:7,代码来源:TileRFLoader.java

示例14: isOutputter

import cofh.api.energy.IEnergyProvider; //导入依赖的package包/类
public static boolean isOutputter(TileEntity tileEntity, ForgeDirection side)
{
	return (tileEntity instanceof ICableOutputter && ((ICableOutputter)tileEntity).canOutputTo(side.getOpposite())) ||
			(MekanismUtils.useIC2() && tileEntity instanceof IEnergySource && ((IEnergySource)tileEntity).emitsEnergyTo(null, side.getOpposite())) ||
			(MekanismUtils.useRF() && tileEntity instanceof IEnergyProvider && ((IEnergyConnection)tileEntity).canConnectEnergy(side.getOpposite()));
}
 
开发者ID:Microsoft,项目名称:vsminecraft,代码行数:7,代码来源:CableUtils.java

示例15: transferEnergy

import cofh.api.energy.IEnergyProvider; //导入依赖的package包/类
@LuaFunction
public int transferEnergy(String source, ForgeDirection sourceSide, String target, ForgeDirection targetSide, int amount) throws Exception {
	if (!posByName.containsKey(source)) {
		throw new Exception("Invalid source '" + source + "'. Not specified, use setName(x,y,z,name) first.");
	}

	if (!posByName.containsKey(target)) {
		throw new Exception("Invalid target '" + target + "'. Not specified, use setName(x,y,z,name) first.");
	}

	if (amount <= 0) {
		throw new Exception("At least 1 RF needs to be transferred.");
	}

	RelativePos sourcePos = posByName.get(source);
	TileEntity sourceTile = worldObj.getTileEntity(xCoord + sourcePos.x, yCoord + sourcePos.y, zCoord + sourcePos.z);
	if (!(sourceTile instanceof IEnergyProvider)) {
		throw new Exception("Source tile is no energy provider.");
	}

	RelativePos targetPos = posByName.get(target);
	TileEntity targetTile = worldObj.getTileEntity(xCoord + targetPos.x, yCoord + targetPos.y, zCoord + targetPos.z);
	if (!(targetTile instanceof IEnergyReceiver)) {
		throw new Exception("Target tile is no energy receiver.");
	}

	IEnergyProvider provider = (IEnergyProvider) sourceTile;
	IEnergyReceiver receiver = (IEnergyReceiver) targetTile;

	int extractedSim = provider.extractEnergy(sourceSide, amount, true);
	if (extractedSim > 0) {
		int receivedSim = receiver.receiveEnergy(targetSide, extractedSim, true);
		if (receivedSim > 0) {
			int extracted = provider.extractEnergy(sourceSide, receivedSim, false);
			int received = receiver.receiveEnergy(targetSide, extracted, false);

			sourceTile.markDirty();
			targetTile.markDirty();

			return received;
		}
	}

	return 0;
}
 
开发者ID:thraaawn,项目名称:CCFactoryManager,代码行数:46,代码来源:TileEntityFactoryController.java


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