mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-20 12:09:39 +00:00
Clean up Engines a bit.
Remove ISpecialInventory implementations on Engines. Change Engines to IEnergyConnection instead of IEnergyHandler.
This commit is contained in:
1 parent
10a5ba3eb8
commit
6ea4ab4491
8 files changed
+133
-131
No files matched your search
@@ -10,6 +10,7 @@
|
||||
******************************************************************************/
|
||||
package forestry.core.gadgets;
|
||||
|
||||
import cofh.api.energy.IEnergyConnection;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.ICrafting;
|
||||
@@ -17,17 +18,14 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import cofh.api.energy.IEnergyHandler;
|
||||
import forestry.core.TemperatureState;
|
||||
import forestry.core.config.Defaults;
|
||||
import forestry.core.network.PacketPayload;
|
||||
import forestry.core.utils.BlockUtil;
|
||||
import forestry.energy.EnergyManager;
|
||||
|
||||
public abstract class Engine extends TileBase implements IEnergyHandler {
|
||||
public abstract class Engine extends TileBase implements IEnergyConnection {
|
||||
|
||||
@Override
|
||||
public PacketPayload getPacketPayload() {
|
||||
@@ -120,7 +118,6 @@ public abstract class Engine extends TileBase implements IEnergyHandler {
|
||||
}
|
||||
} else if (this.isActive)
|
||||
stagePiston = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -154,13 +151,13 @@ public abstract class Engine extends TileBase implements IEnergyHandler {
|
||||
stagePiston = 0;
|
||||
}
|
||||
|
||||
} else if (canPowerTo(tile)) { // If we are not already running, check if
|
||||
if (getEnergyStored(getOrientation()) > 0) {
|
||||
} else if (canPowerTo(tile)) // If we are not already running, check if
|
||||
if (energyManager.getEnergyStored(getOrientation()) > 0) {
|
||||
stagePiston = 1; // If we can transfer energy, start running
|
||||
setActive(true);
|
||||
} else
|
||||
setActive(false);
|
||||
} else
|
||||
else
|
||||
setActive(false);
|
||||
|
||||
dissipateHeat();
|
||||
@@ -302,32 +299,12 @@ public abstract class Engine extends TileBase implements IEnergyHandler {
|
||||
|
||||
public abstract void sendGUINetworkData(Container containerEngine, ICrafting iCrafting);
|
||||
|
||||
@Override
|
||||
public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) {
|
||||
if (from == getOrientation())
|
||||
return 0;
|
||||
return energyManager.receiveEnergy(from, maxReceive, simulate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate) {
|
||||
if (from != getOrientation())
|
||||
return 0;
|
||||
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);
|
||||
}
|
||||
|
||||
public EnergyManager getEnergyManager() {
|
||||
return energyManager;
|
||||
}
|
||||
}
|
||||
@@ -315,10 +315,7 @@ public abstract class TileForestry extends TileEntity implements INetworkedEntit
|
||||
}
|
||||
|
||||
protected boolean canTakeStackFromSide(int slotIndex, ItemStack itemstack, int side) {
|
||||
if (getAccess() != EnumAccess.SHARED)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
return getAccess() == EnumAccess.SHARED;
|
||||
}
|
||||
|
||||
public boolean canExtractItem(int i, ItemStack itemstack, int j) {
|
||||
@@ -326,10 +323,7 @@ public abstract class TileForestry extends TileEntity implements INetworkedEntit
|
||||
}
|
||||
|
||||
protected boolean canPutStackFromSide(int slotIndex, ItemStack itemstack, int side) {
|
||||
if (getAccess() != EnumAccess.SHARED)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
return getAccess() == EnumAccess.SHARED;
|
||||
}
|
||||
|
||||
public int[] getAccessibleSlotsFromSide(int side) {
|
||||
|
||||
@@ -50,6 +50,9 @@ public class BlockUtil {
|
||||
/**
|
||||
* Searches for inventories adjacent to block, excludes IPowerReceptor
|
||||
*
|
||||
* @param world
|
||||
* @param blockPos
|
||||
* @param from
|
||||
* @return
|
||||
*/
|
||||
public static IInventory[] getAdjacentInventories(World world, Vect blockPos, ForgeDirection from) {
|
||||
@@ -75,6 +78,7 @@ public class BlockUtil {
|
||||
*
|
||||
* @param world
|
||||
* @param blockPos
|
||||
* @param from
|
||||
* @return
|
||||
*/
|
||||
public static ForgeDirection[] getPipeDirections(World world, Vect blockPos, ForgeDirection from) {
|
||||
@@ -108,9 +112,10 @@ public class BlockUtil {
|
||||
ArrayList<ForgeDirection> filtered = new ArrayList<ForgeDirection>();
|
||||
ArrayList<ForgeDirection> excludeList = new ArrayList<ForgeDirection>(Arrays.asList(exclude));
|
||||
|
||||
for (int i = 0; i < all.length; i++)
|
||||
if (!excludeList.contains(all[i]))
|
||||
filtered.add(all[i]);
|
||||
for (ForgeDirection dir : all) {
|
||||
if (!excludeList.contains(dir))
|
||||
filtered.add(dir);
|
||||
}
|
||||
|
||||
return filtered;
|
||||
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
package forestry.core.utils;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@@ -41,12 +40,10 @@ public class InventoryAdapter implements IInventory, INBTTagable {
|
||||
configureSided();
|
||||
}
|
||||
|
||||
/*
|
||||
public InventoryAdapter enableDebug() {
|
||||
this.debug = true;
|
||||
return this;
|
||||
}
|
||||
*/
|
||||
// public InventoryAdapter enableDebug() {
|
||||
// this.debug = true;
|
||||
// return this;
|
||||
// }
|
||||
|
||||
/**
|
||||
* @return Copy of this inventory. Stacks are copies.
|
||||
@@ -54,24 +51,27 @@ public class InventoryAdapter implements IInventory, INBTTagable {
|
||||
public InventoryAdapter copy() {
|
||||
InventoryAdapter copy = new InventoryAdapter(inventory.getSizeInventory(), inventory.getInventoryName(), inventory.getInventoryStackLimit());
|
||||
|
||||
for (int i = 0; i < inventory.getSizeInventory(); i++)
|
||||
for (int i = 0; i < inventory.getSizeInventory(); i++) {
|
||||
if (inventory.getStackInSlot(i) != null)
|
||||
copy.setInventorySlotContents(i, inventory.getStackInSlot(i).copy());
|
||||
}
|
||||
|
||||
return copy;
|
||||
}
|
||||
|
||||
public ItemStack[] getStacks() {
|
||||
ItemStack[] stacks = new ItemStack[inventory.getSizeInventory()];
|
||||
for(int i = 0; i < inventory.getSizeInventory(); i++)
|
||||
for (int i = 0; i < inventory.getSizeInventory(); i++) {
|
||||
stacks[i] = inventory.getStackInSlot(i);
|
||||
}
|
||||
return stacks;
|
||||
}
|
||||
|
||||
public ItemStack[] getStacks(int slot1, int length) {
|
||||
ItemStack[] result = new ItemStack[length];
|
||||
for(int i = slot1; i < slot1 + length; i++)
|
||||
for (int i = slot1; i < slot1 + length; i++) {
|
||||
result[i - slot1] = inventory.getStackInSlot(i);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -191,7 +191,7 @@ public class InventoryAdapter implements IInventory, INBTTagable {
|
||||
|
||||
/* CONTAINS */
|
||||
public boolean contains(ItemStack query, int startSlot, int slots) {
|
||||
ItemStack[] queryArray = new ItemStack[] {query};
|
||||
ItemStack[] queryArray = new ItemStack[]{query};
|
||||
return contains(queryArray, startSlot, slots);
|
||||
}
|
||||
|
||||
@@ -214,7 +214,7 @@ public class InventoryAdapter implements IInventory, INBTTagable {
|
||||
}
|
||||
if (stackMax == 0)
|
||||
return false;
|
||||
return ((float)amount / (float)stackMax) >= percent;
|
||||
return ((float) amount / (float) stackMax) >= percent;
|
||||
}
|
||||
|
||||
public boolean containsAmount(int amount, int slot1, int length) {
|
||||
@@ -236,6 +236,15 @@ public class InventoryAdapter implements IInventory, INBTTagable {
|
||||
* Removes the exact items first if they exist, and then removes crafting equivalents.
|
||||
* If the inventory doesn't have all the required items, returns false without removing anything.
|
||||
* If stowContainer is true, items with containers will have their container stowed.
|
||||
* @param count
|
||||
* @param set
|
||||
* @param firstSlotIndex
|
||||
* @param slotCount
|
||||
* @param player
|
||||
* @param stowContainer
|
||||
* @param oreDictionary
|
||||
* @param craftingTools
|
||||
* @return
|
||||
*/
|
||||
public boolean removeSets(int count, ItemStack[] set, int firstSlotIndex, int slotCount, EntityPlayer player, boolean stowContainer, boolean oreDictionary, boolean craftingTools) {
|
||||
|
||||
@@ -270,7 +279,6 @@ public class InventoryAdapter implements IInventory, INBTTagable {
|
||||
if (!StackUtils.isCraftingEquivalent(stackToRemove, stackInSlot, oreDictionary, craftingTools))
|
||||
continue;
|
||||
|
||||
|
||||
ItemStack removed = decrStackSize(j, stackToRemove.stackSize);
|
||||
stackToRemove.stackSize -= removed.stackSize;
|
||||
|
||||
@@ -379,20 +387,22 @@ public class InventoryAdapter implements IInventory, INBTTagable {
|
||||
}
|
||||
|
||||
public InventoryAdapter configureSided(int side, int startSlot, int count) {
|
||||
return configureSided(new int[] { side }, startSlot, count);
|
||||
return configureSided(new int[]{side}, startSlot, count);
|
||||
}
|
||||
|
||||
public InventoryAdapter configureSided(int[] sides, int startSlot, int count) {
|
||||
int[] slots = new int[count];
|
||||
for(int i = 0; i < count; i++)
|
||||
for (int i = 0; i < count; i++) {
|
||||
slots[i] = startSlot + i;
|
||||
}
|
||||
|
||||
return configureSided(sides, slots);
|
||||
}
|
||||
|
||||
public InventoryAdapter configureSided(int[] sides, int[] slots) {
|
||||
for(int side : sides)
|
||||
for (int side : sides) {
|
||||
slotMap[side] = slots;
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
@@ -415,13 +425,14 @@ public class InventoryAdapter implements IInventory, INBTTagable {
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbttagcompound) {
|
||||
NBTTagList nbttaglist = new NBTTagList();
|
||||
for (int i = 0; i < inventory.getSizeInventory(); i++)
|
||||
for (int i = 0; i < inventory.getSizeInventory(); i++) {
|
||||
if (inventory.getStackInSlot(i) != null) {
|
||||
NBTTagCompound nbttagcompound2 = new NBTTagCompound();
|
||||
nbttagcompound2.setByte("Slot", (byte) i);
|
||||
inventory.getStackInSlot(i).writeToNBT(nbttagcompound2);
|
||||
nbttaglist.appendTag(nbttagcompound2);
|
||||
}
|
||||
}
|
||||
nbttagcompound.setTag(inventory.getInventoryName(), nbttaglist);
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ public class EnergyManager implements IEnergyHandler {
|
||||
EXTRACT, RECEIVE, BOTH;
|
||||
}
|
||||
|
||||
private int energyPerWork;
|
||||
private final int energyPerWork;
|
||||
protected EnergyStorage energyStorage;
|
||||
private EnergyTransferMode mode = EnergyTransferMode.BOTH;
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@ package forestry.energy.gadgets;
|
||||
|
||||
import forestry.api.core.EnumErrorCode;
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.core.ISpecialInventory;
|
||||
import forestry.api.fuels.EngineBronzeFuel;
|
||||
import forestry.api.fuels.FuelManager;
|
||||
import forestry.core.config.Config;
|
||||
@@ -27,9 +26,11 @@ import forestry.core.network.GuiId;
|
||||
import forestry.core.network.PacketPayload;
|
||||
import forestry.core.utils.LiquidHelper;
|
||||
import forestry.core.utils.TileInventoryAdapter;
|
||||
import static forestry.factory.gadgets.MachineBottler.SLOT_PRODUCT;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.ICrafting;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
@@ -39,7 +40,7 @@ import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
|
||||
public class EngineBronze extends Engine implements ISpecialInventory, ILiquidTankContainer {
|
||||
public class EngineBronze extends Engine implements ISidedInventory, ILiquidTankContainer {
|
||||
|
||||
/* CONSTANTS */
|
||||
public static final short SLOT_CAN = 0;
|
||||
@@ -50,9 +51,9 @@ public class EngineBronze extends Engine implements ISpecialInventory, ILiquidTa
|
||||
PacketPayload payload = super.getPacketPayload();
|
||||
|
||||
if (shutdown)
|
||||
payload.append(new int[] { 1 });
|
||||
payload.append(new int[]{1});
|
||||
else
|
||||
payload.append(new int[] { 0 });
|
||||
payload.append(new int[]{0});
|
||||
|
||||
return payload;
|
||||
}
|
||||
@@ -91,6 +92,7 @@ public class EngineBronze extends Engine implements ISpecialInventory, ILiquidTa
|
||||
this.tankManager = new TankManager(fuelTank, heatingTank);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TankManager getTankManager() {
|
||||
return tankManager;
|
||||
}
|
||||
@@ -160,7 +162,7 @@ public class EngineBronze extends Engine implements ISpecialInventory, ILiquidTa
|
||||
}
|
||||
|
||||
// We need a minimum temperature to generate energy
|
||||
if (heatStage > 0.2) {
|
||||
if (heatStage > 0.2)
|
||||
|
||||
if (burnTime > 0) {
|
||||
burnTime--;
|
||||
@@ -171,12 +173,11 @@ public class EngineBronze extends Engine implements ISpecialInventory, ILiquidTa
|
||||
currentFluidId = fuelTank.getFluid().getFluid().getID();
|
||||
fuelTank.drain(Defaults.BUCKET_VOLUME, true);
|
||||
}
|
||||
|
||||
} else
|
||||
else
|
||||
shutdown(true);
|
||||
}
|
||||
|
||||
if(burnTime <= 0)
|
||||
if (burnTime <= 0)
|
||||
currentFluidId = -1;
|
||||
}
|
||||
|
||||
@@ -299,6 +300,7 @@ public class EngineBronze extends Engine implements ISpecialInventory, ILiquidTa
|
||||
|
||||
/**
|
||||
* Reads saved data
|
||||
* @param nbt
|
||||
*/
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
@@ -321,6 +323,7 @@ public class EngineBronze extends Engine implements ISpecialInventory, ILiquidTa
|
||||
|
||||
/**
|
||||
* Writes data to save
|
||||
* @param nbt
|
||||
*/
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbt) {
|
||||
@@ -417,6 +420,8 @@ public class EngineBronze extends Engine implements ISpecialInventory, ILiquidTa
|
||||
|
||||
/**
|
||||
* TODO: just a specialsource workaround
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer player) {
|
||||
@@ -430,6 +435,7 @@ public class EngineBronze extends Engine implements ISpecialInventory, ILiquidTa
|
||||
|
||||
/**
|
||||
* TODO: just a specialsource workaround
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean hasCustomInventoryName() {
|
||||
@@ -438,6 +444,9 @@ public class EngineBronze extends Engine implements ISpecialInventory, ILiquidTa
|
||||
|
||||
/**
|
||||
* TODO: just a specialsource workaround
|
||||
* @param slotIndex
|
||||
* @param itemstack
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int slotIndex, ItemStack itemstack) {
|
||||
@@ -451,23 +460,63 @@ public class EngineBronze extends Engine implements ISpecialInventory, ILiquidTa
|
||||
return super.isItemValidForSlot(slotIndex, itemstack);
|
||||
}
|
||||
|
||||
/* ISPECIALINVENTORY */
|
||||
/* ISIDEDINVENTORY */
|
||||
@Override
|
||||
public int addItem(ItemStack stack, boolean doAdd, ForgeDirection from) {
|
||||
protected boolean canTakeStackFromSide(int slotIndex, ItemStack stack, int side) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canPutStackFromSide(int slotIndex, ItemStack stack, int side) {
|
||||
if (!super.canTakeStackFromSide(slotIndex, stack, side))
|
||||
return false;
|
||||
|
||||
FluidContainerData container = LiquidHelper.getLiquidContainer(stack);
|
||||
if (container == null)
|
||||
return 0;
|
||||
|
||||
return inventory.addStack(stack, false, doAdd);
|
||||
return container != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: just a specialsource workaround
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public ItemStack[] extractItem(boolean doRemove, ForgeDirection from, int maxItemCount) {
|
||||
return null;
|
||||
public boolean canExtractItem(int i, ItemStack itemstack, int j) {
|
||||
return super.canExtractItem(i, itemstack, j);
|
||||
}
|
||||
|
||||
// IFluidHandler
|
||||
/**
|
||||
* TODO: just a specialsource workaround
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean canInsertItem(int i, ItemStack itemstack, int j) {
|
||||
return super.canInsertItem(i, itemstack, j);
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: just a specialsource workaround
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public int[] getAccessibleSlotsFromSide(int side) {
|
||||
return super.getAccessibleSlotsFromSide(side); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
|
||||
/* ISPECIALINVENTORY */
|
||||
// @Override
|
||||
// public int addItem(ItemStack stack, boolean doAdd, ForgeDirection from) {
|
||||
// FluidContainerData container = LiquidHelper.getLiquidContainer(stack);
|
||||
// if (container == null)
|
||||
// return 0;
|
||||
//
|
||||
// return inventory.addStack(stack, false, doAdd);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public ItemStack[] extractItem(boolean doRemove, ForgeDirection from, int maxItemCount) {
|
||||
// return null;
|
||||
// }
|
||||
// IFluidHandler
|
||||
@Override
|
||||
public int fill(ForgeDirection from, FluidStack resource, boolean doFill) {
|
||||
return tankManager.fill(from, resource, doFill);
|
||||
|
||||
@@ -15,7 +15,6 @@ import cpw.mods.fml.common.Optional;
|
||||
import cpw.mods.fml.common.registry.GameData;
|
||||
import forestry.api.core.EnumErrorCode;
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.core.ISpecialInventory;
|
||||
import forestry.api.fuels.FuelManager;
|
||||
import forestry.core.TemperatureState;
|
||||
import forestry.core.config.Config;
|
||||
@@ -42,7 +41,7 @@ import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedList;
|
||||
|
||||
public class EngineCopper extends Engine implements ISpecialInventory, ISidedInventory {
|
||||
public class EngineCopper extends Engine implements ISidedInventory {
|
||||
|
||||
/* CONSTANTS */
|
||||
public static final short SLOT_FUEL = 0;
|
||||
@@ -169,16 +168,16 @@ public class EngineCopper extends Engine implements ISpecialInventory, ISidedInv
|
||||
@Override
|
||||
public int generateHeat() {
|
||||
|
||||
int heat = 0;
|
||||
int heatToAdd = 0;
|
||||
|
||||
if (isBurning()) {
|
||||
heat++;
|
||||
heatToAdd++;
|
||||
if (((double) energyManager.getTotalEnergyStored() / (double) maxEnergy) > 0.5)
|
||||
heat++;
|
||||
heatToAdd++;
|
||||
}
|
||||
|
||||
addHeat(heat);
|
||||
return heat;
|
||||
addHeat(heatToAdd);
|
||||
return heatToAdd;
|
||||
}
|
||||
|
||||
private void addAsh(int amount) {
|
||||
@@ -242,10 +241,11 @@ public class EngineCopper extends Engine implements ISpecialInventory, ISidedInv
|
||||
continue;
|
||||
|
||||
ArrayList<ForgeDirection> filtered;
|
||||
filtered = BlockUtil.filterPipeDirections(pipes, new ForgeDirection[] { getOrientation() });
|
||||
filtered = BlockUtil.filterPipeDirections(pipes, new ForgeDirection[]{getOrientation()});
|
||||
|
||||
while (inventory.getStackInSlot(i).stackSize > 0 && filtered.size() > 0)
|
||||
while (inventory.getStackInSlot(i).stackSize > 0 && filtered.size() > 0) {
|
||||
BlockUtil.putFromStackIntoPipe(this, filtered, inventory.getStackInSlot(i));
|
||||
}
|
||||
|
||||
if (inventory.getStackInSlot(i).stackSize <= 0)
|
||||
inventory.setInventorySlotContents(i, null);
|
||||
@@ -253,7 +253,6 @@ public class EngineCopper extends Engine implements ISpecialInventory, ISidedInv
|
||||
}
|
||||
|
||||
// / STATE INFORMATION
|
||||
|
||||
@Override
|
||||
public boolean isBurning() {
|
||||
return mayBurn() && burnTime > 0;
|
||||
@@ -279,6 +278,7 @@ public class EngineCopper extends Engine implements ISpecialInventory, ISidedInv
|
||||
// / LOADING AND SAVING
|
||||
/**
|
||||
* Reads saved data
|
||||
* @param nbttagcompound
|
||||
*/
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbttagcompound) {
|
||||
@@ -286,7 +286,8 @@ public class EngineCopper extends Engine implements ISpecialInventory, ISidedInv
|
||||
|
||||
String fuelItemName = nbttagcompound.getString("EngineFuelItem");
|
||||
|
||||
if (!fuelItemName.isEmpty()) fuelItem = GameData.getItemRegistry().getRaw(fuelItemName);
|
||||
if (!fuelItemName.isEmpty())
|
||||
fuelItem = GameData.getItemRegistry().getRaw(fuelItemName);
|
||||
|
||||
fuelItemMeta = nbttagcompound.getInteger("EngineFuelMeta");
|
||||
burnTime = nbttagcompound.getInteger("EngineBurnTime");
|
||||
@@ -300,14 +301,14 @@ public class EngineCopper extends Engine implements ISpecialInventory, ISidedInv
|
||||
|
||||
/**
|
||||
* Writes data to save
|
||||
* @param nbttagcompound
|
||||
*/
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbttagcompound) {
|
||||
super.writeToNBT(nbttagcompound);
|
||||
|
||||
if (fuelItem != null) {
|
||||
if (fuelItem != null)
|
||||
nbttagcompound.setString("EngineFuelItem", GameData.getItemRegistry().getNameForObject(fuelItem));
|
||||
}
|
||||
|
||||
nbttagcompound.setInteger("EngineFuelMeta", fuelItemMeta);
|
||||
nbttagcompound.setInteger("EngineBurnTime", burnTime);
|
||||
@@ -449,55 +450,20 @@ public class EngineCopper extends Engine implements ISpecialInventory, ISidedInv
|
||||
|
||||
@Override
|
||||
protected boolean canTakeStackFromSide(int slotIndex, ItemStack itemstack, int side) {
|
||||
if(!super.canTakeStackFromSide(slotIndex, itemstack, side))
|
||||
if (!super.canTakeStackFromSide(slotIndex, itemstack, side))
|
||||
return false;
|
||||
|
||||
if(slotIndex >= SLOT_WASTE_1 && slotIndex < SLOT_WASTE_1 + SLOT_WASTE_COUNT)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
return slotIndex >= SLOT_WASTE_1 && slotIndex < SLOT_WASTE_1 + SLOT_WASTE_COUNT;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canPutStackFromSide(int slotIndex, ItemStack itemstack, int side) {
|
||||
if(!super.canPutStackFromSide(slotIndex, itemstack, side))
|
||||
if (!super.canPutStackFromSide(slotIndex, itemstack, side))
|
||||
return false;
|
||||
|
||||
if(slotIndex == SLOT_FUEL && FuelManager.copperEngineFuel.containsKey(itemstack))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
||||
return slotIndex == SLOT_FUEL && FuelManager.copperEngineFuel.containsKey(itemstack);
|
||||
}
|
||||
|
||||
/* ISPECIALINVENTORY */
|
||||
@Override
|
||||
public int addItem(ItemStack stack, boolean doAdd, ForgeDirection from) {
|
||||
// Peat
|
||||
if (FuelManager.copperEngineFuel.containsKey(stack))
|
||||
return inventory.addStack(stack, SLOT_FUEL, 1, false, doAdd);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack[] extractItem(boolean doRemove, ForgeDirection from, int maxItemCount) {
|
||||
for (int i = SLOT_WASTE_1; i < SLOT_WASTE_1 + SLOT_WASTE_COUNT; i++) {
|
||||
if (inventory.getStackInSlot(i) == null)
|
||||
continue;
|
||||
|
||||
// Only ash can be extracted
|
||||
if (!ForestryItem.ash.isItemEqual(inventory.getStackInSlot(i)))
|
||||
continue;
|
||||
|
||||
ItemStack product = ForestryItem.ash.getItemStack();
|
||||
if (doRemove)
|
||||
decrStackSize(i, 1);
|
||||
return new ItemStack[] { product };
|
||||
}
|
||||
|
||||
return new ItemStack[0];
|
||||
}
|
||||
|
||||
/* ITRIGGERPROVIDER */
|
||||
@Optional.Method(modid = "BuildCraftAPI|statements")
|
||||
|
||||
@@ -49,7 +49,7 @@ public abstract class GuiEngine extends GuiForestryTitled<Engine> {
|
||||
fontRendererObj.drawStringWithShadow(StringUtil.localize("gui.currentOutput") + ":", x + 22, y + 20, fontColor.get("ledger.power.subheader"));
|
||||
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(engine.getOrientation()) + " RF", x + 22, y + 56, fontColor.get("ledger.power.text"));
|
||||
fontRendererObj.drawString(engine.getEnergyManager().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"));
|
||||
|
||||
|
||||
Reference in new issue
Block a user