cofh.api.energy.IEnergyStorage Java Examples
The following examples show how to use
cofh.api.energy.IEnergyStorage.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CoFHCore.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
public static IEnergyStorage getEnergyStorage(IDrone entity){ ExtendedPropertyRF property = (ExtendedPropertyRF)entity.getProperty("PneumaticCraft_RF"); if(property == null) { property = new ExtendedPropertyRF(); entity.setProperty("PneumaticCraft_RF", property); } else { property.energy.setCapacity(100000 + 100000 * entity.getUpgrades(ItemMachineUpgrade.UPGRADE_DISPENSER_DAMAGE)); property.energy.setMaxExtract(property.energy.getMaxEnergyStored() / 100); property.energy.setMaxReceive(property.energy.getMaxExtract()); } return property.energy; }
Example #2
Source File: DroneInteractRFImport.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
@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; } }
Example #3
Source File: DroneInteractRFExport.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
@Override public boolean doInteract(ChunkPosition pos, IDrone drone, IBlockInteractHandler interactHandler, boolean simulate){ IEnergyStorage droneEnergy = CoFHCore.getEnergyStorage(drone); if(droneEnergy.getEnergyStored() == 0) { interactHandler.abort(); return false; } else { TileEntity te = drone.getWorld().getTileEntity(pos.chunkPosX, pos.chunkPosY, pos.chunkPosZ); if(te instanceof IEnergyReceiver) { IEnergyReceiver receiver = (IEnergyReceiver)te; for(ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) { if(interactHandler.getSides()[d.ordinal()]) { int transferedEnergy = droneEnergy.extractEnergy(receiver.receiveEnergy(d, interactHandler.useCount() ? interactHandler.getRemainingCount() : Integer.MAX_VALUE, true), true); if(transferedEnergy > 0) { if(!simulate) { interactHandler.decreaseCount(transferedEnergy); droneEnergy.extractEnergy(transferedEnergy, false); receiver.receiveEnergy(d, transferedEnergy, false); } return true; } } } } return false; } }
Example #4
Source File: ElementEnergyStoredAdv.java From SimplyJetpacks with MIT License | 4 votes |
public ElementEnergyStoredAdv(GuiBase gui, int posX, int posY, IEnergyStorage storage) { super(gui, posX, posY, storage); this.texture = new ResourceLocation(SimplyJetpacks.RESOURCE_PREFIX + "textures/gui/elements/energy.png"); }
Example #5
Source File: EntityRobotBase.java From Framez with GNU General Public License v3.0 | votes |
public abstract IEnergyStorage getBattery();