mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-19 19:49:54 +00:00
Close #797 With Nirek: Chipset upgrades for Machines
This commit is contained in:
1 parent
1da8001b92
commit
fbf731b858
75 files changed
+1117
-698
No files matched your search
@@ -16,7 +16,7 @@ import forestry.apiculture.multiblock.IAlvearyController;
|
||||
import forestry.apiculture.multiblock.TileAlvearyPlain;
|
||||
import forestry.core.config.Defaults;
|
||||
import forestry.core.gui.GuiForestryTitled;
|
||||
import forestry.core.gui.OwnerLedger;
|
||||
import forestry.core.gui.ledgers.OwnerLedger;
|
||||
import forestry.core.utils.EnumTankLevel;
|
||||
import forestry.core.utils.Utils;
|
||||
|
||||
|
||||
@@ -15,10 +15,8 @@ import forestry.api.apiculture.IBeeHousing;
|
||||
import forestry.core.interfaces.IClimatised;
|
||||
import forestry.core.interfaces.IRestrictedAccessTile;
|
||||
import forestry.core.inventory.IInventoryAdapter;
|
||||
import forestry.core.network.IStreamableGui;
|
||||
|
||||
|
||||
public interface IAlvearyController extends IBeeHousing, IClimatised, IRestrictedAccessTile, IStreamableGui {
|
||||
public interface IAlvearyController extends IBeeHousing, IClimatised, IRestrictedAccessTile {
|
||||
IInventoryAdapter getInternalInventory();
|
||||
|
||||
Iterable<IAlvearyComponent> getComponents();
|
||||
|
||||
@@ -26,6 +26,9 @@ import cofh.api.energy.IEnergyHandler;
|
||||
|
||||
public abstract class TileAlvearyClimatiser extends TileAlveary implements IEnergyHandler, IActivatable, IAlvearyComponent.Climatiser {
|
||||
|
||||
private static final int WORK_CYCLES = 1;
|
||||
private static final int ENERGY_PER_OPERATION = 50;
|
||||
|
||||
protected interface IClimitiserDefinition {
|
||||
float getChangePerTransfer();
|
||||
|
||||
@@ -49,16 +52,16 @@ public abstract class TileAlvearyClimatiser extends TileAlveary implements IEner
|
||||
protected TileAlvearyClimatiser(IClimitiserDefinition definition) {
|
||||
this.definition = definition;
|
||||
|
||||
this.energyManager = new EnergyManager(1000, 50, 2000);
|
||||
this.energyManager = new EnergyManager(1000, 2000);
|
||||
this.energyManager.setReceiveOnly();
|
||||
}
|
||||
|
||||
/* UPDATING */
|
||||
@Override
|
||||
public void changeClimate(int tick, IClimateControlled climateControlled) {
|
||||
if (workingTime < 20 && energyManager.consumeEnergyToDoWork()) {
|
||||
// consume 10 RF per tick of work
|
||||
workingTime += energyManager.getEnergyPerWork() / 10;
|
||||
if (workingTime < 20 && energyManager.consumeEnergyToDoWork(WORK_CYCLES, ENERGY_PER_OPERATION)) {
|
||||
// one tick of work for every 10 RF
|
||||
workingTime += ENERGY_PER_OPERATION / 10;
|
||||
}
|
||||
|
||||
if (workingTime > 0) {
|
||||
|
||||
@@ -24,10 +24,9 @@ import forestry.core.interfaces.ITitled;
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.DataOutputStreamForestry;
|
||||
import forestry.core.network.GuiId;
|
||||
import forestry.core.network.IStreamableGui;
|
||||
import forestry.core.utils.EnumAccess;
|
||||
|
||||
public abstract class TileAlvearyWithGui extends TileAlveary implements IStreamableGui, ITitled, IRestrictedAccessTile {
|
||||
public abstract class TileAlvearyWithGui extends TileAlveary implements ITitled, IRestrictedAccessTile {
|
||||
|
||||
private final AccessHandler accessHandler;
|
||||
private final String unlocalizedTitle;
|
||||
|
||||
@@ -98,4 +98,8 @@ public abstract class Circuit implements ICircuit {
|
||||
public static ICircuit farmOrchardManual;
|
||||
public static ICircuit farmRubberManual;
|
||||
public static ICircuit farmEnderManaged;
|
||||
|
||||
public static ICircuit machineSpeedUpgrade1;
|
||||
public static ICircuit machineSpeedUpgrade2;
|
||||
public static ICircuit machineEfficiencyUpgrade1;
|
||||
}
|
||||
Executable → Regular
+1
-1
@@ -8,7 +8,7 @@
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.core.interfaces;
|
||||
package forestry.core.circuits;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.core.circuits;
|
||||
|
||||
public interface ISpeedUpgradable {
|
||||
void applySpeedUpgrade(double speedChange, double powerChange);
|
||||
}
|
||||
@@ -145,10 +145,6 @@ public class Defaults {
|
||||
// Factory
|
||||
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 = 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;
|
||||
|
||||
@@ -131,6 +131,11 @@ public class StandardTank extends FluidTank {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean canDrain(int amount) {
|
||||
FluidStack drained = drain(amount, false);
|
||||
return (drained != null) && (drained.amount == amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(int maxDrain, boolean doDrain) {
|
||||
if (maxDrain <= 0) {
|
||||
|
||||
@@ -35,10 +35,9 @@ import net.minecraftforge.fluids.IFluidHandler;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.core.circuits.ISocketable;
|
||||
import forestry.core.fluids.FluidHelper;
|
||||
import forestry.core.interfaces.IAccessHandler;
|
||||
import forestry.core.interfaces.IRestrictedAccessTile;
|
||||
import forestry.core.interfaces.ISocketable;
|
||||
import forestry.core.items.ItemNBTTile;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.PlayerUtil;
|
||||
|
||||
@@ -18,7 +18,7 @@ import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import forestry.core.interfaces.ISocketable;
|
||||
import forestry.core.circuits.ISocketable;
|
||||
import forestry.core.multiblock.MultiblockControllerBase;
|
||||
import forestry.core.multiblock.MultiblockTileEntityBase;
|
||||
import forestry.core.proxy.Proxies;
|
||||
|
||||
@@ -56,7 +56,7 @@ public abstract class Engine extends TileBase implements IEnergyConnection, IAct
|
||||
|
||||
protected Engine(int maxHeat, int maxEnergy) {
|
||||
this.maxHeat = maxHeat;
|
||||
energyManager = new EnergyManager(2000, 100, maxEnergy);
|
||||
energyManager = new EnergyManager(2000, maxEnergy);
|
||||
|
||||
// allow engines to chain, but not have energy sucked out of them
|
||||
energyManager.setReceiveOnly();
|
||||
|
||||
@@ -69,15 +69,15 @@ public class TileAnalyzer extends TilePowered implements ISidedInventory, ILiqui
|
||||
private int analyzeTime;
|
||||
|
||||
private final FilteredTank resourceTank;
|
||||
|
||||
private final TankManager tankManager;
|
||||
|
||||
private final IInventory invInput;
|
||||
private final IInventory invOutput;
|
||||
|
||||
private ItemStack individualOnDisplayClient;
|
||||
|
||||
/* CONSTRUCTOR */
|
||||
public TileAnalyzer() {
|
||||
super(800, 40, Defaults.MACHINE_MAX_ENERGY);
|
||||
super(800, Defaults.MACHINE_MAX_ENERGY, 160);
|
||||
setInternalInventory(new AnalyzerInventoryAdapter(this));
|
||||
resourceTank = new FilteredTank(Defaults.PROCESSOR_TANK_CAPACITY, Fluids.HONEY.getFluid());
|
||||
tankManager = new TankManager(resourceTank);
|
||||
@@ -225,14 +225,17 @@ public class TileAnalyzer extends TilePowered implements ISidedInventory, ILiqui
|
||||
}
|
||||
|
||||
/* STATE INFORMATION */
|
||||
// @Override
|
||||
@Override
|
||||
public boolean isWorking() {
|
||||
return analyzeTime > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasWork() {
|
||||
ItemStack stackToAnalyze = getStackInSlot(SLOT_ANALYZE);
|
||||
if (stackToAnalyze != null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (getInputSlot() != null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Set<IErrorState> errors = new HashSet<IErrorState>(getErrorLogic().getErrorStates());
|
||||
errors.remove(EnumErrorCode.NOPOWER);
|
||||
return errors.size() == 0;
|
||||
@@ -242,8 +245,6 @@ public class TileAnalyzer extends TilePowered implements ISidedInventory, ILiqui
|
||||
return (analyzeTime * i) / TIME_TO_ANALYZE;
|
||||
}
|
||||
|
||||
private ItemStack individualOnDisplayClient;
|
||||
|
||||
public ItemStack getIndividualOnDisplay() {
|
||||
if (worldObj.isRemote) {
|
||||
return individualOnDisplayClient;
|
||||
|
||||
@@ -42,7 +42,6 @@ import forestry.core.inventory.IInventoryAdapter;
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.DataOutputStreamForestry;
|
||||
import forestry.core.network.IStreamable;
|
||||
import forestry.core.network.IStreamableGui;
|
||||
import forestry.core.network.PacketTileStream;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.AdjacentTileCache;
|
||||
@@ -54,7 +53,7 @@ import buildcraft.api.statements.ITriggerInternal;
|
||||
import buildcraft.api.statements.ITriggerProvider;
|
||||
|
||||
@Optional.Interface(iface = "buildcraft.api.statements.ITriggerProvider", modid = "BuildCraftAPI|statements")
|
||||
public abstract class TileForestry extends TileEntity implements IStreamable, IErrorLogicSource, ITriggerProvider, ISidedInventory, IFilterSlotDelegate, IRestrictedAccessTile, IStreamableGui, ITitled {
|
||||
public abstract class TileForestry extends TileEntity implements IStreamable, IErrorLogicSource, ITriggerProvider, ISidedInventory, IFilterSlotDelegate, IRestrictedAccessTile, ITitled {
|
||||
|
||||
private static final Random rand = new Random();
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ import cpw.mods.fml.common.Optional;
|
||||
|
||||
import forestry.api.core.IErrorLogic;
|
||||
import forestry.core.EnumErrorCode;
|
||||
import forestry.core.circuits.ISpeedUpgradable;
|
||||
import forestry.core.interfaces.IPowerHandler;
|
||||
import forestry.core.interfaces.IRenderableMachine;
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
@@ -30,20 +31,53 @@ import forestry.energy.EnergyManager;
|
||||
import buildcraft.api.tiles.IHasWork;
|
||||
|
||||
@Optional.Interface(iface = "buildcraft.api.tiles.IHasWork", modid = "BuildCraftAPI|tiles")
|
||||
public abstract class TilePowered extends TileBase implements IRenderableMachine, IPowerHandler, IHasWork {
|
||||
|
||||
private static final int WORK_CYCLES = 4;
|
||||
public abstract class TilePowered extends TileBase implements IRenderableMachine, IPowerHandler, IHasWork, ISpeedUpgradable {
|
||||
|
||||
private final EnergyManager energyManager;
|
||||
|
||||
protected TilePowered(int maxTransfer, int energyPerWork, int capacity) {
|
||||
this.energyManager = new EnergyManager(maxTransfer, energyPerWork, capacity);
|
||||
private int workCounter;
|
||||
private int ticksPerWorkCycle;
|
||||
private int energyPerWorkCycle;
|
||||
|
||||
protected float speedMultiplier = 1.0f;
|
||||
protected float powerMultiplier = 1.0f;
|
||||
|
||||
// the number of work ticks that this machine has had no power
|
||||
private int noPowerTime = 0;
|
||||
|
||||
protected TilePowered(int maxTransfer, int capacity, int energyPerWorkCycle) {
|
||||
this.energyManager = new EnergyManager(maxTransfer, capacity);
|
||||
this.energyManager.setReceiveOnly();
|
||||
|
||||
setEnergyPerWorkCycle(energyPerWorkCycle);
|
||||
this.ticksPerWorkCycle = 4;
|
||||
}
|
||||
|
||||
public int getWorkCounter() {
|
||||
return workCounter;
|
||||
}
|
||||
|
||||
public void setTicksPerWorkCycle(int ticksPerWorkCycle) {
|
||||
this.ticksPerWorkCycle = ticksPerWorkCycle;
|
||||
this.workCounter = 0;
|
||||
}
|
||||
|
||||
public int getTicksPerWorkCycle() {
|
||||
if (worldObj.isRemote) {
|
||||
return ticksPerWorkCycle;
|
||||
}
|
||||
return Math.round(ticksPerWorkCycle / speedMultiplier);
|
||||
}
|
||||
|
||||
public void setEnergyPerWorkCycle(int energyPerWorkCycle) {
|
||||
this.energyPerWorkCycle = EnergyManager.scaleForDifficulty(energyPerWorkCycle);
|
||||
}
|
||||
|
||||
public int getEnergyPerWorkCycle() {
|
||||
return Math.round(energyPerWorkCycle * powerMultiplier);
|
||||
}
|
||||
|
||||
/* STATE INFORMATION */
|
||||
public abstract boolean isWorking();
|
||||
|
||||
public boolean hasResourcesMin(float percentage) {
|
||||
return false;
|
||||
}
|
||||
@@ -54,12 +88,15 @@ public abstract class TilePowered extends TileBase implements IRenderableMachine
|
||||
|
||||
public abstract boolean hasWork();
|
||||
|
||||
private int workCounter;
|
||||
|
||||
@Override
|
||||
protected void updateServerSide() {
|
||||
super.updateServerSide();
|
||||
|
||||
// one Forestry work tick happens every 5 game ticks
|
||||
if (!updateOnInterval(5)) {
|
||||
return;
|
||||
}
|
||||
|
||||
IErrorLogic errorLogic = getErrorLogic();
|
||||
|
||||
boolean disabled = isRedstoneActivated();
|
||||
@@ -68,17 +105,27 @@ public abstract class TilePowered extends TileBase implements IRenderableMachine
|
||||
return;
|
||||
}
|
||||
|
||||
if (updateOnInterval(20)) {
|
||||
boolean hasEnergy = energyManager.hasEnergyToDoWork();
|
||||
errorLogic.setCondition(!hasEnergy, EnumErrorCode.NOPOWER);
|
||||
if (!hasWork()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (workCounter < WORK_CYCLES) {
|
||||
if (energyManager.consumeEnergyToDoWork()) {
|
||||
int ticksPerWorkCycle = getTicksPerWorkCycle();
|
||||
|
||||
if (workCounter < ticksPerWorkCycle) {
|
||||
int energyPerWorkCycle = getEnergyPerWorkCycle();
|
||||
boolean consumedEnergy = energyManager.consumeEnergyToDoWork(ticksPerWorkCycle, energyPerWorkCycle);
|
||||
if (consumedEnergy) {
|
||||
errorLogic.setCondition(false, EnumErrorCode.NOPOWER);
|
||||
workCounter++;
|
||||
noPowerTime = 0;
|
||||
} else {
|
||||
noPowerTime++;
|
||||
if (noPowerTime > 4) {
|
||||
errorLogic.setCondition(true, EnumErrorCode.NOPOWER);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (updateOnInterval(5) && workCycle()) {
|
||||
if (workCycle()) {
|
||||
workCounter = 0;
|
||||
}
|
||||
}
|
||||
@@ -86,6 +133,15 @@ public abstract class TilePowered extends TileBase implements IRenderableMachine
|
||||
|
||||
protected abstract boolean workCycle();
|
||||
|
||||
public int getProgressScaled(int i) {
|
||||
int ticksPerWorkCycle = getTicksPerWorkCycle();
|
||||
if (ticksPerWorkCycle == 0) {
|
||||
return i;
|
||||
}
|
||||
|
||||
return ((ticksPerWorkCycle - workCounter) * i) / ticksPerWorkCycle;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbt) {
|
||||
super.writeToNBT(nbt);
|
||||
@@ -102,12 +158,24 @@ public abstract class TilePowered extends TileBase implements IRenderableMachine
|
||||
public void writeGuiData(DataOutputStreamForestry data) throws IOException {
|
||||
super.writeGuiData(data);
|
||||
energyManager.writeData(data);
|
||||
data.writeVarInt(workCounter);
|
||||
data.writeVarInt(getTicksPerWorkCycle());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readGuiData(DataInputStreamForestry data) throws IOException {
|
||||
super.readGuiData(data);
|
||||
energyManager.readData(data);
|
||||
workCounter = data.readVarInt();
|
||||
ticksPerWorkCycle = data.readVarInt();
|
||||
}
|
||||
|
||||
/* ISpeedUpgradable */
|
||||
@Override
|
||||
public void applySpeedUpgrade(double speedChange, double powerChange) {
|
||||
speedMultiplier += speedChange;
|
||||
powerMultiplier += powerChange;
|
||||
workCounter = 0;
|
||||
}
|
||||
|
||||
// / ADDITIONAL LIQUID HANDLING
|
||||
|
||||
@@ -14,69 +14,29 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.ICrafting;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.IFluidTank;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.api.core.IToolPipette;
|
||||
import forestry.core.interfaces.ILiquidTankContainer;
|
||||
import forestry.core.network.IStreamableGui;
|
||||
import forestry.core.network.PacketId;
|
||||
import forestry.core.network.PacketSlotClick;
|
||||
import forestry.core.proxy.Proxies;
|
||||
|
||||
public abstract class ContainerLiquidTanks<T extends TileEntity & ILiquidTankContainer & IStreamableGui> extends ContainerTile<T> {
|
||||
public abstract class ContainerLiquidTanks<T extends TileEntity & ILiquidTankContainer> extends ContainerTile<T> implements IContainerLiquidTanks {
|
||||
|
||||
private final ContainerLiquidTanksHelper<T> helper;
|
||||
|
||||
protected ContainerLiquidTanks(T tile, InventoryPlayer playerInventory, int xInv, int yInv) {
|
||||
super(tile, playerInventory, xInv, yInv);
|
||||
this.helper = new ContainerLiquidTanksHelper<T>(tile);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void handlePipetteClickClient(int slot, EntityPlayer player) {
|
||||
ItemStack itemstack = player.inventory.getItemStack();
|
||||
if (itemstack == null || !(itemstack.getItem() instanceof IToolPipette)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Proxies.net.sendToServer(new PacketSlotClick(PacketId.PIPETTE_CLICK, tile, slot));
|
||||
helper.handlePipetteClickClient(slot, player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePipetteClick(int slot, EntityPlayerMP player) {
|
||||
|
||||
ItemStack itemstack = player.inventory.getItemStack();
|
||||
if (itemstack == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Item held = itemstack.getItem();
|
||||
if (!(held instanceof IToolPipette)) {
|
||||
return;
|
||||
}
|
||||
|
||||
IToolPipette pipette = (IToolPipette) held;
|
||||
IFluidTank tank = tile.getTankManager().getTank(slot);
|
||||
int liquidAmount = tank.getFluidAmount();
|
||||
|
||||
if (pipette.canPipette(itemstack) && liquidAmount > 0) {
|
||||
if (liquidAmount > 0) {
|
||||
FluidStack fillAmount = tank.drain(1000, false);
|
||||
int filled = pipette.fill(itemstack, fillAmount, true);
|
||||
tank.drain(filled, true);
|
||||
player.updateHeldItem();
|
||||
}
|
||||
} else {
|
||||
FluidStack potential = pipette.drain(itemstack, pipette.getCapacity(itemstack), false);
|
||||
if (potential != null) {
|
||||
pipette.drain(itemstack, tank.fill(potential, true), true);
|
||||
player.updateHeldItem();
|
||||
}
|
||||
}
|
||||
helper.handlePipetteClick(slot, player);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.core.gui;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.IFluidTank;
|
||||
|
||||
import forestry.api.core.IToolPipette;
|
||||
import forestry.core.interfaces.ILiquidTankContainer;
|
||||
import forestry.core.network.PacketId;
|
||||
import forestry.core.network.PacketSlotClick;
|
||||
import forestry.core.proxy.Proxies;
|
||||
|
||||
public class ContainerLiquidTanksHelper<T extends TileEntity & ILiquidTankContainer> implements IContainerLiquidTanks {
|
||||
|
||||
private final T tile;
|
||||
|
||||
public ContainerLiquidTanksHelper(T tile) {
|
||||
this.tile = tile;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePipetteClickClient(int slot, EntityPlayer player) {
|
||||
ItemStack itemstack = player.inventory.getItemStack();
|
||||
if (itemstack == null || !(itemstack.getItem() instanceof IToolPipette)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Proxies.net.sendToServer(new PacketSlotClick(PacketId.PIPETTE_CLICK, tile, slot));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePipetteClick(int slot, EntityPlayerMP player) {
|
||||
ItemStack itemstack = player.inventory.getItemStack();
|
||||
if (itemstack == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Item held = itemstack.getItem();
|
||||
if (!(held instanceof IToolPipette)) {
|
||||
return;
|
||||
}
|
||||
|
||||
IToolPipette pipette = (IToolPipette) held;
|
||||
IFluidTank tank = tile.getTankManager().getTank(slot);
|
||||
int liquidAmount = tank.getFluidAmount();
|
||||
|
||||
if (pipette.canPipette(itemstack) && liquidAmount > 0) {
|
||||
if (liquidAmount > 0) {
|
||||
FluidStack fillAmount = tank.drain(1000, false);
|
||||
int filled = pipette.fill(itemstack, fillAmount, true);
|
||||
tank.drain(filled, true);
|
||||
player.updateHeldItem();
|
||||
}
|
||||
} else {
|
||||
FluidStack potential = pipette.drain(itemstack, pipette.getCapacity(itemstack), false);
|
||||
if (potential != null) {
|
||||
pipette.drain(itemstack, tank.fill(potential, true), true);
|
||||
player.updateHeldItem();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFluidTank getTank(int slot) {
|
||||
return tile.getTankManager().getTank(slot);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.core.gui;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.ICrafting;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import net.minecraftforge.fluids.IFluidTank;
|
||||
|
||||
import forestry.core.circuits.ISocketable;
|
||||
import forestry.core.interfaces.ILiquidTankContainer;
|
||||
|
||||
public abstract class ContainerLiquidTanksSocketed<T extends TileEntity & ILiquidTankContainer & ISocketable> extends ContainerTile<T> implements IContainerSocketed, IContainerLiquidTanks {
|
||||
|
||||
private final ContainerSocketedHelper<T> socketedHelper;
|
||||
private final ContainerLiquidTanksHelper<T> tanksHelper;
|
||||
|
||||
protected ContainerLiquidTanksSocketed(T tile, InventoryPlayer playerInventory, int xInv, int yInv) {
|
||||
super(tile, playerInventory, xInv, yInv);
|
||||
this.socketedHelper = new ContainerSocketedHelper<T>(tile);
|
||||
this.tanksHelper = new ContainerLiquidTanksHelper<T>(tile);
|
||||
}
|
||||
|
||||
/* IContainerLiquidTanks */
|
||||
@Override
|
||||
public void handlePipetteClickClient(int slot, EntityPlayer player) {
|
||||
tanksHelper.handlePipetteClickClient(slot, player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePipetteClick(int slot, EntityPlayerMP player) {
|
||||
tanksHelper.handlePipetteClick(slot, player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateProgressBar(int messageId, int data) {
|
||||
super.updateProgressBar(messageId, data);
|
||||
|
||||
tile.getTankManager().processGuiUpdate(messageId, data);
|
||||
tile.getGUINetworkData(messageId, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public void detectAndSendChanges() {
|
||||
super.detectAndSendChanges();
|
||||
tile.getTankManager().updateGuiData(this, crafters);
|
||||
for (Object crafter : crafters) {
|
||||
tile.sendGUINetworkData(this, (ICrafting) crafter);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCraftingToCrafters(ICrafting icrafting) {
|
||||
super.addCraftingToCrafters(icrafting);
|
||||
tile.getTankManager().initGuiData(this, icrafting);
|
||||
}
|
||||
|
||||
public IFluidTank getTank(int slot) {
|
||||
return tile.getTankManager().getTank(slot);
|
||||
}
|
||||
|
||||
/* IContainerSocketed */
|
||||
@Override
|
||||
public void handleChipsetClick(int slot) {
|
||||
socketedHelper.handleChipsetClick(slot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleChipsetClickServer(int slot, EntityPlayerMP player, ItemStack itemstack) {
|
||||
socketedHelper.handleChipsetClickServer(slot, player, itemstack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleSolderingIronClick(int slot) {
|
||||
socketedHelper.handleSolderingIronClick(slot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleSolderingIronClickServer(int slot, EntityPlayerMP player, ItemStack itemstack) {
|
||||
socketedHelper.handleSolderingIronClickServer(slot, player, itemstack);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -15,67 +15,34 @@ import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import forestry.core.interfaces.ISocketable;
|
||||
import forestry.core.network.IStreamableGui;
|
||||
import forestry.core.network.PacketId;
|
||||
import forestry.core.network.PacketSlotClick;
|
||||
import forestry.core.network.PacketSocketUpdate;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.StackUtils;
|
||||
import forestry.core.circuits.ISocketable;
|
||||
|
||||
public abstract class ContainerSocketed<T extends TileEntity & IStreamableGui & ISocketable> extends ContainerTile<T> {
|
||||
public abstract class ContainerSocketed<T extends TileEntity & ISocketable> extends ContainerTile<T> implements IContainerSocketed {
|
||||
|
||||
private final ContainerSocketedHelper<T> helper;
|
||||
|
||||
protected ContainerSocketed(T tile, InventoryPlayer playerInventory, int xInv, int yInv) {
|
||||
super(tile, playerInventory, xInv, yInv);
|
||||
this.helper = new ContainerSocketedHelper<T>(tile);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleChipsetClick(int slot) {
|
||||
PacketSlotClick packet = new PacketSlotClick(PacketId.CHIPSET_CLICK, tile, slot);
|
||||
Proxies.net.sendToServer(packet);
|
||||
helper.handleChipsetClick(slot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleChipsetClickServer(int slot, EntityPlayerMP player, ItemStack itemstack) {
|
||||
ItemStack toSocket = itemstack.copy();
|
||||
toSocket.stackSize = 1;
|
||||
tile.setSocket(slot, toSocket);
|
||||
|
||||
ItemStack stack = player.inventory.getItemStack();
|
||||
stack.stackSize--;
|
||||
if (stack.stackSize <= 0) {
|
||||
player.inventory.setItemStack(null);
|
||||
}
|
||||
player.updateHeldItem();
|
||||
|
||||
PacketSocketUpdate packet = new PacketSocketUpdate(tile);
|
||||
Proxies.net.sendToPlayer(packet, player);
|
||||
helper.handleChipsetClickServer(slot, player, itemstack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleSolderingIronClick(int slot) {
|
||||
PacketSlotClick packet = new PacketSlotClick(PacketId.SOLDERING_IRON_CLICK, tile, slot);
|
||||
Proxies.net.sendToServer(packet);
|
||||
helper.handleSolderingIronClick(slot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleSolderingIronClickServer(int slot, EntityPlayerMP player, ItemStack itemstack) {
|
||||
ItemStack socket = tile.getSocket(slot);
|
||||
if (socket == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
StackUtils.stowInInventory(socket, player.inventory, true);
|
||||
// Not sufficient space in player's inventory. failed to stow.
|
||||
if (socket.stackSize > 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
tile.setSocket(slot, null);
|
||||
itemstack.damageItem(1, player);
|
||||
if (itemstack.stackSize <= 0) {
|
||||
player.inventory.setItemStack(null);
|
||||
}
|
||||
player.updateHeldItem();
|
||||
|
||||
|
||||
PacketSocketUpdate packet = new PacketSocketUpdate(tile);
|
||||
Proxies.net.sendToPlayer(packet, player);
|
||||
helper.handleSolderingIronClickServer(slot, player, itemstack);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.core.gui;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import forestry.core.circuits.ISocketable;
|
||||
import forestry.core.network.PacketId;
|
||||
import forestry.core.network.PacketSlotClick;
|
||||
import forestry.core.network.PacketSocketUpdate;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.StackUtils;
|
||||
|
||||
public class ContainerSocketedHelper<T extends TileEntity & ISocketable> implements IContainerSocketed {
|
||||
|
||||
private final T tile;
|
||||
|
||||
public ContainerSocketedHelper(T tile) {
|
||||
this.tile = tile;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleChipsetClick(int slot) {
|
||||
PacketSlotClick packet = new PacketSlotClick(PacketId.CHIPSET_CLICK, tile, slot);
|
||||
Proxies.net.sendToServer(packet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleChipsetClickServer(int slot, EntityPlayerMP player, ItemStack itemstack) {
|
||||
if (tile.getSocket(slot) != null) {
|
||||
return;
|
||||
}
|
||||
|
||||
ItemStack toSocket = itemstack.copy();
|
||||
toSocket.stackSize = 1;
|
||||
tile.setSocket(slot, toSocket);
|
||||
|
||||
ItemStack stack = player.inventory.getItemStack();
|
||||
stack.stackSize--;
|
||||
if (stack.stackSize <= 0) {
|
||||
player.inventory.setItemStack(null);
|
||||
}
|
||||
player.updateHeldItem();
|
||||
|
||||
PacketSocketUpdate packet = new PacketSocketUpdate(tile);
|
||||
Proxies.net.sendToPlayer(packet, player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleSolderingIronClick(int slot) {
|
||||
PacketSlotClick packet = new PacketSlotClick(PacketId.SOLDERING_IRON_CLICK, tile, slot);
|
||||
Proxies.net.sendToServer(packet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleSolderingIronClickServer(int slot, EntityPlayerMP player, ItemStack itemstack) {
|
||||
ItemStack socket = tile.getSocket(slot);
|
||||
if (socket == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
StackUtils.stowInInventory(socket, player.inventory, true);
|
||||
// Not sufficient space in player's inventory. failed to stow.
|
||||
if (socket.stackSize > 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
tile.setSocket(slot, null);
|
||||
itemstack.damageItem(1, player);
|
||||
if (itemstack.stackSize <= 0) {
|
||||
player.inventory.setItemStack(null);
|
||||
}
|
||||
player.updateHeldItem();
|
||||
|
||||
|
||||
PacketSocketUpdate packet = new PacketSocketUpdate(tile);
|
||||
Proxies.net.sendToPlayer(packet, player);
|
||||
}
|
||||
}
|
||||
@@ -19,10 +19,10 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import forestry.api.core.IErrorLogicSource;
|
||||
import forestry.api.core.IErrorState;
|
||||
import forestry.core.delegates.FakeAccessHandler;
|
||||
import forestry.core.gadgets.TilePowered;
|
||||
import forestry.core.interfaces.IAccessHandler;
|
||||
import forestry.core.interfaces.IPowerHandler;
|
||||
import forestry.core.interfaces.IRestrictedAccessTile;
|
||||
import forestry.core.network.IStreamableGui;
|
||||
import forestry.core.network.PacketErrorUpdate;
|
||||
import forestry.core.network.PacketGuiEnergy;
|
||||
import forestry.core.network.PacketGuiUpdate;
|
||||
@@ -30,7 +30,7 @@ import forestry.core.utils.EnumAccess;
|
||||
import forestry.core.utils.Utils;
|
||||
import forestry.energy.EnergyManager;
|
||||
|
||||
public abstract class ContainerTile<T extends TileEntity & IStreamableGui> extends ContainerForestry {
|
||||
public abstract class ContainerTile<T extends TileEntity> extends ContainerForestry {
|
||||
|
||||
protected final T tile;
|
||||
private final IAccessHandler accessHandler;
|
||||
@@ -64,6 +64,8 @@ public abstract class ContainerTile<T extends TileEntity & IStreamableGui> exten
|
||||
private ImmutableSet<IErrorState> previousErrorStates;
|
||||
private int previousEnergyManagerData = 0;
|
||||
private EnumAccess previousAccess;
|
||||
private int previousWorkCounter = 0;
|
||||
private int previousTicksPerWorkCycle = 0;
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
@@ -92,15 +94,42 @@ public abstract class ContainerTile<T extends TileEntity & IStreamableGui> exten
|
||||
}
|
||||
}
|
||||
|
||||
if (tile instanceof IRestrictedAccessTile) {
|
||||
boolean guiUpdated = false;
|
||||
|
||||
if (!guiUpdated && tile instanceof IRestrictedAccessTile) {
|
||||
IRestrictedAccessTile restrictedAccessTile = (IRestrictedAccessTile) tile;
|
||||
IAccessHandler accessHandler = restrictedAccessTile.getAccessHandler();
|
||||
EnumAccess access = accessHandler.getAccessType();
|
||||
if (access != previousAccess) {
|
||||
PacketGuiUpdate packet = new PacketGuiUpdate(tile);
|
||||
PacketGuiUpdate packet = new PacketGuiUpdate(restrictedAccessTile);
|
||||
sendPacketToCrafters(packet);
|
||||
|
||||
previousAccess = access;
|
||||
guiUpdated = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!guiUpdated && tile instanceof TilePowered) {
|
||||
TilePowered tilePowered = (TilePowered) tile;
|
||||
|
||||
boolean changed = false;
|
||||
|
||||
int workCounter = tilePowered.getWorkCounter();
|
||||
if (workCounter != previousWorkCounter) {
|
||||
changed = true;
|
||||
previousWorkCounter = workCounter;
|
||||
}
|
||||
|
||||
int ticksPerWorkCycle = tilePowered.getTicksPerWorkCycle();
|
||||
if (ticksPerWorkCycle != previousTicksPerWorkCycle) {
|
||||
changed = true;
|
||||
previousTicksPerWorkCycle = ticksPerWorkCycle;
|
||||
}
|
||||
|
||||
if (changed) {
|
||||
PacketGuiUpdate packet = new PacketGuiUpdate(tilePowered);
|
||||
sendPacketToCrafters(packet);
|
||||
guiUpdated = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ import forestry.core.gadgets.NaturalistGame;
|
||||
import forestry.core.gadgets.NaturalistGame.GameToken;
|
||||
import forestry.core.gadgets.TileEscritoire;
|
||||
import forestry.core.gui.widgets.Widget;
|
||||
import forestry.core.gui.widgets.WidgetManager;
|
||||
import forestry.core.network.PacketGuiSelect;
|
||||
import forestry.core.network.PacketId;
|
||||
import forestry.core.proxy.Proxies;
|
||||
|
||||
@@ -38,10 +38,16 @@ import forestry.api.core.IErrorLogicSource;
|
||||
import forestry.api.core.IErrorSource;
|
||||
import forestry.core.config.Config;
|
||||
import forestry.core.gadgets.TileForestry;
|
||||
import forestry.core.gui.ledgers.ClimateLedger;
|
||||
import forestry.core.gui.ledgers.HintLedger;
|
||||
import forestry.core.gui.ledgers.LedgerManager;
|
||||
import forestry.core.gui.ledgers.OwnerLedger;
|
||||
import forestry.core.gui.ledgers.PowerLedger;
|
||||
import forestry.core.gui.tooltips.IToolTipProvider;
|
||||
import forestry.core.gui.tooltips.ToolTip;
|
||||
import forestry.core.gui.tooltips.ToolTipLine;
|
||||
import forestry.core.gui.widgets.Widget;
|
||||
import forestry.core.gui.widgets.WidgetManager;
|
||||
import forestry.core.interfaces.IClimatised;
|
||||
import forestry.core.interfaces.IHintSource;
|
||||
import forestry.core.interfaces.IPowerHandler;
|
||||
@@ -313,7 +319,7 @@ public abstract class GuiForestry<C extends Container, I extends IInventory> ext
|
||||
InventoryPlayer playerInv = mc.thePlayer.inventory;
|
||||
|
||||
if (playerInv.getItemStack() == null) {
|
||||
drawToolTips(widgetManager.widgets, mouseX, mouseY);
|
||||
drawToolTips(widgetManager.getWidgets(), mouseX, mouseY);
|
||||
drawToolTips(buttonList, mouseX, mouseY);
|
||||
drawToolTips(inventorySlots.inventorySlots, mouseX, mouseY);
|
||||
}
|
||||
@@ -409,6 +415,10 @@ public abstract class GuiForestry<C extends Container, I extends IInventory> ext
|
||||
return guiTop;
|
||||
}
|
||||
|
||||
public FontColour getFontColor() {
|
||||
return fontColor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawGradientRect(int par1, int par2, int par3, int par4, int par5, int par6) {
|
||||
super.drawGradientRect(par1, par2, par3, par4, par5, par6);
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.core.gui;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
|
||||
import net.minecraftforge.fluids.IFluidTank;
|
||||
|
||||
public interface IContainerLiquidTanks {
|
||||
void handlePipetteClickClient(int slot, EntityPlayer player);
|
||||
|
||||
void handlePipetteClick(int slot, EntityPlayerMP player);
|
||||
|
||||
IFluidTank getTank(int slot);
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.core.gui;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IContainerSocketed {
|
||||
void handleChipsetClick(int slot);
|
||||
|
||||
void handleChipsetClickServer(int slot, EntityPlayerMP player, ItemStack itemstack);
|
||||
|
||||
void handleSolderingIronClick(int slot);
|
||||
|
||||
void handleSolderingIronClickServer(int slot, EntityPlayerMP player, ItemStack itemstack);
|
||||
}
|
||||
Executable → Regular
+1
-1
@@ -8,7 +8,7 @@
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.core.gui;
|
||||
package forestry.core.gui.ledgers;
|
||||
|
||||
import forestry.api.core.EnumTemperature;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
Executable → Regular
+1
-1
@@ -8,7 +8,7 @@
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.core.gui;
|
||||
package forestry.core.gui.ledgers;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
Executable → Regular
+1
-1
@@ -8,7 +8,7 @@
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.core.gui;
|
||||
package forestry.core.gui.ledgers;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
Executable → Regular
+5
-5
@@ -8,7 +8,7 @@
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.core.gui;
|
||||
package forestry.core.gui.ledgers;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.util.IIcon;
|
||||
@@ -65,10 +65,10 @@ public abstract class Ledger {
|
||||
texture = ledgerTextureLeft;
|
||||
}
|
||||
|
||||
fontColorHeader = manager.gui.fontColor.get("ledger." + name + ".header");
|
||||
fontColorSubheader = manager.gui.fontColor.get("ledger." + name + ".subheader");
|
||||
fontColorText = manager.gui.fontColor.get("ledger." + name + ".text");
|
||||
overlayColor = manager.gui.fontColor.get("ledger." + name + ".background");
|
||||
fontColorHeader = manager.gui.getFontColor().get("ledger." + name + ".header");
|
||||
fontColorSubheader = manager.gui.getFontColor().get("ledger." + name + ".subheader");
|
||||
fontColorText = manager.gui.getFontColor().get("ledger." + name + ".text");
|
||||
overlayColor = manager.gui.getFontColor().get("ledger." + name + ".background");
|
||||
}
|
||||
|
||||
// adjust the update's move amount to match the look of 60 fps (16.67 ms per update)
|
||||
Executable → Regular
+4
-3
@@ -8,7 +8,7 @@
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.core.gui;
|
||||
package forestry.core.gui.ledgers;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
@@ -23,6 +23,7 @@ import forestry.api.core.IErrorSource;
|
||||
import forestry.api.core.IErrorState;
|
||||
import forestry.core.config.SessionVars;
|
||||
import forestry.core.delegates.FakeErrorSource;
|
||||
import forestry.core.gui.GuiForestry;
|
||||
import forestry.core.proxy.Proxies;
|
||||
|
||||
public class LedgerManager {
|
||||
@@ -106,7 +107,7 @@ public class LedgerManager {
|
||||
return null;
|
||||
}
|
||||
|
||||
protected void drawLedgers() {
|
||||
public void drawLedgers() {
|
||||
|
||||
int yPos = 8;
|
||||
for (Ledger ledger : ledgers) {
|
||||
@@ -143,7 +144,7 @@ public class LedgerManager {
|
||||
}
|
||||
}
|
||||
|
||||
protected void drawTooltips(int mouseX, int mouseY) {
|
||||
public void drawTooltips(int mouseX, int mouseY) {
|
||||
|
||||
Ledger ledger = getAtPosition(mouseX, mouseY);
|
||||
if (ledger != null) {
|
||||
Executable → Regular
+1
-1
@@ -8,7 +8,7 @@
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.core.gui;
|
||||
package forestry.core.gui.ledgers;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
Executable → Regular
+1
-1
@@ -8,7 +8,7 @@
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.core.gui;
|
||||
package forestry.core.gui.ledgers;
|
||||
|
||||
import forestry.core.interfaces.IPowerHandler;
|
||||
import forestry.core.render.TextureManager;
|
||||
@@ -16,7 +16,6 @@ import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import forestry.core.gui.WidgetManager;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.render.SpriteSheet;
|
||||
|
||||
|
||||
@@ -17,13 +17,12 @@ import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
|
||||
import forestry.core.circuits.ISocketable;
|
||||
import forestry.core.circuits.ISolderingIron;
|
||||
import forestry.core.circuits.ItemCircuitBoard;
|
||||
import forestry.core.gui.ContainerSocketed;
|
||||
import forestry.core.gui.GuiForestry;
|
||||
import forestry.core.gui.WidgetManager;
|
||||
import forestry.core.gui.IContainerSocketed;
|
||||
import forestry.core.gui.tooltips.ToolTip;
|
||||
import forestry.core.interfaces.ISocketable;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.StringUtil;
|
||||
|
||||
@@ -79,11 +78,11 @@ public class SocketWidget extends Widget {
|
||||
Item held = itemstack.getItem();
|
||||
|
||||
Container container = manager.gui.inventorySlots;
|
||||
if (!(container instanceof ContainerSocketed)) {
|
||||
if (!(container instanceof IContainerSocketed)) {
|
||||
return;
|
||||
}
|
||||
|
||||
ContainerSocketed containerSocketed = (ContainerSocketed) container;
|
||||
IContainerSocketed containerSocketed = (IContainerSocketed) container;
|
||||
|
||||
// Insert chipsets
|
||||
if (held instanceof ItemCircuitBoard) {
|
||||
|
||||
@@ -22,8 +22,7 @@ import org.lwjgl.opengl.GL11;
|
||||
|
||||
import forestry.api.core.IToolPipette;
|
||||
import forestry.core.fluids.tanks.StandardTank;
|
||||
import forestry.core.gui.ContainerLiquidTanks;
|
||||
import forestry.core.gui.WidgetManager;
|
||||
import forestry.core.gui.IContainerLiquidTanks;
|
||||
import forestry.core.gui.tooltips.ToolTip;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.render.SpriteSheet;
|
||||
@@ -52,8 +51,8 @@ public class TankWidget extends Widget {
|
||||
|
||||
public IFluidTank getTank() {
|
||||
Container container = manager.gui.inventorySlots;
|
||||
if (container instanceof ContainerLiquidTanks) {
|
||||
return ((ContainerLiquidTanks) container).getTank(slot);
|
||||
if (container instanceof IContainerLiquidTanks) {
|
||||
return ((IContainerLiquidTanks) container).getTank(slot);
|
||||
} else if (container instanceof ContainerFarm) {
|
||||
return ((ContainerFarm) container).getTank(slot);
|
||||
}
|
||||
@@ -124,9 +123,8 @@ public class TankWidget extends Widget {
|
||||
}
|
||||
|
||||
Item held = itemstack.getItem();
|
||||
if (held instanceof IToolPipette && manager.gui.inventorySlots instanceof ContainerLiquidTanks) {
|
||||
((ContainerLiquidTanks) manager.gui.inventorySlots).handlePipetteClickClient(slot, manager.minecraft.thePlayer);
|
||||
if (held instanceof IToolPipette && manager.gui.inventorySlots instanceof IContainerLiquidTanks) {
|
||||
((IContainerLiquidTanks) manager.gui.inventorySlots).handlePipetteClickClient(slot, manager.minecraft.thePlayer);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,6 @@ package forestry.core.gui.widgets;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
import forestry.core.gui.WidgetManager;
|
||||
import forestry.core.gui.tooltips.IToolTipProvider;
|
||||
import forestry.core.gui.tooltips.ToolTip;
|
||||
import forestry.core.proxy.Proxies;
|
||||
|
||||
Executable → Regular
+9
-4
@@ -8,22 +8,23 @@
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.core.gui;
|
||||
package forestry.core.gui.widgets;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import forestry.core.gui.widgets.Widget;
|
||||
import forestry.core.gui.GuiForestry;
|
||||
import forestry.core.proxy.Proxies;
|
||||
|
||||
public class WidgetManager {
|
||||
|
||||
public final GuiForestry gui;
|
||||
public final Minecraft minecraft;
|
||||
protected final ArrayList<Widget> widgets = new ArrayList<Widget>();
|
||||
protected final List<Widget> widgets = new ArrayList<Widget>();
|
||||
|
||||
public WidgetManager(GuiForestry gui) {
|
||||
this.gui = gui;
|
||||
@@ -42,7 +43,11 @@ public class WidgetManager {
|
||||
this.widgets.clear();
|
||||
}
|
||||
|
||||
protected Widget getAtPosition(int mX, int mY) {
|
||||
public List<Widget> getWidgets() {
|
||||
return widgets;
|
||||
}
|
||||
|
||||
public Widget getAtPosition(int mX, int mY) {
|
||||
for (Widget slot : widgets) {
|
||||
if (slot.isMouseOver(mX, mY)) {
|
||||
return slot;
|
||||
@@ -12,9 +12,10 @@ package forestry.core.interfaces;
|
||||
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
|
||||
import forestry.core.network.IStreamableGui;
|
||||
import forestry.core.utils.EnumAccess;
|
||||
|
||||
public interface IRestrictedAccessTile {
|
||||
public interface IRestrictedAccessTile extends IStreamableGui {
|
||||
IAccessHandler getAccessHandler();
|
||||
|
||||
ChunkCoordinates getCoordinates();
|
||||
|
||||
@@ -413,6 +413,15 @@ public abstract class InvTools {
|
||||
return ((float) amount / (float) stackMax) >= percent;
|
||||
}
|
||||
|
||||
public static boolean isEmpty(IInventory inventory, int slotStart, int slotCount) {
|
||||
for (int i = slotStart; i < slotStart + slotCount; i++) {
|
||||
if (inventory.getStackInSlot(i) != null) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static ItemStack[] getStacks(IInventory inventory) {
|
||||
ItemStack[] stacks = new ItemStack[inventory.getSizeInventory()];
|
||||
for (int i = 0; i < inventory.getSizeInventory(); i++) {
|
||||
|
||||
@@ -32,7 +32,6 @@ import forestry.core.inventory.FakeInventoryAdapter;
|
||||
import forestry.core.inventory.IInventoryAdapter;
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.DataOutputStreamForestry;
|
||||
import forestry.core.network.IStreamableGui;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.StringUtil;
|
||||
|
||||
@@ -42,7 +41,7 @@ import forestry.core.utils.StringUtil;
|
||||
*
|
||||
* Subordinate TileEntities implement the IMultiblockPart class and, generally, should not have an update() loop.
|
||||
*/
|
||||
public abstract class MultiblockControllerBase implements ISidedInventory, IRestrictedAccessTile, IStreamableGui, IErrorLogicSource {
|
||||
public abstract class MultiblockControllerBase implements ISidedInventory, IRestrictedAccessTile, IErrorLogicSource {
|
||||
public static final short DIMENSION_UNBOUNDED = -1;
|
||||
|
||||
// Multiblock stuff - do not mess with
|
||||
|
||||
@@ -37,13 +37,13 @@ import forestry.apiculture.multiblock.IAlvearyController;
|
||||
import forestry.apiculture.multiblock.TileAlveary;
|
||||
import forestry.apiculture.network.PacketActiveUpdate;
|
||||
import forestry.core.circuits.ContainerSolderingIron;
|
||||
import forestry.core.circuits.ISocketable;
|
||||
import forestry.core.circuits.ItemCircuitBoard;
|
||||
import forestry.core.genetics.BreedingTracker;
|
||||
import forestry.core.gui.ContainerLiquidTanks;
|
||||
import forestry.core.gui.ContainerSocketed;
|
||||
import forestry.core.gui.IContainerLiquidTanks;
|
||||
import forestry.core.gui.IContainerSocketed;
|
||||
import forestry.core.gui.IGuiSelectable;
|
||||
import forestry.core.interfaces.IRestrictedAccessTile;
|
||||
import forestry.core.interfaces.ISocketable;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.farming.multiblock.IFarmController;
|
||||
import forestry.farming.multiblock.TileFarm;
|
||||
@@ -251,7 +251,7 @@ public class PacketHandler {
|
||||
private static void onChipsetClick(PacketSlotClick packet, EntityPlayerMP player) {
|
||||
assert FMLCommonHandler.instance().getEffectiveSide().isServer();
|
||||
|
||||
if (!(player.openContainer instanceof ContainerSocketed)) {
|
||||
if (!(player.openContainer instanceof IContainerSocketed)) {
|
||||
return;
|
||||
}
|
||||
ItemStack itemstack = player.inventory.getItemStack();
|
||||
@@ -259,18 +259,18 @@ public class PacketHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
((ContainerSocketed) player.openContainer).handleChipsetClickServer(packet.getSlot(), player, itemstack);
|
||||
((IContainerSocketed) player.openContainer).handleChipsetClickServer(packet.getSlot(), player, itemstack);
|
||||
}
|
||||
|
||||
private static void onSolderingIronClick(PacketSlotClick packet, EntityPlayerMP player) {
|
||||
assert FMLCommonHandler.instance().getEffectiveSide().isServer();
|
||||
|
||||
if (!(player.openContainer instanceof ContainerSocketed)) {
|
||||
if (!(player.openContainer instanceof IContainerSocketed)) {
|
||||
return;
|
||||
}
|
||||
ItemStack itemstack = player.inventory.getItemStack();
|
||||
|
||||
((ContainerSocketed) player.openContainer).handleSolderingIronClickServer(packet.getSlot(), player, itemstack);
|
||||
((IContainerSocketed) player.openContainer).handleSolderingIronClickServer(packet.getSlot(), player, itemstack);
|
||||
}
|
||||
|
||||
private static void onAccessSwitch(PacketCoordinates packet, EntityPlayer playerEntity) {
|
||||
@@ -296,10 +296,8 @@ public class PacketHandler {
|
||||
private static void onPipetteClick(PacketSlotClick packet, EntityPlayerMP player) {
|
||||
assert FMLCommonHandler.instance().getEffectiveSide().isServer();
|
||||
|
||||
if (!(player.openContainer instanceof ContainerLiquidTanks)) {
|
||||
return;
|
||||
if ((player.openContainer instanceof IContainerLiquidTanks)) {
|
||||
((IContainerLiquidTanks) player.openContainer).handlePipetteClick(packet.getSlot(), player);
|
||||
}
|
||||
|
||||
((ContainerLiquidTanks) player.openContainer).handlePipetteClick(packet.getSlot(), player);
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,7 @@ import java.io.IOException;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import forestry.core.interfaces.ISocketable;
|
||||
import forestry.core.circuits.ISocketable;
|
||||
|
||||
public class PacketSocketUpdate extends PacketCoordinates {
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ import net.minecraftforge.oredict.OreDictionary;
|
||||
import cpw.mods.fml.common.registry.EntityRegistry;
|
||||
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.core.interfaces.ISocketable;
|
||||
import forestry.core.circuits.ISocketable;
|
||||
import forestry.core.proxy.Proxies;
|
||||
|
||||
import buildcraft.api.tools.IToolWrench;
|
||||
|
||||
@@ -23,16 +23,14 @@ public class EnergyManager implements IEnergyHandler, IStreamable {
|
||||
EXTRACT, RECEIVE, BOTH
|
||||
}
|
||||
|
||||
private final int energyPerWork;
|
||||
private final EnergyStorage energyStorage;
|
||||
private EnergyTransferMode mode = EnergyTransferMode.BOTH;
|
||||
|
||||
public EnergyManager(int maxTransfer, int energyPerWork, int capacity) {
|
||||
this.energyPerWork = scaleForDifficulty(energyPerWork);
|
||||
public EnergyManager(int maxTransfer, int capacity) {
|
||||
this.energyStorage = new EnergyStorage(scaleForDifficulty(capacity), scaleForDifficulty(maxTransfer), scaleForDifficulty(maxTransfer));
|
||||
}
|
||||
|
||||
private static int scaleForDifficulty(int energyPerUse) {
|
||||
public static int scaleForDifficulty(int energyPerUse) {
|
||||
return Math.round(energyPerUse * GameMode.getGameMode().getFloatSetting("energy.demand.modifier"));
|
||||
}
|
||||
|
||||
@@ -149,25 +147,19 @@ public class EnergyManager implements IEnergyHandler, IStreamable {
|
||||
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 (!hasEnergyToDoWork()) {
|
||||
public boolean consumeEnergyToDoWork(int ticksPerWorkCycle, int energyPerWorkCycle) {
|
||||
int energyPerCycle = (int) Math.ceil(energyPerWorkCycle / (float) ticksPerWorkCycle);
|
||||
if (energyStorage.getEnergyStored() < energyPerCycle) {
|
||||
return false;
|
||||
}
|
||||
energyStorage.modifyEnergyStored(-energyPerWork);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean hasEnergyToDoWork() {
|
||||
return energyStorage.getEnergyStored() >= energyPerWork;
|
||||
energyStorage.modifyEnergyStored(-energyPerCycle);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -23,10 +23,10 @@ import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.core.IErrorLogic;
|
||||
import forestry.core.EnumErrorCode;
|
||||
import forestry.core.TemperatureState;
|
||||
import forestry.core.circuits.ISocketable;
|
||||
import forestry.core.config.Config;
|
||||
import forestry.core.config.Defaults;
|
||||
import forestry.core.gadgets.Engine;
|
||||
import forestry.core.interfaces.ISocketable;
|
||||
import forestry.core.inventory.InventoryAdapter;
|
||||
import forestry.core.inventory.TileInventoryAdapter;
|
||||
import forestry.core.network.GuiId;
|
||||
|
||||
@@ -14,7 +14,7 @@ import net.minecraft.inventory.Container;
|
||||
|
||||
import forestry.core.gadgets.Engine;
|
||||
import forestry.core.gui.GuiForestryTitled;
|
||||
import forestry.core.gui.Ledger;
|
||||
import forestry.core.gui.ledgers.Ledger;
|
||||
import forestry.core.render.TextureManager;
|
||||
import forestry.core.utils.StringUtil;
|
||||
|
||||
|
||||
@@ -21,9 +21,9 @@ import net.minecraftforge.fluids.FluidStack;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import forestry.core.config.Defaults;
|
||||
import forestry.core.gui.WidgetManager;
|
||||
import forestry.core.gui.widgets.TankWidget;
|
||||
import forestry.core.gui.widgets.Widget;
|
||||
import forestry.core.gui.widgets.WidgetManager;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.render.SpriteSheet;
|
||||
import forestry.core.utils.StringUtil;
|
||||
|
||||
@@ -15,6 +15,8 @@ import net.minecraft.world.World;
|
||||
|
||||
import forestry.core.GuiHandlerBase;
|
||||
import forestry.core.network.GuiId;
|
||||
import forestry.core.network.PacketSocketUpdate;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.factory.gadgets.MachineBottler;
|
||||
import forestry.factory.gadgets.MachineCarpenter;
|
||||
import forestry.factory.gadgets.MachineCentrifuge;
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.factory.circuits;
|
||||
|
||||
import forestry.core.circuits.Circuit;
|
||||
import forestry.core.circuits.ISpeedUpgradable;
|
||||
|
||||
public class CircuitSpeedUpgrade extends Circuit {
|
||||
|
||||
private final double speedBoost;
|
||||
private final float powerDraw;
|
||||
|
||||
public CircuitSpeedUpgrade(String uid, double speedBoost, float powerDraw, int limit) {
|
||||
super(uid, false);
|
||||
this.setLimit(limit);
|
||||
this.speedBoost = speedBoost;
|
||||
this.powerDraw = powerDraw;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCircuitable(Object tile) {
|
||||
return tile instanceof ISpeedUpgradable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInsertion(int slot, Object tile) {
|
||||
if (!isCircuitable(tile)) {
|
||||
return;
|
||||
}
|
||||
if (tile instanceof ISpeedUpgradable) {
|
||||
ISpeedUpgradable machine = (ISpeedUpgradable) tile;
|
||||
machine.applySpeedUpgrade(speedBoost, powerDraw);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoad(int slot, Object tile) {
|
||||
onInsertion(slot, tile);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRemoval(int slot, Object tile) {
|
||||
if (!isCircuitable(tile)) {
|
||||
return;
|
||||
}
|
||||
if (tile instanceof ISpeedUpgradable) {
|
||||
ISpeedUpgradable machine = (ISpeedUpgradable) tile;
|
||||
machine.applySpeedUpgrade(-speedBoost, -powerDraw);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTick(int slot, Object tile) {
|
||||
}
|
||||
}
|
||||
@@ -145,7 +145,7 @@ public class MachineBottler extends TilePowered implements ISidedInventory, ILiq
|
||||
private int fillingTotalTime;
|
||||
|
||||
public MachineBottler() {
|
||||
super(1100, 50, 4000);
|
||||
super(1100, 4000, 200);
|
||||
|
||||
setInternalInventory(new BottlerInventoryAdapter(this));
|
||||
|
||||
@@ -265,10 +265,6 @@ public class MachineBottler extends TilePowered implements ISidedInventory, ILiq
|
||||
}
|
||||
|
||||
// / STATE INFORMATION
|
||||
@Override
|
||||
public boolean isWorking() {
|
||||
return fillingTime > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasResourcesMin(float percentage) {
|
||||
@@ -290,7 +286,7 @@ public class MachineBottler extends TilePowered implements ISidedInventory, ILiq
|
||||
return 0;
|
||||
}
|
||||
|
||||
return (fillingTime * i) / fillingTotalTime;
|
||||
return ((fillingTotalTime - fillingTime) * i) / fillingTotalTime;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@ public class MachineCarpenter extends TilePowered implements ISidedInventory, IL
|
||||
}
|
||||
|
||||
public MachineCarpenter() {
|
||||
super(1100, 50, 4000);
|
||||
super(1100, 4000, 200);
|
||||
setHints(Config.hints.get("carpenter"));
|
||||
resourceTank = new FilteredTank(Defaults.PROCESSOR_TANK_CAPACITY, RecipeManager.recipeFluids);
|
||||
|
||||
@@ -327,22 +327,15 @@ public class MachineCarpenter extends TilePowered implements ISidedInventory, IL
|
||||
}
|
||||
|
||||
/* STATE INFORMATION */
|
||||
@Override
|
||||
public boolean isWorking() {
|
||||
return packageTime > 0 || pendingProduct != null || currentRecipe != null && validateResources();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasWork() {
|
||||
if (currentRecipe == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
IInventoryAdapter accessibleInventory = getInternalInventory();
|
||||
// Stop working if the output slot cannot take more
|
||||
if (accessibleInventory.getStackInSlot(SLOT_PRODUCT) != null
|
||||
&& accessibleInventory.getStackInSlot(SLOT_PRODUCT).getMaxStackSize() - accessibleInventory.getStackInSlot(SLOT_PRODUCT).stackSize < currentRecipe
|
||||
.getCraftingResult().stackSize) {
|
||||
ItemStack product = getStackInSlot(SLOT_PRODUCT);
|
||||
if (product != null && product.getMaxStackSize() - product.stackSize < currentRecipe.getCraftingResult().stackSize) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -499,10 +492,6 @@ public class MachineCarpenter extends TilePowered implements ISidedInventory, IL
|
||||
return internal.matches(inventorycrafting, world);
|
||||
}
|
||||
|
||||
public boolean isIngredient(ItemStack resource) {
|
||||
return internal.isIngredient(resource);
|
||||
}
|
||||
|
||||
public ItemStack getBox() {
|
||||
return box;
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ package forestry.factory.gadgets;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
@@ -23,8 +24,6 @@ import java.util.Set;
|
||||
import java.util.Stack;
|
||||
|
||||
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;
|
||||
@@ -35,16 +34,23 @@ import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import cpw.mods.fml.common.Optional;
|
||||
|
||||
import forestry.api.circuits.ChipsetManager;
|
||||
import forestry.api.circuits.ICircuitBoard;
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.core.IErrorLogic;
|
||||
import forestry.api.recipes.ICentrifugeManager;
|
||||
import forestry.api.recipes.ICentrifugeRecipe;
|
||||
import forestry.core.EnumErrorCode;
|
||||
import forestry.core.circuits.ISocketable;
|
||||
import forestry.core.config.Config;
|
||||
import forestry.core.config.Defaults;
|
||||
import forestry.core.gadgets.TilePowered;
|
||||
import forestry.core.inventory.IInventoryAdapter;
|
||||
import forestry.core.inventory.InvTools;
|
||||
import forestry.core.inventory.InventoryAdapter;
|
||||
import forestry.core.inventory.TileInventoryAdapter;
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.DataOutputStreamForestry;
|
||||
import forestry.core.network.GuiId;
|
||||
import forestry.core.utils.StackUtils;
|
||||
import forestry.core.utils.Utils;
|
||||
@@ -52,7 +58,12 @@ import forestry.factory.triggers.FactoryTriggers;
|
||||
|
||||
import buildcraft.api.statements.ITriggerExternal;
|
||||
|
||||
public class MachineCentrifuge extends TilePowered implements ISidedInventory {
|
||||
public class MachineCentrifuge extends TilePowered implements ISocketable, ISidedInventory {
|
||||
|
||||
private static final int TICKS_PER_RECIPE_TIME = 4;
|
||||
private static final int ENERGY_PER_RECIPE_TIME = 210;
|
||||
|
||||
private final InventoryAdapter sockets = new InventoryAdapter(1, "sockets");
|
||||
|
||||
/* CONSTANTS */
|
||||
public static final int SLOT_RESOURCE = 0;
|
||||
@@ -63,11 +74,9 @@ public class MachineCentrifuge extends TilePowered implements ISidedInventory {
|
||||
private ICentrifugeRecipe currentRecipe;
|
||||
|
||||
private final Stack<ItemStack> pendingProducts = new Stack<ItemStack>();
|
||||
private int productionTime;
|
||||
private int timePerItem;
|
||||
|
||||
public MachineCentrifuge() {
|
||||
super(800, 40, Defaults.MACHINE_MAX_ENERGY);
|
||||
super(800, Defaults.MACHINE_MAX_ENERGY, 4200);
|
||||
setInternalInventory(new CentrifugeInventoryAdapter(this));
|
||||
setHints(Config.hints.get("centrifuge"));
|
||||
}
|
||||
@@ -82,8 +91,7 @@ public class MachineCentrifuge extends TilePowered implements ISidedInventory {
|
||||
public void writeToNBT(NBTTagCompound nbttagcompound) {
|
||||
super.writeToNBT(nbttagcompound);
|
||||
|
||||
nbttagcompound.setInteger("ProductionTime", productionTime);
|
||||
nbttagcompound.setInteger("TimePerItem", timePerItem);
|
||||
sockets.writeToNBT(nbttagcompound);
|
||||
|
||||
NBTTagList nbttaglist = new NBTTagList();
|
||||
ItemStack[] offspring = pendingProducts.toArray(new ItemStack[pendingProducts.size()]);
|
||||
@@ -102,35 +110,37 @@ public class MachineCentrifuge extends TilePowered implements ISidedInventory {
|
||||
public void readFromNBT(NBTTagCompound nbttagcompound) {
|
||||
super.readFromNBT(nbttagcompound);
|
||||
|
||||
productionTime = nbttagcompound.getInteger("ProductionTime");
|
||||
timePerItem = nbttagcompound.getInteger("TimePerItem");
|
||||
|
||||
NBTTagList nbttaglist = nbttagcompound.getTagList("PendingProducts", 10);
|
||||
for (int i = 0; i < nbttaglist.tagCount(); i++) {
|
||||
NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i);
|
||||
pendingProducts.add(ItemStack.loadItemStackFromNBT(nbttagcompound1));
|
||||
}
|
||||
sockets.readFromNBT(nbttagcompound);
|
||||
|
||||
checkRecipe();
|
||||
ItemStack chip = sockets.getStackInSlot(0);
|
||||
if (chip != null) {
|
||||
ICircuitBoard chipset = ChipsetManager.circuitRegistry.getCircuitboard(chip);
|
||||
if (chipset != null) {
|
||||
chipset.onLoad(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateServerSide() {
|
||||
super.updateServerSide();
|
||||
public void writeGuiData(DataOutputStreamForestry data) throws IOException {
|
||||
super.writeGuiData(data);
|
||||
sockets.writeData(data);
|
||||
}
|
||||
|
||||
if (!updateOnInterval(20)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Check and reset recipe if necessary
|
||||
checkRecipe();
|
||||
@Override
|
||||
public void readGuiData(DataInputStreamForestry data) throws IOException {
|
||||
super.readGuiData(data);
|
||||
sockets.readData(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean workCycle() {
|
||||
|
||||
checkRecipe();
|
||||
|
||||
// If we add pending products, we skip to the next work cycle.
|
||||
if (tryAddPending()) {
|
||||
return false;
|
||||
@@ -140,53 +150,32 @@ public class MachineCentrifuge extends TilePowered implements ISidedInventory {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Continue work if nothing needs to be added
|
||||
if (productionTime <= 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (currentRecipe == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
productionTime--;
|
||||
// Still not done, return
|
||||
if (productionTime > 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// We are done, add products to queue
|
||||
Collection<ItemStack> products = currentRecipe.getProducts(worldObj.rand);
|
||||
pendingProducts.addAll(products);
|
||||
|
||||
getInternalInventory().decrStackSize(SLOT_RESOURCE, 1);
|
||||
checkRecipe();
|
||||
resetRecipeTimes();
|
||||
|
||||
tryAddPending();
|
||||
return true;
|
||||
}
|
||||
|
||||
private void checkRecipe() {
|
||||
ICentrifugeRecipe machingRecipe = RecipeManager.findMatchingRecipe(getInternalInventory().getStackInSlot(SLOT_RESOURCE));
|
||||
ItemStack resource = getStackInSlot(SLOT_RESOURCE);
|
||||
ICentrifugeRecipe matchingRecipe = RecipeManager.findMatchingRecipe(resource);
|
||||
|
||||
if (currentRecipe != machingRecipe) {
|
||||
currentRecipe = machingRecipe;
|
||||
resetRecipeTimes();
|
||||
if (currentRecipe != matchingRecipe) {
|
||||
currentRecipe = matchingRecipe;
|
||||
if (currentRecipe != null) {
|
||||
int recipeTime = currentRecipe.getProcessingTime();
|
||||
setTicksPerWorkCycle(recipeTime * TICKS_PER_RECIPE_TIME);
|
||||
setEnergyPerWorkCycle(recipeTime * ENERGY_PER_RECIPE_TIME);
|
||||
}
|
||||
}
|
||||
|
||||
getErrorLogic().setCondition(currentRecipe == null, EnumErrorCode.NORECIPE);
|
||||
}
|
||||
|
||||
private void resetRecipeTimes() {
|
||||
if (currentRecipe == null) {
|
||||
productionTime = 0;
|
||||
timePerItem = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
productionTime = currentRecipe.getProcessingTime();
|
||||
timePerItem = currentRecipe.getProcessingTime();
|
||||
}
|
||||
|
||||
private boolean tryAddPending() {
|
||||
@@ -206,11 +195,6 @@ public class MachineCentrifuge extends TilePowered implements ISidedInventory {
|
||||
return added;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWorking() {
|
||||
return currentRecipe != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasResourcesMin(float percentage) {
|
||||
IInventoryAdapter inventory = getInternalInventory();
|
||||
@@ -223,32 +207,14 @@ public class MachineCentrifuge extends TilePowered implements ISidedInventory {
|
||||
|
||||
@Override
|
||||
public boolean hasWork() {
|
||||
return currentRecipe != null;
|
||||
}
|
||||
checkRecipe();
|
||||
|
||||
public int getProgressScaled(int i) {
|
||||
if (timePerItem == 0) {
|
||||
return i;
|
||||
}
|
||||
boolean hasResource = getStackInSlot(SLOT_RESOURCE) != null;
|
||||
|
||||
return ((timePerItem - productionTime) * i) / timePerItem;
|
||||
}
|
||||
IErrorLogic errorLogic = getErrorLogic();
|
||||
errorLogic.setCondition(!hasResource, EnumErrorCode.NORESOURCE);
|
||||
|
||||
/* GUI */
|
||||
public void getGUINetworkData(int i, int j) {
|
||||
switch (i) {
|
||||
case 0:
|
||||
productionTime = j;
|
||||
break;
|
||||
case 1:
|
||||
timePerItem = j;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void sendGUINetworkData(Container container, ICrafting iCrafting) {
|
||||
iCrafting.sendProgressBarUpdate(container, 0, productionTime);
|
||||
iCrafting.sendProgressBarUpdate(container, 1, timePerItem);
|
||||
return hasResource;
|
||||
}
|
||||
|
||||
/* ITRIGGERPROVIDER */
|
||||
@@ -277,6 +243,45 @@ public class MachineCentrifuge extends TilePowered implements ISidedInventory {
|
||||
}
|
||||
}
|
||||
|
||||
/* ISocketable */
|
||||
@Override
|
||||
public int getSocketCount() {
|
||||
return sockets.getSizeInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getSocket(int slot) {
|
||||
return sockets.getStackInSlot(slot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSocket(int slot, ItemStack stack) {
|
||||
|
||||
if (stack != null && !ChipsetManager.circuitRegistry.isChipset(stack)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Dispose correctly of old chipsets
|
||||
if (sockets.getStackInSlot(slot) != null) {
|
||||
if (ChipsetManager.circuitRegistry.isChipset(sockets.getStackInSlot(slot))) {
|
||||
ICircuitBoard chipset = ChipsetManager.circuitRegistry.getCircuitboard(sockets.getStackInSlot(slot));
|
||||
if (chipset != null) {
|
||||
chipset.onRemoval(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sockets.setInventorySlotContents(slot, stack);
|
||||
if (stack == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
ICircuitBoard chipset = ChipsetManager.circuitRegistry.getCircuitboard(stack);
|
||||
if (chipset != null) {
|
||||
chipset.onInsertion(this);
|
||||
}
|
||||
}
|
||||
|
||||
/* RECIPE MANAGEMENT */
|
||||
public static class CentrifugeRecipe implements ICentrifugeRecipe {
|
||||
|
||||
@@ -344,10 +349,14 @@ public class MachineCentrifuge extends TilePowered implements ISidedInventory {
|
||||
addRecipe(recipe);
|
||||
}
|
||||
|
||||
public static ICentrifugeRecipe findMatchingRecipe(ItemStack item) {
|
||||
public static ICentrifugeRecipe findMatchingRecipe(ItemStack itemStack) {
|
||||
if (itemStack == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
for (ICentrifugeRecipe recipe : recipes) {
|
||||
ItemStack recipeInput = recipe.getInput();
|
||||
if (StackUtils.isCraftingEquivalent(recipeInput, item)) {
|
||||
if (StackUtils.isCraftingEquivalent(recipeInput, itemStack)) {
|
||||
return recipe;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ public class MachineFabricator extends TilePowered implements ICrafter, ILiquidT
|
||||
private int guiMeltingPoint = 0;
|
||||
|
||||
public MachineFabricator() {
|
||||
super(1100, 50, 3300);
|
||||
super(1100, 3300, 200);
|
||||
craftingInventory = new TileInventoryAdapter<MachineFabricator>(this, SLOT_CRAFTING_COUNT, "CraftItems");
|
||||
setInternalInventory(new FabricatorInventoryAdapter(this));
|
||||
moltenTank = new FilteredTank(2 * Defaults.BUCKET_VOLUME, Fluids.GLASS.getFluid());
|
||||
@@ -298,11 +298,6 @@ public class MachineFabricator extends TilePowered implements ICrafter, ILiquidT
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWorking() {
|
||||
return this.heat <= MAX_HEAT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasWork() {
|
||||
IInventoryAdapter inventory = getInternalInventory();
|
||||
|
||||
@@ -177,7 +177,7 @@ public class MachineFermenter extends TilePowered implements ISidedInventory, IL
|
||||
private int fuelCurrentFerment = 0;
|
||||
|
||||
public MachineFermenter() {
|
||||
super(2000, 150, 8000);
|
||||
super(2000, 8000, 600);
|
||||
setInternalInventory(new FermenterInventoryAdapter(this));
|
||||
setHints(Config.hints.get("fermenter"));
|
||||
resourceTank = new FilteredTank(Defaults.PROCESSOR_TANK_CAPACITY, RecipeManager.recipeFluidInputs);
|
||||
@@ -394,19 +394,7 @@ public class MachineFermenter extends TilePowered implements ISidedInventory, IL
|
||||
return ((IVariableFermentable) itemstack.getItem()).getFermentationModifier(itemstack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWorking() {
|
||||
IInventoryAdapter inventory = getInternalInventory();
|
||||
if (currentRecipe == null
|
||||
&& RecipeManager.findMatchingRecipe(inventory.getStackInSlot(SLOT_RESOURCE), resourceTank.getFluid()) == null) {
|
||||
return false;
|
||||
}
|
||||
if (fuelBurnTime > 0) {
|
||||
return resourceTank.getFluidAmount() > 0 && productTank.getFluidAmount() < Defaults.PROCESSOR_TANK_CAPACITY;
|
||||
} else {
|
||||
return determineFuelValue(getFuelStack()) > 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean hasResourcesMin(float percentage) {
|
||||
@@ -428,32 +416,23 @@ public class MachineFermenter extends TilePowered implements ISidedInventory, IL
|
||||
|
||||
@Override
|
||||
public boolean hasWork() {
|
||||
IInventoryAdapter inventory = getInternalInventory();
|
||||
if (this.getFuelStack() == null && fuelBurnTime <= 0) {
|
||||
if (currentRecipe == null && RecipeManager.findMatchingRecipe(getStackInSlot(SLOT_RESOURCE), resourceTank.getFluid()) == null) {
|
||||
return false;
|
||||
} else if (fuelBurnTime <= 0) {
|
||||
if (RecipeManager.findMatchingRecipe(inventory.getStackInSlot(SLOT_RESOURCE), resourceTank.getFluid()) == null) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.getFermentationStack() == null && fermentationTime <= 0) {
|
||||
if (fuelBurnTime <= 0 && determineFuelValue(getFuelStack()) <= 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (fermentationTime <= 0 && this.getFermentationStack() == null) {
|
||||
return false;
|
||||
} else if (fermentationTime <= 0) {
|
||||
if (RecipeManager.findMatchingRecipe(inventory.getStackInSlot(SLOT_RESOURCE), resourceTank.getFluid()) == null) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (resourceTank.getFluidAmount() <= fuelCurrentFerment) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (productTank.getFluidAmount() >= productTank.getCapacity()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return productTank.getFluidAmount() < productTank.getCapacity();
|
||||
}
|
||||
|
||||
public int getBurnTimeRemainingScaled(int i) {
|
||||
|
||||
@@ -29,10 +29,14 @@ import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
|
||||
import forestry.api.circuits.ChipsetManager;
|
||||
import forestry.api.circuits.ICircuitBoard;
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.core.IErrorLogic;
|
||||
import forestry.api.recipes.ISqueezerManager;
|
||||
import forestry.core.EnumErrorCode;
|
||||
import forestry.core.circuits.ISocketable;
|
||||
import forestry.core.circuits.ISpeedUpgradable;
|
||||
import forestry.core.config.Config;
|
||||
import forestry.core.config.Defaults;
|
||||
import forestry.core.fluids.FluidHelper;
|
||||
@@ -41,8 +45,8 @@ import forestry.core.fluids.tanks.FilteredTank;
|
||||
import forestry.core.fluids.tanks.StandardTank;
|
||||
import forestry.core.gadgets.TilePowered;
|
||||
import forestry.core.interfaces.ILiquidTankContainer;
|
||||
import forestry.core.inventory.IInventoryAdapter;
|
||||
import forestry.core.inventory.InvTools;
|
||||
import forestry.core.inventory.InventoryAdapter;
|
||||
import forestry.core.inventory.TileInventoryAdapter;
|
||||
import forestry.core.network.DataInputStreamForestry;
|
||||
import forestry.core.network.DataOutputStreamForestry;
|
||||
@@ -52,15 +56,310 @@ import forestry.core.utils.EnumTankLevel;
|
||||
import forestry.core.utils.StackUtils;
|
||||
import forestry.core.utils.Utils;
|
||||
|
||||
public class MachineSqueezer extends TilePowered implements ISidedInventory, ILiquidTankContainer {
|
||||
public class MachineSqueezer extends TilePowered implements ISocketable, ISidedInventory, ILiquidTankContainer, ISpeedUpgradable {
|
||||
|
||||
/* CONSTANTS */
|
||||
public static final short SLOT_RESOURCE_1 = 0;
|
||||
public static final short SLOTS_RESOURCE_COUNT = 9;
|
||||
public static final short SLOT_REMNANT = 9;
|
||||
public static final short SLOT_REMNANT_COUNT = 1;
|
||||
public static final short SLOT_CAN_INPUT = 10;
|
||||
public static final short SLOT_CAN_OUTPUT = 11;
|
||||
private static final int TICKS_PER_RECIPE_TIME = 4;
|
||||
private static final int ENERGY_PER_RECIPE_TIME = 200;
|
||||
|
||||
private final InventoryAdapter sockets = new InventoryAdapter(1, "sockets");
|
||||
|
||||
/* MEMBER */
|
||||
private final TankManager tankManager;
|
||||
private final FilteredTank productTank;
|
||||
private final SqueezerInventory inventory;
|
||||
|
||||
private Recipe currentRecipe;
|
||||
|
||||
public MachineSqueezer() {
|
||||
super(1100, 4000, 2000);
|
||||
this.inventory = new SqueezerInventory(this);
|
||||
setInternalInventory(this.inventory);
|
||||
setHints(Config.hints.get("squeezer"));
|
||||
this.productTank = new FilteredTank(Defaults.PROCESSOR_TANK_CAPACITY, RecipeManager.recipeFluids);
|
||||
this.productTank.tankMode = StandardTank.TankMode.OUTPUT;
|
||||
this.tankManager = new TankManager(productTank);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openGui(EntityPlayer player) {
|
||||
player.openGui(ForestryAPI.instance, GuiId.SqueezerGUI.ordinal(), player.worldObj, xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
/* LOADING & SAVING */
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbttagcompound) {
|
||||
super.writeToNBT(nbttagcompound);
|
||||
tankManager.writeTanksToNBT(nbttagcompound);
|
||||
sockets.writeToNBT(nbttagcompound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbttagcompound) {
|
||||
super.readFromNBT(nbttagcompound);
|
||||
tankManager.readTanksFromNBT(nbttagcompound);
|
||||
sockets.readFromNBT(nbttagcompound);
|
||||
|
||||
ItemStack chip = sockets.getStackInSlot(0);
|
||||
if (chip != null) {
|
||||
ICircuitBoard chipset = ChipsetManager.circuitRegistry.getCircuitboard(chip);
|
||||
if (chipset != null) {
|
||||
chipset.onLoad(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeData(DataOutputStreamForestry data) throws IOException {
|
||||
super.writeData(data);
|
||||
tankManager.writePacketData(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readData(DataInputStreamForestry data) throws IOException {
|
||||
super.readData(data);
|
||||
tankManager.readPacketData(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeGuiData(DataOutputStreamForestry data) throws IOException {
|
||||
super.writeGuiData(data);
|
||||
sockets.writeData(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readGuiData(DataInputStreamForestry data) throws IOException {
|
||||
super.readGuiData(data);
|
||||
sockets.readData(data);
|
||||
}
|
||||
|
||||
// / WORKING
|
||||
@Override
|
||||
public void updateServerSide() {
|
||||
super.updateServerSide();
|
||||
|
||||
if (updateOnInterval(20)) {
|
||||
inventory.fillContainers(productTank.getFluid(), tankManager);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean workCycle() {
|
||||
EntityPlayer player = Proxies.common.getPlayer(worldObj, getAccessHandler().getOwner());
|
||||
if (!inventory.removeResources(currentRecipe.resources, player)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
FluidStack resultFluid = currentRecipe.liquid;
|
||||
productTank.fill(resultFluid, true);
|
||||
|
||||
if (currentRecipe.remnants != null && worldObj.rand.nextInt(100) < currentRecipe.chance) {
|
||||
ItemStack remnant = currentRecipe.remnants.copy();
|
||||
inventory.addRemnant(remnant, true);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean checkRecipe() {
|
||||
ItemStack[] resources = inventory.getResources();
|
||||
Recipe matchingRecipe = RecipeManager.findMatchingRecipe(resources);
|
||||
|
||||
if (currentRecipe != matchingRecipe) {
|
||||
currentRecipe = matchingRecipe;
|
||||
if (currentRecipe != null) {
|
||||
int recipeTime = currentRecipe.timePerItem;
|
||||
setTicksPerWorkCycle(recipeTime * TICKS_PER_RECIPE_TIME);
|
||||
setEnergyPerWorkCycle(recipeTime * ENERGY_PER_RECIPE_TIME);
|
||||
}
|
||||
}
|
||||
|
||||
getErrorLogic().setCondition(currentRecipe == null, EnumErrorCode.NORECIPE);
|
||||
return currentRecipe != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasWork() {
|
||||
checkRecipe();
|
||||
|
||||
boolean hasResources = inventory.hasResources();
|
||||
boolean hasRecipe = true;
|
||||
boolean canFill = true;
|
||||
boolean canAdd = true;
|
||||
|
||||
if (hasResources) {
|
||||
hasRecipe = (currentRecipe != null);
|
||||
if (hasRecipe) {
|
||||
FluidStack resultFluid = currentRecipe.liquid;
|
||||
canFill = (productTank.fill(resultFluid, false) == resultFluid.amount);
|
||||
|
||||
if (currentRecipe.remnants != null) {
|
||||
canAdd = inventory.addRemnant(currentRecipe.remnants, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IErrorLogic errorLogic = getErrorLogic();
|
||||
errorLogic.setCondition(!hasResources, EnumErrorCode.NORESOURCE);
|
||||
errorLogic.setCondition(!hasRecipe, EnumErrorCode.NORECIPE);
|
||||
errorLogic.setCondition(!canFill, EnumErrorCode.NOSPACETANK);
|
||||
errorLogic.setCondition(!canAdd, EnumErrorCode.NOSPACE);
|
||||
|
||||
return hasResources && hasRecipe && canFill && canAdd;
|
||||
}
|
||||
|
||||
public int getResourceScaled(int i) {
|
||||
return (productTank.getFluidAmount() * i) / Defaults.PROCESSOR_TANK_CAPACITY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumTankLevel getSecondaryLevel() {
|
||||
return Utils.rateTankLevel(getResourceScaled(100));
|
||||
}
|
||||
|
||||
/* ILIQUIDCONTAINER IMPLEMENTATION */
|
||||
@Override
|
||||
public TankManager getTankManager() {
|
||||
return tankManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getGUINetworkData(int messageId, int data) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendGUINetworkData(Container container, ICrafting iCrafting) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill(ForgeDirection from, FluidStack resource, boolean doFill) {
|
||||
return tankManager.fill(from, resource, doFill);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) {
|
||||
return tankManager.drain(from, resource, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) {
|
||||
return tankManager.drain(from, maxDrain, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFill(ForgeDirection from, Fluid fluid) {
|
||||
return tankManager.canFill(from, fluid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrain(ForgeDirection from, Fluid fluid) {
|
||||
return tankManager.canDrain(from, fluid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTankInfo[] getTankInfo(ForgeDirection from) {
|
||||
return tankManager.getTankInfo(from);
|
||||
}
|
||||
|
||||
/* ISocketable */
|
||||
@Override
|
||||
public int getSocketCount() {
|
||||
return sockets.getSizeInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getSocket(int slot) {
|
||||
return sockets.getStackInSlot(slot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSocket(int slot, ItemStack stack) {
|
||||
|
||||
if (stack != null && !ChipsetManager.circuitRegistry.isChipset(stack)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Dispose correctly of old chipsets
|
||||
if (sockets.getStackInSlot(slot) != null) {
|
||||
if (ChipsetManager.circuitRegistry.isChipset(sockets.getStackInSlot(slot))) {
|
||||
ICircuitBoard chipset = ChipsetManager.circuitRegistry.getCircuitboard(sockets.getStackInSlot(slot));
|
||||
if (chipset != null) {
|
||||
chipset.onRemoval(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sockets.setInventorySlotContents(slot, stack);
|
||||
if (stack == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
ICircuitBoard chipset = ChipsetManager.circuitRegistry.getCircuitboard(stack);
|
||||
if (chipset != null) {
|
||||
chipset.onInsertion(this);
|
||||
}
|
||||
}
|
||||
|
||||
public static class SqueezerInventory extends TileInventoryAdapter<MachineSqueezer> {
|
||||
public static final short SLOT_RESOURCE_1 = 0;
|
||||
public static final short SLOTS_RESOURCE_COUNT = 9;
|
||||
public static final short SLOT_REMNANT = 9;
|
||||
public static final short SLOT_REMNANT_COUNT = 1;
|
||||
public static final short SLOT_CAN_INPUT = 10;
|
||||
public static final short SLOT_CAN_OUTPUT = 11;
|
||||
|
||||
public SqueezerInventory(MachineSqueezer squeezer) {
|
||||
super(squeezer, 12, "Items");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
|
||||
if (slotIndex == SLOT_CAN_INPUT) {
|
||||
return FluidHelper.isEmptyContainer(itemStack);
|
||||
}
|
||||
|
||||
if (slotIndex >= SLOT_RESOURCE_1 && slotIndex < SLOT_RESOURCE_1 + SLOTS_RESOURCE_COUNT) {
|
||||
if (FluidHelper.isEmptyContainer(itemStack)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (RecipeManager.canUse(itemStack)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int slotIndex, ItemStack itemstack, int side) {
|
||||
return slotIndex == SLOT_REMNANT || slotIndex == SLOT_CAN_OUTPUT;
|
||||
}
|
||||
|
||||
public boolean hasResources() {
|
||||
return !InvTools.isEmpty(this, SLOT_RESOURCE_1, SLOTS_RESOURCE_COUNT);
|
||||
}
|
||||
|
||||
public ItemStack[] getResources() {
|
||||
return InvTools.getStacks(this, SLOT_RESOURCE_1, SLOTS_RESOURCE_COUNT);
|
||||
}
|
||||
|
||||
public boolean removeResources(ItemStack[] stacks, EntityPlayer player) {
|
||||
return InvTools.removeSets(this, 1, stacks, SLOT_RESOURCE_1, SLOTS_RESOURCE_COUNT, player, false, true);
|
||||
}
|
||||
|
||||
public boolean addRemnant(ItemStack remnant, boolean doAdd) {
|
||||
return InvTools.tryAddStack(this, remnant, SLOT_REMNANT, SLOT_REMNANT_COUNT, true, doAdd);
|
||||
}
|
||||
|
||||
public void fillContainers(FluidStack fluidStack, TankManager tankManager) {
|
||||
if (getStackInSlot(SLOT_CAN_INPUT) == null || fluidStack == null) {
|
||||
return;
|
||||
}
|
||||
FluidHelper.fillContainers(tankManager, this, SLOT_CAN_INPUT, SLOT_CAN_OUTPUT, fluidStack.getFluid());
|
||||
}
|
||||
}
|
||||
|
||||
/* RECIPE MANAGMENT */
|
||||
public static class Recipe {
|
||||
@@ -140,280 +439,4 @@ public class MachineSqueezer extends TilePowered implements ISidedInventory, ILi
|
||||
}
|
||||
}
|
||||
|
||||
/* MEMBER */
|
||||
private final TankManager tankManager;
|
||||
private final FilteredTank productTank;
|
||||
|
||||
private Recipe currentRecipe;
|
||||
|
||||
private int productionTime;
|
||||
private int timePerItem;
|
||||
|
||||
public MachineSqueezer() {
|
||||
super(1100, 50, 4000);
|
||||
setInternalInventory(new SqueezerInventoryAdapter(this));
|
||||
setHints(Config.hints.get("squeezer"));
|
||||
productTank = new FilteredTank(Defaults.PROCESSOR_TANK_CAPACITY, RecipeManager.recipeFluids);
|
||||
productTank.tankMode = StandardTank.TankMode.OUTPUT;
|
||||
tankManager = new TankManager(productTank);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openGui(EntityPlayer player) {
|
||||
player.openGui(ForestryAPI.instance, GuiId.SqueezerGUI.ordinal(), player.worldObj, xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
/* LOADING & SAVING */
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbttagcompound) {
|
||||
super.writeToNBT(nbttagcompound);
|
||||
|
||||
nbttagcompound.setInteger("ProductionTime", productionTime);
|
||||
nbttagcompound.setInteger("TimePerItem", timePerItem);
|
||||
|
||||
tankManager.writeTanksToNBT(nbttagcompound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbttagcompound) {
|
||||
super.readFromNBT(nbttagcompound);
|
||||
|
||||
productionTime = nbttagcompound.getInteger("ProductionTime");
|
||||
timePerItem = nbttagcompound.getInteger("TimePerItem");
|
||||
tankManager.readTanksFromNBT(nbttagcompound);
|
||||
|
||||
checkRecipe();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeData(DataOutputStreamForestry data) throws IOException {
|
||||
super.writeData(data);
|
||||
tankManager.writePacketData(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readData(DataInputStreamForestry data) throws IOException {
|
||||
super.readData(data);
|
||||
tankManager.readPacketData(data);
|
||||
}
|
||||
|
||||
// / WORKING
|
||||
@Override
|
||||
public void updateServerSide() {
|
||||
super.updateServerSide();
|
||||
|
||||
if (!updateOnInterval(20)) {
|
||||
return;
|
||||
}
|
||||
|
||||
IInventoryAdapter inventory = getInternalInventory();
|
||||
// Can/capsule input/output needs to be handled here.
|
||||
if (inventory.getStackInSlot(SLOT_CAN_INPUT) != null) {
|
||||
FluidStack fluidStack = productTank.getFluid();
|
||||
if (fluidStack != null) {
|
||||
FluidHelper.fillContainers(tankManager, inventory, SLOT_CAN_INPUT, SLOT_CAN_OUTPUT, fluidStack.getFluid());
|
||||
}
|
||||
}
|
||||
|
||||
checkRecipe();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean workCycle() {
|
||||
|
||||
if (!checkRecipe()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
IErrorLogic errorLogic = getErrorLogic();
|
||||
|
||||
FluidStack resultFluid = currentRecipe.liquid;
|
||||
boolean canFill = productTank.fill(resultFluid, false) == resultFluid.amount;
|
||||
errorLogic.setCondition(!canFill, EnumErrorCode.NOSPACETANK);
|
||||
|
||||
if (!canFill) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ItemStack remnant = null;
|
||||
if (currentRecipe.remnants != null) {
|
||||
remnant = currentRecipe.remnants.copy();
|
||||
boolean canAdd = InvTools.tryAddStack(getInternalInventory(), remnant, SLOT_REMNANT, SLOT_REMNANT_COUNT, true, false);
|
||||
errorLogic.setCondition(!canAdd, EnumErrorCode.NOSPACE);
|
||||
if (!canAdd) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (productionTime <= 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (currentRecipe == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
productionTime--;
|
||||
// Still not done, return
|
||||
if (productionTime > 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!removeResources(currentRecipe.resources)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
productTank.fill(resultFluid, true);
|
||||
if (remnant != null && worldObj.rand.nextInt(100) < currentRecipe.chance) {
|
||||
InvTools.tryAddStack(getInternalInventory(), remnant, SLOT_REMNANT, SLOT_REMNANT_COUNT, true);
|
||||
}
|
||||
|
||||
checkRecipe();
|
||||
resetRecipeTimes();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean checkRecipe() {
|
||||
ItemStack[] resources = InvTools.getStacks(getInternalInventory(), SLOT_RESOURCE_1, SLOTS_RESOURCE_COUNT);
|
||||
Recipe matchingRecipe = RecipeManager.findMatchingRecipe(resources);
|
||||
|
||||
if (currentRecipe != matchingRecipe) {
|
||||
currentRecipe = matchingRecipe;
|
||||
resetRecipeTimes();
|
||||
}
|
||||
|
||||
getErrorLogic().setCondition(currentRecipe == null, EnumErrorCode.NORECIPE);
|
||||
return currentRecipe != null;
|
||||
}
|
||||
|
||||
private void resetRecipeTimes() {
|
||||
if (currentRecipe == null) {
|
||||
productionTime = 0;
|
||||
timePerItem = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
productionTime = currentRecipe.timePerItem;
|
||||
timePerItem = currentRecipe.timePerItem;
|
||||
}
|
||||
|
||||
private boolean removeResources(ItemStack[] stacks) {
|
||||
EntityPlayer player = Proxies.common.getPlayer(worldObj, getAccessHandler().getOwner());
|
||||
return InvTools.removeSets(getInternalInventory(), 1, stacks, SLOT_RESOURCE_1, SLOTS_RESOURCE_COUNT, player, false, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWorking() {
|
||||
return currentRecipe != null && productTank.getFluidAmount() < productTank.getCapacity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasWork() {
|
||||
return currentRecipe != null && productTank.getFluidAmount() < productTank.getCapacity();
|
||||
}
|
||||
|
||||
public int getProgressScaled(int i) {
|
||||
if (timePerItem == 0) {
|
||||
return i;
|
||||
}
|
||||
|
||||
return (productionTime * i) / timePerItem;
|
||||
}
|
||||
|
||||
public int getResourceScaled(int i) {
|
||||
return (productTank.getFluidAmount() * i) / Defaults.PROCESSOR_TANK_CAPACITY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumTankLevel getSecondaryLevel() {
|
||||
return Utils.rateTankLevel(getResourceScaled(100));
|
||||
}
|
||||
|
||||
/* SMP GUI */
|
||||
@Override
|
||||
public void getGUINetworkData(int i, int j) {
|
||||
i -= tankManager.maxMessageId() + 1;
|
||||
switch (i) {
|
||||
case 0:
|
||||
productionTime = j;
|
||||
break;
|
||||
case 1:
|
||||
timePerItem = j;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendGUINetworkData(Container container, ICrafting iCrafting) {
|
||||
int i = tankManager.maxMessageId() + 1;
|
||||
iCrafting.sendProgressBarUpdate(container, i, productionTime);
|
||||
iCrafting.sendProgressBarUpdate(container, i + 1, timePerItem);
|
||||
}
|
||||
|
||||
/* ILIQUIDCONTAINER IMPLEMENTATION */
|
||||
@Override
|
||||
public TankManager getTankManager() {
|
||||
return tankManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill(ForgeDirection from, FluidStack resource, boolean doFill) {
|
||||
return tankManager.fill(from, resource, doFill);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) {
|
||||
return tankManager.drain(from, resource, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) {
|
||||
return tankManager.drain(from, maxDrain, doDrain);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFill(ForgeDirection from, Fluid fluid) {
|
||||
return tankManager.canFill(from, fluid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrain(ForgeDirection from, Fluid fluid) {
|
||||
return tankManager.canDrain(from, fluid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTankInfo[] getTankInfo(ForgeDirection from) {
|
||||
return tankManager.getTankInfo(from);
|
||||
}
|
||||
|
||||
private static class SqueezerInventoryAdapter extends TileInventoryAdapter<MachineSqueezer> {
|
||||
public SqueezerInventoryAdapter(MachineSqueezer squeezer) {
|
||||
super(squeezer, 12, "Items");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
|
||||
if (slotIndex == SLOT_CAN_INPUT) {
|
||||
return FluidHelper.isEmptyContainer(itemStack);
|
||||
}
|
||||
|
||||
if (slotIndex >= SLOT_RESOURCE_1 && slotIndex < SLOT_RESOURCE_1 + SLOTS_RESOURCE_COUNT) {
|
||||
if (FluidHelper.isEmptyContainer(itemStack)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (RecipeManager.canUse(itemStack)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int slotIndex, ItemStack itemstack, int side) {
|
||||
return slotIndex == SLOT_REMNANT || slotIndex == SLOT_CAN_OUTPUT;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -131,7 +131,7 @@ public class MachineStill extends TilePowered implements ISidedInventory, ILiqui
|
||||
private int distillationTotalTime = 0;
|
||||
|
||||
public MachineStill() {
|
||||
super(1100, 50, 8000);
|
||||
super(1100, 8000, 200);
|
||||
setInternalInventory(new StillInventoryAdapter(this));
|
||||
setHints(Config.hints.get("still"));
|
||||
resourceTank = new FilteredTank(Defaults.PROCESSOR_TANK_CAPACITY, RecipeManager.recipeFluidInputs);
|
||||
@@ -258,11 +258,6 @@ public class MachineStill extends TilePowered implements ISidedInventory, ILiqui
|
||||
getErrorLogic().setCondition(currentRecipe == null, EnumErrorCode.NORECIPE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWorking() {
|
||||
return distillationTime > 0 || currentRecipe != null && productTank.getFluidAmount() + currentRecipe.output.amount <= Defaults.PROCESSOR_TANK_CAPACITY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasWork() {
|
||||
if (currentRecipe == null) {
|
||||
|
||||
@@ -11,20 +11,19 @@
|
||||
package forestry.factory.gui;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.ICrafting;
|
||||
|
||||
import forestry.core.gui.ContainerTile;
|
||||
import forestry.core.gui.ContainerSocketed;
|
||||
import forestry.core.gui.slots.SlotFiltered;
|
||||
import forestry.core.gui.slots.SlotOutput;
|
||||
import forestry.factory.gadgets.MachineCentrifuge;
|
||||
|
||||
public class ContainerCentrifuge extends ContainerTile<MachineCentrifuge> {
|
||||
public class ContainerCentrifuge extends ContainerSocketed<MachineCentrifuge> {
|
||||
|
||||
public ContainerCentrifuge(InventoryPlayer player, MachineCentrifuge tile) {
|
||||
super(tile, player, 8, 84);
|
||||
|
||||
// Resource
|
||||
this.addSlotToContainer(new SlotFiltered(tile, 0, 34, 37));
|
||||
this.addSlotToContainer(new SlotFiltered(tile, 0, 30, 37));
|
||||
|
||||
// Product Inventory
|
||||
for (int l = 0; l < 3; l++) {
|
||||
@@ -34,18 +33,4 @@ public class ContainerCentrifuge extends ContainerTile<MachineCentrifuge> {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateProgressBar(int i, int j) {
|
||||
tile.getGUINetworkData(i, j);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
super.detectAndSendChanges();
|
||||
|
||||
for (Object crafter : crafters) {
|
||||
tile.sendGUINetworkData(this, (ICrafting) crafter);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -12,29 +12,29 @@ package forestry.factory.gui;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
import forestry.core.gui.ContainerLiquidTanks;
|
||||
import forestry.core.gui.ContainerLiquidTanksSocketed;
|
||||
import forestry.core.gui.slots.SlotFiltered;
|
||||
import forestry.core.gui.slots.SlotOutput;
|
||||
import forestry.factory.gadgets.MachineSqueezer;
|
||||
|
||||
public class ContainerSqueezer extends ContainerLiquidTanks<MachineSqueezer> {
|
||||
public class ContainerSqueezer extends ContainerLiquidTanksSocketed<MachineSqueezer> {
|
||||
|
||||
public ContainerSqueezer(InventoryPlayer player, MachineSqueezer tile) {
|
||||
super(tile, player, 8, 84);
|
||||
|
||||
// Resource inventory
|
||||
for (int l = 0; l < 3; l++) {
|
||||
for (int k = 0; k < 3; k++) {
|
||||
addSlotToContainer(new SlotFiltered(tile, k + l * 3, 19 + k * 18, 18 + l * 18));
|
||||
for (int row = 0; row < 3; row++) {
|
||||
for (int column = 0; column < 3; column++) {
|
||||
addSlotToContainer(new SlotFiltered(tile, column + row * 3, 17 + column * 18, 21 + row * 18));
|
||||
}
|
||||
}
|
||||
|
||||
// Remnants slot
|
||||
this.addSlotToContainer(new SlotOutput(tile, MachineSqueezer.SLOT_REMNANT, 123, 19));
|
||||
this.addSlotToContainer(new SlotOutput(tile, MachineSqueezer.SqueezerInventory.SLOT_REMNANT, 97, 60));
|
||||
|
||||
// Can slot
|
||||
this.addSlotToContainer(new SlotFiltered(tile, MachineSqueezer.SLOT_CAN_INPUT, 106, 55));
|
||||
this.addSlotToContainer(new SlotFiltered(tile, MachineSqueezer.SqueezerInventory.SLOT_CAN_INPUT, 147, 24));
|
||||
// Output slot
|
||||
this.addSlotToContainer(new SlotOutput(tile, MachineSqueezer.SLOT_CAN_OUTPUT, 140, 55));
|
||||
this.addSlotToContainer(new SlotOutput(tile, MachineSqueezer.SqueezerInventory.SLOT_CAN_OUTPUT, 147, 60));
|
||||
}
|
||||
}
|
||||
@@ -29,9 +29,7 @@ public class GuiBottler extends GuiForestryTitled<ContainerBottler, MachineBottl
|
||||
super.drawGuiContainerBackgroundLayer(var1, mouseX, mouseY);
|
||||
MachineBottler bottler = inventory;
|
||||
|
||||
if (bottler.isWorking()) {
|
||||
int i1 = bottler.getFillProgressScaled(24);
|
||||
drawTexturedModalRect(guiLeft + 80, guiTop + 39, 176, 74, 24 - i1, 16);
|
||||
}
|
||||
int i1 = bottler.getFillProgressScaled(24);
|
||||
drawTexturedModalRect(guiLeft + 80, guiTop + 39, 176, 74, i1, 16);
|
||||
}
|
||||
}
|
||||
@@ -30,11 +30,8 @@ public class GuiCarpenter extends GuiForestryTitled<ContainerCarpenter, MachineC
|
||||
protected void drawGuiContainerBackgroundLayer(float var1, int mouseX, int mouseY) {
|
||||
super.drawGuiContainerBackgroundLayer(var1, mouseX, mouseY);
|
||||
MachineCarpenter machine = inventory;
|
||||
|
||||
if (machine.isWorking()) {
|
||||
int progressScaled = machine.getCraftingProgressScaled(16);
|
||||
drawTexturedModalRect(guiLeft + 98, guiTop + 51 + 16 - progressScaled, 176, 60 + 16 - progressScaled, 4, progressScaled);
|
||||
}
|
||||
int progressScaled = machine.getCraftingProgressScaled(16);
|
||||
drawTexturedModalRect(guiLeft + 98, guiTop + 51 + 16 - progressScaled, 176, 60 + 16 - progressScaled, 4, progressScaled);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,20 +14,21 @@ import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
import forestry.core.config.Defaults;
|
||||
import forestry.core.gui.GuiForestryTitled;
|
||||
import forestry.core.gui.widgets.SocketWidget;
|
||||
import forestry.factory.gadgets.MachineCentrifuge;
|
||||
|
||||
public class GuiCentrifuge extends GuiForestryTitled<ContainerCentrifuge, MachineCentrifuge> {
|
||||
|
||||
public GuiCentrifuge(InventoryPlayer inventory, MachineCentrifuge tile) {
|
||||
super(Defaults.TEXTURE_PATH_GUI + "/centrifuge.png", new ContainerCentrifuge(inventory, tile), tile);
|
||||
super(Defaults.TEXTURE_PATH_GUI + "/centrifugesocket.png", new ContainerCentrifuge(inventory, tile), tile);
|
||||
widgetManager.add(new SocketWidget(this.widgetManager, 71, 37, tile, 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float var1, int mouseX, int mouseY) {
|
||||
super.drawGuiContainerBackgroundLayer(var1, mouseX, mouseY);
|
||||
MachineCentrifuge machine = inventory;
|
||||
|
||||
int progress = machine.getProgressScaled(16);
|
||||
drawTexturedModalRect(guiLeft + 62, guiTop + 36 + 17 - progress, 176, 17 - progress, 4, progress);
|
||||
int progress = 16 - inventory.getProgressScaled(16);
|
||||
drawTexturedModalRect(guiLeft + 58, guiTop + 36 + 17 - progress, 176, 17 - progress, 4, progress);
|
||||
}
|
||||
}
|
||||
@@ -14,20 +14,22 @@ import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
import forestry.core.config.Defaults;
|
||||
import forestry.core.gui.GuiForestryTitled;
|
||||
import forestry.core.gui.widgets.SocketWidget;
|
||||
import forestry.core.gui.widgets.TankWidget;
|
||||
import forestry.factory.gadgets.MachineSqueezer;
|
||||
|
||||
public class GuiSqueezer extends GuiForestryTitled<ContainerSqueezer, MachineSqueezer> {
|
||||
|
||||
public GuiSqueezer(InventoryPlayer inventory, MachineSqueezer tile) {
|
||||
super(Defaults.TEXTURE_PATH_GUI + "/squeezer.png", new ContainerSqueezer(inventory, tile), tile);
|
||||
widgetManager.add(new TankWidget(this.widgetManager, 85, 15, 0));
|
||||
super(Defaults.TEXTURE_PATH_GUI + "/squeezersocket.png", new ContainerSqueezer(inventory, tile), tile);
|
||||
widgetManager.add(new TankWidget(this.widgetManager, 122, 18, 0));
|
||||
widgetManager.add(new SocketWidget(this.widgetManager, 75, 20, tile, 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawWidgets() {
|
||||
int progress = inventory.getProgressScaled(43);
|
||||
drawTexturedModalRect(75, 20, 176, 60, 43 - progress, 18);
|
||||
drawTexturedModalRect(75, 41, 176, 60, 43 - progress, 18);
|
||||
|
||||
super.drawWidgets();
|
||||
}
|
||||
|
||||
@@ -30,9 +30,7 @@ public class GuiStill extends GuiForestryTitled<ContainerStill, MachineStill> {
|
||||
super.drawGuiContainerBackgroundLayer(var1, mouseX, mouseY);
|
||||
MachineStill still = inventory;
|
||||
|
||||
if (still.isWorking()) {
|
||||
drawTexturedModalRect(guiLeft + 81, guiTop + 57, 176, 60, 14, 14);
|
||||
}
|
||||
drawTexturedModalRect(guiLeft + 81, guiTop + 57, 176, 60, 14, 14);
|
||||
|
||||
int massRemaining = still.getDistillationProgressScaled(16);
|
||||
if (massRemaining > 0) {
|
||||
|
||||
@@ -18,8 +18,8 @@ import org.lwjgl.opengl.GL11;
|
||||
|
||||
import forestry.core.config.Defaults;
|
||||
import forestry.core.gui.GuiForestryTitled;
|
||||
import forestry.core.gui.WidgetManager;
|
||||
import forestry.core.gui.widgets.Widget;
|
||||
import forestry.core.gui.widgets.WidgetManager;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.render.SpriteSheet;
|
||||
import forestry.core.render.TextureManager;
|
||||
|
||||
@@ -12,8 +12,8 @@ package forestry.farming.gui;
|
||||
|
||||
import net.minecraft.init.Items;
|
||||
|
||||
import forestry.core.gui.Ledger;
|
||||
import forestry.core.gui.LedgerManager;
|
||||
import forestry.core.gui.ledgers.Ledger;
|
||||
import forestry.core.gui.ledgers.LedgerManager;
|
||||
import forestry.core.utils.StringUtil;
|
||||
|
||||
public class FarmLedger extends Ledger {
|
||||
|
||||
@@ -18,14 +18,14 @@ import org.lwjgl.opengl.GL11;
|
||||
import forestry.api.farming.FarmDirection;
|
||||
import forestry.api.farming.IFarmLogic;
|
||||
import forestry.core.config.Defaults;
|
||||
import forestry.core.gui.ClimateLedger;
|
||||
import forestry.core.gui.GuiForestry;
|
||||
import forestry.core.gui.OwnerLedger;
|
||||
import forestry.core.gui.WidgetManager;
|
||||
import forestry.core.gui.ledgers.ClimateLedger;
|
||||
import forestry.core.gui.ledgers.OwnerLedger;
|
||||
import forestry.core.gui.tooltips.ToolTip;
|
||||
import forestry.core.gui.widgets.SocketWidget;
|
||||
import forestry.core.gui.widgets.TankWidget;
|
||||
import forestry.core.gui.widgets.Widget;
|
||||
import forestry.core.gui.widgets.WidgetManager;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.StringUtil;
|
||||
import forestry.farming.multiblock.IFarmController;
|
||||
|
||||
@@ -12,15 +12,14 @@ package forestry.farming.multiblock;
|
||||
|
||||
import forestry.api.core.IErrorLogicSource;
|
||||
import forestry.api.farming.IFarmHousing;
|
||||
import forestry.core.circuits.ISocketable;
|
||||
import forestry.core.fluids.ITankManager;
|
||||
import forestry.core.interfaces.IClimatised;
|
||||
import forestry.core.interfaces.IRestrictedAccessTile;
|
||||
import forestry.core.interfaces.ISocketable;
|
||||
import forestry.core.inventory.IInventoryAdapter;
|
||||
import forestry.core.network.IStreamableGui;
|
||||
import forestry.farming.gui.IFarmLedgerDelegate;
|
||||
|
||||
public interface IFarmController extends IFarmHousing, ISocketable, IClimatised, IRestrictedAccessTile, IErrorLogicSource, IStreamableGui {
|
||||
public interface IFarmController extends IFarmHousing, ISocketable, IClimatised, IRestrictedAccessTile, IErrorLogicSource {
|
||||
IFarmLedgerDelegate getFarmLedgerDelegate();
|
||||
|
||||
IInventoryAdapter getInternalInventory();
|
||||
|
||||
@@ -22,9 +22,9 @@ import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.core.IErrorLogic;
|
||||
import forestry.api.core.IErrorLogicSource;
|
||||
import forestry.api.farming.IFarmComponent;
|
||||
import forestry.core.circuits.ISocketable;
|
||||
import forestry.core.config.Config;
|
||||
import forestry.core.interfaces.IHintSource;
|
||||
import forestry.core.interfaces.ISocketable;
|
||||
import forestry.core.inventory.IInventoryAdapter;
|
||||
import forestry.core.multiblock.MultiblockControllerBase;
|
||||
import forestry.core.multiblock.MultiblockValidationException;
|
||||
|
||||
@@ -23,6 +23,7 @@ import forestry.energy.EnergyManager;
|
||||
public class TileGearbox extends TileFarm implements IPowerHandler, IFarmComponent.Active {
|
||||
|
||||
private static final int WORK_CYCLES = 4;
|
||||
private static final int ENERGY_PER_OPERATION = WORK_CYCLES * 50;
|
||||
|
||||
private final EnergyManager energyManager;
|
||||
|
||||
@@ -31,7 +32,7 @@ public class TileGearbox extends TileFarm implements IPowerHandler, IFarmCompone
|
||||
private int workCounter;
|
||||
|
||||
public TileGearbox() {
|
||||
energyManager = new EnergyManager(200, 50, 10000);
|
||||
energyManager = new EnergyManager(200, 10000);
|
||||
}
|
||||
|
||||
/* SAVING & LOADING */
|
||||
@@ -71,7 +72,7 @@ public class TileGearbox extends TileFarm implements IPowerHandler, IFarmCompone
|
||||
}
|
||||
|
||||
// Hard limit to 4 cycles / second.
|
||||
if (workCounter < WORK_CYCLES && energyManager.consumeEnergyToDoWork()) {
|
||||
if (workCounter < WORK_CYCLES && energyManager.consumeEnergyToDoWork(WORK_CYCLES, ENERGY_PER_OPERATION)) {
|
||||
workCounter++;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,8 +21,12 @@ import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import cpw.mods.fml.common.network.IGuiHandler;
|
||||
|
||||
import forestry.api.circuits.ChipsetManager;
|
||||
import forestry.api.circuits.ICircuitLayout;
|
||||
import forestry.api.recipes.RecipeManagers;
|
||||
import forestry.core.GameMode;
|
||||
import forestry.core.circuits.Circuit;
|
||||
import forestry.core.circuits.CircuitLayout;
|
||||
import forestry.core.config.Defaults;
|
||||
import forestry.core.config.ForestryBlock;
|
||||
import forestry.core.config.ForestryItem;
|
||||
@@ -37,6 +41,7 @@ import forestry.core.utils.RecipeUtil;
|
||||
import forestry.core.utils.ShapedRecipeCustom;
|
||||
import forestry.factory.DummyManagers;
|
||||
import forestry.factory.GuiHandlerFactory;
|
||||
import forestry.factory.circuits.CircuitSpeedUpgrade;
|
||||
import forestry.factory.gadgets.MachineBottler;
|
||||
import forestry.factory.gadgets.MachineCarpenter;
|
||||
import forestry.factory.gadgets.MachineCentrifuge;
|
||||
@@ -226,6 +231,10 @@ public class PluginFactory extends ForestryPlugin {
|
||||
'W', Blocks.crafting_table,
|
||||
'C', Blocks.chest))
|
||||
.setFaces(0, 1, 2, 3, 4, 4));
|
||||
|
||||
ICircuitLayout layoutMachineUpgrade = new CircuitLayout("machine.upgrade");
|
||||
ChipsetManager.circuitRegistry.registerLayout(layoutMachineUpgrade);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -249,6 +258,9 @@ public class PluginFactory extends ForestryPlugin {
|
||||
definitionRainmaker.register();
|
||||
definitionWorktable.register();
|
||||
|
||||
Circuit.machineSpeedUpgrade1 = new CircuitSpeedUpgrade("machine.speed.boost.1", 0.125f, 0.05f, 4);
|
||||
Circuit.machineSpeedUpgrade2 = new CircuitSpeedUpgrade("machine.speed.boost.2", 0.250f, 0.10f, 4);
|
||||
Circuit.machineEfficiencyUpgrade1 = new CircuitSpeedUpgrade("machine.efficiency.1", 0, -0.10f, 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -462,6 +474,12 @@ public class PluginFactory extends ForestryPlugin {
|
||||
if (PluginManager.Module.STORAGE.isEnabled()) {
|
||||
PluginStorage.createCrateRecipes();
|
||||
}
|
||||
ICircuitLayout layout = ChipsetManager.circuitRegistry.getLayout("forestry.machine.upgrade");
|
||||
|
||||
// / Solder Manager
|
||||
ChipsetManager.solderManager.addRecipe(layout, ForestryItem.tubes.getItemStack(1, 9), Circuit.machineSpeedUpgrade1);
|
||||
ChipsetManager.solderManager.addRecipe(layout, ForestryItem.tubes.getItemStack(1, 7), Circuit.machineSpeedUpgrade2);
|
||||
ChipsetManager.solderManager.addRecipe(layout, ForestryItem.tubes.getItemStack(1, 4), Circuit.machineEfficiencyUpgrade1);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user