mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-19 19:49:54 +00:00
Merge pull request #231 from ForestryMC/redstoneflux
Converted from MJ to RF
This commit is contained in:
commit
b4f11c9649
43 files changed
+973
-427
No files matched your search
+5
-5
@@ -67,13 +67,13 @@ repositories {
|
||||
}
|
||||
|
||||
configurations {
|
||||
buildcraft
|
||||
compile.extendsFrom buildcraft
|
||||
apis
|
||||
compile.extendsFrom apis
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile 'net.industrial-craft:industrialcraft-2:2.2.575-experimental:api'
|
||||
buildcraft 'com.mod-buildcraft:buildcraft:6.0.18:dev'
|
||||
apis 'com.mod-buildcraft:buildcraft:6.0.18:dev'
|
||||
}
|
||||
|
||||
processResources {
|
||||
@@ -174,7 +174,7 @@ jar {
|
||||
archiveName = "main.jar"
|
||||
|
||||
from {
|
||||
configurations.buildcraft.collect {
|
||||
configurations.apis.collect {
|
||||
it.isDirectory() ? it : zipTree(it).matching {
|
||||
include '**/api/**'
|
||||
}
|
||||
@@ -252,7 +252,7 @@ task devJar ( type: Zip, dependsOn: devJarSigned ) {
|
||||
}
|
||||
|
||||
from {
|
||||
configurations.buildcraft.collect {
|
||||
configurations.apis.collect {
|
||||
it.isDirectory() ? it : zipTree(it).matching {
|
||||
include '**/api/**'
|
||||
}
|
||||
|
||||
+1
-1
Submodule lang updated: a96c1f92b2...336f0558c7.
@@ -0,0 +1,11 @@
|
||||
package cofh.api;
|
||||
|
||||
public class CoFHAPIProps {
|
||||
|
||||
private CoFHAPIProps() {
|
||||
|
||||
}
|
||||
|
||||
public static final String VERSION = "1.7.10R1.0.1";
|
||||
|
||||
}
|
||||
@@ -0,0 +1,158 @@
|
||||
package cofh.api.energy;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
/**
|
||||
* Reference implementation of {@link IEnergyStorage}. Use/extend this or implement your own.
|
||||
*
|
||||
* @author King Lemming
|
||||
*
|
||||
*/
|
||||
public class EnergyStorage implements IEnergyStorage {
|
||||
|
||||
protected int energy;
|
||||
protected int capacity;
|
||||
protected int maxReceive;
|
||||
protected int maxExtract;
|
||||
|
||||
public EnergyStorage(int capacity) {
|
||||
|
||||
this(capacity, capacity, capacity);
|
||||
}
|
||||
|
||||
public EnergyStorage(int capacity, int maxTransfer) {
|
||||
|
||||
this(capacity, maxTransfer, maxTransfer);
|
||||
}
|
||||
|
||||
public EnergyStorage(int capacity, int maxReceive, int maxExtract) {
|
||||
|
||||
this.capacity = capacity;
|
||||
this.maxReceive = maxReceive;
|
||||
this.maxExtract = maxExtract;
|
||||
}
|
||||
|
||||
public EnergyStorage readFromNBT(NBTTagCompound nbt) {
|
||||
|
||||
this.energy = nbt.getInteger("Energy");
|
||||
|
||||
if (energy > capacity) {
|
||||
energy = capacity;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
|
||||
|
||||
if (energy < 0) {
|
||||
energy = 0;
|
||||
}
|
||||
nbt.setInteger("Energy", energy);
|
||||
return nbt;
|
||||
}
|
||||
|
||||
public void setCapacity(int capacity) {
|
||||
|
||||
this.capacity = capacity;
|
||||
|
||||
if (energy > capacity) {
|
||||
energy = capacity;
|
||||
}
|
||||
}
|
||||
|
||||
public void setMaxTransfer(int maxTransfer) {
|
||||
|
||||
setMaxReceive(maxTransfer);
|
||||
setMaxExtract(maxTransfer);
|
||||
}
|
||||
|
||||
public void setMaxReceive(int maxReceive) {
|
||||
|
||||
this.maxReceive = maxReceive;
|
||||
}
|
||||
|
||||
public void setMaxExtract(int maxExtract) {
|
||||
|
||||
this.maxExtract = maxExtract;
|
||||
}
|
||||
|
||||
public int getMaxReceive() {
|
||||
|
||||
return maxReceive;
|
||||
}
|
||||
|
||||
public int getMaxExtract() {
|
||||
|
||||
return maxExtract;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is included to allow for server -> client sync. Do not call this externally to the containing Tile Entity, as not all IEnergyHandlers are
|
||||
* guaranteed to have it.
|
||||
*
|
||||
* @param energy
|
||||
*/
|
||||
public void setEnergyStored(int energy) {
|
||||
|
||||
this.energy = energy;
|
||||
|
||||
if (this.energy > capacity) {
|
||||
this.energy = capacity;
|
||||
} else if (this.energy < 0) {
|
||||
this.energy = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is included to allow the containing tile to directly and efficiently modify the energy contained in the EnergyStorage. Do not rely on this
|
||||
* externally, as not all IEnergyHandlers are guaranteed to have it.
|
||||
*
|
||||
* @param energy
|
||||
*/
|
||||
public void modifyEnergyStored(int energy) {
|
||||
|
||||
this.energy += energy;
|
||||
|
||||
if (this.energy > capacity) {
|
||||
this.energy = capacity;
|
||||
} else if (this.energy < 0) {
|
||||
this.energy = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* IEnergyStorage */
|
||||
@Override
|
||||
public int receiveEnergy(int maxReceive, boolean simulate) {
|
||||
|
||||
int energyReceived = Math.min(capacity - energy, Math.min(this.maxReceive, maxReceive));
|
||||
|
||||
if (!simulate) {
|
||||
energy += energyReceived;
|
||||
}
|
||||
return energyReceived;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int extractEnergy(int maxExtract, boolean simulate) {
|
||||
|
||||
int energyExtracted = Math.min(energy, Math.min(this.maxExtract, maxExtract));
|
||||
|
||||
if (!simulate) {
|
||||
energy -= energyExtracted;
|
||||
}
|
||||
return energyExtracted;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyStored() {
|
||||
|
||||
return energy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxEnergyStored() {
|
||||
|
||||
return capacity;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package cofh.api.energy;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
/**
|
||||
* Implement this interface on TileEntities which should connect to energy transportation blocks. This is intended for blocks which generate energy but do not
|
||||
* accept it; otherwise just use IEnergyHandler.
|
||||
*
|
||||
* Note that {@link IEnergyHandler} is an extension of this.
|
||||
*
|
||||
* @author King Lemming
|
||||
*
|
||||
*/
|
||||
public interface IEnergyConnection {
|
||||
|
||||
/**
|
||||
* Returns TRUE if the TileEntity can connect on a given side.
|
||||
*/
|
||||
boolean canConnectEnergy(ForgeDirection from);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package cofh.api.energy;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
/**
|
||||
* Implement this interface on Item classes that support external manipulation of their internal energy storages.
|
||||
*
|
||||
* A reference implementation is provided {@link ItemEnergyContainer}.
|
||||
*
|
||||
* @author King Lemming
|
||||
*
|
||||
*/
|
||||
public interface IEnergyContainerItem {
|
||||
|
||||
/**
|
||||
* Adds energy to a container item. Returns the quantity of energy that was accepted. This should always return 0 if the item cannot be externally charged.
|
||||
*
|
||||
* @param container
|
||||
* ItemStack to be charged.
|
||||
* @param maxReceive
|
||||
* Maximum amount of energy to be sent into the item.
|
||||
* @param simulate
|
||||
* If TRUE, the charge will only be simulated.
|
||||
* @return Amount of energy that was (or would have been, if simulated) received by the item.
|
||||
*/
|
||||
int receiveEnergy(ItemStack container, int maxReceive, boolean simulate);
|
||||
|
||||
/**
|
||||
* Removes energy from a container item. Returns the quantity of energy that was removed. This should always return 0 if the item cannot be externally
|
||||
* discharged.
|
||||
*
|
||||
* @param container
|
||||
* ItemStack to be discharged.
|
||||
* @param maxExtract
|
||||
* Maximum amount of energy to be extracted from the item.
|
||||
* @param simulate
|
||||
* If TRUE, the discharge will only be simulated.
|
||||
* @return Amount of energy that was (or would have been, if simulated) extracted from the item.
|
||||
*/
|
||||
int extractEnergy(ItemStack container, int maxExtract, boolean simulate);
|
||||
|
||||
/**
|
||||
* Get the amount of energy currently stored in the container item.
|
||||
*/
|
||||
int getEnergyStored(ItemStack container);
|
||||
|
||||
/**
|
||||
* Get the max amount of energy that can be stored in the container item.
|
||||
*/
|
||||
int getMaxEnergyStored(ItemStack container);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package cofh.api.energy;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
/**
|
||||
* Implement this interface on Tile Entities which should handle energy, generally storing it in one or more internal {@link IEnergyStorage} objects.
|
||||
*
|
||||
* A reference implementation is provided {@link TileEnergyHandler}.
|
||||
*
|
||||
* @author King Lemming
|
||||
*
|
||||
*/
|
||||
public interface IEnergyHandler extends IEnergyConnection {
|
||||
|
||||
/**
|
||||
* Add energy to an IEnergyHandler, internal distribution is left entirely to the IEnergyHandler.
|
||||
*
|
||||
* @param from
|
||||
* Orientation the energy is received from.
|
||||
* @param maxReceive
|
||||
* Maximum amount of energy to receive.
|
||||
* @param simulate
|
||||
* If TRUE, the charge will only be simulated.
|
||||
* @return Amount of energy that was (or would have been, if simulated) received.
|
||||
*/
|
||||
int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate);
|
||||
|
||||
/**
|
||||
* Remove energy from an IEnergyHandler, internal distribution is left entirely to the IEnergyHandler.
|
||||
*
|
||||
* @param from
|
||||
* Orientation the energy is extracted from.
|
||||
* @param maxExtract
|
||||
* Maximum amount of energy to extract.
|
||||
* @param simulate
|
||||
* If TRUE, the extraction will only be simulated.
|
||||
* @return Amount of energy that was (or would have been, if simulated) extracted.
|
||||
*/
|
||||
int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate);
|
||||
|
||||
/**
|
||||
* Returns the amount of energy currently stored.
|
||||
*/
|
||||
int getEnergyStored(ForgeDirection from);
|
||||
|
||||
/**
|
||||
* Returns the maximum amount of energy that can be stored.
|
||||
*/
|
||||
int getMaxEnergyStored(ForgeDirection from);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package cofh.api.energy;
|
||||
|
||||
/**
|
||||
* An energy storage is the unit of interaction with Energy inventories.
|
||||
*
|
||||
* A reference implementation can be found at {@link EnergyStorage}.
|
||||
*
|
||||
* @author King Lemming
|
||||
*
|
||||
*/
|
||||
public interface IEnergyStorage {
|
||||
|
||||
/**
|
||||
* Adds energy to the storage. Returns quantity of energy that was accepted.
|
||||
*
|
||||
* @param maxReceive
|
||||
* Maximum amount of energy to be inserted.
|
||||
* @param simulate
|
||||
* If TRUE, the insertion will only be simulated.
|
||||
* @return Amount of energy that was (or would have been, if simulated) accepted by the storage.
|
||||
*/
|
||||
int receiveEnergy(int maxReceive, boolean simulate);
|
||||
|
||||
/**
|
||||
* Removes energy from the storage. Returns quantity of energy that was removed.
|
||||
*
|
||||
* @param maxExtract
|
||||
* Maximum amount of energy to be extracted.
|
||||
* @param simulate
|
||||
* If TRUE, the extraction will only be simulated.
|
||||
* @return Amount of energy that was (or would have been, if simulated) extracted from the storage.
|
||||
*/
|
||||
int extractEnergy(int maxExtract, boolean simulate);
|
||||
|
||||
/**
|
||||
* Returns the amount of energy currently stored.
|
||||
*/
|
||||
int getEnergyStored();
|
||||
|
||||
/**
|
||||
* Returns the maximum amount of energy that can be stored.
|
||||
*/
|
||||
int getMaxEnergyStored();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
package cofh.api.energy;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
/**
|
||||
* Reference implementation of {@link IEnergyContainerItem}. Use/extend this or implement your own.
|
||||
*
|
||||
* @author King Lemming
|
||||
*
|
||||
*/
|
||||
public class ItemEnergyContainer extends Item implements IEnergyContainerItem {
|
||||
|
||||
protected int capacity;
|
||||
protected int maxReceive;
|
||||
protected int maxExtract;
|
||||
|
||||
public ItemEnergyContainer() {
|
||||
|
||||
}
|
||||
|
||||
public ItemEnergyContainer(int capacity) {
|
||||
|
||||
this(capacity, capacity, capacity);
|
||||
}
|
||||
|
||||
public ItemEnergyContainer(int capacity, int maxTransfer) {
|
||||
|
||||
this(capacity, maxTransfer, maxTransfer);
|
||||
}
|
||||
|
||||
public ItemEnergyContainer(int capacity, int maxReceive, int maxExtract) {
|
||||
|
||||
this.capacity = capacity;
|
||||
this.maxReceive = maxReceive;
|
||||
this.maxExtract = maxExtract;
|
||||
}
|
||||
|
||||
public ItemEnergyContainer setCapacity(int capacity) {
|
||||
|
||||
this.capacity = capacity;
|
||||
return this;
|
||||
}
|
||||
|
||||
public void setMaxTransfer(int maxTransfer) {
|
||||
|
||||
setMaxReceive(maxTransfer);
|
||||
setMaxExtract(maxTransfer);
|
||||
}
|
||||
|
||||
public void setMaxReceive(int maxReceive) {
|
||||
|
||||
this.maxReceive = maxReceive;
|
||||
}
|
||||
|
||||
public void setMaxExtract(int maxExtract) {
|
||||
|
||||
this.maxExtract = maxExtract;
|
||||
}
|
||||
|
||||
/* IEnergyContainerItem */
|
||||
@Override
|
||||
public int receiveEnergy(ItemStack container, int maxReceive, boolean simulate) {
|
||||
|
||||
if (container.stackTagCompound == null) {
|
||||
container.stackTagCompound = new NBTTagCompound();
|
||||
}
|
||||
int energy = container.stackTagCompound.getInteger("Energy");
|
||||
int energyReceived = Math.min(capacity - energy, Math.min(this.maxReceive, maxReceive));
|
||||
|
||||
if (!simulate) {
|
||||
energy += energyReceived;
|
||||
container.stackTagCompound.setInteger("Energy", energy);
|
||||
}
|
||||
return energyReceived;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int extractEnergy(ItemStack container, int maxExtract, boolean simulate) {
|
||||
|
||||
if (container.stackTagCompound == null || !container.stackTagCompound.hasKey("Energy")) {
|
||||
return 0;
|
||||
}
|
||||
int energy = container.stackTagCompound.getInteger("Energy");
|
||||
int energyExtracted = Math.min(energy, Math.min(this.maxExtract, maxExtract));
|
||||
|
||||
if (!simulate) {
|
||||
energy -= energyExtracted;
|
||||
container.stackTagCompound.setInteger("Energy", energy);
|
||||
}
|
||||
return energyExtracted;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyStored(ItemStack container) {
|
||||
|
||||
if (container.stackTagCompound == null || !container.stackTagCompound.hasKey("Energy")) {
|
||||
return 0;
|
||||
}
|
||||
return container.stackTagCompound.getInteger("Energy");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxEnergyStored(ItemStack container) {
|
||||
|
||||
return capacity;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package cofh.api.energy;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
/**
|
||||
* Reference implementation of {@link IEnergyHandler}. Use/extend this or implement your own.
|
||||
*
|
||||
* @author King Lemming
|
||||
*
|
||||
*/
|
||||
public class TileEnergyHandler extends TileEntity implements IEnergyHandler {
|
||||
|
||||
protected EnergyStorage storage = new EnergyStorage(32000);
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
|
||||
super.readFromNBT(nbt);
|
||||
storage.readFromNBT(nbt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbt) {
|
||||
|
||||
super.writeToNBT(nbt);
|
||||
storage.writeToNBT(nbt);
|
||||
}
|
||||
|
||||
/* IEnergyHandler */
|
||||
@Override
|
||||
public boolean canConnectEnergy(ForgeDirection from) {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) {
|
||||
|
||||
return storage.receiveEnergy(maxReceive, simulate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate) {
|
||||
|
||||
return storage.extractEnergy(maxExtract, simulate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyStored(ForgeDirection from) {
|
||||
|
||||
return storage.getEnergyStored();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxEnergyStored(ForgeDirection from) {
|
||||
|
||||
return storage.getMaxEnergyStored();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
/**
|
||||
* (C) 2014 Team CoFH / CoFH / Cult of the Full Hub
|
||||
* http://www.teamcofh.com
|
||||
*/
|
||||
@API(apiVersion = CoFHAPIProps.VERSION, owner = "CoFHAPI", provides = "CoFHAPI|energy")
|
||||
package cofh.api.energy;
|
||||
|
||||
import cofh.api.CoFHAPIProps;
|
||||
import cpw.mods.fml.common.API;
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
/**
|
||||
* (C) 2014 Team CoFH / CoFH / Cult of the Full Hub
|
||||
* http://www.teamcofh.com
|
||||
*/
|
||||
@API(apiVersion = CoFHAPIProps.VERSION, owner = "CoFHLib", provides = "CoFHAPI")
|
||||
package cofh.api;
|
||||
|
||||
import cpw.mods.fml.common.API;
|
||||
|
||||
@@ -12,7 +12,6 @@ package forestry.apiculture.gadgets;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
@@ -10,20 +10,15 @@
|
||||
******************************************************************************/
|
||||
package forestry.apiculture.gadgets;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import buildcraft.api.power.IPowerReceptor;
|
||||
import buildcraft.api.power.PowerHandler;
|
||||
import buildcraft.api.power.PowerHandler.PowerReceiver;
|
||||
import buildcraft.api.power.PowerHandler.Type;
|
||||
|
||||
import cofh.api.energy.IEnergyHandler;
|
||||
import forestry.api.apiculture.IAlvearyComponent;
|
||||
import forestry.core.network.PacketPayload;
|
||||
import forestry.energy.EnergyManager;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public abstract class TileAlvearyClimatiser extends TileAlveary implements IPowerReceptor {
|
||||
public abstract class TileAlvearyClimatiser extends TileAlveary implements IEnergyHandler {
|
||||
|
||||
public static class ClimateControl {
|
||||
|
||||
@@ -37,7 +32,7 @@ public abstract class TileAlvearyClimatiser extends TileAlveary implements IPowe
|
||||
this.boundaryUp = boundaryUp;
|
||||
}
|
||||
}
|
||||
PowerHandler powerProvider;
|
||||
protected EnergyManager energyManager;
|
||||
ClimateControl climateControl;
|
||||
private int transferTime = 0;
|
||||
private int animationDelay = 0;
|
||||
@@ -47,8 +42,8 @@ public abstract class TileAlvearyClimatiser extends TileAlveary implements IPowe
|
||||
public TileAlvearyClimatiser(ClimateControl control, int textureOff, int textureOn, int componentBlockMeta) {
|
||||
super(componentBlockMeta);
|
||||
this.climateControl = control;
|
||||
powerProvider = new PowerHandler(this, Type.MACHINE);
|
||||
powerProvider.configure(10, 100, 25, 200);
|
||||
energyManager = new EnergyManager(100, 1000, 250, 2000);
|
||||
energyManager.setReceiveOnly();
|
||||
this.textureOff = textureOff;
|
||||
this.textureOn = textureOn;
|
||||
}
|
||||
@@ -62,14 +57,20 @@ public abstract class TileAlvearyClimatiser extends TileAlveary implements IPowe
|
||||
protected void updateServerSide() {
|
||||
super.updateServerSide();
|
||||
|
||||
// BC Power
|
||||
if (powerProvider != null) {
|
||||
powerProvider.update();
|
||||
}
|
||||
|
||||
if (!this.hasMaster())
|
||||
return;
|
||||
|
||||
if (energyManager.consumeEnergyToDoWork()) {
|
||||
|
||||
transferTime = energyManager.getEnergyPerWork();
|
||||
|
||||
if (animationDelay <= 0) {
|
||||
animationDelay = 100;
|
||||
sendNetworkUpdate();
|
||||
} else
|
||||
animationDelay = 100;
|
||||
}
|
||||
|
||||
if (transferTime > 0) {
|
||||
transferTime--;
|
||||
IAlvearyComponent component = (IAlvearyComponent) this.getCentralTE();
|
||||
@@ -98,41 +99,18 @@ public abstract class TileAlvearyClimatiser extends TileAlveary implements IPowe
|
||||
return textureOff;
|
||||
}
|
||||
|
||||
/* IPOWERRECEPTOR */
|
||||
@Override
|
||||
public void doWork(PowerHandler workProvider) {
|
||||
if (!this.hasMaster())
|
||||
return;
|
||||
|
||||
if (powerProvider.useEnergy(powerProvider.getActivationEnergy(), powerProvider.getEnergyStored(), false) < powerProvider.getActivationEnergy())
|
||||
return;
|
||||
|
||||
transferTime = (int) Math.round(powerProvider.useEnergy(powerProvider.getActivationEnergy(), powerProvider.getEnergyStored(), true));
|
||||
|
||||
if (animationDelay <= 0) {
|
||||
animationDelay = 100;
|
||||
sendNetworkUpdate();
|
||||
} else
|
||||
animationDelay = 100;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PowerReceiver getPowerReceiver(ForgeDirection side) {
|
||||
return powerProvider.getPowerReceiver();
|
||||
}
|
||||
|
||||
/* LOADING & SAVING */
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbttagcompound) {
|
||||
super.readFromNBT(nbttagcompound);
|
||||
powerProvider.readFromNBT(nbttagcompound);
|
||||
energyManager.readFromNBT(nbttagcompound);
|
||||
transferTime = nbttagcompound.getInteger("Heating");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbttagcompound) {
|
||||
super.writeToNBT(nbttagcompound);
|
||||
powerProvider.writeToNBT(nbttagcompound);
|
||||
energyManager.writeToNBT(nbttagcompound);
|
||||
nbttagcompound.setInteger("Heating", transferTime);
|
||||
}
|
||||
|
||||
@@ -153,4 +131,30 @@ public abstract class TileAlvearyClimatiser extends TileAlveary implements IPowe
|
||||
payload.shortPayload[0] = (short) animationDelay;
|
||||
return payload;
|
||||
}
|
||||
|
||||
/* IEnergyHandler */
|
||||
@Override
|
||||
public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) {
|
||||
return energyManager.receiveEnergy(from, maxReceive, simulate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate) {
|
||||
return energyManager.extractEnergy(from, maxExtract, simulate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyStored(ForgeDirection from) {
|
||||
return energyManager.getEnergyStored(from);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxEnergyStored(ForgeDirection from) {
|
||||
return energyManager.getMaxEnergyStored(from);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnectEnergy(ForgeDirection from) {
|
||||
return energyManager.canConnectEnergy(from);
|
||||
}
|
||||
}
|
||||
@@ -178,12 +178,12 @@ public class Defaults {
|
||||
public static final int ENGINE_CYCLE_DURATION_SEED_OIL = 2500;
|
||||
public static final int ENGINE_CYCLE_DURATION_BIOMASS = 2500;
|
||||
public static final int ENGINE_CYCLE_DURATION_ETHANOL = 15000;
|
||||
public static final int ENGINE_FUEL_VALUE_WATER = 1;
|
||||
public static final int ENGINE_FUEL_VALUE_JUICE = 1;
|
||||
public static final int ENGINE_FUEL_VALUE_HONEY = 2;
|
||||
public static final int ENGINE_FUEL_VALUE_MILK = 1;
|
||||
public static final int ENGINE_FUEL_VALUE_SEED_OIL = 3;
|
||||
public static final int ENGINE_FUEL_VALUE_BIOMASS = 5;
|
||||
public static final int ENGINE_FUEL_VALUE_WATER = 10;
|
||||
public static final int ENGINE_FUEL_VALUE_JUICE = 10;
|
||||
public static final int ENGINE_FUEL_VALUE_HONEY = 20;
|
||||
public static final int ENGINE_FUEL_VALUE_MILK = 10;
|
||||
public static final int ENGINE_FUEL_VALUE_SEED_OIL = 30;
|
||||
public static final int ENGINE_FUEL_VALUE_BIOMASS = 50;
|
||||
public static final int ENGINE_HEAT_VALUE_LAVA = 20;
|
||||
|
||||
public static final float ENGINE_PISTON_SPEED_MAX = 0.08f;
|
||||
@@ -195,15 +195,15 @@ public class Defaults {
|
||||
public static final int ENGINE_BRONZE_HEAT_GENERATION_ENERGY = 1;
|
||||
|
||||
public static final int ENGINE_COPPER_CYCLE_DURATION_PEAT = 5000;
|
||||
public static final int ENGINE_COPPER_FUEL_VALUE_PEAT = 1;
|
||||
public static final int ENGINE_COPPER_FUEL_VALUE_PEAT = 10;
|
||||
public static final int ENGINE_COPPER_CYCLE_DURATION_BITUMINOUS_PEAT = 6000;
|
||||
public static final int ENGINE_COPPER_FUEL_VALUE_BITUMINOUS_PEAT = 2;
|
||||
public static final int ENGINE_COPPER_FUEL_VALUE_BITUMINOUS_PEAT = 20;
|
||||
public static final int ENGINE_COPPER_HEAT_MAX = 10000;
|
||||
public static final int ENGINE_COPPER_ASH_FOR_ITEM = 7500;
|
||||
|
||||
public static final int ENGINE_TIN_HEAT_MAX = 3000;
|
||||
public static final int ENGINE_TIN_EU_FOR_CYCLE = 6;
|
||||
public static final int ENGINE_TIN_ENERGY_PER_CYCLE = 2;
|
||||
public static final int ENGINE_TIN_EU_FOR_CYCLE = 5; //Reduced from 6 to 5, as per the 4 RF to 1 EU ratio
|
||||
public static final int ENGINE_TIN_ENERGY_PER_CYCLE = 20;
|
||||
public static final int ENGINE_TIN_MAX_EU_STORED = 2 * ENGINE_TIN_EU_FOR_CYCLE;
|
||||
public static final int ENGINE_TIN_MAX_EU_BATTERY = 100;
|
||||
|
||||
@@ -211,10 +211,10 @@ public class Defaults {
|
||||
public static final int PROCESSOR_TANK_CAPACITY = 10 * BUCKET_VOLUME;
|
||||
|
||||
public static final int MACHINE_LATENCY = 1000;
|
||||
public static final int MACHINE_MIN_ENERGY_RECEIVED = 5;
|
||||
public static final int MACHINE_MAX_ENERGY_RECEIVED = 40;
|
||||
public static final int MACHINE_MIN_ACTIVATION_ENERGY = 15;
|
||||
public static final int MACHINE_MAX_ENERGY = 500;
|
||||
public static final int MACHINE_MIN_ENERGY_RECEIVED = 50;
|
||||
public static final int MACHINE_MAX_ENERGY_RECEIVED = 400;
|
||||
public static final int MACHINE_MIN_ACTIVATION_ENERGY = 150;
|
||||
public static final int MACHINE_MAX_ENERGY = 5000;
|
||||
|
||||
public static final int RAINMAKER_RAIN_DURATION_IODINE = 10000;
|
||||
|
||||
|
||||
@@ -20,23 +20,14 @@ import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import buildcraft.api.core.Position;
|
||||
import buildcraft.api.power.IPowerEmitter;
|
||||
import buildcraft.api.power.IPowerReceptor;
|
||||
import buildcraft.api.power.PowerHandler;
|
||||
import buildcraft.api.power.PowerHandler.PowerReceiver;
|
||||
import buildcraft.api.transport.IPipeConnection;
|
||||
import buildcraft.api.transport.IPipeTile.PipeType;
|
||||
|
||||
import cofh.api.energy.IEnergyHandler;
|
||||
import forestry.core.TemperatureState;
|
||||
import forestry.core.config.Defaults;
|
||||
import forestry.core.interfaces.IPowerHandler;
|
||||
import forestry.core.network.PacketPayload;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.BlockUtil;
|
||||
import forestry.plugins.PluginBuildCraft;
|
||||
import forestry.energy.EnergyManager;
|
||||
|
||||
public abstract class Engine extends TileBase implements IPowerHandler, IPipeConnection, IPowerEmitter {
|
||||
public abstract class Engine extends TileBase implements IEnergyHandler {
|
||||
|
||||
@Override
|
||||
public PacketPayload getPacketPayload() {
|
||||
@@ -46,7 +37,7 @@ public abstract class Engine extends TileBase implements IPowerHandler, IPipeCon
|
||||
payload.intPayload[0] = 1;
|
||||
else
|
||||
payload.intPayload[0] = 0;
|
||||
payload.intPayload[1] = (int) storedEnergy;
|
||||
payload.intPayload[1] = energyManager.toPacketInt();
|
||||
payload.intPayload[2] = heat;
|
||||
|
||||
payload.floatPayload[0] = pistonSpeedServer;
|
||||
@@ -56,11 +47,8 @@ public abstract class Engine extends TileBase implements IPowerHandler, IPipeCon
|
||||
@Override
|
||||
public void fromPacketPayload(PacketPayload payload) {
|
||||
|
||||
if (payload.intPayload[0] > 0)
|
||||
isActive = true;
|
||||
else
|
||||
isActive = false;
|
||||
storedEnergy = payload.intPayload[1];
|
||||
isActive = payload.intPayload[0] > 0;
|
||||
energyManager.fromPacketInt(payload.intPayload[1]);
|
||||
heat = payload.intPayload[2];
|
||||
|
||||
pistonSpeedServer = payload.floatPayload[0];
|
||||
@@ -78,71 +66,24 @@ public abstract class Engine extends TileBase implements IPowerHandler, IPipeCon
|
||||
protected int currentOutput = 0;
|
||||
public final int maxEnergy;
|
||||
public final int maxEnergyExtracted;
|
||||
public float storedEnergy;
|
||||
public int heat;
|
||||
protected final int maxHeat;
|
||||
protected boolean forceCooldown = false;
|
||||
public float progress;
|
||||
private final PowerHandler powerProvider;
|
||||
protected EnergyManager energyManager;
|
||||
|
||||
public Engine(int maxHeat, int maxEnergy, int maxEnergyExtracted) {
|
||||
this.maxHeat = maxHeat;
|
||||
this.maxEnergy = maxEnergy;
|
||||
this.maxEnergyExtracted = maxEnergyExtracted;
|
||||
powerProvider = new PowerHandler(this, PowerHandler.Type.ENGINE);
|
||||
powerProvider.configure(10, 200, 10, 100000);
|
||||
energyManager = new EnergyManager(100, 2000, 100, 1000000);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void rotateAfterPlacement(World world, int x, int y, int z, EntityLivingBase entityliving, ItemStack itemstack) {
|
||||
rotateEngine();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds energy
|
||||
*
|
||||
* @param addition
|
||||
*/
|
||||
public void addEnergy(float addition) {
|
||||
storedEnergy += addition;
|
||||
|
||||
if (storedEnergy > maxEnergy)
|
||||
storedEnergy = maxEnergy;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param min Minimum energy to extract. Will return 0 if storedEnergy less
|
||||
* than min.
|
||||
* @param max Maximum energy to extract.
|
||||
* @param doExtract Determines whether energy will actually be removed from
|
||||
* the engine.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public double extractEnergy(double min, double max, boolean doExtract) {
|
||||
if (storedEnergy < min)
|
||||
return 0;
|
||||
|
||||
double ceiling = max > maxEnergyExtracted ? maxEnergyExtracted : max;
|
||||
|
||||
double extracted;
|
||||
|
||||
if (storedEnergy >= ceiling) {
|
||||
extracted = ceiling;
|
||||
if (doExtract)
|
||||
storedEnergy -= ceiling;
|
||||
} else {
|
||||
extracted = storedEnergy;
|
||||
if (doExtract)
|
||||
storedEnergy = 0;
|
||||
}
|
||||
|
||||
return extracted;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds heat
|
||||
*
|
||||
@@ -159,10 +100,6 @@ public abstract class Engine extends TileBase implements IPowerHandler, IPipeCon
|
||||
|
||||
public abstract int generateHeat();
|
||||
|
||||
public int maxEnergyReceived() {
|
||||
return 200;
|
||||
}
|
||||
|
||||
public boolean mayBurn() {
|
||||
return !forceCooldown;
|
||||
}
|
||||
@@ -192,9 +129,7 @@ public abstract class Engine extends TileBase implements IPowerHandler, IPipeCon
|
||||
forceCooldown = false;
|
||||
|
||||
// Determine targeted tile
|
||||
Position posTarget = new Position(xCoord, yCoord, zCoord, this.getOrientation());
|
||||
posTarget.moveForwards(1.0);
|
||||
TileEntity tile = worldObj.getTileEntity((int) posTarget.x, (int) posTarget.y, (int) posTarget.z);
|
||||
TileEntity tile = worldObj.getTileEntity(xCoord + getOrientation().offsetX, yCoord + getOrientation().offsetY, zCoord + getOrientation().offsetZ);
|
||||
|
||||
float newPistonSpeed = getPistonSpeed();
|
||||
if (newPistonSpeed != pistonSpeedServer) {
|
||||
@@ -206,26 +141,18 @@ public abstract class Engine extends TileBase implements IPowerHandler, IPipeCon
|
||||
|
||||
progress += pistonSpeedServer;
|
||||
|
||||
if (progress > 0.5 && stagePiston == 1) {
|
||||
if (progress > 0.25 && stagePiston == 1) {
|
||||
stagePiston = 2;
|
||||
|
||||
if (BlockUtil.isPoweredTile(getOrientation().getOpposite(), tile)) {
|
||||
IPowerReceptor receptor = (IPowerReceptor) tile;
|
||||
double extractedEnergy = extractEnergy(receptor.getPowerReceiver(getOrientation().getOpposite()).getMinEnergyReceived(), receptor.getPowerReceiver(getOrientation().getOpposite()).getMaxEnergyReceived(),
|
||||
true);
|
||||
if (extractedEnergy > 0)
|
||||
PluginBuildCraft.instance.invokeReceiveEnergyMethod(PowerHandler.Type.ENGINE, receptor.getPowerReceiver(getOrientation().getOpposite()), extractedEnergy, getOrientation().getOpposite());
|
||||
// receptor.getPowerProvider().receiveEnergy(extractedEnergy);
|
||||
}
|
||||
energyManager.sendEnergy(getOrientation(), tile);
|
||||
|
||||
} else if (progress >= 1) {
|
||||
} else if (progress >= 0.5) {
|
||||
progress = 0;
|
||||
stagePiston = 0;
|
||||
}
|
||||
|
||||
} else if (canPowerTo(tile)) { // If we are not already running, check if
|
||||
IPowerReceptor receptor = (IPowerReceptor) tile;
|
||||
if (extractEnergy(receptor.getPowerReceiver(getOrientation().getOpposite()).getMinEnergyReceived(), receptor.getPowerReceiver(getOrientation().getOpposite()).getMaxEnergyReceived(), false) > 0) {
|
||||
if (extractEnergy(getOrientation(), 1, true) > 0) {
|
||||
stagePiston = 1; // If we can transfer energy, start running
|
||||
setActive(true);
|
||||
} else
|
||||
@@ -239,12 +166,12 @@ public abstract class Engine extends TileBase implements IPowerHandler, IPipeCon
|
||||
if (mayBurn())
|
||||
burn();
|
||||
else
|
||||
extractEnergy(0, 2, true);
|
||||
energyManager.drainEnergy(20);
|
||||
|
||||
}
|
||||
|
||||
private boolean canPowerTo(TileEntity tile) {
|
||||
return isActivated() && BlockUtil.isPoweredTile(getOrientation().getOpposite(), tile);
|
||||
return isActivated() && BlockUtil.isRFTile(getOrientation().getOpposite(), tile);
|
||||
}
|
||||
|
||||
private void setActive(boolean isActive) {
|
||||
@@ -261,12 +188,9 @@ public abstract class Engine extends TileBase implements IPowerHandler, IPipeCon
|
||||
for (int i = getOrientation().ordinal() + 1; i <= getOrientation().ordinal() + 6; ++i) {
|
||||
ForgeDirection orient = ForgeDirection.values()[i % 6];
|
||||
|
||||
Position pos = new Position(xCoord, yCoord, zCoord, orient);
|
||||
pos.moveForwards(1.0F);
|
||||
TileEntity tile = worldObj.getTileEntity(xCoord + orient.offsetX, yCoord + orient.offsetY, zCoord + orient.offsetZ);
|
||||
|
||||
TileEntity tile = worldObj.getTileEntity((int) pos.x, (int) pos.y, (int) pos.z);
|
||||
|
||||
if (BlockUtil.isPoweredTile(getOrientation().getOpposite(), tile)) {
|
||||
if (BlockUtil.isRFTile(getOrientation().getOpposite(), tile)) {
|
||||
setOrientation(orient);
|
||||
worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord));
|
||||
worldObj.func_147479_m(xCoord, yCoord, zCoord);
|
||||
@@ -297,10 +221,6 @@ public abstract class Engine extends TileBase implements IPowerHandler, IPipeCon
|
||||
return 0;
|
||||
}
|
||||
|
||||
public float getEnergyStored() {
|
||||
return storedEnergy;
|
||||
}
|
||||
|
||||
public int getHeat() {
|
||||
return heat;
|
||||
}
|
||||
@@ -356,12 +276,9 @@ public abstract class Engine extends TileBase implements IPowerHandler, IPipeCon
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
super.readFromNBT(nbt);
|
||||
energyManager.readFromNBT(nbt);
|
||||
|
||||
heat = nbt.getInteger("EngineHeat");
|
||||
if (nbt.hasKey("EngineStoredEnergy"))
|
||||
storedEnergy = nbt.getInteger("EngineStoredEnergy");
|
||||
else
|
||||
storedEnergy = nbt.getFloat("EngineStored");
|
||||
|
||||
progress = nbt.getFloat("EngineProgress");
|
||||
forceCooldown = nbt.getBoolean("ForceCooldown");
|
||||
@@ -370,9 +287,9 @@ public abstract class Engine extends TileBase implements IPowerHandler, IPipeCon
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbt) {
|
||||
super.writeToNBT(nbt);
|
||||
energyManager.writeToNBT(nbt);
|
||||
|
||||
nbt.setInteger("EngineHeat", heat);
|
||||
nbt.setFloat("EngineStored", storedEnergy);
|
||||
nbt.setFloat("EngineProgress", progress);
|
||||
nbt.setBoolean("ForceCooldown", forceCooldown);
|
||||
}
|
||||
@@ -382,38 +299,32 @@ public abstract class Engine extends TileBase implements IPowerHandler, IPipeCon
|
||||
|
||||
public abstract void sendGUINetworkData(Container containerEngine, ICrafting iCrafting);
|
||||
|
||||
/* IPOWERRECEPTOR */
|
||||
@Override
|
||||
public PowerReceiver getPowerReceiver(ForgeDirection side) {
|
||||
return powerProvider.getPowerReceiver();
|
||||
public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) {
|
||||
if (from == getOrientation())
|
||||
return 0;
|
||||
return energyManager.receiveEnergy(from, maxReceive, simulate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PowerHandler getPowerHandler() {
|
||||
return powerProvider;
|
||||
public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate) {
|
||||
if (from != getOrientation())
|
||||
return 0;
|
||||
return energyManager.extractEnergy(from, maxExtract, simulate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doWork(PowerHandler workProvider) {
|
||||
if (!Proxies.common.isSimulating(worldObj))
|
||||
return;
|
||||
|
||||
addEnergy((int) (PluginBuildCraft.instance.invokeUseEnergyMethod(workProvider, 1, maxEnergyReceived(), true) * 0.95F));
|
||||
public int getEnergyStored(ForgeDirection from) {
|
||||
return energyManager.getEnergyStored(from);
|
||||
}
|
||||
|
||||
/* IPIPECONNECTION */
|
||||
@Override
|
||||
public ConnectOverride overridePipeConnection(PipeType type, ForgeDirection with) {
|
||||
if (type == PipeType.POWER)
|
||||
return ConnectOverride.DEFAULT;
|
||||
if (with == getOrientation())
|
||||
return ConnectOverride.DISCONNECT;
|
||||
return ConnectOverride.DEFAULT;
|
||||
public int getMaxEnergyStored(ForgeDirection from) {
|
||||
return energyManager.getMaxEnergyStored(from);
|
||||
}
|
||||
|
||||
/* IPOWEREMITTER */
|
||||
@Override
|
||||
public boolean canEmitPowerFrom(ForgeDirection side) {
|
||||
return side == getOrientation();
|
||||
public boolean canConnectEnergy(ForgeDirection from) {
|
||||
return energyManager.canConnectEnergy(from);
|
||||
}
|
||||
}
|
||||
@@ -23,6 +23,7 @@ public abstract class Mill extends TilePowered {
|
||||
public float progress;
|
||||
|
||||
public Mill() {
|
||||
super(0, 0, 0, 0);
|
||||
speed = 0.01F;
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,6 @@ import forestry.core.config.Config;
|
||||
import forestry.core.config.Defaults;
|
||||
import forestry.core.interfaces.IErrorSource;
|
||||
import forestry.core.interfaces.IOwnable;
|
||||
import forestry.core.interfaces.IPowerHandler;
|
||||
import forestry.core.network.ForestryPacket;
|
||||
import forestry.core.network.INetworkedEntity;
|
||||
import forestry.core.network.PacketPayload;
|
||||
@@ -45,9 +44,6 @@ import forestry.core.utils.Vect;
|
||||
public abstract class TileForestry extends TileEntity implements INetworkedEntity, IOwnable, IErrorSource {
|
||||
|
||||
protected boolean isInited = false;
|
||||
protected int energyConsumed;
|
||||
protected int energyLast;
|
||||
protected int energyReceived;
|
||||
|
||||
public Vect Coords() {
|
||||
return new Vect(xCoord, yCoord, zCoord);
|
||||
@@ -84,13 +80,6 @@ public abstract class TileForestry extends TileEntity implements INetworkedEntit
|
||||
|
||||
if (!Proxies.common.isSimulating(worldObj))
|
||||
return;
|
||||
|
||||
if (this instanceof IPowerHandler) {
|
||||
IPowerHandler receptor = (IPowerHandler) this;
|
||||
if (receptor.getPowerHandler() != null) {
|
||||
receptor.getPowerHandler().update();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public abstract void initialize();
|
||||
|
||||
Executable → Regular
+50
-79
@@ -10,28 +10,22 @@
|
||||
******************************************************************************/
|
||||
package forestry.core.gadgets;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry.FluidContainerData;
|
||||
|
||||
import buildcraft.api.power.PowerHandler;
|
||||
import buildcraft.api.power.PowerHandler.PowerReceiver;
|
||||
import buildcraft.api.power.PowerHandler.Type;
|
||||
|
||||
import forestry.core.GameMode;
|
||||
import forestry.core.config.Defaults;
|
||||
import forestry.core.fluids.tanks.StandardTank;
|
||||
import forestry.core.interfaces.IPowerHandler;
|
||||
import forestry.core.interfaces.IRenderableMachine;
|
||||
import forestry.core.network.ClassMap;
|
||||
import forestry.core.network.EntityNetData;
|
||||
import forestry.core.network.IndexInPayload;
|
||||
import forestry.core.network.PacketPayload;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.EnumTankLevel;
|
||||
import forestry.core.fluids.tanks.StandardTank;
|
||||
import forestry.energy.EnergyManager;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry.FluidContainerData;
|
||||
|
||||
public abstract class TilePowered extends TileBase implements IPowerHandler, IRenderableMachine {
|
||||
public abstract class TilePowered extends TileBase implements IRenderableMachine, IPowerHandler {
|
||||
|
||||
public static int WORK_CYCLES = 4;
|
||||
|
||||
@@ -69,25 +63,12 @@ public abstract class TilePowered extends TileBase implements IPowerHandler, IRe
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
private final PowerHandler powerHandler;
|
||||
|
||||
public TilePowered() {
|
||||
powerHandler = new PowerHandler(this, Type.MACHINE);
|
||||
configurePowerProvider(powerHandler);
|
||||
adjustPowerProvider(powerHandler);
|
||||
}
|
||||
protected final EnergyManager energyManager;
|
||||
|
||||
protected void configurePowerProvider(PowerHandler provider) {
|
||||
provider.configure(Defaults.MACHINE_MIN_ENERGY_RECEIVED, Defaults.MACHINE_MAX_ENERGY_RECEIVED,
|
||||
Defaults.MACHINE_MIN_ACTIVATION_ENERGY, Defaults.MACHINE_MAX_ENERGY);
|
||||
}
|
||||
|
||||
private void adjustPowerProvider(PowerHandler provider) {
|
||||
provider.configure(
|
||||
provider.getMinEnergyReceived(),
|
||||
Math.round(provider.getMaxEnergyReceived() * GameMode.getGameMode().getFloatSetting("energy.demand.modifier")),
|
||||
Math.round(provider.getActivationEnergy() * GameMode.getGameMode().getFloatSetting("energy.demand.modifier")),
|
||||
Math.round(provider.getMaxEnergyStored() * GameMode.getGameMode().getFloatSetting("energy.demand.modifier")));
|
||||
public TilePowered(int minAcceptedEnergy, int maxTransfer, int energyPerWork, int capacity) {
|
||||
this.energyManager = new EnergyManager(minAcceptedEnergy, maxTransfer, energyPerWork, capacity);
|
||||
this.energyManager.setReceiveOnly();
|
||||
}
|
||||
|
||||
/* STATE INFORMATION */
|
||||
@@ -105,79 +86,38 @@ public abstract class TilePowered extends TileBase implements IPowerHandler, IRe
|
||||
return false;
|
||||
}
|
||||
|
||||
/* IPOWERRECEPTOR */
|
||||
@Override
|
||||
public PowerHandler getPowerHandler() {
|
||||
return powerHandler;
|
||||
}
|
||||
private int workCounter;
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
super.updateEntity();
|
||||
if (worldObj.isRemote)
|
||||
if (!Proxies.common.isSimulating(worldObj))
|
||||
return;
|
||||
|
||||
if (workCounter < WORK_CYCLES && energyManager.consumeEnergyToDoWork()) {
|
||||
workCounter++;
|
||||
}
|
||||
|
||||
if (workCounter >= WORK_CYCLES && worldObj.getTotalWorldTime() % 5 == 0) {
|
||||
if (workCycle())
|
||||
workCounter = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doWork(PowerHandler workProvider) {
|
||||
|
||||
if (!Proxies.common.isSimulating(worldObj))
|
||||
return;
|
||||
|
||||
// Hard limit to 4 cycles / second.
|
||||
if (workCounter < WORK_CYCLES) {
|
||||
powerHandler.useEnergy(powerHandler.getActivationEnergy(), powerHandler.getActivationEnergy(), true);
|
||||
workCounter++;
|
||||
}
|
||||
|
||||
/*
|
||||
// Hard limit to 4 cycles / second.
|
||||
if (worldObj.getTotalWorldTime() % 5 * 10 != 0)
|
||||
return;
|
||||
|
||||
PluginBuildCraft.instance.invokeUseEnergyMethod(powerHandler, powerHandler.getActivationEnergy(), powerHandler.getActivationEnergy(), false);
|
||||
|
||||
// Do not consume energy if the boiler didn't do any work.
|
||||
if (!workCycle())
|
||||
return;
|
||||
|
||||
// Use up energy since we did some work.
|
||||
PluginBuildCraft.instance.invokeUseEnergyMethod(powerHandler, powerHandler.getActivationEnergy(), powerHandler.getActivationEnergy(), true);
|
||||
*/
|
||||
}
|
||||
|
||||
public abstract boolean workCycle();
|
||||
|
||||
@Override
|
||||
public PowerReceiver getPowerReceiver(ForgeDirection side) {
|
||||
return powerHandler.getPowerReceiver();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbt) {
|
||||
super.writeToNBT(nbt);
|
||||
powerHandler.writeToNBT(nbt);
|
||||
energyManager.writeToNBT(nbt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
super.readFromNBT(nbt);
|
||||
powerHandler.readFromNBT(nbt);
|
||||
energyManager.readFromNBT(nbt);
|
||||
}
|
||||
|
||||
/*
|
||||
@Override
|
||||
public int powerRequest(ForgeDirection direction) {
|
||||
float needed = powerProvider.getMaxEnergyStored() - powerProvider.getEnergyStored();
|
||||
return (int) Math.ceil(Math.min(powerProvider.getMaxEnergyReceived(), needed));
|
||||
} */
|
||||
|
||||
/* LIQUID CONTAINER HANDLING */
|
||||
protected ItemStack bottleIntoContainer(ItemStack canStack, ItemStack outputStack, FluidContainerData container, StandardTank tank) {
|
||||
if (tank.getFluidAmount() < container.fluid.amount)
|
||||
@@ -210,4 +150,35 @@ public abstract class TilePowered extends TileBase implements IPowerHandler, IRe
|
||||
public EnumTankLevel getSecondaryLevel() {
|
||||
return EnumTankLevel.EMPTY;
|
||||
}
|
||||
|
||||
/* IPowerHandler */
|
||||
@Override
|
||||
public EnergyManager getEnergyManager() {
|
||||
return energyManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) {
|
||||
return energyManager.receiveEnergy(from, maxReceive, simulate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int extractEnergy(ForgeDirection from, int maxReceive, boolean simulate) {
|
||||
return energyManager.extractEnergy(from, maxReceive, simulate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyStored(ForgeDirection from) {
|
||||
return energyManager.getEnergyStored(from);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxEnergyStored(ForgeDirection from) {
|
||||
return energyManager.getMaxEnergyStored(from);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnectEnergy(ForgeDirection from) {
|
||||
return energyManager.canConnectEnergy(from);
|
||||
}
|
||||
}
|
||||
@@ -96,7 +96,7 @@ public abstract class GuiForestry<T extends TileForestry> extends GuiContainer i
|
||||
if (inventory instanceof IClimatised && ((IClimatised) inventory).isClimatized())
|
||||
ledgerManager.add(new ClimateLedger(ledgerManager, (IClimatised) inventory));
|
||||
|
||||
if (!Config.disableEnergyStat && inventory instanceof IPowerHandler)
|
||||
if (!Config.disableEnergyStat && inventory instanceof IPowerHandler && ((IPowerHandler) inventory).getEnergyManager().getMaxEnergyStored() > 0)
|
||||
ledgerManager.add(new PowerLedger(ledgerManager, (IPowerHandler) inventory));
|
||||
|
||||
if (!Config.disableHints && inventory instanceof IHintSource && ((IHintSource) inventory).hasHints())
|
||||
|
||||
@@ -10,11 +10,10 @@
|
||||
******************************************************************************/
|
||||
package forestry.core.gui;
|
||||
|
||||
import buildcraft.api.power.PowerHandler;
|
||||
|
||||
import forestry.core.interfaces.IPowerHandler;
|
||||
import forestry.core.render.TextureManager;
|
||||
import forestry.core.utils.StringUtil;
|
||||
import forestry.energy.EnergyManager;
|
||||
|
||||
public class PowerLedger extends Ledger {
|
||||
|
||||
@@ -38,23 +37,23 @@ public class PowerLedger extends Ledger {
|
||||
if (!isFullyOpened())
|
||||
return;
|
||||
|
||||
PowerHandler handler = tile.getPowerHandler();
|
||||
EnergyManager energyManager = tile.getEnergyManager();
|
||||
manager.minecraft.fontRenderer.drawStringWithShadow(StringUtil.localize("gui.energy"), x + 22, y + 8, manager.gui.fontColor.get("ledger.power.header"));
|
||||
manager.minecraft.fontRenderer.drawStringWithShadow(StringUtil.localize("gui.stored") + ":", x + 22, y + 20,
|
||||
manager.gui.fontColor.get("ledger.power.subheader"));
|
||||
manager.minecraft.fontRenderer.drawString(handler.getEnergyStored() + " MJ", x + 22, y + 32, manager.gui.fontColor.get("ledger.power.text"));
|
||||
manager.minecraft.fontRenderer.drawString(energyManager.getTotalEnergyStored() + " RF", x + 22, y + 32, manager.gui.fontColor.get("ledger.power.text"));
|
||||
manager.minecraft.fontRenderer.drawStringWithShadow(StringUtil.localize("gui.maxenergy") + ":", x + 22, y + 44,
|
||||
manager.gui.fontColor.get("ledger.power.subheader"));
|
||||
manager.minecraft.fontRenderer.drawString(handler.getMaxEnergyStored() + " MJ", x + 22, y + 56, manager.gui.fontColor.get("ledger.power.text"));
|
||||
manager.minecraft.fontRenderer.drawString(energyManager.getMaxEnergyStored() + " RF", x + 22, y + 56, manager.gui.fontColor.get("ledger.power.text"));
|
||||
manager.minecraft.fontRenderer.drawStringWithShadow(StringUtil.localize("gui.maxenergyreceive") + ":", x + 22, y + 68,
|
||||
manager.gui.fontColor.get("ledger.power.subheader"));
|
||||
manager.minecraft.fontRenderer.drawString(handler.getMaxEnergyReceived() + " MJ", x + 22, y + 80, manager.gui.fontColor.get("ledger.power.text"));
|
||||
manager.minecraft.fontRenderer.drawString(energyManager.getMaxEnergyReceived() + " RF", x + 22, y + 80, manager.gui.fontColor.get("ledger.power.text"));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return tile.getPowerHandler().getEnergyStored() + " MJ";
|
||||
return tile.getEnergyManager().getTotalEnergyStored() + " RF";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10,9 +10,9 @@
|
||||
******************************************************************************/
|
||||
package forestry.core.interfaces;
|
||||
|
||||
import buildcraft.api.power.IPowerReceptor;
|
||||
import buildcraft.api.power.PowerHandler;
|
||||
import cofh.api.energy.IEnergyHandler;
|
||||
import forestry.energy.EnergyManager;
|
||||
|
||||
public interface IPowerHandler extends IPowerReceptor {
|
||||
PowerHandler getPowerHandler();
|
||||
public interface IPowerHandler extends IEnergyHandler {
|
||||
EnergyManager getEnergyManager();
|
||||
}
|
||||
Executable → Regular
+5
-4
@@ -34,6 +34,7 @@ import buildcraft.api.transport.IPipeConnection.ConnectOverride;
|
||||
import buildcraft.api.transport.IPipeTile;
|
||||
import buildcraft.api.transport.IPipeTile.PipeType;
|
||||
|
||||
import cofh.api.energy.IEnergyHandler;
|
||||
import forestry.core.config.Defaults;
|
||||
|
||||
public class BlockUtil {
|
||||
@@ -146,15 +147,15 @@ public class BlockUtil {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isPoweredTile(ForgeDirection side, TileEntity tile) {
|
||||
public static boolean isRFTile(ForgeDirection side, TileEntity tile) {
|
||||
if (tile == null)
|
||||
return false;
|
||||
|
||||
if (!(tile instanceof IPowerReceptor))
|
||||
if (!(tile instanceof IEnergyHandler))
|
||||
return false;
|
||||
|
||||
IPowerReceptor receptor = (IPowerReceptor) tile;
|
||||
return receptor.getPowerReceiver(side) != null;
|
||||
IEnergyHandler receptor = (IEnergyHandler) tile;
|
||||
return receptor.canConnectEnergy(side);
|
||||
}
|
||||
|
||||
public static boolean tryPlantPot(World world, int x, int y, int z, Block block) {
|
||||
|
||||
@@ -0,0 +1,191 @@
|
||||
package forestry.energy;
|
||||
|
||||
import cofh.api.energy.EnergyStorage;
|
||||
import cofh.api.energy.IEnergyHandler;
|
||||
import forestry.core.GameMode;
|
||||
import forestry.core.utils.BlockUtil;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class EnergyManager implements IEnergyHandler {
|
||||
private enum EnergyTransferMode {
|
||||
EXTRACT, RECEIVE, BOTH;
|
||||
}
|
||||
|
||||
private int energyPerWork;
|
||||
private int minAcceptedEnergy;
|
||||
protected EnergyStorage energyStorage;
|
||||
private EnergyTransferMode mode = EnergyTransferMode.BOTH;
|
||||
|
||||
public EnergyManager(int minAcceptedEnergy, int maxTransfer, int energyPerWork, int capacity) {
|
||||
this.energyPerWork = scaleForDifficulty(energyPerWork);
|
||||
this.minAcceptedEnergy = scaleForDifficulty(minAcceptedEnergy);
|
||||
energyStorage = new EnergyStorage(scaleForDifficulty(capacity), scaleForDifficulty(maxTransfer), scaleForDifficulty(maxTransfer));
|
||||
}
|
||||
|
||||
private static int scaleForDifficulty(int energyPerUse) {
|
||||
return Math.round(energyPerUse * GameMode.getGameMode().getFloatSetting("energy.demand.modifier"));
|
||||
}
|
||||
|
||||
public void setExtractOnly() {
|
||||
mode = EnergyTransferMode.EXTRACT;
|
||||
}
|
||||
|
||||
public void setReceiveOnly() {
|
||||
mode = EnergyTransferMode.RECEIVE;
|
||||
}
|
||||
|
||||
private boolean canExtract() {
|
||||
switch (mode) {
|
||||
case EXTRACT:
|
||||
case BOTH:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean canReceive() {
|
||||
switch (mode) {
|
||||
case RECEIVE:
|
||||
case BOTH:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/* NBT */
|
||||
public EnergyManager readFromNBT(NBTTagCompound nbt) {
|
||||
|
||||
NBTTagCompound energyManagerNBT = nbt.getCompoundTag("EnergyManager");
|
||||
NBTTagCompound energyStorageNBT = energyManagerNBT.getCompoundTag("EnergyStorage");
|
||||
energyStorage.readFromNBT(energyStorageNBT);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
|
||||
|
||||
NBTTagCompound energyStorageNBT = new NBTTagCompound();
|
||||
energyStorage.writeToNBT(energyStorageNBT);
|
||||
|
||||
NBTTagCompound energyManagerNBT = new NBTTagCompound();
|
||||
energyManagerNBT.setTag("EnergyStorage", energyStorageNBT);
|
||||
nbt.setTag("EnergyManager", energyManagerNBT);
|
||||
|
||||
return nbt;
|
||||
}
|
||||
|
||||
/* Packets */
|
||||
public int toPacketInt() {
|
||||
return energyStorage.getEnergyStored();
|
||||
}
|
||||
|
||||
public void fromPacketInt(int packetInt) {
|
||||
energyStorage.setEnergyStored(packetInt);
|
||||
}
|
||||
|
||||
/* IEnergyHandler */
|
||||
@Override
|
||||
public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) {
|
||||
if (!canReceive() || maxReceive < minAcceptedEnergy)
|
||||
return 0;
|
||||
return energyStorage.receiveEnergy(maxReceive, simulate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate) {
|
||||
if (!canExtract())
|
||||
return 0;
|
||||
return energyStorage.extractEnergy(maxExtract, simulate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyStored(ForgeDirection from) {
|
||||
return energyStorage.getEnergyStored();
|
||||
}
|
||||
|
||||
public int getTotalEnergyStored() {
|
||||
return energyStorage.getEnergyStored();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxEnergyStored(ForgeDirection from) {
|
||||
return energyStorage.getMaxEnergyStored();
|
||||
}
|
||||
|
||||
public int getMaxEnergyStored() {
|
||||
return energyStorage.getMaxEnergyStored();
|
||||
}
|
||||
|
||||
public int getMaxEnergyReceived() {
|
||||
return energyStorage.getMaxReceive();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnectEnergy(ForgeDirection from) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public int getEnergyPerWork() {
|
||||
return energyPerWork;
|
||||
}
|
||||
|
||||
/**
|
||||
* Consumes one work cycle's worth of energy.
|
||||
* @return true if the energy to do work was consumed
|
||||
*/
|
||||
public boolean consumeEnergyToDoWork() {
|
||||
if (energyStorage.getEnergyStored() < energyPerWork)
|
||||
return false;
|
||||
energyStorage.modifyEnergyStored(-energyPerWork);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends as much energy as it can to the tile at orientation
|
||||
* @param orientation
|
||||
* @param tile
|
||||
* @return amount sent
|
||||
*/
|
||||
public int sendEnergy(ForgeDirection orientation, TileEntity tile) {
|
||||
return sendEnergy(orientation, tile, Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends amount of energy to the tile at orientation
|
||||
* @param orientation
|
||||
* @param tile
|
||||
* @param amount
|
||||
* @return amount sent
|
||||
*/
|
||||
public int sendEnergy(ForgeDirection orientation, TileEntity tile, int amount) {
|
||||
int sent = 0;
|
||||
if (BlockUtil.isRFTile(orientation.getOpposite(), tile)) {
|
||||
IEnergyHandler receptor = (IEnergyHandler) tile;
|
||||
|
||||
int extractable = extractEnergy(orientation, amount, true);
|
||||
if (extractable > 0) {
|
||||
sent = receptor.receiveEnergy(orientation.getOpposite(), extractable, false);
|
||||
extractEnergy(orientation, sent, false);
|
||||
}
|
||||
}
|
||||
return sent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Drains an amount of energy, due to decay from lack of work or other factors
|
||||
* @param amount
|
||||
*/
|
||||
public void drainEnergy(int amount) {
|
||||
energyStorage.modifyEnergyStored(-amount);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an amount of energy, generated by engines
|
||||
* @param amount
|
||||
*/
|
||||
public void generateEnergy(int amount) {
|
||||
energyStorage.modifyEnergyStored(amount);
|
||||
}
|
||||
}
|
||||
@@ -12,10 +12,10 @@ package forestry.energy.circuits;
|
||||
|
||||
public class CircuitElectricBoost extends CircuitElectricChange {
|
||||
|
||||
public CircuitElectricBoost(String uid, int limit, int eu, int mj) {
|
||||
public CircuitElectricBoost(String uid, int limit, int eu, int rf) {
|
||||
super(uid, false);
|
||||
this.setLimit(limit);
|
||||
this.configureChange(eu, mj);
|
||||
this.configureChange(eu, rf);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -18,15 +18,15 @@ import forestry.energy.gadgets.EngineTin;
|
||||
public abstract class CircuitElectricChange extends Circuit {
|
||||
|
||||
int euChange = 7;
|
||||
int mjChange = 2;
|
||||
int rfChange = 20;
|
||||
|
||||
public CircuitElectricChange(String uid, boolean requiresDiscovery) {
|
||||
super(uid, requiresDiscovery);
|
||||
}
|
||||
|
||||
protected void configureChange(int euChange, int mjChange) {
|
||||
protected void configureChange(int euChange, int rfChange) {
|
||||
this.euChange = euChange;
|
||||
this.mjChange = mjChange;
|
||||
this.rfChange = rfChange;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -40,7 +40,7 @@ public abstract class CircuitElectricChange extends Circuit {
|
||||
return;
|
||||
|
||||
EngineTin engine = (EngineTin) tile;
|
||||
engine.changeEnergyConfig(euChange, mjChange, 2 * euChange);
|
||||
engine.changeEnergyConfig(euChange, rfChange, 2 * euChange);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -54,7 +54,7 @@ public abstract class CircuitElectricChange extends Circuit {
|
||||
return;
|
||||
|
||||
EngineTin engine = (EngineTin) tile;
|
||||
engine.changeEnergyConfig(-euChange, -mjChange, -(2 * euChange));
|
||||
engine.changeEnergyConfig(-euChange, -rfChange, -(2 * euChange));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -14,7 +14,7 @@ public class CircuitElectricChoke extends CircuitElectricChange {
|
||||
|
||||
public CircuitElectricChoke(String uid) {
|
||||
super(uid, false);
|
||||
this.configureChange(-2, -1);
|
||||
this.configureChange(-2, -10);
|
||||
this.setLimit(1);
|
||||
}
|
||||
}
|
||||
@@ -81,7 +81,7 @@ public class EngineBronze extends Engine implements ISpecialInventory, ILiquidTa
|
||||
private boolean shutdown;
|
||||
|
||||
public EngineBronze() {
|
||||
super(Defaults.ENGINE_BRONZE_HEAT_MAX, 30000, 500);
|
||||
super(Defaults.ENGINE_BRONZE_HEAT_MAX, 300000, 5000);
|
||||
setHints(Config.hints.get("engine.bronze"));
|
||||
|
||||
inventory = new TileInventoryAdapter(this, 1, "Items");
|
||||
@@ -167,7 +167,7 @@ public class EngineBronze extends Engine implements ISpecialInventory, ILiquidTa
|
||||
if (burnTime > 0) {
|
||||
burnTime--;
|
||||
currentOutput = determineFuelValue(FluidRegistry.getFluid(currentFluidId));
|
||||
addEnergy(currentOutput);
|
||||
energyManager.generateEnergy(currentOutput);
|
||||
} else {
|
||||
burnTime = totalTime = this.determineBurnTime(fuelTank.getFluid().getFluid());
|
||||
currentFluidId = fuelTank.getFluid().getFluid().getID();
|
||||
@@ -353,7 +353,7 @@ public class EngineBronze extends Engine implements ISpecialInventory, ILiquidTa
|
||||
currentOutput = data;
|
||||
break;
|
||||
case 3:
|
||||
storedEnergy = data;
|
||||
energyManager.fromPacketInt(data);
|
||||
break;
|
||||
case 4:
|
||||
heat = data;
|
||||
@@ -370,7 +370,7 @@ public class EngineBronze extends Engine implements ISpecialInventory, ILiquidTa
|
||||
iCrafting.sendProgressBarUpdate(containerEngine, i, burnTime);
|
||||
iCrafting.sendProgressBarUpdate(containerEngine, i + 1, totalTime);
|
||||
iCrafting.sendProgressBarUpdate(containerEngine, i + 2, currentOutput);
|
||||
iCrafting.sendProgressBarUpdate(containerEngine, i + 3, (int) storedEnergy);
|
||||
iCrafting.sendProgressBarUpdate(containerEngine, i + 3, energyManager.toPacketInt());
|
||||
iCrafting.sendProgressBarUpdate(containerEngine, i + 4, heat);
|
||||
iCrafting.sendProgressBarUpdate(containerEngine, i + 5, currentFluidId);
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ public class EngineClockwork extends Engine {
|
||||
private final static int WIND_DELAY = 10;
|
||||
|
||||
private static final int ENGINE_CLOCKWORK_HEAT_MAX = 300000;
|
||||
private static final float ENGINE_CLOCKWORK_ENERGY_PER_CYCLE = 0.25f;
|
||||
private static final int ENGINE_CLOCKWORK_ENERGY_PER_CYCLE = 2;
|
||||
private static final float ENGINE_CLOCKWORK_WIND_MAX = 8f;
|
||||
|
||||
private static final DamageSourceForestry damageSourceEngineClockwork = new DamageSourceForestry("engine.clockwork");
|
||||
@@ -38,7 +38,7 @@ public class EngineClockwork extends Engine {
|
||||
private short delay = 0;
|
||||
|
||||
public EngineClockwork() {
|
||||
super(ENGINE_CLOCKWORK_HEAT_MAX, 1000, 50);
|
||||
super(ENGINE_CLOCKWORK_HEAT_MAX, 10000, 500);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -112,7 +112,7 @@ public class EngineClockwork extends Engine {
|
||||
tension *= 0.9995f;
|
||||
else
|
||||
tension = 0;
|
||||
addEnergy(ENGINE_CLOCKWORK_ENERGY_PER_CYCLE * tension);
|
||||
energyManager.generateEnergy(ENGINE_CLOCKWORK_ENERGY_PER_CYCLE * (int)tension);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -142,7 +142,7 @@ public class EngineClockwork extends Engine {
|
||||
return 0;
|
||||
|
||||
float fromClockwork = (tension / ENGINE_CLOCKWORK_WIND_MAX) * Defaults.ENGINE_PISTON_SPEED_MAX;
|
||||
return fromClockwork >= 0.01f ? fromClockwork : storedEnergy > 0 ? 0.01f : 0;
|
||||
return fromClockwork >= 0.01f ? fromClockwork : energyManager.getTotalEnergyStored() > 0 ? 0.01f : 0;
|
||||
}
|
||||
|
||||
@Override public void getGUINetworkData(int i, int j) {}
|
||||
|
||||
@@ -61,7 +61,7 @@ public class EngineCopper extends Engine implements ISpecialInventory, ISidedInv
|
||||
private final TileInventoryAdapter inventory;
|
||||
|
||||
public EngineCopper() {
|
||||
super(Defaults.ENGINE_COPPER_HEAT_MAX, 20000, 400);
|
||||
super(Defaults.ENGINE_COPPER_HEAT_MAX, 200000, 4000);
|
||||
setHints(Config.hints.get("engine.copper"));
|
||||
|
||||
ashForItem = Defaults.ENGINE_COPPER_ASH_FOR_ITEM;
|
||||
@@ -133,7 +133,7 @@ public class EngineCopper extends Engine implements ISpecialInventory, ISidedInv
|
||||
|
||||
if (isActivated()) {
|
||||
currentOutput = determineFuelValue(new ItemStack(fuelItem, 1, fuelItemMeta));
|
||||
addEnergy(currentOutput);
|
||||
energyManager.generateEnergy(currentOutput);
|
||||
}
|
||||
} else if (isActivated()) {
|
||||
int fuelslot = getFuelSlot();
|
||||
@@ -174,7 +174,7 @@ public class EngineCopper extends Engine implements ISpecialInventory, ISidedInv
|
||||
|
||||
if (isBurning()) {
|
||||
heat++;
|
||||
if (((double) storedEnergy / (double) maxEnergy) > 0.5)
|
||||
if (((double) energyManager.getTotalEnergyStored() / (double) maxEnergy) > 0.5)
|
||||
heat++;
|
||||
}
|
||||
|
||||
@@ -333,7 +333,7 @@ public class EngineCopper extends Engine implements ISpecialInventory, ISidedInv
|
||||
currentOutput = j;
|
||||
break;
|
||||
case 3:
|
||||
storedEnergy = j;
|
||||
energyManager.fromPacketInt(j);
|
||||
break;
|
||||
case 4:
|
||||
heat = j;
|
||||
@@ -346,7 +346,7 @@ public class EngineCopper extends Engine implements ISpecialInventory, ISidedInv
|
||||
iCrafting.sendProgressBarUpdate(containerEngine, 0, burnTime);
|
||||
iCrafting.sendProgressBarUpdate(containerEngine, 1, totalBurnTime);
|
||||
iCrafting.sendProgressBarUpdate(containerEngine, 2, currentOutput);
|
||||
iCrafting.sendProgressBarUpdate(containerEngine, 3, (int)storedEnergy);
|
||||
iCrafting.sendProgressBarUpdate(containerEngine, 3, energyManager.toPacketInt());
|
||||
iCrafting.sendProgressBarUpdate(containerEngine, 4, heat);
|
||||
}
|
||||
|
||||
|
||||
@@ -39,13 +39,13 @@ public class EngineTin extends Engine implements ISocketable, IInventory {
|
||||
|
||||
protected static class EuConfig {
|
||||
public int euForCycle;
|
||||
public int mjPerCycle;
|
||||
public int rfPerCycle;
|
||||
public int euStorage;
|
||||
public int euMaxAccept = 512;
|
||||
|
||||
public EuConfig(int euForCycle, int mjPerCycle, int euStorage) {
|
||||
public EuConfig(int euForCycle, int rfPerCycle, int euStorage) {
|
||||
this.euForCycle = euForCycle;
|
||||
this.mjPerCycle = mjPerCycle;
|
||||
this.rfPerCycle = rfPerCycle;
|
||||
this.euStorage = euStorage;
|
||||
}
|
||||
}
|
||||
@@ -60,7 +60,7 @@ public class EngineTin extends Engine implements ISocketable, IInventory {
|
||||
private final DelayTimer delayUpdateTimer = new DelayTimer();
|
||||
|
||||
public EngineTin() {
|
||||
super(Defaults.ENGINE_TIN_HEAT_MAX, 10000, 400);
|
||||
super(Defaults.ENGINE_TIN_HEAT_MAX, 100000, 4000);
|
||||
setHints(Config.hints.get("engine.tin"));
|
||||
|
||||
if (PluginIC2.instance.isAvailable()) ic2EnergySink = new BasicSink(this, euConfig.euStorage, 3);
|
||||
@@ -136,7 +136,7 @@ public class EngineTin extends Engine implements ISocketable, IInventory {
|
||||
int gain = 0;
|
||||
if (isActivated() && isBurning()) {
|
||||
gain++;
|
||||
if (((double) storedEnergy / (double) maxEnergy) > 0.5)
|
||||
if (((double) energyManager.getTotalEnergyStored() / (double) maxEnergy) > 0.5)
|
||||
gain++;
|
||||
}
|
||||
|
||||
@@ -184,8 +184,8 @@ public class EngineTin extends Engine implements ISocketable, IInventory {
|
||||
return;
|
||||
|
||||
if (ic2EnergySink.useEnergy(euConfig.euForCycle)) {
|
||||
currentOutput = euConfig.mjPerCycle;
|
||||
addEnergy(euConfig.mjPerCycle);
|
||||
currentOutput = euConfig.rfPerCycle;
|
||||
energyManager.generateEnergy(euConfig.rfPerCycle);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -233,7 +233,7 @@ public class EngineTin extends Engine implements ISocketable, IInventory {
|
||||
currentOutput = j;
|
||||
break;
|
||||
case 1:
|
||||
storedEnergy = j;
|
||||
energyManager.fromPacketInt(j);
|
||||
break;
|
||||
case 2:
|
||||
heat = j;
|
||||
@@ -248,7 +248,7 @@ public class EngineTin extends Engine implements ISocketable, IInventory {
|
||||
@Override
|
||||
public void sendGUINetworkData(Container containerEngine, ICrafting iCrafting) {
|
||||
iCrafting.sendProgressBarUpdate(containerEngine, 0, currentOutput);
|
||||
iCrafting.sendProgressBarUpdate(containerEngine, 1, (int)storedEnergy);
|
||||
iCrafting.sendProgressBarUpdate(containerEngine, 1, energyManager.toPacketInt());
|
||||
iCrafting.sendProgressBarUpdate(containerEngine, 2, heat);
|
||||
if (ic2EnergySink != null) {
|
||||
iCrafting.sendProgressBarUpdate(containerEngine, 3, (short) ic2EnergySink.getEnergyStored());
|
||||
@@ -256,9 +256,9 @@ public class EngineTin extends Engine implements ISocketable, IInventory {
|
||||
}
|
||||
|
||||
// / ENERGY CONFIG CHANGE
|
||||
public void changeEnergyConfig(int euChange, int mjChange, int storageChange) {
|
||||
public void changeEnergyConfig(int euChange, int rfChange, int storageChange) {
|
||||
euConfig.euForCycle += euChange;
|
||||
euConfig.mjPerCycle += mjChange;
|
||||
euConfig.rfPerCycle += rfChange;
|
||||
euConfig.euStorage += storageChange;
|
||||
|
||||
if (ic2EnergySink != null) ic2EnergySink.setCapacity(euConfig.euStorage);
|
||||
|
||||
@@ -47,9 +47,9 @@ public abstract class GuiEngine extends GuiForestryTitled<Engine> {
|
||||
|
||||
fontRendererObj.drawStringWithShadow(StringUtil.localize("gui.energy"), x + 22, y + 8, fontColor.get("ledger.power.header"));
|
||||
fontRendererObj.drawStringWithShadow(StringUtil.localize("gui.currentOutput") + ":", x + 22, y + 20, fontColor.get("ledger.power.subheader"));
|
||||
fontRendererObj.drawString(engine.getCurrentOutput() + " MJ/t", x + 22, y + 32, fontColor.get("ledger.power.text"));
|
||||
fontRendererObj.drawString(engine.getCurrentOutput() + " RF/t", x + 22, y + 32, fontColor.get("ledger.power.text"));
|
||||
fontRendererObj.drawStringWithShadow(StringUtil.localize("gui.stored") + ":", x + 22, y + 44, fontColor.get("ledger.power.subheader"));
|
||||
fontRendererObj.drawString(engine.getEnergyStored() + " MJ", x + 22, y + 56, fontColor.get("ledger.power.text"));
|
||||
fontRendererObj.drawString(engine.getEnergyStored(engine.getOrientation()) + " RF", x + 22, y + 56, fontColor.get("ledger.power.text"));
|
||||
fontRendererObj.drawStringWithShadow(StringUtil.localize("gui.heat") + ":", x + 22, y + 68, fontColor.get("ledger.power.subheader"));
|
||||
fontRendererObj.drawString((((double) engine.getHeat() / (double) 10) + 20.0) + " C", x + 22, y + 80, fontColor.get("ledger.power.text"));
|
||||
|
||||
@@ -57,7 +57,7 @@ public abstract class GuiEngine extends GuiForestryTitled<Engine> {
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return engine.getCurrentOutput() + " MJ/t";
|
||||
return engine.getCurrentOutput() + " RF/t";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,6 @@ import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
|
||||
import buildcraft.api.gates.ITrigger;
|
||||
import buildcraft.api.power.PowerHandler;
|
||||
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.core.EnumErrorCode;
|
||||
@@ -156,6 +155,7 @@ public class MachineBottler extends TilePowered implements ISidedInventory, ILiq
|
||||
private int fillingTotalTime;
|
||||
|
||||
public MachineBottler() {
|
||||
super(500, 1100, 50, 4000);
|
||||
setHints(Config.hints.get("bottler"));
|
||||
resourceTank = new StandardTank(Defaults.PROCESSOR_TANK_CAPACITY);
|
||||
tankManager = new TankManager(resourceTank);
|
||||
@@ -171,12 +171,6 @@ public class MachineBottler extends TilePowered implements ISidedInventory, ILiq
|
||||
player.openGui(ForestryAPI.instance, GuiId.BottlerGUI.ordinal(), player.worldObj, xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void configurePowerProvider(PowerHandler provider) {
|
||||
provider.configure(50, 110, 5, 400);
|
||||
}
|
||||
|
||||
/* SAVING & LOADING */
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbttagcompound) {
|
||||
|
||||
@@ -35,7 +35,6 @@ import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
|
||||
import buildcraft.api.gates.ITrigger;
|
||||
import buildcraft.api.power.PowerHandler;
|
||||
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.recipes.ICarpenterManager;
|
||||
@@ -234,6 +233,7 @@ public class MachineCarpenter extends TilePowered implements ISidedInventory, IL
|
||||
}
|
||||
|
||||
public MachineCarpenter() {
|
||||
super(500, 1100, 50, 4000);
|
||||
setHints(Config.hints.get("carpenter"));
|
||||
resourceTank = new FilteredTank(Defaults.PROCESSOR_TANK_CAPACITY, RecipeManager.recipeFluids);
|
||||
craftingInventory = new TileInventoryAdapter(this, 10, "CraftItems");
|
||||
@@ -252,11 +252,6 @@ public class MachineCarpenter extends TilePowered implements ISidedInventory, IL
|
||||
player.openGui(ForestryAPI.instance, GuiId.CarpenterGUI.ordinal(), player.worldObj, xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configurePowerProvider(PowerHandler provider) {
|
||||
provider.configure(50, 110, 5, 400);
|
||||
}
|
||||
|
||||
/* LOADING & SAVING */
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbttagcompound) {
|
||||
|
||||
@@ -27,7 +27,6 @@ import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import buildcraft.api.gates.ITrigger;
|
||||
import buildcraft.api.power.PowerHandler;
|
||||
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.core.ISpecialInventory;
|
||||
@@ -143,6 +142,7 @@ public class MachineCentrifuge extends TilePowered implements ISidedInventory, I
|
||||
private int timePerItem;
|
||||
|
||||
public MachineCentrifuge() {
|
||||
super(400, 800, 40, Defaults.MACHINE_MAX_ENERGY);
|
||||
setHints(Config.hints.get("centrifuge"));
|
||||
}
|
||||
|
||||
@@ -156,11 +156,6 @@ public class MachineCentrifuge extends TilePowered implements ISidedInventory, I
|
||||
player.openGui(ForestryAPI.instance, GuiId.CentrifugeGUI.ordinal(), player.worldObj, xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configurePowerProvider(PowerHandler provider) {
|
||||
provider.configure(40, 80, 4, Defaults.MACHINE_MAX_ENERGY);
|
||||
}
|
||||
|
||||
/* LOADING & SAVING */
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbttagcompound) {
|
||||
|
||||
@@ -27,8 +27,6 @@ import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import buildcraft.api.power.PowerHandler;
|
||||
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.core.ISpecialInventory;
|
||||
import forestry.api.recipes.IFabricatorManager;
|
||||
@@ -238,23 +236,17 @@ public class MachineFabricator extends TilePowered implements ICrafter, ISpecial
|
||||
private final TankManager tankManager;
|
||||
private FilteredTank moltenTank;
|
||||
private final InventoryAdapter inventory = new InventoryAdapter(30, "Items");
|
||||
private final int moltenTankIndex;
|
||||
private int heat = 0;
|
||||
private int guiMeltingPoint = 0;
|
||||
|
||||
private FluidStack pendingSmelt;
|
||||
|
||||
public MachineFabricator() {
|
||||
super(500, 1100, 50, 3300);
|
||||
Fluid liquidGlass = FluidRegistry.getFluid(Defaults.LIQUID_GLASS);
|
||||
moltenTank = new FilteredTank(2 * Defaults.BUCKET_VOLUME, liquidGlass);
|
||||
moltenTank.tankMode = StandardTank.TankMode.INTERNAL;
|
||||
tankManager = new TankManager(moltenTank);
|
||||
moltenTankIndex = moltenTank.getTankIndex();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configurePowerProvider(PowerHandler provider) {
|
||||
provider.configure(50, 110, 5, 330);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -30,7 +30,6 @@ import net.minecraftforge.fluids.FluidContainerRegistry.FluidContainerData;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import buildcraft.api.gates.ITrigger;
|
||||
import buildcraft.api.power.PowerHandler;
|
||||
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.fuels.FuelManager;
|
||||
@@ -197,6 +196,7 @@ public class MachineFermenter extends TilePowered implements ISidedInventory, IL
|
||||
public int fuelCurrentFerment = 0;
|
||||
|
||||
public MachineFermenter() {
|
||||
super(50, 2000, 150, 8000);
|
||||
setHints(Config.hints.get("fermenter"));
|
||||
resourceTank = new FilteredTank(Defaults.PROCESSOR_TANK_CAPACITY, RecipeManager.recipeFluidInputs);
|
||||
resourceTank.tankMode = StandardTank.TankMode.INPUT;
|
||||
@@ -215,11 +215,6 @@ public class MachineFermenter extends TilePowered implements ISidedInventory, IL
|
||||
player.openGui(ForestryAPI.instance, GuiId.FermenterGUI.ordinal(), player.worldObj, xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configurePowerProvider(PowerHandler provider) {
|
||||
provider.configure(5, 200, 15, 800);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbttagcompound) {
|
||||
super.writeToNBT(nbttagcompound);
|
||||
|
||||
@@ -145,6 +145,7 @@ public class MachineMoistener extends TilePowered implements ISpecialInventory,
|
||||
private ItemStack pendingProduct;
|
||||
|
||||
public MachineMoistener() {
|
||||
super(0, 0, 0, 0);
|
||||
setHints(Config.hints.get("moistener"));
|
||||
resourceTank = new FilteredTank(Defaults.PROCESSOR_TANK_CAPACITY, FluidRegistry.WATER);
|
||||
tankManager = new TankManager(resourceTank);
|
||||
|
||||
@@ -32,7 +32,6 @@ import net.minecraftforge.fluids.FluidContainerRegistry.FluidContainerData;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import buildcraft.api.gates.ITrigger;
|
||||
import buildcraft.api.power.PowerHandler;
|
||||
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.core.ISpecialInventory;
|
||||
@@ -150,6 +149,7 @@ public class MachineSqueezer extends TilePowered implements ISpecialInventory, I
|
||||
private int timePerItem;
|
||||
|
||||
public MachineSqueezer() {
|
||||
super(500, 1100, 50, 4000);
|
||||
setHints(Config.hints.get("squeezer"));
|
||||
productTank = new FilteredTank(Defaults.PROCESSOR_TANK_CAPACITY, RecipeManager.recipeFluids);
|
||||
productTank.tankMode = StandardTank.TankMode.OUTPUT;
|
||||
@@ -166,11 +166,6 @@ public class MachineSqueezer extends TilePowered implements ISpecialInventory, I
|
||||
player.openGui(ForestryAPI.instance, GuiId.SqueezerGUI.ordinal(), player.worldObj, xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configurePowerProvider(PowerHandler provider) {
|
||||
provider.configure(50, 110, 5, 400);
|
||||
}
|
||||
|
||||
/* LOADING & SAVING */
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbttagcompound) {
|
||||
|
||||
@@ -29,7 +29,6 @@ import net.minecraftforge.fluids.FluidContainerRegistry.FluidContainerData;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import buildcraft.api.gates.ITrigger;
|
||||
import buildcraft.api.power.PowerHandler;
|
||||
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.core.ISpecialInventory;
|
||||
@@ -140,6 +139,7 @@ public class MachineStill extends TilePowered implements ISpecialInventory, ISid
|
||||
public int distillationTotalTime = 0;
|
||||
|
||||
public MachineStill() {
|
||||
super(500, 1100, 50, 8000);
|
||||
setHints(Config.hints.get("still"));
|
||||
resourceTank = new FilteredTank(Defaults.PROCESSOR_TANK_CAPACITY, RecipeManager.recipeFluidInputs);
|
||||
resourceTank.tankMode = StandardTank.TankMode.INPUT;
|
||||
@@ -158,11 +158,6 @@ public class MachineStill extends TilePowered implements ISpecialInventory, ISid
|
||||
player.openGui(ForestryAPI.instance, GuiId.StillGUI.ordinal(), player.worldObj, xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configurePowerProvider(PowerHandler provider) {
|
||||
provider.configure(50, 110, 5, 800);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbttagcompound) {
|
||||
super.writeToNBT(nbttagcompound);
|
||||
|
||||
@@ -10,37 +10,23 @@
|
||||
******************************************************************************/
|
||||
package forestry.farming.gadgets;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import buildcraft.api.power.PowerHandler;
|
||||
import buildcraft.api.power.PowerHandler.PowerReceiver;
|
||||
import buildcraft.api.power.PowerHandler.Type;
|
||||
|
||||
import forestry.api.core.ITileStructure;
|
||||
import forestry.api.farming.IFarmHousing;
|
||||
import forestry.core.GameMode;
|
||||
import forestry.core.interfaces.IPowerHandler;
|
||||
import forestry.energy.EnergyManager;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class TileGearbox extends TileFarm implements IPowerHandler {
|
||||
|
||||
public static int WORK_CYCLES = 4;
|
||||
public static int MIN_ENERGY_RECEIVED = 5;
|
||||
public static int MAX_ENERGY_RECEIVED = 20;
|
||||
public static int MIN_ACTIVATION_ENERGY = 5;
|
||||
public static int MAX_ENERGY = 1000;
|
||||
private int activationDelay = 0;
|
||||
private int previousDelays = 0;
|
||||
private int workCounter;
|
||||
private final EnergyManager energyManager;
|
||||
|
||||
public TileGearbox() {
|
||||
powerProvider = new PowerHandler(this, Type.MACHINE);
|
||||
powerProvider.configurePowerPerdition(0, 100);
|
||||
powerProvider.configure(MIN_ENERGY_RECEIVED,
|
||||
Math.round(MAX_ENERGY_RECEIVED * GameMode.getGameMode().getFloatSetting("energy.demand.modifier")),
|
||||
Math.round(MIN_ACTIVATION_ENERGY * GameMode.getGameMode().getFloatSetting("energy.demand.modifier")),
|
||||
Math.round(MAX_ENERGY * GameMode.getGameMode().getFloatSetting("energy.demand.modifier")));
|
||||
energyManager = new EnergyManager(50, 200, 50, 10000);
|
||||
|
||||
fixedType = TYPE_GEARS;
|
||||
}
|
||||
@@ -58,7 +44,7 @@ public class TileGearbox extends TileFarm implements IPowerHandler {
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbttagcompound) {
|
||||
super.readFromNBT(nbttagcompound);
|
||||
powerProvider.readFromNBT(nbttagcompound);
|
||||
energyManager.readFromNBT(nbttagcompound);
|
||||
|
||||
activationDelay = nbttagcompound.getInteger("ActivationDelay");
|
||||
previousDelays = nbttagcompound.getInteger("PrevDelays");
|
||||
@@ -67,25 +53,12 @@ public class TileGearbox extends TileFarm implements IPowerHandler {
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbttagcompound) {
|
||||
super.writeToNBT(nbttagcompound);
|
||||
powerProvider.writeToNBT(nbttagcompound);
|
||||
energyManager.writeToNBT(nbttagcompound);
|
||||
|
||||
nbttagcompound.setInteger("ActivationDelay", activationDelay);
|
||||
nbttagcompound.setInteger("PrevDelays", previousDelays);
|
||||
}
|
||||
|
||||
/* IPOWERRECEPTOR */
|
||||
PowerHandler powerProvider;
|
||||
|
||||
@Override
|
||||
public PowerReceiver getPowerReceiver(ForgeDirection side) {
|
||||
return powerProvider.getPowerReceiver();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PowerHandler getPowerHandler() {
|
||||
return powerProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateServerSide() {
|
||||
super.updateServerSide();
|
||||
@@ -95,6 +68,11 @@ public class TileGearbox extends TileFarm implements IPowerHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
// Hard limit to 4 cycles / second.
|
||||
if (workCounter < WORK_CYCLES && energyManager.consumeEnergyToDoWork()) {
|
||||
workCounter++;
|
||||
}
|
||||
|
||||
if (workCounter >= WORK_CYCLES && worldObj.getTotalWorldTime() % 5 == 0) {
|
||||
ITileStructure central = getCentralTE();
|
||||
if (!(central instanceof IFarmHousing))
|
||||
@@ -111,12 +89,34 @@ public class TileGearbox extends TileFarm implements IPowerHandler {
|
||||
}
|
||||
}
|
||||
|
||||
/* IPowerHandler */
|
||||
@Override
|
||||
public void doWork(PowerHandler workProvider) {
|
||||
// Hard limit to 4 cycles / second.
|
||||
if (workCounter < WORK_CYCLES) {
|
||||
powerProvider.useEnergy(MIN_ACTIVATION_ENERGY, MIN_ACTIVATION_ENERGY, true);
|
||||
workCounter++;
|
||||
}
|
||||
public EnergyManager getEnergyManager() {
|
||||
return energyManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) {
|
||||
return energyManager.receiveEnergy(from, maxReceive, simulate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate) {
|
||||
return energyManager.extractEnergy(from, maxExtract, simulate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyStored(ForgeDirection from) {
|
||||
return energyManager.getEnergyStored(from);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxEnergyStored(ForgeDirection from) {
|
||||
return energyManager.getMaxEnergyStored(from);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnectEnergy(ForgeDirection from) {
|
||||
return energyManager.canConnectEnergy(from);
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,6 @@ import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
@@ -26,8 +25,6 @@ import buildcraft.api.fuels.IronEngineFuel;
|
||||
import buildcraft.api.gates.ActionManager;
|
||||
import buildcraft.api.gates.ITrigger;
|
||||
import buildcraft.api.gates.ITriggerProvider;
|
||||
import buildcraft.api.power.PowerHandler;
|
||||
import buildcraft.api.power.PowerHandler.PowerReceiver;
|
||||
import buildcraft.api.recipes.BuildcraftRecipes;
|
||||
import buildcraft.api.transport.IPipeTile;
|
||||
|
||||
@@ -134,14 +131,6 @@ public class PluginBuildCraft extends ForestryPlugin implements ITriggerProvider
|
||||
Proxies.common.addRecipe(new ItemStack(pipeWaterproof), "#", '#', ForestryItem.beeswax);
|
||||
}
|
||||
|
||||
public double invokeUseEnergyMethod(PowerHandler workProvider, float min, float max, boolean doUse) {
|
||||
return workProvider.useEnergy(min, max, doUse);
|
||||
}
|
||||
|
||||
public void invokeReceiveEnergyMethod(PowerHandler.Type type, PowerReceiver receiver, double extractedEnergy, ForgeDirection from) {
|
||||
receiver.receiveEnergy(type, extractedEnergy, from);
|
||||
}
|
||||
|
||||
// / ITRIGGERPROVIDER
|
||||
@Override
|
||||
public LinkedList<ITrigger> getPipeTriggers(IPipeTile pipe) {
|
||||
|
||||
@@ -129,8 +129,8 @@ public class PluginEnergy extends ForestryPlugin {
|
||||
Circuit.energyElectricChoke1 = new CircuitElectricChoke("electric.choke.1");
|
||||
Circuit.energyFireDampener1 = new CircuitFireDampener("dampener.1");
|
||||
Circuit.energyElectricEfficiency1 = new CircuitElectricEfficiency("electric.efficiency.1");
|
||||
Circuit.energyElectricBoost1 = new CircuitElectricBoost("electric.boost.1", 2, 7, 2);
|
||||
Circuit.energyElectricBoost2 = new CircuitElectricBoost("electric.boost.2", 2, 15, 4);
|
||||
Circuit.energyElectricBoost1 = new CircuitElectricBoost("electric.boost.1", 2, 7, 20);
|
||||
Circuit.energyElectricBoost2 = new CircuitElectricBoost("electric.boost.2", 2, 15, 40);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user