mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-21 12:32:23 +00:00
#666 Refactor error states, display multiple error states
This commit is contained in:
1 parent
5d9175a00d
commit
ff00017586
64 files changed
+1152
-1041
No files matched your search
@@ -60,26 +60,11 @@ public abstract class TileAlveary extends TileForestry implements IAlvearyCompon
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
super.updateEntity();
|
||||
|
||||
if (!Proxies.common.isSimulating(worldObj)) {
|
||||
updateClientSide();
|
||||
} else {
|
||||
// Periodic validation if needed
|
||||
if (updateOnInterval(200) && (!isIntegratedIntoStructure() || isMaster())) {
|
||||
validateStructure();
|
||||
}
|
||||
|
||||
updateServerSide();
|
||||
}
|
||||
}
|
||||
|
||||
protected void updateServerSide() {
|
||||
}
|
||||
|
||||
protected void updateClientSide() {
|
||||
// Periodic validation if needed
|
||||
if (updateOnInterval(200) && (!isIntegratedIntoStructure() || isMaster())) {
|
||||
validateStructure();
|
||||
}
|
||||
}
|
||||
|
||||
/* TEXTURES */
|
||||
|
||||
@@ -75,7 +75,7 @@ public abstract class TileAlvearyClimatiser extends TileAlveary implements IEner
|
||||
}
|
||||
|
||||
if ((wasInactive && workingTime > 0) || (!wasInactive && workingTime == 0)) {
|
||||
sendNetworkUpdate();
|
||||
setNeedsNetworkUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -69,16 +69,7 @@ public class TileAlvearyHygroregulator extends TileAlveary implements IInventory
|
||||
public TileAlvearyHygroregulator() {
|
||||
super(BLOCK_META);
|
||||
|
||||
setInternalInventory(new TileInventoryAdapter(this, 1, "CanInv") {
|
||||
@Override
|
||||
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
|
||||
if (slotIndex == SLOT_INPUT) {
|
||||
Fluid fluid = FluidHelper.getFluidInContainer(itemStack);
|
||||
return liquidTank.accepts(fluid);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
setInternalInventory(new HygroInventoryAdapter(this));
|
||||
|
||||
Fluid water = Fluids.WATER.getFluid();
|
||||
Fluid lava = Fluids.LAVA.getFluid();
|
||||
@@ -231,4 +222,19 @@ public class TileAlvearyHygroregulator extends TileAlveary implements IInventory
|
||||
@Override
|
||||
public void sendGUINetworkData(Container container, ICrafting iCrafting) {
|
||||
}
|
||||
|
||||
private static class HygroInventoryAdapter extends TileInventoryAdapter<TileAlvearyHygroregulator> {
|
||||
public HygroInventoryAdapter(TileAlvearyHygroregulator alvearyHygroregulator) {
|
||||
super(alvearyHygroregulator, 1, "CanInv");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
|
||||
if (slotIndex == SLOT_INPUT) {
|
||||
Fluid fluid = FluidHelper.getFluidInContainer(itemStack);
|
||||
return tile.liquidTank.accepts(fluid);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -91,7 +91,6 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB
|
||||
|
||||
private void setBiomeInformation() {
|
||||
this.biome = Utils.getBiomeAt(worldObj, xCoord, zCoord);
|
||||
setErrorState(EnumErrorCode.OK);
|
||||
}
|
||||
|
||||
/* LOADING & SAVING */
|
||||
@@ -105,7 +104,6 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB
|
||||
if (beekeepingLogic != null) {
|
||||
beekeepingLogic.readFromNBT(nbttagcompound);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -118,7 +116,6 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB
|
||||
if (beekeepingLogic != null) {
|
||||
beekeepingLogic.writeToNBT(nbttagcompound);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* UPDATING */
|
||||
@@ -130,6 +127,7 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB
|
||||
|
||||
@Override
|
||||
protected void updateServerSide() {
|
||||
super.updateServerSide();
|
||||
|
||||
if (beekeepingLogic == null) {
|
||||
return;
|
||||
@@ -157,23 +155,22 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB
|
||||
}
|
||||
}
|
||||
|
||||
if (getErrorState() == EnumErrorCode.OK) {
|
||||
if (!hasErrorState()) {
|
||||
queen.doFX(beekeepingLogic.getEffectData(), this);
|
||||
|
||||
if (updateOnInterval(50)) {
|
||||
float f = xCoord + 0.5F;
|
||||
float f1 = yCoord + 0.0F + (worldObj.rand.nextFloat() * 6F) / 16F;
|
||||
float f2 = zCoord + 0.5F;
|
||||
float f3 = 0.52F;
|
||||
float f4 = worldObj.rand.nextFloat() * 0.6F - 0.3F;
|
||||
|
||||
Proxies.common.addEntitySwarmFX(worldObj, (f - f3), f1, (f2 + f4), 0F, 0F, 0F);
|
||||
Proxies.common.addEntitySwarmFX(worldObj, (f + f3), f1, (f2 + f4), 0F, 0F, 0F);
|
||||
Proxies.common.addEntitySwarmFX(worldObj, (f + f4), f1, (f2 - f3), 0F, 0F, 0F);
|
||||
Proxies.common.addEntitySwarmFX(worldObj, (f + f4), f1, (f2 + f3), 0F, 0F, 0F);
|
||||
}
|
||||
}
|
||||
|
||||
if (getErrorState() == EnumErrorCode.OK && updateOnInterval(50)) {
|
||||
float f = xCoord + 0.5F;
|
||||
float f1 = yCoord + 0.0F + (worldObj.rand.nextFloat() * 6F) / 16F;
|
||||
float f2 = zCoord + 0.5F;
|
||||
float f3 = 0.52F;
|
||||
float f4 = worldObj.rand.nextFloat() * 0.6F - 0.3F;
|
||||
|
||||
Proxies.common.addEntitySwarmFX(worldObj, (f - f3), f1, (f2 + f4), 0F, 0F, 0F);
|
||||
Proxies.common.addEntitySwarmFX(worldObj, (f + f3), f1, (f2 + f4), 0F, 0F, 0F);
|
||||
Proxies.common.addEntitySwarmFX(worldObj, (f + f4), f1, (f2 - f3), 0F, 0F, 0F);
|
||||
Proxies.common.addEntitySwarmFX(worldObj, (f + f4), f1, (f2 + f3), 0F, 0F, 0F);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -183,15 +180,19 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB
|
||||
return;
|
||||
}
|
||||
|
||||
ISidedInventory inventory = getStructureInventory();
|
||||
if (inventory == null) {
|
||||
if (hasErrorState()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// / Multiplayer FX
|
||||
ItemStack queenStack = inventory.getStackInSlot(SLOT_QUEEN);
|
||||
if (BeeManager.beeRoot.isMated(queenStack)) {
|
||||
if (getErrorState() == EnumErrorCode.OK && updateOnInterval(2)) {
|
||||
if (updateOnInterval(2)) {
|
||||
ISidedInventory inventory = getStructureInventory();
|
||||
if (inventory == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// / Multiplayer FX
|
||||
ItemStack queenStack = inventory.getStackInSlot(SLOT_QUEEN);
|
||||
if (BeeManager.beeRoot.isMated(queenStack)) {
|
||||
IBee displayQueen = BeeManager.beeRoot.getMember(queenStack);
|
||||
displayQueen.doFX(beekeepingLogic.getEffectData(), this);
|
||||
}
|
||||
@@ -262,22 +263,7 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB
|
||||
/* STRUCTURE MANAGMENT */
|
||||
@Override
|
||||
protected void createInventory() {
|
||||
setInternalInventory(new TileInventoryAdapter(this, 9, "Items") {
|
||||
@Override
|
||||
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
|
||||
if (slotIndex == SLOT_QUEEN) {
|
||||
return BeeManager.beeRoot.isMember(itemStack) && !BeeManager.beeRoot.isDrone(itemStack);
|
||||
} else if (slotIndex == SLOT_DRONE) {
|
||||
return BeeManager.beeRoot.isDrone(itemStack);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int slotIndex, ItemStack itemstack, int side) {
|
||||
return slotIndex != SLOT_QUEEN && slotIndex != SLOT_DRONE;
|
||||
}
|
||||
});
|
||||
setInternalInventory(new AlvearyInventoryAdapter(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -460,6 +446,15 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB
|
||||
return InvTools.tryAddStack(inventory, product, SLOT_PRODUCT_1, inventory.getSizeInventory() - SLOT_PRODUCT_1, all);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public void setErrorState(IErrorState state) {
|
||||
removeErrorStates();
|
||||
if (state != EnumErrorCode.OK) {
|
||||
addErrorState(state);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void wearOutEquipment(int amount) {
|
||||
for (IBeeListener eventHandler : eventHandlers) {
|
||||
@@ -609,16 +604,26 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB
|
||||
}
|
||||
|
||||
/* IERRORSOURCE */
|
||||
@Deprecated
|
||||
@Override
|
||||
public IErrorState getErrorState() {
|
||||
Set<IErrorState> errorStates = null;
|
||||
if (hasMaster()) {
|
||||
ITileStructure tile = this.getCentralTE();
|
||||
ITileStructure tile = getCentralTE();
|
||||
if (tile != null) {
|
||||
return ((IErrorSource) tile).getErrorState();
|
||||
errorStates = ((IErrorSource) tile).getErrorStates();
|
||||
}
|
||||
}
|
||||
|
||||
return errorState;
|
||||
if (errorStates == null) {
|
||||
errorStates = this.getErrorStates();
|
||||
}
|
||||
|
||||
if (errorStates.size() == 0) {
|
||||
return EnumErrorCode.OK;
|
||||
} else {
|
||||
return getErrorStates().iterator().next();
|
||||
}
|
||||
}
|
||||
|
||||
/* ICLIMATISED */
|
||||
@@ -659,4 +664,25 @@ public class TileAlvearyPlain extends TileAlveary implements ISidedInventory, IB
|
||||
public GameProfile getOwnerName() {
|
||||
return this.getOwnerProfile();
|
||||
}
|
||||
|
||||
private static class AlvearyInventoryAdapter extends TileInventoryAdapter<TileAlvearyPlain> {
|
||||
public AlvearyInventoryAdapter(TileAlvearyPlain tileAlvearyPlain) {
|
||||
super(tileAlvearyPlain, 9, "Items");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
|
||||
if (slotIndex == SLOT_QUEEN) {
|
||||
return BeeManager.beeRoot.isMember(itemStack) && !BeeManager.beeRoot.isDrone(itemStack);
|
||||
} else if (slotIndex == SLOT_DRONE) {
|
||||
return BeeManager.beeRoot.isDrone(itemStack);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int slotIndex, ItemStack itemstack, int side) {
|
||||
return slotIndex != SLOT_QUEEN && slotIndex != SLOT_DRONE;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -39,12 +39,7 @@ public class TileAlvearySieve extends TileAlveary implements ICrafter, IBeeListe
|
||||
|
||||
public TileAlvearySieve() {
|
||||
super(BLOCK_META);
|
||||
setInternalInventory(new TileInventoryAdapter(this, 5, "Items", 1) {
|
||||
@Override
|
||||
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
|
||||
return StackUtils.isIdenticalItem(ForestryItem.craftingMaterial.getItemStack(1, 3), itemStack);
|
||||
}
|
||||
});
|
||||
setInternalInventory(new AlvearySieveInventoryAdapter(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -187,4 +182,15 @@ public class TileAlvearySieve extends TileAlveary implements ICrafter, IBeeListe
|
||||
public boolean onEggLaid(IBee queen) {
|
||||
return false;
|
||||
}
|
||||
|
||||
private static class AlvearySieveInventoryAdapter extends TileInventoryAdapter<TileAlvearySieve> {
|
||||
public AlvearySieveInventoryAdapter(TileAlvearySieve alvearySieve) {
|
||||
super(alvearySieve, 5, "Items", 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
|
||||
return StackUtils.isIdenticalItem(ForestryItem.craftingMaterial.getItemStack(1, 3), itemStack);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -45,12 +45,7 @@ public class TileAlvearySwarmer extends TileAlveary implements ISidedInventory {
|
||||
|
||||
public TileAlvearySwarmer() {
|
||||
super(BLOCK_META);
|
||||
setInternalInventory(new TileInventoryAdapter(this, 4, "SwarmInv") {
|
||||
@Override
|
||||
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
|
||||
return StackUtils.containsItemStack(BeeManager.inducers.keySet(), itemStack);
|
||||
}
|
||||
});
|
||||
setInternalInventory(new SwarmerInventoryAdapter(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -151,7 +146,7 @@ public class TileAlvearySwarmer extends TileAlveary implements ISidedInventory {
|
||||
private void setIsActive(boolean isActive) {
|
||||
if (this.isActive != isActive) {
|
||||
this.isActive = isActive;
|
||||
sendNetworkUpdate();
|
||||
setNeedsNetworkUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -221,4 +216,15 @@ public class TileAlvearySwarmer extends TileAlveary implements ISidedInventory {
|
||||
nbttagcompound.setTag("PendingSpawns", nbttaglist);
|
||||
|
||||
}
|
||||
|
||||
private static class SwarmerInventoryAdapter extends TileInventoryAdapter<TileAlvearySwarmer> {
|
||||
public SwarmerInventoryAdapter(TileAlvearySwarmer alvearySwarmer) {
|
||||
super(alvearySwarmer, 4, "SwarmInv");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
|
||||
return StackUtils.containsItemStack(BeeManager.inducers.keySet(), itemStack);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,8 @@
|
||||
******************************************************************************/
|
||||
package forestry.apiculture.gadgets;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.ICrafting;
|
||||
@@ -29,6 +31,7 @@ import forestry.api.apiculture.IHiveFrame;
|
||||
import forestry.api.core.EnumHumidity;
|
||||
import forestry.api.core.EnumTemperature;
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.core.IErrorState;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.core.EnumErrorCode;
|
||||
import forestry.core.config.Config;
|
||||
@@ -48,30 +51,6 @@ import forestry.core.utils.GuiUtil;
|
||||
import forestry.core.utils.Utils;
|
||||
|
||||
public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised {
|
||||
|
||||
protected static class BeehouseInventoryAdapter extends TileInventoryAdapter {
|
||||
public BeehouseInventoryAdapter(TileForestry tile, int size, String name) {
|
||||
super(tile, size, name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
|
||||
if (slotIndex == SLOT_QUEEN) {
|
||||
return BeeManager.beeRoot.isMember(itemStack) && !BeeManager.beeRoot.isDrone(itemStack);
|
||||
} else if (GuiUtil.isIndexInRange(slotIndex, SLOT_FRAMES_1, SLOT_FRAMES_COUNT)) {
|
||||
return itemStack.getItem() instanceof IHiveFrame;
|
||||
} else if (slotIndex == SLOT_DRONE) {
|
||||
return BeeManager.beeRoot.isDrone(itemStack);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int slotIndex, ItemStack itemstack, int side) {
|
||||
return GuiUtil.isIndexInRange(slotIndex, SLOT_PRODUCT_1, SLOT_PRODUCT_COUNT);
|
||||
}
|
||||
}
|
||||
|
||||
// CONSTANTS
|
||||
public static final int SLOT_QUEEN = 0;
|
||||
public static final int SLOT_DRONE = 1;
|
||||
@@ -143,6 +122,26 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised {
|
||||
return EnumHumidity.getFromValue(getExactHumidity());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public void setErrorState(IErrorState state) {
|
||||
removeErrorStates();
|
||||
if (state != EnumErrorCode.OK) {
|
||||
addErrorState(state);
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public IErrorState getErrorState() {
|
||||
Set<IErrorState> errorStates = getErrorStates();
|
||||
if (errorStates.size() == 0) {
|
||||
return EnumErrorCode.OK;
|
||||
} else {
|
||||
return getErrorStates().iterator().next();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getExactTemperature() {
|
||||
return biome.temperature;
|
||||
@@ -159,7 +158,7 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised {
|
||||
|
||||
// / Multiplayer FX
|
||||
if (BeeManager.beeRoot.isMated(getInternalInventory().getStackInSlot(SLOT_QUEEN))) {
|
||||
if (getErrorState() == EnumErrorCode.OK && updateOnInterval(2)) {
|
||||
if (!hasErrorState() && updateOnInterval(2)) {
|
||||
IBee displayQueen = BeeManager.beeRoot.getMember(getInternalInventory().getStackInSlot(SLOT_QUEEN));
|
||||
displayQueen.doFX(logic.getEffectData(), this);
|
||||
}
|
||||
@@ -185,7 +184,7 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised {
|
||||
|
||||
// @Override
|
||||
public boolean isWorking() {
|
||||
return getErrorState() == EnumErrorCode.OK;
|
||||
return !hasErrorState();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -252,7 +251,6 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised {
|
||||
BiomeGenBase biome = Utils.getBiomeAt(worldObj, xCoord, zCoord);
|
||||
if (biome != null) {
|
||||
this.biome = biome;
|
||||
setErrorState(EnumErrorCode.OK);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -412,4 +410,27 @@ public class TileBeehouse extends TileBase implements IBeeHousing, IClimatised {
|
||||
public GameProfile getOwnerName() {
|
||||
return this.getOwnerProfile();
|
||||
}
|
||||
|
||||
protected static class BeehouseInventoryAdapter extends TileInventoryAdapter<TileBeehouse> {
|
||||
public BeehouseInventoryAdapter(TileBeehouse tile, int size, String name) {
|
||||
super(tile, size, name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
|
||||
if (slotIndex == SLOT_QUEEN) {
|
||||
return BeeManager.beeRoot.isMember(itemStack) && !BeeManager.beeRoot.isDrone(itemStack);
|
||||
} else if (GuiUtil.isIndexInRange(slotIndex, SLOT_FRAMES_1, SLOT_FRAMES_COUNT)) {
|
||||
return itemStack.getItem() instanceof IHiveFrame;
|
||||
} else if (slotIndex == SLOT_DRONE) {
|
||||
return BeeManager.beeRoot.isDrone(itemStack);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int slotIndex, ItemStack itemstack, int side) {
|
||||
return GuiUtil.isIndexInRange(slotIndex, SLOT_PRODUCT_1, SLOT_PRODUCT_COUNT);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,8 @@
|
||||
******************************************************************************/
|
||||
package forestry.apiculture.genetics;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -37,6 +39,7 @@ import forestry.api.apiculture.IBeekeepingMode;
|
||||
import forestry.api.core.BiomeHelper;
|
||||
import forestry.api.core.EnumHumidity;
|
||||
import forestry.api.core.EnumTemperature;
|
||||
import forestry.api.core.IErrorState;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.genetics.IAllele;
|
||||
import forestry.api.genetics.IAlleleTolerance;
|
||||
@@ -239,48 +242,56 @@ public class Bee extends IndividualLiving implements IBee {
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumErrorCode canWork(IBeeHousing housing) {
|
||||
|
||||
public Set<IErrorState> getCanWork(IBeeHousing housing) {
|
||||
World world = housing.getWorld();
|
||||
BiomeGenBase biome = housing.getBiome();
|
||||
|
||||
ImmutableSet.Builder<IErrorState> errorStates = ImmutableSet.builder();
|
||||
|
||||
// / Rain needs tolerant flyers
|
||||
if (world.isRaining() && !genome.getTolerantFlyer() && BiomeHelper.canRainOrSnow(biome) && !housing.isSealed()) {
|
||||
return EnumErrorCode.ISRAINING;
|
||||
errorStates.add(EnumErrorCode.ISRAINING);
|
||||
}
|
||||
|
||||
// / Night or darkness requires nocturnal species
|
||||
if (world.isDaytime()) {
|
||||
if (!canWorkDuringDay()) {
|
||||
return EnumErrorCode.NOTNIGHT;
|
||||
errorStates.add(EnumErrorCode.NOTNIGHT);
|
||||
}
|
||||
} else if (!canWorkAtNight() && !housing.isSelfLighted()) {
|
||||
return EnumErrorCode.NOTDAY;
|
||||
errorStates.add(EnumErrorCode.NOTDAY);
|
||||
}
|
||||
|
||||
if (world.getBlockLightValue(housing.getXCoord(), housing.getYCoord() + 2, housing.getZCoord()) > Defaults.APIARY_MIN_LEVEL_LIGHT) {
|
||||
if (!canWorkDuringDay()) {
|
||||
return EnumErrorCode.NOTGLOOMY;
|
||||
errorStates.add(EnumErrorCode.NOTGLOOMY);
|
||||
}
|
||||
} else if (!canWorkAtNight() && !housing.isSelfLighted()) {
|
||||
return EnumErrorCode.NOTLUCID;
|
||||
errorStates.add(EnumErrorCode.NOTLUCID);
|
||||
}
|
||||
|
||||
// / No sky, except if in hell
|
||||
if (biome == null) {
|
||||
return EnumErrorCode.NOSKY;
|
||||
}
|
||||
if (!BiomeHelper.isBiomeHellish(biome) && !world.canBlockSeeTheSky(housing.getXCoord(), housing.getYCoord() + 3, housing.getZCoord())
|
||||
&& !genome.getCaveDwelling() && !housing.isSunlightSimulated()) {
|
||||
return EnumErrorCode.NOSKY;
|
||||
if (biome != null && !BiomeHelper.isBiomeHellish(biome) && !world.canBlockSeeTheSky(housing.getXCoord(), housing.getYCoord() + 3, housing.getZCoord())
|
||||
&& !genome.getCaveDwelling() && !housing.isSunlightSimulated()) {
|
||||
errorStates.add(EnumErrorCode.NOSKY);
|
||||
}
|
||||
|
||||
// / And finally climate check
|
||||
if (!isSuitableClimate(housing.getTemperature(), housing.getHumidity())) {
|
||||
return EnumErrorCode.INVALIDBIOME;
|
||||
errorStates.add(EnumErrorCode.INVALIDBIOME);
|
||||
}
|
||||
|
||||
return EnumErrorCode.OK;
|
||||
return errorStates.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IErrorState canWork(IBeeHousing housing) {
|
||||
Set<IErrorState> errorStates = getCanWork(housing);
|
||||
if (errorStates.size() == 0) {
|
||||
return EnumErrorCode.OK;
|
||||
} else {
|
||||
return errorStates.iterator().next();
|
||||
}
|
||||
}
|
||||
|
||||
private boolean canWorkAtNight() {
|
||||
|
||||
@@ -19,9 +19,7 @@ import forestry.api.apiculture.BeeManager;
|
||||
import forestry.api.apiculture.IBee;
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.core.Tabs;
|
||||
import forestry.core.EnumErrorCode;
|
||||
import forestry.core.config.Config;
|
||||
import forestry.core.interfaces.IErrorSource;
|
||||
import forestry.core.interfaces.IHintSource;
|
||||
import forestry.core.inventory.AlyzerInventory;
|
||||
import forestry.core.items.ItemInventoried;
|
||||
@@ -30,7 +28,7 @@ import forestry.core.proxy.Proxies;
|
||||
|
||||
public class ItemBeealyzer extends ItemInventoried {
|
||||
|
||||
public static class BeealyzerInventory extends AlyzerInventory implements IErrorSource, IHintSource {
|
||||
public static class BeealyzerInventory extends AlyzerInventory implements IHintSource {
|
||||
|
||||
public BeealyzerInventory(EntityPlayer player, ItemStack itemStack) {
|
||||
super(ItemBeealyzer.class, 7, itemStack);
|
||||
@@ -95,21 +93,6 @@ public class ItemBeealyzer extends ItemInventoried {
|
||||
public String[] getHints() {
|
||||
return Config.hints.get("beealyzer");
|
||||
}
|
||||
|
||||
// / IERRORSOURCE
|
||||
@Override
|
||||
public boolean throwsErrors() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumErrorCode getErrorState() {
|
||||
if (BeeManager.beeRoot.isMember(inventoryStacks[SLOT_SPECIMEN]) && !isEnergy(getStackInSlot(SLOT_ENERGY))) {
|
||||
return EnumErrorCode.NOHONEY;
|
||||
}
|
||||
|
||||
return EnumErrorCode.OK;
|
||||
}
|
||||
}
|
||||
|
||||
public ItemBeealyzer() {
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
******************************************************************************/
|
||||
package forestry.apiculture.items;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
@@ -37,6 +39,7 @@ import forestry.api.apiculture.IBee;
|
||||
import forestry.api.core.EnumHumidity;
|
||||
import forestry.api.core.EnumTemperature;
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.core.IErrorState;
|
||||
import forestry.api.core.Tabs;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.apiculture.render.TextureHabitatLocator;
|
||||
@@ -120,17 +123,22 @@ public class ItemHabitatLocator extends ItemInventoried {
|
||||
|
||||
// / IERRORSOURCE
|
||||
@Override
|
||||
public boolean throwsErrors() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumErrorCode getErrorState() {
|
||||
if (BeeManager.beeRoot.isMember(inventoryStacks[SLOT_SPECIMEN]) && !isEnergy(getStackInSlot(SLOT_ENERGY))) {
|
||||
return EnumErrorCode.NOHONEY;
|
||||
public ImmutableSet<IErrorState> getErrorStates() {
|
||||
if (getStackInSlot(SLOT_ANALYZED) != null) {
|
||||
return ImmutableSet.of();
|
||||
}
|
||||
|
||||
return EnumErrorCode.OK;
|
||||
ImmutableSet.Builder<IErrorState> errorStates = ImmutableSet.builder();
|
||||
|
||||
if (!BeeManager.beeRoot.isMember(inventoryStacks[SLOT_SPECIMEN])) {
|
||||
errorStates.add(EnumErrorCode.NOTHINGANALYZE);
|
||||
}
|
||||
|
||||
if (!isEnergy(getStackInSlot(SLOT_ENERGY))) {
|
||||
errorStates.add(EnumErrorCode.NOHONEY);
|
||||
}
|
||||
|
||||
return errorStates.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -37,8 +37,7 @@ public class TriggerMissingDrone extends Trigger {
|
||||
return false;
|
||||
}
|
||||
|
||||
return ((IErrorSource) tile).getErrorState() == EnumErrorCode.NODRONE;
|
||||
|
||||
return ((IErrorSource) tile).getErrorStates().contains(EnumErrorCode.NODRONE);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -37,6 +37,6 @@ public class TriggerMissingQueen extends Trigger {
|
||||
return false;
|
||||
}
|
||||
|
||||
return ((IErrorSource) tile).getErrorState() == EnumErrorCode.NOQUEEN;
|
||||
return ((IErrorSource) tile).getErrorStates().contains(EnumErrorCode.NOQUEEN);
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,8 @@
|
||||
******************************************************************************/
|
||||
package forestry.arboriculture.gadgets;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
@@ -505,6 +507,16 @@ public class TileLeaves extends TileTreeContainer implements IPollinatable, IFru
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setErrorCondition(boolean condition, IErrorState errorState) {
|
||||
return condition;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ImmutableSet<IErrorState> getErrorStates() {
|
||||
return ImmutableSet.of();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setErrorState(IErrorState state) {
|
||||
}
|
||||
|
||||
@@ -18,9 +18,7 @@ import net.minecraft.world.World;
|
||||
import forestry.api.arboriculture.ITree;
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.core.Tabs;
|
||||
import forestry.core.EnumErrorCode;
|
||||
import forestry.core.config.Config;
|
||||
import forestry.core.interfaces.IErrorSource;
|
||||
import forestry.core.interfaces.IHintSource;
|
||||
import forestry.core.inventory.AlyzerInventory;
|
||||
import forestry.core.items.ItemInventoried;
|
||||
@@ -31,7 +29,7 @@ import forestry.plugins.PluginArboriculture;
|
||||
|
||||
public class ItemTreealyzer extends ItemInventoried {
|
||||
|
||||
public static class TreealyzerInventory extends AlyzerInventory implements IErrorSource, IHintSource {
|
||||
public static class TreealyzerInventory extends AlyzerInventory implements IHintSource {
|
||||
|
||||
public TreealyzerInventory(EntityPlayer player, ItemStack itemStack) {
|
||||
super(ItemTreealyzer.class, 7, itemStack);
|
||||
@@ -108,21 +106,6 @@ public class ItemTreealyzer extends ItemInventoried {
|
||||
public String[] getHints() {
|
||||
return Config.hints.get("treealyzer");
|
||||
}
|
||||
|
||||
// / IERRORSOURCE
|
||||
@Override
|
||||
public boolean throwsErrors() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumErrorCode getErrorState() {
|
||||
if (PluginArboriculture.treeInterface.isMember(inventoryStacks[SLOT_SPECIMEN]) && !isEnergy(getStackInSlot(SLOT_ENERGY))) {
|
||||
return EnumErrorCode.NOHONEY;
|
||||
}
|
||||
|
||||
return EnumErrorCode.OK;
|
||||
}
|
||||
}
|
||||
|
||||
public ItemTreealyzer() {
|
||||
|
||||
@@ -18,6 +18,7 @@ import forestry.core.config.Defaults;
|
||||
public enum EnumErrorCode implements IErrorState {
|
||||
|
||||
UNKNOWN("unknown"),
|
||||
@Deprecated // use no error code
|
||||
OK("ok"),
|
||||
INVALIDBIOME("invalidBiome"),
|
||||
ISRAINING("isRaining"),
|
||||
@@ -48,16 +49,21 @@ public enum EnumErrorCode implements IErrorState {
|
||||
NOSTAMPS("noStamps"),
|
||||
NOCIRCUITBOARD("noCircuitBoard"),
|
||||
NOCIRCUITLAYOUT("noCircuitLayout"),
|
||||
@Deprecated // wrong stack size is prevented in code
|
||||
WRONGSTACKSIZE("wrongStacksize"),
|
||||
NOFERTILIZER("noFertilizer"),
|
||||
NOFARMLAND("noFarmland"),
|
||||
CIRCUITMISMATCH("circuitMismatch"),
|
||||
NOLIQUID("noLiquid"),
|
||||
NOPAPER("noPaper"),
|
||||
@Deprecated // use two error codes instead: NOSTAMPS and NOPAPER
|
||||
NOSTAMPSNOPAPER("noStampsNoPaper", "noStamps"),
|
||||
NOSUPPLIES("noSupplies", "noResource"),
|
||||
NOTRADE("noTrade", "noResource"),
|
||||
NOPOWER("noPower");
|
||||
NOPOWER("noPower"),
|
||||
NOREDSTONE("noRedstone", "disabled"), // needs redstone signal
|
||||
DISABLED("disabledRedstone", "disabled") // disabled by redstone signal
|
||||
;
|
||||
|
||||
private final String name;
|
||||
private final String iconName;
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
******************************************************************************/
|
||||
package forestry.core.circuits;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
@@ -100,12 +102,11 @@ public class ItemSolderingIron extends ItemForestry implements ISolderingIron {
|
||||
public static class SolderingInventory extends ItemInventory implements IErrorSource {
|
||||
|
||||
private final RevolvingList<ICircuitLayout> layouts = new RevolvingList<ICircuitLayout>(ChipsetManager.circuitRegistry.getRegisteredLayouts().values());
|
||||
private EnumErrorCode errorState;
|
||||
|
||||
private final short blankSlot = 0;
|
||||
private final short finishedSlot = 1;
|
||||
private final short ingredientSlot1 = 2;
|
||||
private final short ingredientSlotCount = 4;
|
||||
private static final short blankSlot = 0;
|
||||
private static final short finishedSlot = 1;
|
||||
private static final short ingredientSlot1 = 2;
|
||||
private static final short ingredientSlotCount = 4;
|
||||
|
||||
public SolderingInventory(ItemStack itemStack) {
|
||||
super(ItemSolderingIron.class, 6, itemStack);
|
||||
@@ -196,10 +197,7 @@ public class ItemSolderingIron extends ItemForestry implements ISolderingIron {
|
||||
EnumCircuitBoardType type = EnumCircuitBoardType.values()[blank.getItemDamage()];
|
||||
Collection<ICircuit> circuits = getCircuits(type, false);
|
||||
|
||||
if (circuits.size() <= 0) {
|
||||
return;
|
||||
} else if (circuits.size() != type.sockets) {
|
||||
errorState = EnumErrorCode.CIRCUITMISMATCH;
|
||||
if (circuits.size() != type.sockets) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -208,7 +206,7 @@ public class ItemSolderingIron extends ItemForestry implements ISolderingIron {
|
||||
inventoryStacks[blankSlot] = null;
|
||||
}
|
||||
|
||||
public int getCount(ICircuit circuit, ArrayList<ICircuit> circuits) {
|
||||
public static int getCount(ICircuit circuit, ArrayList<ICircuit> circuits) {
|
||||
int count = 0;
|
||||
for (ICircuit other : circuits) {
|
||||
if (other.getUID().equals(circuit.getUID())) {
|
||||
@@ -220,31 +218,42 @@ public class ItemSolderingIron extends ItemForestry implements ISolderingIron {
|
||||
|
||||
@Override
|
||||
public void markDirty() {
|
||||
errorState = EnumErrorCode.OK;
|
||||
trySolder();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean throwsErrors() {
|
||||
return true;
|
||||
}
|
||||
public ImmutableSet<IErrorState> getErrorStates() {
|
||||
ImmutableSet.Builder<IErrorState> errorStates = ImmutableSet.builder();
|
||||
|
||||
@Override
|
||||
public IErrorState getErrorState() {
|
||||
if (layouts.getCurrent() == CircuitRegistry.DUMMY_LAYOUT) {
|
||||
return EnumErrorCode.NOCIRCUITLAYOUT;
|
||||
}
|
||||
if (inventoryStacks[blankSlot] == null) {
|
||||
return EnumErrorCode.NOCIRCUITBOARD;
|
||||
}
|
||||
if (inventoryStacks[blankSlot].stackSize > 1) {
|
||||
return EnumErrorCode.WRONGSTACKSIZE;
|
||||
}
|
||||
if (errorState != EnumErrorCode.OK) {
|
||||
return errorState;
|
||||
errorStates.add(EnumErrorCode.NOCIRCUITLAYOUT);
|
||||
}
|
||||
|
||||
return EnumErrorCode.OK;
|
||||
ItemStack blankCircuitBoard = inventoryStacks[blankSlot];
|
||||
|
||||
if (blankCircuitBoard == null) {
|
||||
errorStates.add(EnumErrorCode.NOCIRCUITBOARD);
|
||||
} else {
|
||||
EnumCircuitBoardType type = EnumCircuitBoardType.values()[blankCircuitBoard.getItemDamage()];
|
||||
|
||||
int circuitCount = 0;
|
||||
for (short i = 0; i < type.sockets; i++) {
|
||||
if (inventoryStacks[ingredientSlot1 + i] != null) {
|
||||
circuitCount++;
|
||||
}
|
||||
}
|
||||
|
||||
if (circuitCount != type.sockets) {
|
||||
errorStates.add(EnumErrorCode.CIRCUITMISMATCH);
|
||||
} else {
|
||||
Collection<ICircuit> circuits = getCircuits(type, false);
|
||||
if (circuits.size() != type.sockets) {
|
||||
errorStates.add(EnumErrorCode.NOCIRCUITLAYOUT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return errorStates.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -20,6 +20,7 @@ import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import forestry.core.EnumErrorCode;
|
||||
import forestry.core.TemperatureState;
|
||||
import forestry.core.config.Defaults;
|
||||
import forestry.core.network.PacketPayload;
|
||||
@@ -131,13 +132,18 @@ public abstract class Engine extends TileBase implements IEnergyConnection {
|
||||
forceCooldown = false;
|
||||
}
|
||||
|
||||
setErrorCondition(forceCooldown, EnumErrorCode.FORCEDCOOLDOWN);
|
||||
|
||||
boolean enabledRedstone = isRedstoneActivated();
|
||||
setErrorCondition(!enabledRedstone, EnumErrorCode.NOREDSTONE);
|
||||
|
||||
// Determine targeted tile
|
||||
TileEntity tile = worldObj.getTileEntity(xCoord + getOrientation().offsetX, yCoord + getOrientation().offsetY, zCoord + getOrientation().offsetZ);
|
||||
|
||||
float newPistonSpeed = getPistonSpeed();
|
||||
if (newPistonSpeed != pistonSpeedServer) {
|
||||
pistonSpeedServer = newPistonSpeed;
|
||||
sendNetworkUpdate();
|
||||
setNeedsNetworkUpdate();
|
||||
}
|
||||
|
||||
if (stagePiston != 0) {
|
||||
@@ -153,9 +159,7 @@ public abstract class Engine extends TileBase implements IEnergyConnection {
|
||||
progress = 0;
|
||||
stagePiston = 0;
|
||||
}
|
||||
|
||||
} else if (canPowerTo(tile)) // If we are not already running, check if
|
||||
{
|
||||
} else if (enabledRedstone && BlockUtil.isEnergyReceiver(getOrientation().getOpposite(), tile)) {
|
||||
if (energyManager.getEnergyStored(getOrientation()) > 0) {
|
||||
stagePiston = 1; // If we can transfer energy, start running
|
||||
setActive(true);
|
||||
@@ -174,11 +178,6 @@ public abstract class Engine extends TileBase implements IEnergyConnection {
|
||||
} else {
|
||||
energyManager.drainEnergy(20);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private boolean canPowerTo(TileEntity tile) {
|
||||
return isActivated() && BlockUtil.isEnergyReceiver(getOrientation().getOpposite(), tile);
|
||||
}
|
||||
|
||||
private void setActive(boolean isActive) {
|
||||
@@ -187,7 +186,7 @@ public abstract class Engine extends TileBase implements IEnergyConnection {
|
||||
}
|
||||
|
||||
this.isActive = isActive;
|
||||
sendNetworkUpdate();
|
||||
setNeedsNetworkUpdate();
|
||||
}
|
||||
|
||||
/* INTERACTION */
|
||||
@@ -223,7 +222,7 @@ public abstract class Engine extends TileBase implements IEnergyConnection {
|
||||
}
|
||||
|
||||
public int getCurrentOutput() {
|
||||
if (isBurning() && isActivated()) {
|
||||
if (isBurning() && isRedstoneActivated()) {
|
||||
return currentOutput;
|
||||
} else {
|
||||
return 0;
|
||||
|
||||
@@ -78,7 +78,7 @@ public abstract class Mill extends TileBase {
|
||||
stage = 2;
|
||||
if (charge < 7 && isSimulating) {
|
||||
charge++;
|
||||
sendNetworkUpdate();
|
||||
setNeedsNetworkUpdate();
|
||||
}
|
||||
}
|
||||
if (progress > 1) {
|
||||
|
||||
@@ -10,6 +10,9 @@
|
||||
******************************************************************************/
|
||||
package forestry.core.gadgets;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.ICrafting;
|
||||
@@ -25,6 +28,7 @@ import net.minecraftforge.fluids.FluidTankInfo;
|
||||
|
||||
import forestry.api.apiculture.BeeManager;
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.core.IErrorState;
|
||||
import forestry.api.genetics.AlleleManager;
|
||||
import forestry.api.genetics.IAllele;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
@@ -34,6 +38,7 @@ import forestry.core.fluids.FluidHelper;
|
||||
import forestry.core.fluids.Fluids;
|
||||
import forestry.core.fluids.TankManager;
|
||||
import forestry.core.fluids.tanks.FilteredTank;
|
||||
import forestry.core.interfaces.IErrorSource;
|
||||
import forestry.core.interfaces.ILiquidTankContainer;
|
||||
import forestry.core.inventory.InvTools;
|
||||
import forestry.core.inventory.TileInventoryAdapter;
|
||||
@@ -71,24 +76,7 @@ public class TileAnalyzer extends TilePowered implements ISidedInventory, ILiqui
|
||||
/* CONSTRUCTOR */
|
||||
public TileAnalyzer() {
|
||||
super(800, 40, Defaults.MACHINE_MAX_ENERGY);
|
||||
setInternalInventory(new TileInventoryAdapter(this, 12, "Items") {
|
||||
@Override
|
||||
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
|
||||
if (GuiUtil.isIndexInRange(slotIndex, SLOT_INPUT_1, SLOT_INPUT_COUNT)) {
|
||||
return AlleleManager.alleleRegistry.isIndividual(itemStack) || GeneticsUtil.getGeneticEquivalent(itemStack) != null;
|
||||
} else if (slotIndex == SLOT_CAN) {
|
||||
Fluid fluid = FluidHelper.getFluidInContainer(itemStack);
|
||||
return resourceTank.accepts(fluid);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int slotIndex, ItemStack stack, int side) {
|
||||
return GuiUtil.isIndexInRange(slotIndex, SLOT_OUTPUT_1, SLOT_OUTPUT_COUNT);
|
||||
}
|
||||
});
|
||||
setInternalInventory(new AnalyzerInventoryAdapter(this));
|
||||
resourceTank = new FilteredTank(Defaults.PROCESSOR_TANK_CAPACITY, Fluids.HONEY.getFluid());
|
||||
tankManager = new TankManager(resourceTank);
|
||||
invInput = new InventoryMapper(getInternalInventory(), SLOT_INPUT_1, SLOT_INPUT_COUNT);
|
||||
@@ -122,6 +110,8 @@ public class TileAnalyzer extends TilePowered implements ISidedInventory, ILiqui
|
||||
|
||||
@Override
|
||||
protected void updateServerSide() {
|
||||
super.updateServerSide();
|
||||
|
||||
if (updateOnInterval(20)) {
|
||||
// Check if we have suitable items waiting in the can slot
|
||||
FluidHelper.drainContainers(tankManager, this, SLOT_CAN);
|
||||
@@ -135,8 +125,8 @@ public class TileAnalyzer extends TilePowered implements ISidedInventory, ILiqui
|
||||
|
||||
if (stackToAnalyze != null) {
|
||||
IIndividual individual = AlleleManager.alleleRegistry.getIndividual(stackToAnalyze);
|
||||
|
||||
if (individual == null) {
|
||||
setErrorState(EnumErrorCode.UNKNOWN);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -153,22 +143,25 @@ public class TileAnalyzer extends TilePowered implements ISidedInventory, ILiqui
|
||||
stackToAnalyze.setTagCompound(nbttagcompound);
|
||||
}
|
||||
|
||||
if (InvTools.tryAddStack(invOutput, stackToAnalyze, true)) {
|
||||
boolean added = InvTools.tryAddStack(invOutput, stackToAnalyze, true);
|
||||
|
||||
if (added) {
|
||||
setInventorySlotContents(SLOT_ANALYZE, null);
|
||||
sendNetworkUpdate();
|
||||
return true;
|
||||
} else {
|
||||
setErrorState(EnumErrorCode.NOSPACE);
|
||||
return false;
|
||||
setNeedsNetworkUpdate();
|
||||
}
|
||||
|
||||
setErrorCondition(!added, EnumErrorCode.NOSPACE);
|
||||
|
||||
return added;
|
||||
}
|
||||
}
|
||||
|
||||
// Look for bees in input slots.
|
||||
IInvSlot slot = getInputSlot();
|
||||
if (slot == null) {
|
||||
// Nothing to analyze
|
||||
setErrorState(EnumErrorCode.NOTHINGANALYZE);
|
||||
|
||||
boolean noInput = (slot == null);
|
||||
setErrorCondition(noInput, EnumErrorCode.NOTHINGANALYZE);
|
||||
if (noInput) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -179,8 +172,9 @@ public class TileAnalyzer extends TilePowered implements ISidedInventory, ILiqui
|
||||
}
|
||||
IIndividual individual = AlleleManager.alleleRegistry.getIndividual(inputStack);
|
||||
if (!individual.isAnalyzed()) {
|
||||
if (resourceTank.getFluidAmount() < HONEY_REQUIRED) {
|
||||
setErrorState(EnumErrorCode.NORESOURCE);
|
||||
boolean hasHoney = resourceTank.getFluidAmount() >= HONEY_REQUIRED;
|
||||
setErrorCondition(!hasHoney, EnumErrorCode.NORESOURCE);
|
||||
if (!hasHoney) {
|
||||
return false;
|
||||
}
|
||||
resourceTank.drain(HONEY_REQUIRED, true);
|
||||
@@ -188,8 +182,7 @@ public class TileAnalyzer extends TilePowered implements ISidedInventory, ILiqui
|
||||
}
|
||||
setInventorySlotContents(SLOT_ANALYZE, inputStack);
|
||||
slot.setStackInSlot(null);
|
||||
setErrorState(EnumErrorCode.OK);
|
||||
sendNetworkUpdate();
|
||||
setNeedsNetworkUpdate();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -251,7 +244,9 @@ public class TileAnalyzer extends TilePowered implements ISidedInventory, ILiqui
|
||||
|
||||
@Override
|
||||
public boolean hasWork() {
|
||||
return getErrorState() == EnumErrorCode.OK || getErrorState() == EnumErrorCode.NOPOWER;
|
||||
Set<IErrorState> errors = new HashSet<IErrorState>(getErrorStates());
|
||||
errors.remove(EnumErrorCode.NOPOWER);
|
||||
return errors.size() == 0;
|
||||
}
|
||||
|
||||
public int getProgressScaled(int i) {
|
||||
@@ -320,4 +315,27 @@ public class TileAnalyzer extends TilePowered implements ISidedInventory, ILiqui
|
||||
public FluidTankInfo[] getTankInfo(ForgeDirection from) {
|
||||
return tankManager.getTankInfo(from);
|
||||
}
|
||||
|
||||
private static class AnalyzerInventoryAdapter extends TileInventoryAdapter<TileAnalyzer> {
|
||||
public AnalyzerInventoryAdapter(TileAnalyzer analyzer) {
|
||||
super(analyzer, 12, "Items");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
|
||||
if (GuiUtil.isIndexInRange(slotIndex, SLOT_INPUT_1, SLOT_INPUT_COUNT)) {
|
||||
return AlleleManager.alleleRegistry.isIndividual(itemStack) || GeneticsUtil.getGeneticEquivalent(itemStack) != null;
|
||||
} else if (slotIndex == SLOT_CAN) {
|
||||
Fluid fluid = FluidHelper.getFluidInContainer(itemStack);
|
||||
return tile.resourceTank.accepts(fluid);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int slotIndex, ItemStack stack, int side) {
|
||||
return GuiUtil.isIndexInRange(slotIndex, SLOT_OUTPUT_1, SLOT_OUTPUT_COUNT);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -28,24 +28,6 @@ public abstract class TileBase extends TileForestry implements IHintSource {
|
||||
public void initialize() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
|
||||
super.updateEntity();
|
||||
|
||||
if (!Proxies.common.isSimulating(worldObj)) {
|
||||
updateClientSide();
|
||||
} else {
|
||||
updateServerSide();
|
||||
}
|
||||
}
|
||||
|
||||
protected void updateClientSide() {
|
||||
}
|
||||
|
||||
protected void updateServerSide() {
|
||||
}
|
||||
|
||||
/* NETWORK */
|
||||
@Override
|
||||
public PacketPayload getPacketPayload() {
|
||||
@@ -57,8 +39,7 @@ public abstract class TileBase extends TileForestry implements IHintSource {
|
||||
}
|
||||
|
||||
/* INTERACTION */
|
||||
public void openGui(EntityPlayer player, TileBase tile) {
|
||||
}
|
||||
public abstract void openGui(EntityPlayer player, TileBase tile);
|
||||
|
||||
public boolean canDrainWithBucket() {
|
||||
return false;
|
||||
|
||||
@@ -152,14 +152,14 @@ public class TileEscritoire extends TileBase implements ISidedInventory, IRender
|
||||
return true;
|
||||
}
|
||||
|
||||
private class EscritoireInventoryAdapter extends TileInventoryAdapter {
|
||||
private static class EscritoireInventoryAdapter extends TileInventoryAdapter<TileEscritoire> {
|
||||
public EscritoireInventoryAdapter(TileEscritoire escritoire) {
|
||||
super(escritoire, 12, "Items");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
|
||||
if (slotIndex >= SLOT_INPUT_1 && slotIndex < SLOT_INPUT_1 + Math.min(game.getSampleSize(), SLOTS_INPUT_COUNT)) {
|
||||
if (slotIndex >= SLOT_INPUT_1 && slotIndex < SLOT_INPUT_1 + Math.min(tile.game.getSampleSize(), SLOTS_INPUT_COUNT)) {
|
||||
ItemStack specimen = getStackInSlot(SLOT_ANALYZE);
|
||||
if (specimen == null) {
|
||||
return false;
|
||||
@@ -186,7 +186,7 @@ public class TileEscritoire extends TileBase implements ISidedInventory, IRender
|
||||
}
|
||||
|
||||
if (GuiUtil.isIndexInRange(slotIndex, SLOT_INPUT_1, SLOTS_INPUT_COUNT)) {
|
||||
if (slotIndex >= SLOT_INPUT_1 + game.getSampleSize()) {
|
||||
if (slotIndex >= SLOT_INPUT_1 + tile.game.getSampleSize()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -202,14 +202,14 @@ public class TileEscritoire extends TileBase implements ISidedInventory, IRender
|
||||
@Override
|
||||
public void setInventorySlotContents(int slotIndex, ItemStack itemstack) {
|
||||
super.setInventorySlotContents(slotIndex, itemstack);
|
||||
if (slotIndex == SLOT_ANALYZE && Proxies.common.isSimulating(worldObj)) {
|
||||
if (slotIndex == SLOT_ANALYZE && Proxies.common.isSimulating(tile.worldObj)) {
|
||||
if (!AlleleManager.alleleRegistry.isIndividual(getStackInSlot(SLOT_ANALYZE)) && getStackInSlot(SLOT_ANALYZE) != null) {
|
||||
ItemStack ersatz = GeneticsUtil.convertSaplingToGeneticEquivalent(getStackInSlot(SLOT_ANALYZE));
|
||||
if (ersatz != null) {
|
||||
setInventorySlotContents(SLOT_ANALYZE, ersatz);
|
||||
}
|
||||
}
|
||||
game.initialize(getStackInSlot(SLOT_ANALYZE));
|
||||
tile.game.initialize(getStackInSlot(SLOT_ANALYZE));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,8 +10,12 @@
|
||||
******************************************************************************/
|
||||
package forestry.core.gadgets;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
@@ -32,7 +36,6 @@ import net.minecraftforge.common.util.ForgeDirection;
|
||||
import cpw.mods.fml.common.Optional;
|
||||
|
||||
import forestry.api.core.IErrorState;
|
||||
import forestry.core.EnumErrorCode;
|
||||
import forestry.core.config.Config;
|
||||
import forestry.core.config.Defaults;
|
||||
import forestry.core.interfaces.IErrorSource;
|
||||
@@ -63,7 +66,8 @@ public abstract class TileForestry extends TileEntity implements INetworkedEntit
|
||||
protected final AdjacentTileCache tileCache = new AdjacentTileCache(this);
|
||||
protected boolean isInited = false;
|
||||
private IInventoryAdapter inventory = FakeInventoryAdapter.instance();
|
||||
private int tickCount = rand.nextInt(128);
|
||||
private int tickCount = rand.nextInt(256);
|
||||
private boolean needsNetworkUpdate = false;
|
||||
|
||||
public AdjacentTileCache getTileCache() {
|
||||
return tileCache;
|
||||
@@ -108,15 +112,33 @@ public abstract class TileForestry extends TileEntity implements INetworkedEntit
|
||||
|
||||
// / UPDATING
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
public final void updateEntity() {
|
||||
tickCount++;
|
||||
|
||||
if (!isInited) {
|
||||
initialize();
|
||||
isInited = true;
|
||||
}
|
||||
|
||||
if (Proxies.common.isSimulating(worldObj)) {
|
||||
updateServerSide();
|
||||
} else {
|
||||
updateClientSide();
|
||||
}
|
||||
|
||||
if (needsNetworkUpdate) {
|
||||
needsNetworkUpdate = false;
|
||||
sendNetworkUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
public final boolean updateOnInterval(int tickInterval) {
|
||||
protected void updateClientSide() {
|
||||
}
|
||||
|
||||
protected void updateServerSide() {
|
||||
}
|
||||
|
||||
protected final boolean updateOnInterval(int tickInterval) {
|
||||
return tickCount % tickInterval == 0;
|
||||
}
|
||||
|
||||
@@ -181,7 +203,10 @@ public abstract class TileForestry extends TileEntity implements INetworkedEntit
|
||||
orientation = packet.getOrientation();
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
errorState = packet.getErrorState();
|
||||
|
||||
errorStates.clear();
|
||||
errorStates.addAll(packet.getErrorStates());
|
||||
|
||||
owner = packet.getOwner();
|
||||
access = packet.getAccess();
|
||||
fromPacketPayload(packet.payload);
|
||||
@@ -212,7 +237,7 @@ public abstract class TileForestry extends TileEntity implements INetworkedEntit
|
||||
/**
|
||||
* @return true if tile is activated by redstone current.
|
||||
*/
|
||||
public boolean isActivated() {
|
||||
public boolean isRedstoneActivated() {
|
||||
return worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
@@ -231,25 +256,52 @@ public abstract class TileForestry extends TileEntity implements INetworkedEntit
|
||||
this.sendNetworkUpdate();
|
||||
}
|
||||
|
||||
protected final void setNeedsNetworkUpdate() {
|
||||
needsNetworkUpdate = true;
|
||||
}
|
||||
|
||||
// / ERROR HANDLING
|
||||
public IErrorState errorState = EnumErrorCode.OK;
|
||||
private final Set<IErrorState> errorStates = new HashSet<IErrorState>();
|
||||
|
||||
public void setErrorState(IErrorState state) {
|
||||
if (this.errorState == state) {
|
||||
return;
|
||||
public final boolean setErrorCondition(boolean condition, IErrorState errorState) {
|
||||
if (condition) {
|
||||
if (errorStates.add(errorState)) {
|
||||
setNeedsNetworkUpdate();
|
||||
}
|
||||
} else {
|
||||
if (errorStates.remove(errorState)) {
|
||||
setNeedsNetworkUpdate();
|
||||
}
|
||||
}
|
||||
this.errorState = state;
|
||||
this.sendNetworkUpdate();
|
||||
return condition;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
protected final void addErrorState(IErrorState state) {
|
||||
if (errorStates.add(state)) {
|
||||
setNeedsNetworkUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
protected final void removeErrorStates() {
|
||||
if (errorStates.size() > 0) {
|
||||
setNeedsNetworkUpdate();
|
||||
}
|
||||
errorStates.clear();
|
||||
}
|
||||
|
||||
public final boolean hasErrorState(IErrorState state) {
|
||||
return errorStates.contains(state);
|
||||
}
|
||||
|
||||
public final boolean hasErrorState() {
|
||||
return errorStates.size() > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean throwsErrors() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IErrorState getErrorState() {
|
||||
return errorState;
|
||||
public ImmutableSet<IErrorState> getErrorStates() {
|
||||
return ImmutableSet.copyOf(errorStates);
|
||||
}
|
||||
|
||||
// / OWNERSHIP
|
||||
|
||||
@@ -36,12 +36,6 @@ public abstract class TileMachine extends TileForestry implements IClimatised, I
|
||||
public TileMachine() {
|
||||
}
|
||||
|
||||
// / IERRORSOURCE
|
||||
@Override
|
||||
public boolean throwsErrors() {
|
||||
return false;
|
||||
}
|
||||
|
||||
// / IHINTSOURCE
|
||||
@Override
|
||||
public boolean hasHints() {
|
||||
|
||||
@@ -21,21 +21,6 @@ import forestry.core.gui.IPagedInventory;
|
||||
import forestry.core.inventory.TileInventoryAdapter;
|
||||
|
||||
public abstract class TileNaturalistChest extends TileBase implements IPagedInventory {
|
||||
|
||||
private static class NaturalistInventoryAdapter extends TileInventoryAdapter {
|
||||
private final ISpeciesRoot speciesRoot;
|
||||
|
||||
public NaturalistInventoryAdapter(TileNaturalistChest tile, int size, String name, ISpeciesRoot speciesRoot) {
|
||||
super(tile, size, name);
|
||||
this.speciesRoot = speciesRoot;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSlotAccept(int slotIndex, ItemStack itemstack) {
|
||||
return speciesRoot.isMember(itemstack);
|
||||
}
|
||||
}
|
||||
|
||||
private final int guiID;
|
||||
|
||||
public TileNaturalistChest(ISpeciesRoot speciesRoot, int guiId) {
|
||||
@@ -54,14 +39,17 @@ public abstract class TileNaturalistChest extends TileBase implements IPagedInve
|
||||
player.openGui(ForestryAPI.instance, GuiHandler.encodeGuiData(guiID, page), player.worldObj, xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
/* UPDATING */
|
||||
@Override
|
||||
public void updateServerSide() {
|
||||
}
|
||||
private static class NaturalistInventoryAdapter extends TileInventoryAdapter<TileNaturalistChest> {
|
||||
private final ISpeciesRoot speciesRoot;
|
||||
|
||||
/* ERROR HANDLING */
|
||||
@Override
|
||||
public boolean throwsErrors() {
|
||||
return false;
|
||||
public NaturalistInventoryAdapter(TileNaturalistChest tile, int size, String name, ISpeciesRoot speciesRoot) {
|
||||
super(tile, size, name);
|
||||
this.speciesRoot = speciesRoot;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSlotAccept(int slotIndex, ItemStack itemstack) {
|
||||
return speciesRoot.isMember(itemstack);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,6 @@ import cpw.mods.fml.common.Optional;
|
||||
import forestry.core.EnumErrorCode;
|
||||
import forestry.core.interfaces.IPowerHandler;
|
||||
import forestry.core.interfaces.IRenderableMachine;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.EnumTankLevel;
|
||||
import forestry.energy.EnergyManager;
|
||||
|
||||
@@ -53,27 +52,28 @@ public abstract class TilePowered extends TileBase implements IRenderableMachine
|
||||
private int workCounter;
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
super.updateEntity();
|
||||
if (!Proxies.common.isSimulating(worldObj)) {
|
||||
protected void updateServerSide() {
|
||||
super.updateServerSide();
|
||||
|
||||
// Disable powered machines on a direct redstone signal
|
||||
boolean disabled = (worldObj.getBlockPowerInput(xCoord, yCoord, zCoord) >= 15);
|
||||
setErrorCondition(disabled, EnumErrorCode.DISABLED);
|
||||
if (disabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Disable powered machines on a direct redstone signal
|
||||
if (worldObj.getBlockPowerInput(xCoord, yCoord, zCoord) >= 15) {
|
||||
return;
|
||||
if (updateOnInterval(20)) {
|
||||
boolean hasEnergy = energyManager.hasEnergyToDoWork();
|
||||
setErrorCondition(!hasEnergy, EnumErrorCode.NOPOWER);
|
||||
}
|
||||
|
||||
if (workCounter < WORK_CYCLES) {
|
||||
if (energyManager.consumeEnergyToDoWork()) {
|
||||
workCounter++;
|
||||
} else {
|
||||
setErrorState(EnumErrorCode.NOPOWER);
|
||||
}
|
||||
} else {
|
||||
if (updateOnInterval(5) && workCycle()) {
|
||||
workCounter = 0;
|
||||
setErrorState(EnumErrorCode.OK);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,9 +10,11 @@
|
||||
******************************************************************************/
|
||||
package forestry.core.gui;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
|
||||
import forestry.api.core.IErrorState;
|
||||
import forestry.core.EnumErrorCode;
|
||||
import forestry.core.interfaces.IErrorSource;
|
||||
import forestry.core.utils.StringUtil;
|
||||
|
||||
/**
|
||||
@@ -20,47 +22,61 @@ import forestry.core.utils.StringUtil;
|
||||
*/
|
||||
public class ErrorLedger extends Ledger {
|
||||
|
||||
private final IErrorSource tile;
|
||||
@Nullable
|
||||
private IErrorState state;
|
||||
|
||||
public ErrorLedger(LedgerManager manager, IErrorSource tile) {
|
||||
super(manager);
|
||||
this.tile = tile;
|
||||
public ErrorLedger(LedgerManager manager) {
|
||||
super(manager, false);
|
||||
maxHeight = 72;
|
||||
overlayColor = manager.gui.fontColor.get("ledger.error.background");
|
||||
}
|
||||
|
||||
public void setState(@Nullable IErrorState state) {
|
||||
this.state = state;
|
||||
if (state != null) {
|
||||
String helpString = StringUtil.localize(state.getHelp());
|
||||
FontRenderer fontRenderer = manager.minecraft.fontRenderer;
|
||||
int lineCount = fontRenderer.listFormattedStringToWidth(helpString, maxWidth - 28).size();
|
||||
maxHeight = lineCount * (fontRenderer.FONT_HEIGHT + 2) + 20;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(int x, int y) {
|
||||
IErrorState state = tile.getErrorState();
|
||||
if (state == EnumErrorCode.OK) {
|
||||
if (state == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Draw background
|
||||
drawBackground(x, y);
|
||||
|
||||
// Draw icon
|
||||
drawIcon(state.getIcon(), x + 3, y + 4);
|
||||
drawIcon(state.getIcon(), x + 5, y + 4);
|
||||
|
||||
// Write description if fully opened
|
||||
if (isFullyOpened()) {
|
||||
// fontRendererObj.drawStringWithShadow(getTooltip(), x + 22, y +
|
||||
// 8, 0xe1c92f);
|
||||
manager.minecraft.fontRenderer.drawStringWithShadow(getTooltip(), x + 22, y + 8, manager.gui.fontColor.get("ledger.error.header"));
|
||||
manager.minecraft.fontRenderer.drawSplitString(StringUtil.localize(tile.getErrorState().getHelp()), x + 22, y + 20, maxWidth - 28,
|
||||
manager.gui.fontColor.get("ledger.error.text"));
|
||||
FontRenderer fontRenderer = manager.minecraft.fontRenderer;
|
||||
|
||||
fontRenderer.drawStringWithShadow(getTooltip(), x + 24, y + 8, manager.gui.fontColor.get("ledger.error.header"));
|
||||
|
||||
String helpString = StringUtil.localize(state.getHelp());
|
||||
fontRenderer.drawSplitString(helpString, x + 24, y + 20, maxWidth - 28, manager.gui.fontColor.get("ledger.error.text"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisible() {
|
||||
IErrorState state = tile.getErrorState();
|
||||
return state != EnumErrorCode.OK;
|
||||
return state != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return StringUtil.localize(tile.getErrorState().getDescription());
|
||||
if (state == null) {
|
||||
return "";
|
||||
}
|
||||
return StringUtil.localize(state.getDescription());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10,6 +10,7 @@
|
||||
******************************************************************************/
|
||||
package forestry.core.gui;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.awt.Color;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
@@ -81,8 +82,8 @@ public abstract class GuiForestry<C extends Container, I extends IInventory> ext
|
||||
/* LEDGERS */
|
||||
protected void initLedgers() {
|
||||
|
||||
if (inventory instanceof IErrorSource && ((IErrorSource) inventory).throwsErrors()) {
|
||||
ledgerManager.add(new ErrorLedger(ledgerManager, (IErrorSource) inventory));
|
||||
if (inventory instanceof IErrorSource) {
|
||||
ledgerManager.add((IErrorSource) inventory);
|
||||
}
|
||||
|
||||
if (inventory instanceof IClimatised && ((IClimatised) inventory).isClimatized()) {
|
||||
@@ -457,7 +458,9 @@ public abstract class GuiForestry<C extends Container, I extends IInventory> ext
|
||||
public ToolTip getToolTip() {
|
||||
EntityPlayer player = Proxies.common.getPlayer();
|
||||
ToolTip tip = new ToolTip();
|
||||
tip.add(itemStack.getTooltip(player, false));
|
||||
if (itemStack != null) {
|
||||
tip.add(itemStack.getTooltip(player, false));
|
||||
}
|
||||
return tip;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,8 @@ package forestry.core.gui;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
|
||||
import forestry.core.interfaces.IHintSource;
|
||||
import forestry.core.render.TextureManager;
|
||||
import forestry.core.utils.StringUtil;
|
||||
@@ -24,9 +26,13 @@ public class HintLedger extends Ledger {
|
||||
public HintLedger(LedgerManager manager, IHintSource tile) {
|
||||
super(manager);
|
||||
this.hints = tile.getHints();
|
||||
maxHeight = 96;
|
||||
position = new Random().nextInt(hints.length);
|
||||
overlayColor = manager.gui.fontColor.get("ledger.hint.background");
|
||||
|
||||
String helpString = StringUtil.localize("hints." + hints[position] + ".desc");
|
||||
FontRenderer fontRenderer = manager.minecraft.fontRenderer;
|
||||
int lineCount = fontRenderer.listFormattedStringToWidth(helpString, maxWidth - 28).size();
|
||||
maxHeight = lineCount * (fontRenderer.FONT_HEIGHT + 2) + 20;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -42,7 +48,7 @@ public class HintLedger extends Ledger {
|
||||
return;
|
||||
}
|
||||
|
||||
manager.minecraft.fontRenderer.drawStringWithShadow(StringUtil.localize("gui.didyouknow") + "?", x + 22, y + 8,
|
||||
manager.minecraft.fontRenderer.drawStringWithShadow(StringUtil.localize("gui.didyouknow") + '?', x + 22, y + 8,
|
||||
manager.gui.fontColor.get("ledger.hint.header"));
|
||||
manager.minecraft.fontRenderer.drawSplitString(StringUtil.localize("hints." + hints[position] + ".desc"), x + 22, y + 20, maxWidth - 28,
|
||||
manager.gui.fontColor.get("ledger.hint.text"));
|
||||
|
||||
@@ -27,7 +27,12 @@ import forestry.core.utils.ForestryResource;
|
||||
public abstract class Ledger {
|
||||
|
||||
private static final int OPEN_SPEED = 8;
|
||||
private static final ResourceLocation ledgerTexture = new ForestryResource(Defaults.TEXTURE_PATH_GUI + "/ledger.png");
|
||||
protected static final int maxWidth = 124;
|
||||
protected static final int minWidth = 24;
|
||||
public static final int minHeight = 24;
|
||||
|
||||
private static final ResourceLocation ledgerTextureRight = new ForestryResource(Defaults.TEXTURE_PATH_GUI + "/ledger.png");
|
||||
private static final ResourceLocation ledgerTextureLeft = new ForestryResource(Defaults.TEXTURE_PATH_GUI + "/ledgerLeft.png");
|
||||
|
||||
protected final LedgerManager manager;
|
||||
|
||||
@@ -37,18 +42,24 @@ public abstract class Ledger {
|
||||
|
||||
public int currentShiftX = 0;
|
||||
public int currentShiftY = 0;
|
||||
|
||||
protected int limitWidth = 128;
|
||||
protected int maxWidth = 124;
|
||||
protected int minWidth = 24;
|
||||
protected int currentWidth = minWidth;
|
||||
|
||||
protected int maxHeight = 24;
|
||||
protected int minHeight = 24;
|
||||
|
||||
protected int currentHeight = minHeight;
|
||||
|
||||
protected final ResourceLocation texture;
|
||||
|
||||
public Ledger(LedgerManager manager) {
|
||||
this(manager, true);
|
||||
}
|
||||
|
||||
public Ledger(LedgerManager manager, boolean rightSide) {
|
||||
this.manager = manager;
|
||||
if (rightSide) {
|
||||
texture = ledgerTextureRight;
|
||||
} else {
|
||||
texture = ledgerTextureLeft;
|
||||
}
|
||||
}
|
||||
|
||||
public void update() {
|
||||
@@ -81,8 +92,8 @@ public abstract class Ledger {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean intersectsWith(int mouseX, int mouseY, int shiftX, int shiftY) {
|
||||
return mouseX >= shiftX && mouseX <= shiftX + currentWidth && mouseY >= shiftY && mouseY <= shiftY + getHeight();
|
||||
public boolean intersectsWith(int mouseX, int mouseY) {
|
||||
return mouseX >= currentShiftX && mouseX <= currentShiftX + currentWidth && mouseY >= currentShiftY && mouseY <= currentShiftY + getHeight();
|
||||
}
|
||||
|
||||
public void setFullyOpen() {
|
||||
@@ -121,13 +132,13 @@ public abstract class Ledger {
|
||||
|
||||
GL11.glColor4f(colorR, colorG, colorB, 1.0F);
|
||||
|
||||
Proxies.common.bindTexture(ledgerTexture);
|
||||
|
||||
manager.gui.drawTexturedModalRect(x, y, 0, 256 - currentHeight, 4, currentHeight);
|
||||
manager.gui.drawTexturedModalRect(x + 4, y, 256 - currentWidth + 4, 0, currentWidth - 4, 4);
|
||||
manager.gui.drawTexturedModalRect(x, y, 0, 0, 4, 4);
|
||||
Proxies.common.bindTexture(texture);
|
||||
|
||||
manager.gui.drawTexturedModalRect(x + 4, y + 4, 256 - currentWidth + 4, 256 - currentHeight + 4, currentWidth - 4, currentHeight - 4);
|
||||
manager.gui.drawTexturedModalRect(x, y + 4, 0, 256 - currentHeight + 4, 4, currentHeight - 4); // left edge
|
||||
manager.gui.drawTexturedModalRect(x + 4, y, 256 - currentWidth + 4, 0, currentWidth - 4, 4); // top edge
|
||||
manager.gui.drawTexturedModalRect(x, y, 0, 0, 4, 4); // top left corner
|
||||
|
||||
manager.gui.drawTexturedModalRect(x + 4, y + 4, 256 - currentWidth + 4, 256 - currentHeight + 4, currentWidth - 4, currentHeight - 4); // body + bottom + right
|
||||
|
||||
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0F);
|
||||
}
|
||||
|
||||
@@ -10,27 +10,42 @@
|
||||
******************************************************************************/
|
||||
package forestry.core.gui;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import forestry.api.core.IErrorState;
|
||||
import forestry.core.config.SessionVars;
|
||||
import forestry.core.interfaces.IErrorSource;
|
||||
import forestry.core.proxy.Proxies;
|
||||
|
||||
public class LedgerManager {
|
||||
|
||||
public final GuiForestry gui;
|
||||
public final Minecraft minecraft;
|
||||
@Nullable
|
||||
public IErrorSource errorSource;
|
||||
|
||||
protected final ArrayList<Ledger> ledgers = new ArrayList<Ledger>();
|
||||
protected final List<Ledger> ledgers = new ArrayList<Ledger>();
|
||||
protected final List<ErrorLedger> errorLedgers = new ArrayList<ErrorLedger>();
|
||||
|
||||
public LedgerManager(GuiForestry gui) {
|
||||
this.gui = gui;
|
||||
this.minecraft = Proxies.common.getClientInstance();
|
||||
}
|
||||
|
||||
public void add(IErrorSource errorSource) {
|
||||
this.errorSource = errorSource;
|
||||
int maxErrorLedgerCount = (gui.getSizeY() - 10) / Ledger.minHeight;
|
||||
for (int i = 0; i < maxErrorLedgerCount; i++) {
|
||||
errorLedgers.add(new ErrorLedger(this));
|
||||
}
|
||||
}
|
||||
|
||||
public void add(Ledger ledger) {
|
||||
this.ledgers.add(ledger);
|
||||
if (SessionVars.getOpenedLedger() != null && ledger.getClass().equals(SessionVars.getOpenedLedger())) {
|
||||
@@ -47,21 +62,42 @@ public class LedgerManager {
|
||||
|
||||
protected Ledger getAtPosition(int mX, int mY) {
|
||||
|
||||
int xShift = ((gui.width - gui.getSizeX()) / 2) + gui.getSizeX();
|
||||
int yShift = ((gui.height - gui.getSizeY()) / 2) + 8;
|
||||
if (ledgers.size() > 0) {
|
||||
final int xShift = ((gui.width - gui.getSizeX()) / 2) + gui.getSizeX();
|
||||
int yShift = ((gui.height - gui.getSizeY()) / 2) + 8;
|
||||
|
||||
for (Ledger ledger : ledgers) {
|
||||
if (!ledger.isVisible()) {
|
||||
continue;
|
||||
for (Ledger ledger : ledgers) {
|
||||
if (!ledger.isVisible()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ledger.currentShiftX = xShift;
|
||||
ledger.currentShiftY = yShift;
|
||||
if (ledger.intersectsWith(mX, mY)) {
|
||||
return ledger;
|
||||
}
|
||||
|
||||
yShift += ledger.getHeight();
|
||||
}
|
||||
}
|
||||
|
||||
ledger.currentShiftX = xShift;
|
||||
ledger.currentShiftY = yShift;
|
||||
if (ledger.intersectsWith(mX, mY, xShift, yShift)) {
|
||||
return ledger;
|
||||
if (errorSource != null) {
|
||||
final int xShiftError = ((gui.width - gui.getSizeX()) / 2);
|
||||
int yShiftError = ((gui.height - gui.getSizeY()) / 2) + 8;
|
||||
|
||||
for (ErrorLedger errorLedger : errorLedgers) {
|
||||
if (!errorLedger.isVisible()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
errorLedger.currentShiftX = xShiftError - errorLedger.currentWidth;
|
||||
errorLedger.currentShiftY = yShiftError;
|
||||
if (errorLedger.intersectsWith(mX, mY)) {
|
||||
return errorLedger;
|
||||
}
|
||||
|
||||
yShiftError += errorLedger.getHeight();
|
||||
}
|
||||
|
||||
yShift += ledger.getHeight();
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -81,6 +117,28 @@ public class LedgerManager {
|
||||
ledger.draw(gui.getSizeX(), yPos);
|
||||
yPos += ledger.getHeight();
|
||||
}
|
||||
|
||||
if (errorSource != null) {
|
||||
yPos = 8;
|
||||
|
||||
int index = 0;
|
||||
for (IErrorState errorState : errorSource.getErrorStates()) {
|
||||
if (index >= errorLedgers.size()) {
|
||||
break;
|
||||
}
|
||||
ErrorLedger errorLedger = errorLedgers.get(index++);
|
||||
errorLedger.setState(errorState);
|
||||
|
||||
errorLedger.update();
|
||||
if (!errorLedger.isVisible()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
errorLedger.draw(-errorLedger.currentWidth, yPos);
|
||||
yPos += errorLedger.getHeight();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void drawTooltips(int mouseX, int mouseY) {
|
||||
@@ -108,7 +166,14 @@ public class LedgerManager {
|
||||
// ledger itself.
|
||||
if (ledger != null && !ledger.handleMouseClicked(x, y, mouseButton)) {
|
||||
|
||||
for (Ledger other : ledgers) {
|
||||
List<? extends Ledger> toggleLedgers;
|
||||
if (ledgers.contains(ledger)) {
|
||||
toggleLedgers = ledgers;
|
||||
} else {
|
||||
toggleLedgers = errorLedgers;
|
||||
}
|
||||
|
||||
for (Ledger other : toggleLedgers) {
|
||||
if (other != ledger && other.isOpen()) {
|
||||
other.toggleOpen();
|
||||
}
|
||||
|
||||
@@ -45,10 +45,6 @@ public class OwnerLedger extends Ledger {
|
||||
return mouseX >= shiftX && mouseX <= currentShiftX + currentWidth && mouseY >= shiftY && mouseY <= shiftY + 12;
|
||||
}
|
||||
|
||||
public boolean isOwnerChangeButton(int mouseX, int mouseY) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(int x, int y) {
|
||||
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* 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.util.IIcon;
|
||||
|
||||
/**
|
||||
* A simple ledger displaying an icon and one-line description.
|
||||
*/
|
||||
public class PlainLedger extends Ledger {
|
||||
|
||||
private final IIcon icon;
|
||||
private final String text;
|
||||
|
||||
public PlainLedger(LedgerManager manager, IIcon icon, String text) {
|
||||
super(manager);
|
||||
this.icon = icon;
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(int x, int y) {
|
||||
|
||||
// Correct maximum width
|
||||
int textWidth = manager.minecraft.fontRenderer.getStringWidth(getTooltip());
|
||||
this.maxWidth = textWidth + 24 + 4;
|
||||
|
||||
// Draw background
|
||||
drawBackground(x, y);
|
||||
|
||||
// Draw icon
|
||||
drawIcon(icon, x + 3, y + 4);
|
||||
|
||||
// Draw description
|
||||
if (isFullyOpened()) {
|
||||
manager.minecraft.fontRenderer.drawString(getTooltip(), x + 22, y + 8, 0x000000);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return text;
|
||||
}
|
||||
}
|
||||
@@ -10,12 +10,12 @@
|
||||
******************************************************************************/
|
||||
package forestry.core.interfaces;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import forestry.api.core.IErrorState;
|
||||
|
||||
public interface IErrorSource {
|
||||
|
||||
boolean throwsErrors();
|
||||
|
||||
IErrorState getErrorState();
|
||||
ImmutableSet<IErrorState> getErrorStates();
|
||||
|
||||
}
|
||||
@@ -1,12 +1,17 @@
|
||||
package forestry.core.inventory;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import forestry.api.core.IErrorState;
|
||||
import forestry.core.EnumErrorCode;
|
||||
import forestry.core.config.ForestryItem;
|
||||
import forestry.core.interfaces.IErrorSource;
|
||||
|
||||
public abstract class AlyzerInventory extends ItemInventory {
|
||||
public abstract class AlyzerInventory extends ItemInventory implements IErrorSource {
|
||||
|
||||
public static final int SLOT_SPECIMEN = 0;
|
||||
public static final int SLOT_ANALYZE_1 = 1;
|
||||
@@ -22,7 +27,7 @@ public abstract class AlyzerInventory extends ItemInventory {
|
||||
super(itemClass, size, itemstack);
|
||||
}
|
||||
|
||||
protected boolean isEnergy(ItemStack itemstack) {
|
||||
protected static boolean isEnergy(ItemStack itemstack) {
|
||||
if (itemstack == null || itemstack.stackSize <= 0) {
|
||||
return false;
|
||||
}
|
||||
@@ -55,4 +60,18 @@ public abstract class AlyzerInventory extends ItemInventory {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final ImmutableSet<IErrorState> getErrorStates() {
|
||||
ImmutableSet.Builder<IErrorState> errorStates = ImmutableSet.builder();
|
||||
|
||||
if (!hasSpecimen()) {
|
||||
errorStates.add(EnumErrorCode.NOTHINGANALYZE);
|
||||
}
|
||||
|
||||
if (!isEnergy(getStackInSlot(SLOT_ENERGY))) {
|
||||
errorStates.add(EnumErrorCode.NOHONEY);
|
||||
}
|
||||
|
||||
return errorStates.build();
|
||||
}
|
||||
}
|
||||
@@ -14,15 +14,15 @@ import net.minecraft.item.ItemStack;
|
||||
|
||||
import forestry.core.gadgets.TileForestry;
|
||||
|
||||
public class TileInventoryAdapter extends InventoryAdapter {
|
||||
public class TileInventoryAdapter<T extends TileForestry> extends InventoryAdapter {
|
||||
|
||||
private final TileForestry tile;
|
||||
protected final T tile;
|
||||
|
||||
public TileInventoryAdapter(TileForestry tile, int size, String name) {
|
||||
public TileInventoryAdapter(T tile, int size, String name) {
|
||||
this(tile, size, name, 64);
|
||||
}
|
||||
|
||||
public TileInventoryAdapter(TileForestry tile, int size, String name, int stackLimit) {
|
||||
public TileInventoryAdapter(T tile, int size, String name, int stackLimit) {
|
||||
super(size, name, stackLimit);
|
||||
this.tile = tile;
|
||||
}
|
||||
|
||||
@@ -13,6 +13,8 @@ package forestry.core.network;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
@@ -21,27 +23,27 @@ import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import forestry.api.core.ErrorStateRegistry;
|
||||
import forestry.api.core.IErrorState;
|
||||
import forestry.core.EnumErrorCode;
|
||||
import forestry.core.gadgets.TileForestry;
|
||||
import forestry.core.utils.EnumAccess;
|
||||
|
||||
public class PacketTileUpdate extends PacketUpdate {
|
||||
|
||||
private ForgeDirection orientation = ForgeDirection.WEST;
|
||||
private IErrorState errorState = EnumErrorCode.OK;
|
||||
private final Set<IErrorState> errorStates;
|
||||
|
||||
private boolean isOwnable = false;
|
||||
private EnumAccess access = EnumAccess.SHARED;
|
||||
private GameProfile owner = null;
|
||||
|
||||
public PacketTileUpdate() {
|
||||
errorStates = new HashSet<IErrorState>();
|
||||
}
|
||||
|
||||
public PacketTileUpdate(TileForestry tile) {
|
||||
super(PacketIds.TILE_FORESTRY_UPDATE, tile);
|
||||
|
||||
orientation = tile.getOrientation();
|
||||
errorState = tile.getErrorState();
|
||||
errorStates = tile.getErrorStates();
|
||||
|
||||
isOwnable = tile.isOwnable();
|
||||
access = tile.getAccess();
|
||||
@@ -52,8 +54,12 @@ public class PacketTileUpdate extends PacketUpdate {
|
||||
public void writeData(DataOutputStream data) throws IOException {
|
||||
super.writeData(data);
|
||||
|
||||
data.writeByte(this.orientation.ordinal());
|
||||
data.writeShort(this.errorState.getID());
|
||||
data.writeByte(orientation.ordinal());
|
||||
|
||||
data.writeShort(errorStates.size());
|
||||
for (IErrorState errorState : errorStates) {
|
||||
data.writeShort(errorState.getID());
|
||||
}
|
||||
|
||||
// TODO: Should this really be sent to the client? Huge network cost.
|
||||
// As far as I know, only GUIs need it, and there are better ways to get the information to a GUI.
|
||||
@@ -78,7 +84,13 @@ public class PacketTileUpdate extends PacketUpdate {
|
||||
super.readData(data);
|
||||
|
||||
orientation = ForgeDirection.getOrientation(data.readByte());
|
||||
errorState = ErrorStateRegistry.getErrorState(data.readShort());
|
||||
|
||||
short errorStateCount = data.readShort();
|
||||
for (int i = 0; i < errorStateCount; i++) {
|
||||
short errorStateId = data.readShort();
|
||||
IErrorState errorState = ErrorStateRegistry.getErrorState(errorStateId);
|
||||
errorStates.add(errorState);
|
||||
}
|
||||
|
||||
int ordinal = data.readByte();
|
||||
isOwnable = ordinal >= 0;
|
||||
@@ -94,18 +106,18 @@ public class PacketTileUpdate extends PacketUpdate {
|
||||
}
|
||||
|
||||
public ForgeDirection getOrientation() {
|
||||
return this.orientation;
|
||||
return orientation;
|
||||
}
|
||||
|
||||
public IErrorState getErrorState() {
|
||||
return this.errorState;
|
||||
public Set<IErrorState> getErrorStates() {
|
||||
return errorStates;
|
||||
}
|
||||
|
||||
public EnumAccess getAccess() {
|
||||
return this.access;
|
||||
return access;
|
||||
}
|
||||
|
||||
public GameProfile getOwner() {
|
||||
return this.owner;
|
||||
return owner;
|
||||
}
|
||||
}
|
||||
@@ -141,13 +141,17 @@ public class EnergyManager implements IEnergyHandler {
|
||||
* @return true if the energy to do work was consumed
|
||||
*/
|
||||
public boolean consumeEnergyToDoWork() {
|
||||
if (energyStorage.getEnergyStored() < energyPerWork) {
|
||||
if (!hasEnergyToDoWork()) {
|
||||
return false;
|
||||
}
|
||||
energyStorage.modifyEnergyStored(-energyPerWork);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean hasEnergyToDoWork() {
|
||||
return energyStorage.getEnergyStored() >= energyPerWork;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends as much energy as it can to the tile at orientation.
|
||||
* For power sources. Ignores canExtract()
|
||||
|
||||
@@ -83,17 +83,7 @@ public class EngineBronze extends Engine implements ISidedInventory, ILiquidTank
|
||||
super(Defaults.ENGINE_BRONZE_HEAT_MAX, 300000, 5000);
|
||||
setHints(Config.hints.get("engine.bronze"));
|
||||
|
||||
setInternalInventory(new TileInventoryAdapter(this, 1, "Items") {
|
||||
@Override
|
||||
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
|
||||
if (slotIndex == SLOT_CAN) {
|
||||
Fluid fluid = FluidHelper.getFluidInContainer(itemStack);
|
||||
return tankManager.accepts(fluid);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
});
|
||||
setInternalInventory(new EngineBronzeInventoryAdapter(this));
|
||||
|
||||
fuelTank = new FilteredTank(Defaults.ENGINE_TANK_CAPACITY, FuelManager.bronzeEngineFuel.keySet());
|
||||
fuelTank.tankMode = StandardTank.TankMode.INPUT;
|
||||
@@ -125,13 +115,11 @@ public class EngineBronze extends Engine implements ISidedInventory, ILiquidTank
|
||||
FluidHelper.drainContainers(tankManager, inventory, SLOT_CAN);
|
||||
}
|
||||
|
||||
if (getHeatLevel() <= 0.2 && heatingTank.getFluidAmount() <= 0) {
|
||||
setErrorState(EnumErrorCode.NOHEAT);
|
||||
} else if (burnTime <= 0 && fuelTank.getFluidAmount() <= 0) {
|
||||
setErrorState(EnumErrorCode.NOFUEL);
|
||||
} else {
|
||||
setErrorState(EnumErrorCode.OK);
|
||||
}
|
||||
boolean hasHeat = getHeatLevel() > 0.2 || heatingTank.getFluidAmount() > 0;
|
||||
setErrorCondition(!hasHeat, EnumErrorCode.NOHEAT);
|
||||
|
||||
boolean hasFuel = burnTime > 0 || fuelTank.getFluidAmount() > 0;
|
||||
setErrorCondition(!hasFuel, EnumErrorCode.NOFUEL);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -142,7 +130,7 @@ public class EngineBronze extends Engine implements ISidedInventory, ILiquidTank
|
||||
|
||||
currentOutput = 0;
|
||||
|
||||
if (isActivated() && (fuelTank.getFluidAmount() >= Defaults.BUCKET_VOLUME || burnTime > 0)) {
|
||||
if (isRedstoneActivated() && (fuelTank.getFluidAmount() >= Defaults.BUCKET_VOLUME || burnTime > 0)) {
|
||||
|
||||
double heatStage = getHeatLevel();
|
||||
|
||||
@@ -221,7 +209,7 @@ public class EngineBronze extends Engine implements ISidedInventory, ILiquidTank
|
||||
|
||||
int generate = 0;
|
||||
|
||||
if (isActivated() && burnTime > 0) {
|
||||
if (isRedstoneActivated() && burnTime > 0) {
|
||||
double heatStage = getHeatLevel();
|
||||
if (heatStage >= 0.75) {
|
||||
generate += Defaults.ENGINE_BRONZE_HEAT_GENERATION_ENERGY * 3;
|
||||
@@ -380,4 +368,19 @@ public class EngineBronze extends Engine implements ISidedInventory, ILiquidTank
|
||||
return tankManager.getTankInfo(from);
|
||||
}
|
||||
|
||||
private static class EngineBronzeInventoryAdapter extends TileInventoryAdapter<EngineBronze> {
|
||||
public EngineBronzeInventoryAdapter(EngineBronze engineBronze) {
|
||||
super(engineBronze, 1, "Items");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
|
||||
if (slotIndex == SLOT_CAN) {
|
||||
Fluid fluid = FluidHelper.getFluidInContainer(itemStack);
|
||||
return tile.tankManager.accepts(fluid);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -85,7 +85,7 @@ public class EngineClockwork extends Engine {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isActivated() {
|
||||
public boolean isRedstoneActivated() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -69,17 +69,7 @@ public class EngineCopper extends Engine implements ISidedInventory {
|
||||
setHints(Config.hints.get("engine.copper"));
|
||||
|
||||
ashForItem = Defaults.ENGINE_COPPER_ASH_FOR_ITEM;
|
||||
setInternalInventory(new TileInventoryAdapter(this, 5, "Items") {
|
||||
@Override
|
||||
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
|
||||
return slotIndex == SLOT_FUEL && FuelManager.copperEngineFuel.containsKey(itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int slotIndex, ItemStack itemstack, int side) {
|
||||
return GuiUtil.isIndexInRange(slotIndex, SLOT_WASTE_1, SLOT_WASTE_COUNT);
|
||||
}
|
||||
});
|
||||
setInternalInventory(new EngineCopperInventoryAdapter(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -128,20 +118,9 @@ public class EngineCopper extends Engine implements ISidedInventory {
|
||||
|
||||
dumpStash();
|
||||
|
||||
if (mayBurn() && burnTime > 0) {
|
||||
setErrorState(EnumErrorCode.OK);
|
||||
return;
|
||||
} else if (forceCooldown) {
|
||||
setErrorState(EnumErrorCode.FORCEDCOOLDOWN);
|
||||
return;
|
||||
}
|
||||
|
||||
int fuelSlot = getFuelSlot();
|
||||
if (fuelSlot >= 0 && determineBurnDuration(getInternalInventory().getStackInSlot(fuelSlot)) > 0) {
|
||||
setErrorState(EnumErrorCode.OK);
|
||||
} else {
|
||||
setErrorState(EnumErrorCode.NOFUEL);
|
||||
}
|
||||
boolean hasFuel = fuelSlot >= 0 && determineBurnDuration(getInternalInventory().getStackInSlot(fuelSlot)) > 0;
|
||||
setErrorCondition(!hasFuel, EnumErrorCode.NOFUEL);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -153,11 +132,11 @@ public class EngineCopper extends Engine implements ISidedInventory {
|
||||
burnTime--;
|
||||
addAsh(1);
|
||||
|
||||
if (isActivated()) {
|
||||
if (isRedstoneActivated()) {
|
||||
currentOutput = determineFuelValue(new ItemStack(fuelItem, 1, fuelItemMeta));
|
||||
energyManager.generateEnergy(currentOutput);
|
||||
}
|
||||
} else if (isActivated()) {
|
||||
} else if (isRedstoneActivated()) {
|
||||
int fuelslot = getFuelSlot();
|
||||
int wasteslot = getFreeWasteSlot();
|
||||
|
||||
@@ -376,4 +355,19 @@ public class EngineCopper extends Engine implements ISidedInventory {
|
||||
return res;
|
||||
}
|
||||
|
||||
private static class EngineCopperInventoryAdapter extends TileInventoryAdapter<EngineCopper> {
|
||||
public EngineCopperInventoryAdapter(EngineCopper engineCopper) {
|
||||
super(engineCopper, 5, "Items");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
|
||||
return slotIndex == SLOT_FUEL && FuelManager.copperEngineFuel.containsKey(itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int slotIndex, ItemStack itemstack, int side) {
|
||||
return GuiUtil.isIndexInRange(slotIndex, SLOT_WASTE_1, SLOT_WASTE_COUNT);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -132,7 +132,7 @@ public class EngineTin extends Engine implements ISocketable, IInventory {
|
||||
|
||||
int loss = 0;
|
||||
|
||||
if (!isBurning() || !isActivated()) {
|
||||
if (!isBurning() || !isRedstoneActivated()) {
|
||||
loss += 1;
|
||||
}
|
||||
|
||||
@@ -149,7 +149,7 @@ public class EngineTin extends Engine implements ISocketable, IInventory {
|
||||
public int generateHeat() {
|
||||
|
||||
int gain = 0;
|
||||
if (isActivated() && isBurning()) {
|
||||
if (isRedstoneActivated() && isBurning()) {
|
||||
gain++;
|
||||
if (((double) energyManager.getTotalEnergyStored() / (double) maxEnergy) > 0.5) {
|
||||
gain++;
|
||||
@@ -164,8 +164,7 @@ public class EngineTin extends Engine implements ISocketable, IInventory {
|
||||
@Override
|
||||
public void updateServerSide() {
|
||||
// No work to be done if IC2 is unavailable.
|
||||
if (ic2EnergySink == null) {
|
||||
setErrorState(EnumErrorCode.NOENERGYNET);
|
||||
if (setErrorCondition(ic2EnergySink == null, EnumErrorCode.NOENERGYNET)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -174,7 +173,6 @@ public class EngineTin extends Engine implements ISocketable, IInventory {
|
||||
super.updateServerSide();
|
||||
|
||||
if (forceCooldown) {
|
||||
setErrorState(EnumErrorCode.FORCEDCOOLDOWN);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -187,11 +185,8 @@ public class EngineTin extends Engine implements ISocketable, IInventory {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!ic2EnergySink.canUseEnergy(euConfig.euForCycle)) {
|
||||
setErrorState(EnumErrorCode.NOFUEL);
|
||||
} else {
|
||||
setErrorState(EnumErrorCode.OK);
|
||||
}
|
||||
boolean canUseEnergy = ic2EnergySink.canUseEnergy(euConfig.euForCycle);
|
||||
setErrorCondition(!canUseEnergy, EnumErrorCode.NOFUEL);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -199,7 +194,7 @@ public class EngineTin extends Engine implements ISocketable, IInventory {
|
||||
|
||||
currentOutput = 0;
|
||||
|
||||
if (!isActivated()) {
|
||||
if (!isRedstoneActivated()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -211,7 +206,7 @@ public class EngineTin extends Engine implements ISocketable, IInventory {
|
||||
}
|
||||
|
||||
private void replenishFromBattery(int slot) {
|
||||
if (!isActivated()) {
|
||||
if (!isRedstoneActivated()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -331,7 +326,7 @@ public class EngineTin extends Engine implements ISocketable, IInventory {
|
||||
}
|
||||
}
|
||||
|
||||
private static class EngineTinInventoryAdapter extends TileInventoryAdapter {
|
||||
private static class EngineTinInventoryAdapter extends TileInventoryAdapter<EngineTin> {
|
||||
public EngineTinInventoryAdapter(EngineTin engineTin) {
|
||||
super(engineTin, 1, "electrical");
|
||||
}
|
||||
|
||||
@@ -58,17 +58,7 @@ public class MachineGenerator extends TileBase implements ISidedInventory, ILiqu
|
||||
public MachineGenerator() {
|
||||
setHints(Config.hints.get("generator"));
|
||||
|
||||
setInternalInventory(new TileInventoryAdapter(this, 1, "Items") {
|
||||
@Override
|
||||
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
|
||||
if (slotIndex == SLOT_CAN) {
|
||||
Fluid fluid = FluidHelper.getFluidInContainer(itemStack);
|
||||
return tankManager.accepts(fluid);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
});
|
||||
setInternalInventory(new GeneratorInventoryAdapter(this));
|
||||
|
||||
resourceTank = new FilteredTank(Defaults.PROCESSOR_TANK_CAPACITY, FuelManager.generatorFuel.keySet());
|
||||
tankManager = new TankManager(resourceTank);
|
||||
@@ -135,8 +125,7 @@ public class MachineGenerator extends TileBase implements ISidedInventory, ILiqu
|
||||
}
|
||||
|
||||
// No work to be done if IC2 is unavailable.
|
||||
if (ic2EnergySource == null) {
|
||||
setErrorState(EnumErrorCode.NOENERGYNET);
|
||||
if (setErrorCondition(ic2EnergySource == null, EnumErrorCode.NOENERGYNET)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -158,11 +147,8 @@ public class MachineGenerator extends TileBase implements ISidedInventory, ILiqu
|
||||
|
||||
}
|
||||
|
||||
if (resourceTank.getFluidAmount() <= 0) {
|
||||
setErrorState(EnumErrorCode.NOFUEL);
|
||||
} else {
|
||||
setErrorState(EnumErrorCode.OK);
|
||||
}
|
||||
boolean hasFuel = resourceTank.getFluidAmount() > 0;
|
||||
setErrorCondition(!hasFuel, EnumErrorCode.NOFUEL);
|
||||
}
|
||||
|
||||
public boolean isWorking() {
|
||||
@@ -246,4 +232,19 @@ public class MachineGenerator extends TileBase implements ISidedInventory, ILiqu
|
||||
return tankManager.getTankInfo(from);
|
||||
}
|
||||
|
||||
private static class GeneratorInventoryAdapter extends TileInventoryAdapter<MachineGenerator> {
|
||||
public GeneratorInventoryAdapter(MachineGenerator generator) {
|
||||
super(generator, 1, "Items");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
|
||||
if (slotIndex == SLOT_CAN) {
|
||||
Fluid fluid = FluidHelper.getFluidInContainer(itemStack);
|
||||
return tile.tankManager.accepts(fluid);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -182,6 +182,8 @@ public class MachineBottler extends TilePowered implements ISidedInventory, ILiq
|
||||
|
||||
@Override
|
||||
public void updateServerSide() {
|
||||
super.updateServerSide();
|
||||
|
||||
if (!updateOnInterval(20)) {
|
||||
return;
|
||||
}
|
||||
@@ -206,8 +208,9 @@ public class MachineBottler extends TilePowered implements ISidedInventory, ILiq
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!InvTools.tryAddStack(this, currentRecipe.bottled, SLOT_OUTPUT, 1, true, false)) {
|
||||
setErrorState(EnumErrorCode.NOSPACE);
|
||||
boolean added = InvTools.tryAddStack(this, currentRecipe.bottled, SLOT_OUTPUT, 1, true, false);
|
||||
|
||||
if (setErrorCondition(!added, EnumErrorCode.NOSPACE)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -228,16 +231,12 @@ public class MachineBottler extends TilePowered implements ISidedInventory, ILiq
|
||||
ItemStack emptyCan = getStackInSlot(SLOT_INPUT_EMPTY_CAN);
|
||||
Recipe recipe = RecipeManager.findMatchingRecipe(resourceTank.getFluid(), emptyCan);
|
||||
|
||||
if (recipe == null) {
|
||||
setErrorState(EnumErrorCode.NORECIPE);
|
||||
} else {
|
||||
setErrorState(EnumErrorCode.OK);
|
||||
}
|
||||
|
||||
if (currentRecipe != recipe) {
|
||||
currentRecipe = recipe;
|
||||
resetRecipe();
|
||||
}
|
||||
|
||||
setErrorCondition(currentRecipe == null, EnumErrorCode.NORECIPE);
|
||||
}
|
||||
|
||||
private void resetRecipe() {
|
||||
@@ -357,7 +356,7 @@ public class MachineBottler extends TilePowered implements ISidedInventory, ILiq
|
||||
return res;
|
||||
}
|
||||
|
||||
private static class BottlerInventoryAdapter extends TileInventoryAdapter {
|
||||
private static class BottlerInventoryAdapter extends TileInventoryAdapter<MachineBottler> {
|
||||
public BottlerInventoryAdapter(MachineBottler machineBottler) {
|
||||
super(machineBottler, 3, "Items");
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
******************************************************************************/
|
||||
package forestry.factory.gadgets;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
@@ -66,6 +67,7 @@ public class MachineCarpenter extends TilePowered implements ISidedInventory, IL
|
||||
public final static int SLOT_CRAFTING_COUNT = 9;
|
||||
public final static int SLOT_BOX = 9;
|
||||
public final static int SLOT_PRODUCT = 10;
|
||||
public final static int SLOT_PRODUCT_COUNT = 1;
|
||||
public final static int SLOT_CAN_INPUT = 11;
|
||||
public final static short SLOT_INVENTORY_1 = 12;
|
||||
public final static short SLOT_INVENTORY_COUNT = 18;
|
||||
@@ -211,6 +213,8 @@ public class MachineCarpenter extends TilePowered implements ISidedInventory, IL
|
||||
public final FilteredTank resourceTank;
|
||||
private final TankManager tankManager;
|
||||
private final TileInventoryAdapter craftingInventory;
|
||||
|
||||
@Nullable
|
||||
public MachineCarpenter.Recipe currentRecipe;
|
||||
public MachineCarpenter.Recipe lastRecipe;
|
||||
public ContainerCarpenter activeContainer;
|
||||
@@ -227,37 +231,8 @@ public class MachineCarpenter extends TilePowered implements ISidedInventory, IL
|
||||
super(1100, 50, 4000);
|
||||
setHints(Config.hints.get("carpenter"));
|
||||
resourceTank = new FilteredTank(Defaults.PROCESSOR_TANK_CAPACITY, RecipeManager.recipeFluids);
|
||||
craftingInventory = new TileInventoryAdapter(this, 10, "CraftItems");
|
||||
setInternalInventory(new TileInventoryAdapter(this, 30, "Items") {
|
||||
@Override
|
||||
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
|
||||
if (slotIndex == SLOT_CAN_INPUT) {
|
||||
Fluid fluid = FluidHelper.getFluidInContainer(itemStack);
|
||||
return tankManager.accepts(fluid);
|
||||
} else if (slotIndex == SLOT_BOX) {
|
||||
return MachineCarpenter.RecipeManager.isBox(itemStack);
|
||||
} else if (canSlotAccept(SLOT_CAN_INPUT, itemStack) || canSlotAccept(SLOT_BOX, itemStack)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return GuiUtil.isIndexInRange(slotIndex, SLOT_INVENTORY_1, SLOT_INVENTORY_COUNT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int slotIndex, ItemStack itemStack) {
|
||||
if (GuiUtil.isIndexInRange(slotIndex, SLOT_INVENTORY_1, SLOT_INVENTORY_COUNT)) {
|
||||
if (lastRecipe != null) {
|
||||
return lastRecipe.isIngredient(itemStack);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int slotIndex, ItemStack itemstack, int side) {
|
||||
return slotIndex == SLOT_PRODUCT;
|
||||
}
|
||||
});
|
||||
craftingInventory = new TileInventoryAdapter<MachineCarpenter>(this, 10, "CraftItems");
|
||||
setInternalInventory(new CarpenterInventoryAdapter(this));
|
||||
InvTools.configureSided(getInternalInventory(), Defaults.FACINGS, SLOT_BOX, 20);
|
||||
|
||||
tankManager = new TankManager(resourceTank);
|
||||
@@ -321,7 +296,7 @@ public class MachineCarpenter extends TilePowered implements ISidedInventory, IL
|
||||
setCurrentRecipe(RecipeManager.findMatchingRecipe(resourceTank.getFluid(), getBoxStack(), container.craftMatrix, worldObj));
|
||||
}
|
||||
|
||||
public void setCurrentRecipe(MachineCarpenter.Recipe currentRecipe) {
|
||||
public void setCurrentRecipe(@Nullable MachineCarpenter.Recipe currentRecipe) {
|
||||
this.currentRecipe = currentRecipe;
|
||||
if (currentRecipe != null) {
|
||||
lastRecipe = currentRecipe;
|
||||
@@ -330,6 +305,7 @@ public class MachineCarpenter extends TilePowered implements ISidedInventory, IL
|
||||
|
||||
@Override
|
||||
public void updateServerSide() {
|
||||
super.updateServerSide();
|
||||
|
||||
if (!updateOnInterval(20)) {
|
||||
return;
|
||||
@@ -349,16 +325,8 @@ public class MachineCarpenter extends TilePowered implements ISidedInventory, IL
|
||||
setCurrentRecipe(MachineCarpenter.RecipeManager.findMatchingRecipe(resourceTank.getFluid(), getBoxStack(), container.craftMatrix, worldObj));
|
||||
}
|
||||
|
||||
if (currentRecipe == null) {
|
||||
setErrorState(EnumErrorCode.NORECIPE);
|
||||
} else if (!validateResources()) {
|
||||
setErrorState(EnumErrorCode.NORESOURCE);
|
||||
} else if (energyManager.getTotalEnergyStored() == 0) {
|
||||
setErrorState(EnumErrorCode.NOPOWER);
|
||||
} else {
|
||||
setErrorState(EnumErrorCode.OK);
|
||||
}
|
||||
|
||||
setErrorCondition(currentRecipe == null, EnumErrorCode.NORECIPE);
|
||||
setErrorCondition(!validateResources(), EnumErrorCode.NORESOURCE);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -420,6 +388,9 @@ public class MachineCarpenter extends TilePowered implements ISidedInventory, IL
|
||||
}
|
||||
|
||||
private boolean validateResources() {
|
||||
if (currentRecipe == null) {
|
||||
return true;
|
||||
}
|
||||
// Check whether liquid is needed and if there is enough available
|
||||
if (currentRecipe.liquid != null) {
|
||||
if (resourceTank.getFluidAmount() < currentRecipe.liquid.amount) {
|
||||
@@ -469,22 +440,18 @@ public class MachineCarpenter extends TilePowered implements ISidedInventory, IL
|
||||
}
|
||||
|
||||
private boolean tryAddPending() {
|
||||
IInventoryAdapter accessibleInventory = getInternalInventory();
|
||||
if (accessibleInventory.getStackInSlot(SLOT_PRODUCT) == null) {
|
||||
accessibleInventory.setInventorySlotContents(SLOT_PRODUCT, pendingProduct.copy());
|
||||
pendingProduct = null;
|
||||
return true;
|
||||
if (pendingProduct == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (accessibleInventory.getStackInSlot(SLOT_PRODUCT).isItemEqual(pendingProduct)
|
||||
&& accessibleInventory.getStackInSlot(SLOT_PRODUCT).stackSize <= accessibleInventory.getStackInSlot(SLOT_PRODUCT).getMaxStackSize() - pendingProduct.stackSize) {
|
||||
accessibleInventory.getStackInSlot(SLOT_PRODUCT).stackSize += pendingProduct.stackSize;
|
||||
boolean added = InvTools.tryAddStack(this, pendingProduct, SLOT_PRODUCT, SLOT_PRODUCT_COUNT, true);
|
||||
|
||||
if (added) {
|
||||
pendingProduct = null;
|
||||
return true;
|
||||
}
|
||||
|
||||
setErrorState(EnumErrorCode.NOSPACE);
|
||||
return false;
|
||||
setErrorCondition(!added, EnumErrorCode.NOSPACE);
|
||||
return added;
|
||||
}
|
||||
|
||||
/* STATE INFORMATION */
|
||||
@@ -596,4 +563,38 @@ public class MachineCarpenter extends TilePowered implements ISidedInventory, IL
|
||||
setCurrentRecipe(RecipeManager.findMatchingRecipe(resourceTank.getFluid(), getBoxStack(), craftMatrix, getWorldObj()));
|
||||
}
|
||||
|
||||
private static class CarpenterInventoryAdapter extends TileInventoryAdapter<MachineCarpenter> {
|
||||
public CarpenterInventoryAdapter(MachineCarpenter carpenter) {
|
||||
super(carpenter, 30, "Items");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
|
||||
if (slotIndex == SLOT_CAN_INPUT) {
|
||||
Fluid fluid = FluidHelper.getFluidInContainer(itemStack);
|
||||
return tile.tankManager.accepts(fluid);
|
||||
} else if (slotIndex == SLOT_BOX) {
|
||||
return RecipeManager.isBox(itemStack);
|
||||
} else if (canSlotAccept(SLOT_CAN_INPUT, itemStack) || canSlotAccept(SLOT_BOX, itemStack)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return GuiUtil.isIndexInRange(slotIndex, SLOT_INVENTORY_1, SLOT_INVENTORY_COUNT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int slotIndex, ItemStack itemStack) {
|
||||
if (GuiUtil.isIndexInRange(slotIndex, SLOT_INVENTORY_1, SLOT_INVENTORY_COUNT)) {
|
||||
if (tile.lastRecipe != null) {
|
||||
return tile.lastRecipe.isIngredient(itemStack);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int slotIndex, ItemStack itemstack, int side) {
|
||||
return slotIndex == SLOT_PRODUCT;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -149,17 +149,7 @@ public class MachineCentrifuge extends TilePowered implements ISidedInventory {
|
||||
|
||||
public MachineCentrifuge() {
|
||||
super(800, 40, Defaults.MACHINE_MAX_ENERGY);
|
||||
setInternalInventory(new TileInventoryAdapter(this, 10, "Items") {
|
||||
@Override
|
||||
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
|
||||
return slotIndex == SLOT_RESOURCE && RecipeManager.findMatchingRecipe(itemStack) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int slotIndex, ItemStack itemstack, int side) {
|
||||
return GuiUtil.isIndexInRange(slotIndex, SLOT_PRODUCT_1, SLOT_PRODUCT_COUNT);
|
||||
}
|
||||
});
|
||||
setInternalInventory(new CentrifugeInventoryAdapter(this));
|
||||
setHints(Config.hints.get("centrifuge"));
|
||||
}
|
||||
|
||||
@@ -207,6 +197,7 @@ public class MachineCentrifuge extends TilePowered implements ISidedInventory {
|
||||
|
||||
@Override
|
||||
public void updateServerSide() {
|
||||
super.updateServerSide();
|
||||
|
||||
if (!updateOnInterval(20)) {
|
||||
return;
|
||||
@@ -214,9 +205,6 @@ public class MachineCentrifuge extends TilePowered implements ISidedInventory {
|
||||
|
||||
// Check and reset recipe if necessary
|
||||
checkRecipe();
|
||||
if (getErrorState() == EnumErrorCode.NORECIPE && currentRecipe != null) {
|
||||
setErrorState(EnumErrorCode.OK);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -245,7 +233,6 @@ public class MachineCentrifuge extends TilePowered implements ISidedInventory {
|
||||
productionTime--;
|
||||
// Still not done, return
|
||||
if (productionTime > 0) {
|
||||
setErrorState(EnumErrorCode.OK);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -260,26 +247,24 @@ public class MachineCentrifuge extends TilePowered implements ISidedInventory {
|
||||
|
||||
getInternalInventory().decrStackSize(SLOT_RESOURCE, 1);
|
||||
checkRecipe();
|
||||
resetRecipe();
|
||||
resetRecipeTimes();
|
||||
|
||||
tryAddPending();
|
||||
return true;
|
||||
}
|
||||
|
||||
public void checkRecipe() {
|
||||
Recipe sameRec = RecipeManager.findMatchingRecipe(getInternalInventory().getStackInSlot(SLOT_RESOURCE));
|
||||
Recipe machingRecipe = RecipeManager.findMatchingRecipe(getInternalInventory().getStackInSlot(SLOT_RESOURCE));
|
||||
|
||||
if (sameRec == null) {
|
||||
setErrorState(EnumErrorCode.NORECIPE);
|
||||
if (currentRecipe != machingRecipe) {
|
||||
currentRecipe = machingRecipe;
|
||||
resetRecipeTimes();
|
||||
}
|
||||
|
||||
if (currentRecipe != sameRec) {
|
||||
currentRecipe = sameRec;
|
||||
resetRecipe();
|
||||
}
|
||||
setErrorCondition(currentRecipe == null, EnumErrorCode.NORECIPE);
|
||||
}
|
||||
|
||||
private void resetRecipe() {
|
||||
private void resetRecipeTimes() {
|
||||
if (currentRecipe == null) {
|
||||
productionTime = 0;
|
||||
timePerItem = 0;
|
||||
@@ -296,17 +281,15 @@ public class MachineCentrifuge extends TilePowered implements ISidedInventory {
|
||||
}
|
||||
|
||||
ItemStack next = pendingProducts.peek();
|
||||
if (addProduct(next, true)) {
|
||||
|
||||
boolean added = InvTools.tryAddStack(this, next, SLOT_PRODUCT_1, SLOT_PRODUCT_COUNT, true);
|
||||
|
||||
if (added) {
|
||||
pendingProducts.pop();
|
||||
return true;
|
||||
}
|
||||
|
||||
setErrorState(EnumErrorCode.NOSPACE);
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean addProduct(ItemStack product, boolean all) {
|
||||
return InvTools.tryAddStack(getInternalInventory(), product, 1, getSizeInventory() - 1, all);
|
||||
setErrorCondition(!added, EnumErrorCode.NOSPACE);
|
||||
return added;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -363,4 +346,20 @@ public class MachineCentrifuge extends TilePowered implements ISidedInventory {
|
||||
res.add(FactoryTriggers.lowResource10);
|
||||
return res;
|
||||
}
|
||||
|
||||
private static class CentrifugeInventoryAdapter extends TileInventoryAdapter<MachineCentrifuge> {
|
||||
public CentrifugeInventoryAdapter(MachineCentrifuge centrifuge) {
|
||||
super(centrifuge, 10, "Items");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
|
||||
return slotIndex == SLOT_RESOURCE && RecipeManager.findMatchingRecipe(itemStack) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int slotIndex, ItemStack itemstack, int side) {
|
||||
return GuiUtil.isIndexInRange(slotIndex, SLOT_PRODUCT_1, SLOT_PRODUCT_COUNT);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -242,23 +242,8 @@ public class MachineFabricator extends TilePowered implements ICrafter, ILiquidT
|
||||
|
||||
public MachineFabricator() {
|
||||
super(1100, 50, 3300);
|
||||
craftingInventory = new TileInventoryAdapter(this, SLOT_CRAFTING_COUNT, "CraftItems");
|
||||
setInternalInventory(new TileInventoryAdapter(this, SLOT_COUNT, "Items") {
|
||||
@Override
|
||||
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
|
||||
if (slotIndex == SLOT_METAL) {
|
||||
return RecipeManager.findMatchingSmelting(itemStack) != null;
|
||||
} else if (slotIndex == SLOT_PLAN) {
|
||||
return RecipeManager.isPlan(itemStack);
|
||||
}
|
||||
return GuiUtil.isIndexInRange(slotIndex, SLOT_INVENTORY_1, SLOT_INVENTORY_COUNT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int slotIndex, ItemStack stack, int side) {
|
||||
return slotIndex == SLOT_RESULT;
|
||||
}
|
||||
});
|
||||
craftingInventory = new TileInventoryAdapter<MachineFabricator>(this, SLOT_CRAFTING_COUNT, "CraftItems");
|
||||
setInternalInventory(new FabricatorInventoryAdapter(this));
|
||||
moltenTank = new FilteredTank(2 * Defaults.BUCKET_VOLUME, Fluids.GLASS.getFluid());
|
||||
moltenTank.tankMode = StandardTank.TankMode.INTERNAL;
|
||||
tankManager = new TankManager(moltenTank);
|
||||
@@ -310,6 +295,7 @@ public class MachineFabricator extends TilePowered implements ICrafter, ILiquidT
|
||||
/* UPDATING */
|
||||
@Override
|
||||
public void updateServerSide() {
|
||||
super.updateServerSide();
|
||||
|
||||
if (!moltenTank.isFull()) {
|
||||
trySmelting();
|
||||
@@ -324,12 +310,6 @@ public class MachineFabricator extends TilePowered implements ICrafter, ILiquidT
|
||||
}
|
||||
|
||||
this.dissipateHeat();
|
||||
|
||||
if (energyManager.getTotalEnergyStored() == 0 && heat == 0) {
|
||||
setErrorState(EnumErrorCode.NOPOWER);
|
||||
} else if (getErrorState() == EnumErrorCode.NOPOWER) {
|
||||
setErrorState(EnumErrorCode.OK);
|
||||
}
|
||||
}
|
||||
|
||||
private void trySmelting() {
|
||||
@@ -583,4 +563,24 @@ public class MachineFabricator extends TilePowered implements ICrafter, ILiquidT
|
||||
return tankManager.getTankInfo(from);
|
||||
}
|
||||
|
||||
private static class FabricatorInventoryAdapter extends TileInventoryAdapter<MachineFabricator> {
|
||||
public FabricatorInventoryAdapter(MachineFabricator fabricator) {
|
||||
super(fabricator, MachineFabricator.SLOT_COUNT, "Items");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
|
||||
if (slotIndex == SLOT_METAL) {
|
||||
return RecipeManager.findMatchingSmelting(itemStack) != null;
|
||||
} else if (slotIndex == SLOT_PLAN) {
|
||||
return RecipeManager.isPlan(itemStack);
|
||||
}
|
||||
return GuiUtil.isIndexInRange(slotIndex, SLOT_INVENTORY_1, SLOT_INVENTORY_COUNT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int slotIndex, ItemStack stack, int side) {
|
||||
return slotIndex == SLOT_RESULT;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -175,27 +175,7 @@ public class MachineFermenter extends TilePowered implements ISidedInventory, IL
|
||||
|
||||
public MachineFermenter() {
|
||||
super(2000, 150, 8000);
|
||||
setInternalInventory(new TileInventoryAdapter(this, 5, "Items") {
|
||||
@Override
|
||||
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
|
||||
if (slotIndex == SLOT_RESOURCE) {
|
||||
return RecipeManager.isResource(itemStack);
|
||||
} else if (slotIndex == SLOT_INPUT) {
|
||||
Fluid fluid = FluidHelper.getFluidInContainer(itemStack);
|
||||
return resourceTank.accepts(fluid);
|
||||
} else if (slotIndex == SLOT_CAN_INPUT) {
|
||||
return FluidHelper.isEmptyContainer(itemStack);
|
||||
} else if (slotIndex == SLOT_FUEL) {
|
||||
return FuelManager.fermenterFuel.containsKey(itemStack);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int slotIndex, ItemStack itemstack, int side) {
|
||||
return slotIndex == SLOT_CAN_OUTPUT;
|
||||
}
|
||||
});
|
||||
setInternalInventory(new FermenterInventoryAdapter(this));
|
||||
setHints(Config.hints.get("fermenter"));
|
||||
resourceTank = new FilteredTank(Defaults.PROCESSOR_TANK_CAPACITY, RecipeManager.recipeFluidInputs);
|
||||
resourceTank.tankMode = StandardTank.TankMode.INPUT;
|
||||
@@ -238,6 +218,7 @@ public class MachineFermenter extends TilePowered implements ISidedInventory, IL
|
||||
|
||||
@Override
|
||||
public void updateServerSide() {
|
||||
super.updateServerSide();
|
||||
|
||||
if (!updateOnInterval(20)) {
|
||||
return;
|
||||
@@ -257,19 +238,14 @@ public class MachineFermenter extends TilePowered implements ISidedInventory, IL
|
||||
}
|
||||
}
|
||||
|
||||
if (RecipeManager.findMatchingRecipe(inventory.getStackInSlot(SLOT_RESOURCE), resourceTank.getFluid()) != null) {
|
||||
if (resourceTank.getFluidAmount() < fuelCurrentFerment) {
|
||||
setErrorState(EnumErrorCode.NORESOURCE);
|
||||
} else {
|
||||
setErrorState(EnumErrorCode.OK);
|
||||
}
|
||||
} else if (inventory.getStackInSlot(SLOT_FUEL) == null && fuelBurnTime <= 0) {
|
||||
setErrorState(EnumErrorCode.NOFUEL);
|
||||
} else if (energyManager.getTotalEnergyStored() == 0) {
|
||||
setErrorState(EnumErrorCode.NOPOWER);
|
||||
} else {
|
||||
setErrorState(EnumErrorCode.NORECIPE);
|
||||
}
|
||||
boolean hasRecipe = RecipeManager.findMatchingRecipe(inventory.getStackInSlot(SLOT_RESOURCE), resourceTank.getFluid()) != null;
|
||||
setErrorCondition(!hasRecipe, EnumErrorCode.NORECIPE);
|
||||
|
||||
boolean hasResource = resourceTank.getFluidAmount() >= fuelCurrentFerment;
|
||||
setErrorCondition(!hasResource, EnumErrorCode.NORESOURCE);
|
||||
|
||||
boolean hasFuel = inventory.getStackInSlot(SLOT_FUEL) != null || fuelBurnTime > 0;
|
||||
setErrorCondition(!hasFuel, EnumErrorCode.NOFUEL);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -576,4 +552,30 @@ public class MachineFermenter extends TilePowered implements ISidedInventory, IL
|
||||
res.add(FactoryTriggers.lowResource10);
|
||||
return res;
|
||||
}
|
||||
|
||||
private static class FermenterInventoryAdapter extends TileInventoryAdapter<MachineFermenter> {
|
||||
public FermenterInventoryAdapter(MachineFermenter fermenter) {
|
||||
super(fermenter, 5, "Items");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
|
||||
if (slotIndex == SLOT_RESOURCE) {
|
||||
return RecipeManager.isResource(itemStack);
|
||||
} else if (slotIndex == SLOT_INPUT) {
|
||||
Fluid fluid = FluidHelper.getFluidInContainer(itemStack);
|
||||
return tile.resourceTank.accepts(fluid);
|
||||
} else if (slotIndex == SLOT_CAN_INPUT) {
|
||||
return FluidHelper.isEmptyContainer(itemStack);
|
||||
} else if (slotIndex == SLOT_FUEL) {
|
||||
return FuelManager.fermenterFuel.containsKey(itemStack);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int slotIndex, ItemStack itemstack, int side) {
|
||||
return slotIndex == SLOT_CAN_OUTPUT;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -134,38 +134,7 @@ public class MachineMoistener extends TileBase implements ISidedInventory, ILiqu
|
||||
private ItemStack pendingProduct;
|
||||
|
||||
public MachineMoistener() {
|
||||
setInternalInventory(new TileInventoryAdapter(this, 12, "Items") {
|
||||
@Override
|
||||
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
|
||||
if (slotIndex == SLOT_RESOURCE) {
|
||||
return RecipeManager.isResource(itemStack);
|
||||
}
|
||||
|
||||
if (GuiUtil.isIndexInRange(slotIndex, SLOT_STASH_1, SLOT_STASH_COUNT)) {
|
||||
return FuelManager.moistenerResource.containsKey(itemStack);
|
||||
}
|
||||
|
||||
if (slotIndex == SLOT_PRODUCT) {
|
||||
Fluid fluid = FluidHelper.getFluidInContainer(itemStack);
|
||||
return resourceTank.accepts(fluid);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int slotIndex, ItemStack itemstack, int side) {
|
||||
if (slotIndex == SLOT_PRODUCT) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (GuiUtil.isIndexInRange(slotIndex, SLOT_STASH_1, SLOT_STASH_COUNT)) {
|
||||
return !FuelManager.moistenerResource.containsKey(itemstack);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
});
|
||||
setInternalInventory(new MoistenerInventoryAdapter(this));
|
||||
setHints(Config.hints.get("moistener"));
|
||||
resourceTank = new FilteredTank(Defaults.PROCESSOR_TANK_CAPACITY, FluidRegistry.WATER);
|
||||
tankManager = new TankManager(resourceTank);
|
||||
@@ -236,8 +205,8 @@ public class MachineMoistener extends TileBase implements ISidedInventory, ILiqu
|
||||
int lightvalue = worldObj.getBlockLightValue(xCoord, yCoord + 1, zCoord);
|
||||
|
||||
// Not working in broad daylight
|
||||
if (lightvalue > 11) {
|
||||
setErrorState(EnumErrorCode.NOTGLOOMY);
|
||||
boolean gloomy = lightvalue <= 11;
|
||||
if (setErrorCondition(!gloomy, EnumErrorCode.NOTGLOOMY)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -256,7 +225,8 @@ public class MachineMoistener extends TileBase implements ISidedInventory, ILiqu
|
||||
// Already running
|
||||
if (burnTime > 0 && pendingProduct == null) {
|
||||
// Not working if there is no water available.
|
||||
if (resourceTank.getFluidAmount() <= 0) {
|
||||
boolean hasLiquid = resourceTank.getFluidAmount() > 0;
|
||||
if (setErrorCondition(!hasLiquid, EnumErrorCode.NORESOURCE)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -281,7 +251,7 @@ public class MachineMoistener extends TileBase implements ISidedInventory, ILiqu
|
||||
tryAddPending();
|
||||
}
|
||||
// Try to start process
|
||||
else // Make sure we have a new item in the working slot.
|
||||
else { // Make sure we have a new item in the working slot.
|
||||
if (rotateWorkingSlot()) {
|
||||
checkRecipe();
|
||||
|
||||
@@ -297,12 +267,9 @@ public class MachineMoistener extends TileBase implements ISidedInventory, ILiqu
|
||||
} else {
|
||||
rotateReservoir();
|
||||
}
|
||||
|
||||
if (currentRecipe != null) {
|
||||
setErrorState(EnumErrorCode.OK);
|
||||
} else {
|
||||
setErrorState(EnumErrorCode.NORECIPE);
|
||||
}
|
||||
|
||||
setErrorCondition(currentRecipe == null, EnumErrorCode.NORECIPE);
|
||||
}
|
||||
|
||||
private boolean tryAddPending() {
|
||||
@@ -310,13 +277,14 @@ public class MachineMoistener extends TileBase implements ISidedInventory, ILiqu
|
||||
return false;
|
||||
}
|
||||
|
||||
IInventoryAdapter inventory = getInternalInventory();
|
||||
if (InvTools.tryAddStack(inventory, pendingProduct, SLOT_PRODUCT, 1, true)) {
|
||||
boolean added = InvTools.tryAddStack(this, pendingProduct, SLOT_PRODUCT, 1, true);
|
||||
setErrorCondition(!added, EnumErrorCode.NOSPACE);
|
||||
|
||||
if (added) {
|
||||
pendingProduct = null;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return added;
|
||||
}
|
||||
|
||||
public void checkRecipe() {
|
||||
@@ -325,6 +293,8 @@ public class MachineMoistener extends TileBase implements ISidedInventory, ILiqu
|
||||
currentRecipe = sameRec;
|
||||
resetRecipe();
|
||||
}
|
||||
|
||||
setErrorCondition(currentRecipe == null, EnumErrorCode.NORECIPE);
|
||||
}
|
||||
|
||||
private void resetRecipe() {
|
||||
@@ -332,21 +302,18 @@ public class MachineMoistener extends TileBase implements ISidedInventory, ILiqu
|
||||
currentProduct = null;
|
||||
productionTime = 0;
|
||||
timePerItem = 0;
|
||||
setErrorState(EnumErrorCode.NORECIPE);
|
||||
return;
|
||||
} else {
|
||||
currentProduct = currentRecipe.product;
|
||||
productionTime = currentRecipe.timePerItem;
|
||||
timePerItem = currentRecipe.timePerItem;
|
||||
}
|
||||
|
||||
currentProduct = currentRecipe.product;
|
||||
productionTime = currentRecipe.timePerItem;
|
||||
timePerItem = currentRecipe.timePerItem;
|
||||
}
|
||||
|
||||
private int getFreeSlot(ItemStack deposit, int startSlot, int endSlot, boolean emptyOnly) {
|
||||
int slot = -1;
|
||||
|
||||
IInventoryAdapter inventory = getInternalInventory();
|
||||
for (int i = startSlot; i < endSlot; i++) {
|
||||
ItemStack slotStack = inventory.getStackInSlot(i);
|
||||
ItemStack slotStack = getStackInSlot(i);
|
||||
// Empty slots are okay.
|
||||
if (slotStack == null) {
|
||||
if (slot < 0) {
|
||||
@@ -420,7 +387,7 @@ public class MachineMoistener extends TileBase implements ISidedInventory, ILiqu
|
||||
|
||||
int targetSlot = getFreeReservoirSlot(deposit);
|
||||
// We stop the whole thing, if we don't have any room anymore.
|
||||
if (targetSlot < 0) {
|
||||
if (setErrorCondition(targetSlot < 0, EnumErrorCode.NOSPACE)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -440,7 +407,7 @@ public class MachineMoistener extends TileBase implements ISidedInventory, ILiqu
|
||||
// Let's look for a new resource to put into the working slot.
|
||||
int resourceSlot = getNextResourceSlot(SLOT_RESERVOIR_1, SLOT_RESERVOIR_1 + SLOT_RESERVOIR_COUNT);
|
||||
// Nothing found, stop.
|
||||
if (resourceSlot < 0) {
|
||||
if (setErrorCondition(resourceSlot < 0, EnumErrorCode.NORESOURCE)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -451,14 +418,12 @@ public class MachineMoistener extends TileBase implements ISidedInventory, ILiqu
|
||||
private void rotateReservoir() {
|
||||
ArrayList<Integer> slotsToShift = new ArrayList<Integer>();
|
||||
|
||||
IInventoryAdapter inventory = getInternalInventory();
|
||||
|
||||
for (int i = SLOT_RESERVOIR_1; i < SLOT_RESERVOIR_1 + SLOT_RESERVOIR_COUNT; i++) {
|
||||
if (inventory.getStackInSlot(i) == null) {
|
||||
if (getStackInSlot(i) == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!FuelManager.moistenerResource.containsKey(inventory.getStackInSlot(i))) {
|
||||
if (!FuelManager.moistenerResource.containsKey(getStackInSlot(i))) {
|
||||
slotsToShift.add(i);
|
||||
}
|
||||
}
|
||||
@@ -466,14 +431,14 @@ public class MachineMoistener extends TileBase implements ISidedInventory, ILiqu
|
||||
// Move consumed items back to stash
|
||||
int shiftedSlots = 0;
|
||||
for (int slot : slotsToShift) {
|
||||
ItemStack slotStack = inventory.getStackInSlot(slot);
|
||||
ItemStack slotStack = getStackInSlot(slot);
|
||||
int targetSlot = getFreeStashSlot(slotStack, true);
|
||||
if (targetSlot < 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
inventory.setInventorySlotContents(targetSlot, slotStack);
|
||||
inventory.setInventorySlotContents(slot, null);
|
||||
setInventorySlotContents(targetSlot, slotStack);
|
||||
setInventorySlotContents(slot, null);
|
||||
shiftedSlots++;
|
||||
}
|
||||
|
||||
@@ -484,19 +449,19 @@ public class MachineMoistener extends TileBase implements ISidedInventory, ILiqu
|
||||
if (resourceSlot < 0) {
|
||||
break;
|
||||
}
|
||||
int targetSlot = getFreeReservoirSlot(inventory.getStackInSlot(resourceSlot));
|
||||
int targetSlot = getFreeReservoirSlot(getStackInSlot(resourceSlot));
|
||||
// No free target slot, stop
|
||||
if (targetSlot < 0) {
|
||||
break;
|
||||
}
|
||||
// Else shift
|
||||
if (inventory.getStackInSlot(targetSlot) == null) {
|
||||
inventory.setInventorySlotContents(targetSlot, inventory.getStackInSlot(resourceSlot));
|
||||
inventory.setInventorySlotContents(resourceSlot, null);
|
||||
if (getStackInSlot(targetSlot) == null) {
|
||||
setInventorySlotContents(targetSlot, getStackInSlot(resourceSlot));
|
||||
setInventorySlotContents(resourceSlot, null);
|
||||
} else {
|
||||
StackUtils.mergeStacks(inventory.getStackInSlot(resourceSlot), inventory.getStackInSlot(targetSlot));
|
||||
if (inventory.getStackInSlot(resourceSlot) != null && inventory.getStackInSlot(resourceSlot).stackSize <= 0) {
|
||||
inventory.setInventorySlotContents(resourceSlot, null);
|
||||
StackUtils.mergeStacks(getStackInSlot(resourceSlot), getStackInSlot(targetSlot));
|
||||
if (getStackInSlot(resourceSlot) != null && getStackInSlot(resourceSlot).stackSize <= 0) {
|
||||
setInventorySlotContents(resourceSlot, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -640,4 +605,40 @@ public class MachineMoistener extends TileBase implements ISidedInventory, ILiqu
|
||||
iCrafting.sendProgressBarUpdate(container, i + 3, timePerItem);
|
||||
}
|
||||
|
||||
private static class MoistenerInventoryAdapter extends TileInventoryAdapter<MachineMoistener> {
|
||||
public MoistenerInventoryAdapter(MachineMoistener moistener) {
|
||||
super(moistener, 12, "Items");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
|
||||
if (slotIndex == SLOT_RESOURCE) {
|
||||
return RecipeManager.isResource(itemStack);
|
||||
}
|
||||
|
||||
if (GuiUtil.isIndexInRange(slotIndex, SLOT_STASH_1, SLOT_STASH_COUNT)) {
|
||||
return FuelManager.moistenerResource.containsKey(itemStack);
|
||||
}
|
||||
|
||||
if (slotIndex == SLOT_PRODUCT) {
|
||||
Fluid fluid = FluidHelper.getFluidInContainer(itemStack);
|
||||
return tile.resourceTank.accepts(fluid);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int slotIndex, ItemStack itemstack, int side) {
|
||||
if (slotIndex == SLOT_PRODUCT) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (GuiUtil.isIndexInRange(slotIndex, SLOT_STASH_1, SLOT_STASH_COUNT)) {
|
||||
return !FuelManager.moistenerResource.containsKey(itemstack);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -56,20 +56,7 @@ public class MachineRaintank extends TileBase implements ISidedInventory, ILiqui
|
||||
private ItemStack usedEmpty;
|
||||
|
||||
public MachineRaintank() {
|
||||
setInternalInventory(new TileInventoryAdapter(this, 3, "Items") {
|
||||
@Override
|
||||
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
|
||||
if (slotIndex == SLOT_RESOURCE) {
|
||||
return FluidHelper.isFillableContainer(itemStack, Fluids.WATER.getFluid(1000));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int slotIndex, ItemStack itemstack, int side) {
|
||||
return slotIndex == SLOT_PRODUCT;
|
||||
}
|
||||
});
|
||||
setInternalInventory(new RaintankInventoryAdapter(this));
|
||||
setHints(Config.hints.get("raintank"));
|
||||
|
||||
resourceTank = new FilteredTank(Defaults.RAINTANK_TANK_CAPACITY, FluidRegistry.WATER);
|
||||
@@ -78,13 +65,11 @@ public class MachineRaintank extends TileBase implements ISidedInventory, ILiqui
|
||||
|
||||
@Override
|
||||
public void validate() {
|
||||
// Raintanks in desert and snow biomes are useless
|
||||
// Raintanks in desert biomes are useless
|
||||
if (worldObj != null) {
|
||||
BiomeGenBase biome = Utils.getBiomeAt(worldObj, xCoord, zCoord);
|
||||
if (!BiomeHelper.canRainOrSnow(biome)) {
|
||||
setErrorState(EnumErrorCode.INVALIDBIOME);
|
||||
isValidBiome = false;
|
||||
}
|
||||
isValidBiome = BiomeHelper.canRainOrSnow(biome);
|
||||
setErrorCondition(!isValidBiome, EnumErrorCode.INVALIDBIOME);
|
||||
}
|
||||
|
||||
super.validate();
|
||||
@@ -120,32 +105,31 @@ public class MachineRaintank extends TileBase implements ISidedInventory, ILiqui
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isValidBiome) {
|
||||
setErrorState(EnumErrorCode.INVALIDBIOME);
|
||||
} else if (!worldObj.canBlockSeeTheSky(xCoord, yCoord + 1, zCoord)) {
|
||||
setErrorState(EnumErrorCode.NOSKY);
|
||||
} else if (!worldObj.isRaining()) {
|
||||
setErrorState(EnumErrorCode.NOTRAINING);
|
||||
} else {
|
||||
setErrorCondition(!isValidBiome, EnumErrorCode.INVALIDBIOME);
|
||||
|
||||
boolean hasSky = worldObj.canBlockSeeTheSky(xCoord, yCoord + 1, zCoord);
|
||||
setErrorCondition(!hasSky, EnumErrorCode.NOSKY);
|
||||
|
||||
setErrorCondition(!worldObj.isRaining(), EnumErrorCode.NOTRAINING);
|
||||
|
||||
if (!hasErrorState()) {
|
||||
resourceTank.fill(STACK_WATER, true);
|
||||
setErrorState(EnumErrorCode.OK);
|
||||
}
|
||||
|
||||
IInventoryAdapter inventory = getInternalInventory();
|
||||
if (!StackUtils.isIdenticalItem(usedEmpty, inventory.getStackInSlot(SLOT_RESOURCE))) {
|
||||
if (!StackUtils.isIdenticalItem(usedEmpty, getStackInSlot(SLOT_RESOURCE))) {
|
||||
fillingTime = 0;
|
||||
usedEmpty = null;
|
||||
}
|
||||
|
||||
if (usedEmpty == null) {
|
||||
usedEmpty = inventory.getStackInSlot(SLOT_RESOURCE);
|
||||
usedEmpty = getStackInSlot(SLOT_RESOURCE);
|
||||
}
|
||||
|
||||
if (!isFilling()) {
|
||||
tryToStartFillling();
|
||||
} else {
|
||||
fillingTime--;
|
||||
if (fillingTime <= 0 && FluidHelper.fillContainers(tankManager, inventory, SLOT_RESOURCE, SLOT_PRODUCT, Fluids.WATER.getFluid())) {
|
||||
if (fillingTime <= 0 && FluidHelper.fillContainers(tankManager, this, SLOT_RESOURCE, SLOT_PRODUCT, Fluids.WATER.getFluid())) {
|
||||
fillingTime = 0;
|
||||
}
|
||||
}
|
||||
@@ -221,4 +205,22 @@ public class MachineRaintank extends TileBase implements ISidedInventory, ILiqui
|
||||
return tankManager.getTankInfo(from);
|
||||
}
|
||||
|
||||
private static class RaintankInventoryAdapter extends TileInventoryAdapter<MachineRaintank> {
|
||||
public RaintankInventoryAdapter(MachineRaintank raintank) {
|
||||
super(raintank, 3, "Items");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
|
||||
if (slotIndex == SLOT_RESOURCE) {
|
||||
return FluidHelper.isFillableContainer(itemStack, Fluids.WATER.getFluid(1000));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int slotIndex, ItemStack itemstack, int side) {
|
||||
return slotIndex == SLOT_PRODUCT;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -148,31 +148,7 @@ public class MachineSqueezer extends TilePowered implements ISidedInventory, ILi
|
||||
|
||||
public MachineSqueezer() {
|
||||
super(1100, 50, 4000);
|
||||
setInternalInventory(new TileInventoryAdapter(this, 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;
|
||||
}
|
||||
});
|
||||
setInternalInventory(new SqueezerInventoryAdapter(this));
|
||||
setHints(Config.hints.get("squeezer"));
|
||||
productTank = new FilteredTank(Defaults.PROCESSOR_TANK_CAPACITY, RecipeManager.recipeFluids);
|
||||
productTank.tankMode = StandardTank.TankMode.OUTPUT;
|
||||
@@ -209,6 +185,7 @@ public class MachineSqueezer extends TilePowered implements ISidedInventory, ILi
|
||||
// / WORKING
|
||||
@Override
|
||||
public void updateServerSide() {
|
||||
super.updateServerSide();
|
||||
|
||||
if (!updateOnInterval(20)) {
|
||||
return;
|
||||
@@ -224,31 +201,29 @@ public class MachineSqueezer extends TilePowered implements ISidedInventory, ILi
|
||||
}
|
||||
|
||||
checkRecipe();
|
||||
if (getErrorState() == EnumErrorCode.NORECIPE && currentRecipe != null) {
|
||||
setErrorState(EnumErrorCode.OK);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean workCycle() {
|
||||
|
||||
checkRecipe();
|
||||
|
||||
if (getErrorState() == EnumErrorCode.NORECIPE) {
|
||||
if (!checkRecipe()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
FluidStack resultFluid = currentRecipe.liquid.copy();
|
||||
if (productTank.fill(resultFluid, false) < resultFluid.amount) {
|
||||
setErrorState(EnumErrorCode.NOSPACETANK);
|
||||
FluidStack resultFluid = currentRecipe.liquid;
|
||||
boolean canFill = productTank.fill(resultFluid, false) == resultFluid.amount;
|
||||
setErrorCondition(!canFill, EnumErrorCode.NOSPACETANK);
|
||||
|
||||
if (!canFill) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ItemStack remnant = null;
|
||||
if (currentRecipe.remnants != null) {
|
||||
remnant = currentRecipe.remnants.copy();
|
||||
if (!InvTools.tryAddStack(getInternalInventory(), remnant, SLOT_REMNANT, SLOT_REMNANT_COUNT, true, false)) {
|
||||
setErrorState(EnumErrorCode.NOSPACE);
|
||||
boolean canAdd = InvTools.tryAddStack(getInternalInventory(), remnant, SLOT_REMNANT, SLOT_REMNANT_COUNT, true, false);
|
||||
setErrorCondition(!canAdd, EnumErrorCode.NOSPACE);
|
||||
if (!canAdd) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -264,7 +239,6 @@ public class MachineSqueezer extends TilePowered implements ISidedInventory, ILi
|
||||
productionTime--;
|
||||
// Still not done, return
|
||||
if (productionTime > 0) {
|
||||
setErrorState(EnumErrorCode.OK);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -277,29 +251,26 @@ public class MachineSqueezer extends TilePowered implements ISidedInventory, ILi
|
||||
InvTools.tryAddStack(getInternalInventory(), remnant, SLOT_REMNANT, SLOT_REMNANT_COUNT, true);
|
||||
}
|
||||
|
||||
setErrorState(EnumErrorCode.OK);
|
||||
|
||||
checkRecipe();
|
||||
resetRecipe();
|
||||
resetRecipeTimes();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void checkRecipe() {
|
||||
private boolean checkRecipe() {
|
||||
ItemStack[] resources = InvTools.getStacks(getInternalInventory(), SLOT_RESOURCE_1, SLOTS_RESOURCE_COUNT);
|
||||
Recipe sameRec = RecipeManager.findMatchingRecipe(resources);
|
||||
Recipe matchingRecipe = RecipeManager.findMatchingRecipe(resources);
|
||||
|
||||
if (sameRec == null) {
|
||||
setErrorState(EnumErrorCode.NORECIPE);
|
||||
if (currentRecipe != matchingRecipe) {
|
||||
currentRecipe = matchingRecipe;
|
||||
resetRecipeTimes();
|
||||
}
|
||||
|
||||
if (currentRecipe != sameRec) {
|
||||
currentRecipe = sameRec;
|
||||
resetRecipe();
|
||||
}
|
||||
setErrorCondition(currentRecipe == null, EnumErrorCode.NORECIPE);
|
||||
return currentRecipe != null;
|
||||
}
|
||||
|
||||
private void resetRecipe() {
|
||||
private void resetRecipeTimes() {
|
||||
if (currentRecipe == null) {
|
||||
productionTime = 0;
|
||||
timePerItem = 0;
|
||||
@@ -398,4 +369,34 @@ public class MachineSqueezer extends TilePowered implements ISidedInventory, ILi
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -129,23 +129,7 @@ public class MachineStill extends TilePowered implements ISidedInventory, ILiqui
|
||||
|
||||
public MachineStill() {
|
||||
super(1100, 50, 8000);
|
||||
setInternalInventory(new TileInventoryAdapter(this, 3, "Items") {
|
||||
@Override
|
||||
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
|
||||
if (slotIndex == SLOT_RESOURCE) {
|
||||
return FluidHelper.isEmptyContainer(itemStack);
|
||||
} else if (slotIndex == SLOT_CAN) {
|
||||
Fluid fluid = FluidHelper.getFluidInContainer(itemStack);
|
||||
return resourceTank.accepts(fluid);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int slotIndex, ItemStack itemstack, int side) {
|
||||
return slotIndex == SLOT_PRODUCT;
|
||||
}
|
||||
});
|
||||
setInternalInventory(new StillInventoryAdapter(this));
|
||||
setHints(Config.hints.get("still"));
|
||||
resourceTank = new FilteredTank(Defaults.PROCESSOR_TANK_CAPACITY, RecipeManager.recipeFluidInputs);
|
||||
resourceTank.tankMode = StandardTank.TankMode.INPUT;
|
||||
@@ -183,6 +167,7 @@ public class MachineStill extends TilePowered implements ISidedInventory, ILiqui
|
||||
|
||||
@Override
|
||||
public void updateServerSide() {
|
||||
super.updateServerSide();
|
||||
|
||||
if (!updateOnInterval(20)) {
|
||||
return;
|
||||
@@ -203,13 +188,6 @@ public class MachineStill extends TilePowered implements ISidedInventory, ILiqui
|
||||
}
|
||||
|
||||
checkRecipe();
|
||||
if (getErrorState() == EnumErrorCode.NORECIPE && currentRecipe != null) {
|
||||
setErrorState(EnumErrorCode.OK);
|
||||
}
|
||||
|
||||
if (energyManager.getTotalEnergyStored() == 0) {
|
||||
setErrorState(EnumErrorCode.NOPOWER);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -218,29 +196,29 @@ public class MachineStill extends TilePowered implements ISidedInventory, ILiqui
|
||||
checkRecipe();
|
||||
|
||||
// Ongoing process
|
||||
if (distillationTime > 0 && currentRecipe != null) {
|
||||
if (distillationTime > 0 && !hasErrorState()) {
|
||||
|
||||
distillationTime -= currentRecipe.input.amount;
|
||||
productTank.fill(currentRecipe.output, true);
|
||||
|
||||
setErrorState(EnumErrorCode.OK);
|
||||
return true;
|
||||
|
||||
} else if (currentRecipe != null) {
|
||||
|
||||
int resourceRequired = currentRecipe.timePerUnit * currentRecipe.input.amount;
|
||||
|
||||
if (productTank.fill(currentRecipe.output, false) < currentRecipe.output.amount) {
|
||||
setErrorState(EnumErrorCode.NOSPACETANK);
|
||||
} else if (resourceTank.getFluidAmount() < resourceRequired) {
|
||||
setErrorState(EnumErrorCode.NORESOURCE);
|
||||
} else {
|
||||
boolean canFill = productTank.fill(currentRecipe.output, false) == currentRecipe.output.amount;
|
||||
setErrorCondition(!canFill, EnumErrorCode.NOSPACETANK);
|
||||
|
||||
boolean hasResource = resourceTank.getFluidAmount() >= resourceRequired;
|
||||
setErrorCondition(!hasResource, EnumErrorCode.NORESOURCE);
|
||||
|
||||
if (!hasErrorState()) {
|
||||
// Start next cycle if enough bio mass is available
|
||||
distillationTime = distillationTotalTime = resourceRequired;
|
||||
resourceTank.drain(resourceRequired, true);
|
||||
bufferedLiquid = new FluidStack(currentRecipe.input, resourceRequired);
|
||||
|
||||
setErrorState(EnumErrorCode.OK);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -250,23 +228,17 @@ public class MachineStill extends TilePowered implements ISidedInventory, ILiqui
|
||||
}
|
||||
|
||||
public void checkRecipe() {
|
||||
Recipe sameRec = RecipeManager.findMatchingRecipe(resourceTank.getFluid());
|
||||
Recipe matchingRecipe = RecipeManager.findMatchingRecipe(resourceTank.getFluid());
|
||||
|
||||
if (sameRec == null && bufferedLiquid != null && distillationTime > 0) {
|
||||
sameRec = RecipeManager.findMatchingRecipe(new FluidStack(bufferedLiquid, distillationTime));
|
||||
if (matchingRecipe == null && bufferedLiquid != null && distillationTime > 0) {
|
||||
matchingRecipe = RecipeManager.findMatchingRecipe(new FluidStack(bufferedLiquid, distillationTime));
|
||||
}
|
||||
|
||||
if (sameRec == null) {
|
||||
setErrorState(EnumErrorCode.NORECIPE);
|
||||
if (currentRecipe != matchingRecipe) {
|
||||
currentRecipe = matchingRecipe;
|
||||
}
|
||||
|
||||
if (currentRecipe != sameRec) {
|
||||
currentRecipe = sameRec;
|
||||
resetRecipe();
|
||||
}
|
||||
}
|
||||
|
||||
private void resetRecipe() {
|
||||
setErrorCondition(currentRecipe == null, EnumErrorCode.NORECIPE);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -367,4 +339,25 @@ public class MachineStill extends TilePowered implements ISidedInventory, ILiqui
|
||||
return tankManager.getTankInfo(from);
|
||||
}
|
||||
|
||||
private static class StillInventoryAdapter extends TileInventoryAdapter<MachineStill> {
|
||||
public StillInventoryAdapter(MachineStill still) {
|
||||
super(still, 3, "Items");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
|
||||
if (slotIndex == SLOT_RESOURCE) {
|
||||
return FluidHelper.isEmptyContainer(itemStack);
|
||||
} else if (slotIndex == SLOT_CAN) {
|
||||
Fluid fluid = FluidHelper.getFluidInContainer(itemStack);
|
||||
return tile.resourceTank.accepts(fluid);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int slotIndex, ItemStack itemstack, int side) {
|
||||
return slotIndex == SLOT_PRODUCT;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -49,7 +49,7 @@ public class TileWorktable extends TileBase implements ICrafter {
|
||||
private final TileInventoryAdapter craftingInventory;
|
||||
|
||||
public TileWorktable() {
|
||||
craftingInventory = new TileInventoryAdapter(this, 10, "CraftItems");
|
||||
craftingInventory = new TileInventoryAdapter<TileWorktable>(this, 10, "CraftItems");
|
||||
setInternalInventory(new WorktableInventoryAdapter(this));
|
||||
|
||||
memorized = new RecipeMemory();
|
||||
@@ -208,7 +208,7 @@ public class TileWorktable extends TileBase implements ICrafter {
|
||||
return craftingInventory;
|
||||
}
|
||||
|
||||
private static class WorktableInventoryAdapter extends TileInventoryAdapter {
|
||||
private static class WorktableInventoryAdapter extends TileInventoryAdapter<TileWorktable> {
|
||||
public WorktableInventoryAdapter(TileWorktable worktable) {
|
||||
super(worktable, 18, "Items");
|
||||
}
|
||||
|
||||
@@ -94,26 +94,11 @@ public abstract class TileFarm extends TileForestry implements IFarmComponent {
|
||||
public void initialize() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
super.updateEntity();
|
||||
|
||||
if (!Proxies.common.isSimulating(worldObj)) {
|
||||
updateClientSide();
|
||||
} else {
|
||||
// Periodic validation if needed
|
||||
if (updateOnInterval(200) && (!isIntegratedIntoStructure() || isMaster())) {
|
||||
validateStructure();
|
||||
}
|
||||
|
||||
updateServerSide();
|
||||
}
|
||||
}
|
||||
|
||||
protected void updateServerSide() {
|
||||
}
|
||||
|
||||
protected void updateClientSide() {
|
||||
// Periodic validation if needed
|
||||
if (updateOnInterval(200) && (!isIntegratedIntoStructure() || isMaster())) {
|
||||
validateStructure();
|
||||
}
|
||||
}
|
||||
|
||||
/* CONSTRUCTION MATERIAL */
|
||||
|
||||
@@ -217,7 +217,6 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable
|
||||
|
||||
private void setBiomeInformation() {
|
||||
this.biome = Utils.getBiomeAt(worldObj, xCoord, zCoord);
|
||||
setErrorState(EnumErrorCode.OK);
|
||||
}
|
||||
|
||||
private static TreeMap<ForgeDirection, List<FarmTarget>> createTargets(World world, Vect targetStart, final int allowedExtent, final int farmSizeNorthSouth, final int farmSizeEastWest) {
|
||||
@@ -296,27 +295,7 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable
|
||||
}
|
||||
|
||||
protected void createInventory() {
|
||||
setInternalInventory(new TileInventoryAdapter(this, SLOT_COUNT, "Items") {
|
||||
@Override
|
||||
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
|
||||
if (GuiUtil.isIndexInRange(slotIndex, SLOT_FERTILIZER, SLOT_FERTILIZER_COUNT)) {
|
||||
return acceptsAsFertilizer(itemStack);
|
||||
} else if (GuiUtil.isIndexInRange(slotIndex, SLOT_GERMLINGS_1, SLOT_GERMLINGS_COUNT)) {
|
||||
return acceptsAsGermling(itemStack);
|
||||
} else if (GuiUtil.isIndexInRange(slotIndex, SLOT_RESOURCES_1, SLOT_RESOURCES_COUNT)) {
|
||||
return acceptsAsResource(itemStack);
|
||||
} else if (GuiUtil.isIndexInRange(slotIndex, SLOT_CAN, SLOT_CAN_COUNT)) {
|
||||
Fluid fluid = FluidHelper.getFluidInContainer(itemStack);
|
||||
return tankManager.accepts(fluid);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int slotIndex, ItemStack stack, int side) {
|
||||
return GuiUtil.isIndexInRange(slotIndex, SLOT_PRODUCTION_1, SLOT_PRODUCTION_COUNT);
|
||||
}
|
||||
});
|
||||
setInternalInventory(new FarmPlainInventoryAdapter(this));
|
||||
FilteredTank liquidTank = new FilteredTank(Defaults.PROCESSOR_TANK_CAPACITY, FluidRegistry.WATER);
|
||||
tankManager = new TankManager(liquidTank);
|
||||
}
|
||||
@@ -344,16 +323,14 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable
|
||||
|
||||
// System.out.println("Nothing pending added.");
|
||||
// Abort if we still have produce waiting.
|
||||
if (!pendingProduce.isEmpty()) {
|
||||
setErrorState(EnumErrorCode.NOSPACE);
|
||||
if (setErrorCondition(!pendingProduce.isEmpty(), EnumErrorCode.NOSPACE)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// System.out.println("Product queue empty.");
|
||||
if (storedFertilizer <= BUFFER_FERTILIZER) {
|
||||
replenishFertilizer();
|
||||
if (storedFertilizer <= 0) {
|
||||
setErrorState(EnumErrorCode.NOFERTILIZER);
|
||||
if (setErrorCondition(storedFertilizer <= 0, EnumErrorCode.NOFERTILIZER)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -402,15 +379,11 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable
|
||||
}
|
||||
}
|
||||
|
||||
if (farmWorkStatus.didWork) {
|
||||
setErrorState(EnumErrorCode.OK);
|
||||
} else if (stage == Stage.CULTIVATE) {
|
||||
if (!farmWorkStatus.hasFarmland) {
|
||||
setErrorState(EnumErrorCode.NOFARMLAND);
|
||||
} else if (!farmWorkStatus.hasFertilizer) {
|
||||
setErrorState(EnumErrorCode.NOFERTILIZER);
|
||||
} else if (!farmWorkStatus.hasLiquid) {
|
||||
setErrorState(EnumErrorCode.NOLIQUID);
|
||||
if (!farmWorkStatus.didWork) {
|
||||
if (stage == Stage.CULTIVATE) {
|
||||
setErrorCondition(!farmWorkStatus.hasFarmland, EnumErrorCode.NOFARMLAND);
|
||||
setErrorCondition(!farmWorkStatus.hasFertilizer, EnumErrorCode.NOFERTILIZER);
|
||||
setErrorCondition(!farmWorkStatus.hasLiquid, EnumErrorCode.NOLIQUID);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -574,15 +547,16 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable
|
||||
}
|
||||
|
||||
// Check fertilizer
|
||||
if (!hasFertilizer(provider.getFertilizerConsumption())) {
|
||||
setErrorState(EnumErrorCode.NOFERTILIZER);
|
||||
Boolean hasFertilizer = hasFertilizer(provider.getFertilizerConsumption());
|
||||
if (setErrorCondition(!hasFertilizer, EnumErrorCode.NOFERTILIZER)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check water
|
||||
FluidStack liquid = Fluids.WATER.getFluid(provider.getWaterConsumption(getHydrationModifier()));
|
||||
if (liquid.amount > 0 && !hasLiquid(liquid)) {
|
||||
setErrorState(EnumErrorCode.NOLIQUID);
|
||||
FluidStack requiredLiquid = Fluids.WATER.getFluid(provider.getWaterConsumption(getHydrationModifier()));
|
||||
boolean hasLiquid = requiredLiquid.amount == 0 || hasLiquid(requiredLiquid);
|
||||
|
||||
if (setErrorCondition(!hasLiquid, EnumErrorCode.NOLIQUID)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -594,7 +568,7 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable
|
||||
|
||||
// Remove fertilizer and water
|
||||
removeFertilizer(provider.getFertilizerConsumption());
|
||||
removeLiquid(liquid);
|
||||
removeLiquid(requiredLiquid);
|
||||
|
||||
// Let event handlers handle the harvest first.
|
||||
for (IFarmListener listener : eventHandlers) {
|
||||
@@ -636,13 +610,15 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable
|
||||
}
|
||||
|
||||
ItemStack next = pendingProduce.peek();
|
||||
if (InvTools.tryAddStack(getInternalInventory(), next, SLOT_PRODUCTION_1, SLOT_PRODUCTION_COUNT, true, true)) {
|
||||
boolean added = InvTools.tryAddStack(getInternalInventory(), next, SLOT_PRODUCTION_1, SLOT_PRODUCTION_COUNT, true, true);
|
||||
|
||||
if (added) {
|
||||
pendingProduce.pop();
|
||||
return true;
|
||||
}
|
||||
|
||||
setErrorState(EnumErrorCode.NOSPACE);
|
||||
return false;
|
||||
setErrorCondition(!added, EnumErrorCode.NOSPACE);
|
||||
|
||||
return added;
|
||||
}
|
||||
|
||||
/* FERTILIZER HANDLING */
|
||||
@@ -1021,4 +997,30 @@ public class TileFarmPlain extends TileFarm implements IFarmHousing, ISocketable
|
||||
public boolean isOwnable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
private static class FarmPlainInventoryAdapter extends TileInventoryAdapter<TileFarmPlain> {
|
||||
public FarmPlainInventoryAdapter(TileFarmPlain tile) {
|
||||
super(tile, TileFarmPlain.SLOT_COUNT, "Items");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
|
||||
if (GuiUtil.isIndexInRange(slotIndex, SLOT_FERTILIZER, SLOT_FERTILIZER_COUNT)) {
|
||||
return tile.acceptsAsFertilizer(itemStack);
|
||||
} else if (GuiUtil.isIndexInRange(slotIndex, SLOT_GERMLINGS_1, SLOT_GERMLINGS_COUNT)) {
|
||||
return tile.acceptsAsGermling(itemStack);
|
||||
} else if (GuiUtil.isIndexInRange(slotIndex, SLOT_RESOURCES_1, SLOT_RESOURCES_COUNT)) {
|
||||
return tile.acceptsAsResource(itemStack);
|
||||
} else if (GuiUtil.isIndexInRange(slotIndex, SLOT_CAN, SLOT_CAN_COUNT)) {
|
||||
Fluid fluid = FluidHelper.getFluidInContainer(itemStack);
|
||||
return tile.tankManager.accepts(fluid);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int slotIndex, ItemStack stack, int side) {
|
||||
return GuiUtil.isIndexInRange(slotIndex, SLOT_PRODUCTION_1, SLOT_PRODUCTION_COUNT);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -62,15 +62,17 @@ public class TileGearbox extends TileFarm implements IPowerHandler {
|
||||
@Override
|
||||
protected void updateServerSide() {
|
||||
super.updateServerSide();
|
||||
|
||||
if (energyManager.getTotalEnergyStored() == 0) {
|
||||
ITileStructure central = getCentralTE();
|
||||
if (!(central instanceof TileForestry)) {
|
||||
return;
|
||||
}
|
||||
|
||||
TileForestry centralHousing = (TileForestry) central;
|
||||
centralHousing.setErrorState(EnumErrorCode.NOPOWER);
|
||||
ITileStructure central = getCentralTE();
|
||||
if (!(central instanceof TileForestry)) {
|
||||
return;
|
||||
}
|
||||
|
||||
TileForestry centralHousing = (TileForestry) central;
|
||||
|
||||
boolean hasPower = energyManager.getTotalEnergyStored() > 0;
|
||||
|
||||
if (centralHousing.setErrorCondition(!hasPower, EnumErrorCode.NOPOWER)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -85,7 +87,6 @@ public class TileGearbox extends TileFarm implements IPowerHandler {
|
||||
}
|
||||
|
||||
if (workCounter >= WORK_CYCLES && updateOnInterval(5)) {
|
||||
ITileStructure central = getCentralTE();
|
||||
if (!(central instanceof IFarmHousing)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -18,9 +18,7 @@ import net.minecraft.world.World;
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.core.Tabs;
|
||||
import forestry.api.lepidopterology.IButterfly;
|
||||
import forestry.core.EnumErrorCode;
|
||||
import forestry.core.config.Config;
|
||||
import forestry.core.interfaces.IErrorSource;
|
||||
import forestry.core.interfaces.IHintSource;
|
||||
import forestry.core.inventory.AlyzerInventory;
|
||||
import forestry.core.items.ItemInventoried;
|
||||
@@ -30,7 +28,7 @@ import forestry.plugins.PluginLepidopterology;
|
||||
|
||||
public class ItemFlutterlyzer extends ItemInventoried {
|
||||
|
||||
public static class FlutterlyzerInventory extends AlyzerInventory implements IErrorSource, IHintSource {
|
||||
public static class FlutterlyzerInventory extends AlyzerInventory implements IHintSource {
|
||||
|
||||
public FlutterlyzerInventory(EntityPlayer player, ItemStack itemStack) {
|
||||
super(ItemFlutterlyzer.class, 7, itemStack);
|
||||
@@ -101,21 +99,6 @@ public class ItemFlutterlyzer extends ItemInventoried {
|
||||
public String[] getHints() {
|
||||
return Config.hints.get("flutterlyzer");
|
||||
}
|
||||
|
||||
/* IERRORSOURCE */
|
||||
@Override
|
||||
public boolean throwsErrors() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumErrorCode getErrorState() {
|
||||
if (PluginLepidopterology.butterflyInterface.isMember(inventoryStacks[SLOT_SPECIMEN]) && !isEnergy(getStackInSlot(SLOT_ENERGY))) {
|
||||
return EnumErrorCode.NOHONEY;
|
||||
}
|
||||
|
||||
return EnumErrorCode.OK;
|
||||
}
|
||||
}
|
||||
|
||||
public ItemFlutterlyzer() {
|
||||
|
||||
@@ -31,12 +31,7 @@ public class MachinePhilatelist extends TileBase implements IInventory {
|
||||
public static final short SLOT_BUFFER_COUNT = 27;
|
||||
|
||||
public MachinePhilatelist() {
|
||||
setInternalInventory(new TileInventoryAdapter(this, 28, "INV") {
|
||||
@Override
|
||||
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
|
||||
return itemStack.getItem() instanceof IStamps;
|
||||
}
|
||||
});
|
||||
setInternalInventory(new PhilatelistInventoryAdapter(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -70,4 +65,15 @@ public class MachinePhilatelist extends TileBase implements IInventory {
|
||||
// Store it.
|
||||
StackUtils.stowInInventory(stamp, inventory, true, SLOT_BUFFER_1, SLOT_BUFFER_COUNT);
|
||||
}
|
||||
|
||||
private static class PhilatelistInventoryAdapter extends TileInventoryAdapter<MachinePhilatelist> {
|
||||
public PhilatelistInventoryAdapter(MachinePhilatelist tile) {
|
||||
super(tile, 28, "INV");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
|
||||
return itemStack.getItem() instanceof IStamps;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,7 @@ package forestry.mail.gadgets;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Items;
|
||||
@@ -123,53 +124,25 @@ public class MachineTrader extends TileBase {
|
||||
return;
|
||||
}
|
||||
|
||||
EnumErrorCode errorCode = EnumErrorCode.OK;
|
||||
|
||||
if (!hasPostageMin(3)) {
|
||||
errorCode = EnumErrorCode.NOSTAMPS;
|
||||
}
|
||||
|
||||
if (!hasPaperMin(2)) {
|
||||
if (errorCode == EnumErrorCode.NOSTAMPS) {
|
||||
errorCode = EnumErrorCode.NOSTAMPSNOPAPER;
|
||||
} else {
|
||||
errorCode = EnumErrorCode.NOPAPER;
|
||||
}
|
||||
}
|
||||
|
||||
if (errorCode != EnumErrorCode.OK) {
|
||||
setErrorState(errorCode);
|
||||
return;
|
||||
}
|
||||
setErrorCondition(!hasPostageMin(3), EnumErrorCode.NOSTAMPS);
|
||||
setErrorCondition(!hasPaperMin(2), EnumErrorCode.NOPAPER);
|
||||
|
||||
IInventory inventory = getInternalInventory();
|
||||
ItemStack tradeGood = inventory.getStackInSlot(TradeStation.SLOT_TRADEGOOD);
|
||||
|
||||
if (tradeGood == null) {
|
||||
setErrorState(EnumErrorCode.NOTRADE);
|
||||
return;
|
||||
}
|
||||
setErrorCondition(tradeGood == null, EnumErrorCode.NOTRADE);
|
||||
|
||||
boolean hasRequest = hasItemCount(TradeStation.SLOT_EXCHANGE_1, TradeStation.SLOT_EXCHANGE_COUNT, null, 1);
|
||||
if (!hasRequest) {
|
||||
setErrorState(EnumErrorCode.NOTRADE);
|
||||
return;
|
||||
}
|
||||
setErrorCondition(!hasRequest, EnumErrorCode.NOTRADE);
|
||||
|
||||
boolean hasSupplies = hasItemCount(TradeStation.SLOT_SEND_BUFFER, TradeStation.SLOT_SEND_BUFFER_COUNT, tradeGood, tradeGood.stackSize);
|
||||
if (!hasSupplies) {
|
||||
setErrorState(EnumErrorCode.NOSUPPLIES);
|
||||
return;
|
||||
if (tradeGood != null) {
|
||||
boolean hasSupplies = hasItemCount(TradeStation.SLOT_SEND_BUFFER, TradeStation.SLOT_SEND_BUFFER_COUNT, tradeGood, tradeGood.stackSize);
|
||||
setErrorCondition(!hasSupplies, EnumErrorCode.NOSUPPLIES);
|
||||
}
|
||||
|
||||
if (inventory instanceof TradeStation) {
|
||||
if (!((TradeStation) inventory).canReceivePayment()) {
|
||||
setErrorState(EnumErrorCode.NOSPACE);
|
||||
return;
|
||||
}
|
||||
boolean canReceivePayment = ((TradeStation) inventory).canReceivePayment();
|
||||
setErrorCondition(!canReceivePayment, EnumErrorCode.NOSPACE);
|
||||
}
|
||||
|
||||
setErrorState(EnumErrorCode.OK);
|
||||
}
|
||||
|
||||
/* STATE INFORMATION */
|
||||
@@ -178,8 +151,7 @@ public class MachineTrader extends TileBase {
|
||||
return false;
|
||||
}
|
||||
|
||||
IErrorState errorState = getErrorState();
|
||||
return errorState != EnumErrorCode.NOTALPHANUMERIC && errorState != EnumErrorCode.NOTUNIQUE;
|
||||
return !hasErrorState(EnumErrorCode.NOTALPHANUMERIC) && !hasErrorState(EnumErrorCode.NOTUNIQUE);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -285,19 +257,16 @@ public class MachineTrader extends TileBase {
|
||||
}
|
||||
|
||||
if (Proxies.common.isSimulating(worldObj)) {
|
||||
if (!PostManager.postRegistry.isValidTradeAddress(worldObj, address)) {
|
||||
setErrorState(EnumErrorCode.NOTALPHANUMERIC);
|
||||
return;
|
||||
}
|
||||
boolean hasValidTradeAddress = PostManager.postRegistry.isValidTradeAddress(worldObj, address);
|
||||
setErrorCondition(!hasValidTradeAddress, EnumErrorCode.NOTALPHANUMERIC);
|
||||
|
||||
if (!PostManager.postRegistry.isAvailableTradeAddress(worldObj, address)) {
|
||||
setErrorState(EnumErrorCode.NOTUNIQUE);
|
||||
return;
|
||||
}
|
||||
boolean hasUniqueTradeAddress = PostManager.postRegistry.isAvailableTradeAddress(worldObj, address);
|
||||
setErrorCondition(!hasUniqueTradeAddress, EnumErrorCode.NOTUNIQUE);
|
||||
|
||||
this.address = address;
|
||||
PostManager.postRegistry.getOrCreateTradeStation(worldObj, getOwnerProfile(), address);
|
||||
setErrorState(EnumErrorCode.OK);
|
||||
if (hasValidTradeAddress & hasUniqueTradeAddress) {
|
||||
this.address = address;
|
||||
PostManager.postRegistry.getOrCreateTradeStation(worldObj, getOwnerProfile(), address);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,6 @@ public class GuiTrader extends GuiForestry<ContainerTrader, MachineTrader> {
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
|
||||
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
||||
String name = StringUtil.localizeTile(inventory.getUnlocalizedName());
|
||||
this.fontRendererObj.drawString(name, getCenteredOffset(name), 6, fontColor.get("gui.mail.text"));
|
||||
|
||||
@@ -36,6 +35,8 @@ public class GuiTrader extends GuiForestry<ContainerTrader, MachineTrader> {
|
||||
|
||||
String send = StringUtil.localize("gui.mail.send");
|
||||
this.fontRendererObj.drawString(send, getCenteredOffset(send, 70) + 51, 99, fontColor.get("gui.mail.text"));
|
||||
|
||||
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
******************************************************************************/
|
||||
package forestry.mail.items;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
@@ -25,6 +27,7 @@ import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.core.IErrorState;
|
||||
import forestry.api.mail.ILetter;
|
||||
import forestry.core.EnumErrorCode;
|
||||
import forestry.core.config.Config;
|
||||
@@ -160,22 +163,19 @@ public class ItemLetter extends ItemInventoried {
|
||||
|
||||
// / IERRORSOURCE
|
||||
@Override
|
||||
public boolean throwsErrors() {
|
||||
return true;
|
||||
}
|
||||
public ImmutableSet<IErrorState> getErrorStates() {
|
||||
|
||||
@Override
|
||||
public EnumErrorCode getErrorState() {
|
||||
ImmutableSet.Builder<IErrorState> errorStates = ImmutableSet.builder();
|
||||
|
||||
if (!letter.hasRecipient()) {
|
||||
return EnumErrorCode.NORECIPIENT;
|
||||
errorStates.add(EnumErrorCode.NORECIPIENT);
|
||||
}
|
||||
|
||||
if (!letter.isProcessed() && !letter.isPostPaid()) {
|
||||
return EnumErrorCode.NOTPOSTPAID;
|
||||
errorStates.add(EnumErrorCode.NOTPOSTPAID);
|
||||
}
|
||||
|
||||
return EnumErrorCode.OK;
|
||||
return errorStates.build();
|
||||
}
|
||||
|
||||
/* IHINTSOURCE */
|
||||
|
||||
Reference in new issue
Block a user