mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-28 15:36:18 +00:00
1 parent
e73e18a3c7
commit
14bdab069e
32 files changed
+217
-148
No files matched your search
@@ -143,15 +143,15 @@ public class TileBottler extends TilePowered implements ISidedInventory, ILiquid
|
||||
|
||||
FluidHelper.FillStatus status;
|
||||
|
||||
if (errorLogic.setCondition(currentRecipe == null, EnumErrorCode.NORECIPE)) {
|
||||
status = FluidHelper.FillStatus.SUCCESS;
|
||||
if (currentRecipe == null) {
|
||||
status = FluidHelper.FillStatus.NO_FLUID;
|
||||
} else {
|
||||
status = FluidHelper.fillContainers(tankManager, this, InventoryBottler.SLOT_INPUT_EMPTY_CAN, InventoryBottler.SLOT_OUTPUT, currentRecipe.input.getFluid(), false);
|
||||
}
|
||||
|
||||
errorLogic.setCondition(status == FluidHelper.FillStatus.NO_FLUID, EnumErrorCode.NORESOURCE);
|
||||
errorLogic.setCondition(status == FluidHelper.FillStatus.NO_SPACE, EnumErrorCode.NOSPACE);
|
||||
return currentRecipe != null && status == FluidHelper.FillStatus.SUCCESS;
|
||||
errorLogic.setCondition(status == FluidHelper.FillStatus.NO_FLUID, EnumErrorCode.NO_RESOURCE_LIQUID);
|
||||
errorLogic.setCondition(status == FluidHelper.FillStatus.NO_SPACE, EnumErrorCode.NO_SPACE_INVENTORY);
|
||||
return status == FluidHelper.FillStatus.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -12,6 +12,7 @@ package forestry.factory.tiles;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
@@ -136,7 +137,10 @@ public class TileCarpenter extends TilePowered implements ISidedInventory, ILiqu
|
||||
|
||||
@Override
|
||||
public boolean workCycle() {
|
||||
if (!removeResources(true)) {
|
||||
if (!removeLiquidResources(true)) {
|
||||
return false;
|
||||
}
|
||||
if (!removeItemResources(true)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -146,7 +150,7 @@ public class TileCarpenter extends TilePowered implements ISidedInventory, ILiqu
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean removeResources(boolean doRemove) {
|
||||
private boolean removeLiquidResources(boolean doRemove) {
|
||||
if (currentRecipe == null) {
|
||||
return true;
|
||||
}
|
||||
@@ -161,6 +165,14 @@ public class TileCarpenter extends TilePowered implements ISidedInventory, ILiqu
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean removeItemResources(boolean doRemove) {
|
||||
if (currentRecipe == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (currentRecipe.getBox() != null) {
|
||||
ItemStack box = getStackInSlot(InventoryCarpenter.SLOT_BOX);
|
||||
if (box == null || box.stackSize == 0) {
|
||||
@@ -185,22 +197,25 @@ public class TileCarpenter extends TilePowered implements ISidedInventory, ILiqu
|
||||
}
|
||||
|
||||
boolean hasRecipe = (currentRecipe != null);
|
||||
boolean hasResources = true;
|
||||
boolean hasLiquidResources = true;
|
||||
boolean hasItemResources = true;
|
||||
boolean canAdd = true;
|
||||
|
||||
if (hasRecipe) {
|
||||
hasResources = removeResources(false);
|
||||
hasLiquidResources = removeLiquidResources(false);
|
||||
hasItemResources = removeItemResources(false);
|
||||
|
||||
ItemStack pendingProduct = currentRecipe.getCraftingGridRecipe().getRecipeOutput();
|
||||
canAdd = InventoryUtil.tryAddStack(this, pendingProduct, InventoryCarpenter.SLOT_PRODUCT, InventoryCarpenter.SLOT_PRODUCT_COUNT, true, false);
|
||||
}
|
||||
|
||||
IErrorLogic errorLogic = getErrorLogic();
|
||||
errorLogic.setCondition(!hasRecipe, EnumErrorCode.NORECIPE);
|
||||
errorLogic.setCondition(!hasResources, EnumErrorCode.NORESOURCE);
|
||||
errorLogic.setCondition(!canAdd, EnumErrorCode.NOSPACE);
|
||||
errorLogic.setCondition(!hasRecipe, EnumErrorCode.NO_RECIPE);
|
||||
errorLogic.setCondition(!hasLiquidResources, EnumErrorCode.NO_RESOURCE_LIQUID);
|
||||
errorLogic.setCondition(!hasItemResources, EnumErrorCode.NO_RESOURCE_INVENTORY);
|
||||
errorLogic.setCondition(!canAdd, EnumErrorCode.NO_SPACE_INVENTORY);
|
||||
|
||||
return hasRecipe && hasResources && canAdd;
|
||||
return hasRecipe && hasItemResources && hasLiquidResources && canAdd;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -168,7 +168,7 @@ public class TileCentrifuge extends TilePowered implements ISocketable, ISidedIn
|
||||
pendingProducts.pop();
|
||||
}
|
||||
|
||||
getErrorLogic().setCondition(!added, EnumErrorCode.NOSPACE);
|
||||
getErrorLogic().setCondition(!added, EnumErrorCode.NO_SPACE_INVENTORY);
|
||||
return added;
|
||||
}
|
||||
|
||||
@@ -189,7 +189,7 @@ public class TileCentrifuge extends TilePowered implements ISocketable, ISidedIn
|
||||
boolean hasResource = getStackInSlot(InventoryCentrifuge.SLOT_RESOURCE) != null;
|
||||
|
||||
IErrorLogic errorLogic = getErrorLogic();
|
||||
errorLogic.setCondition(!hasResource, EnumErrorCode.NORESOURCE);
|
||||
errorLogic.setCondition(!hasResource, EnumErrorCode.NO_RESOURCE);
|
||||
|
||||
return hasResource;
|
||||
}
|
||||
|
||||
@@ -233,10 +233,11 @@ public class TileFermenter extends TilePowered implements ISidedInventory, ILiqu
|
||||
}
|
||||
|
||||
IErrorLogic errorLogic = getErrorLogic();
|
||||
errorLogic.setCondition(!hasRecipe, EnumErrorCode.NORECIPE);
|
||||
errorLogic.setCondition(!hasFuel, EnumErrorCode.NOFUEL);
|
||||
errorLogic.setCondition(!hasResource || !hasFluidResource, EnumErrorCode.NORESOURCE);
|
||||
errorLogic.setCondition(!hasFluidSpace, EnumErrorCode.NOSPACETANK);
|
||||
errorLogic.setCondition(!hasRecipe, EnumErrorCode.NO_RECIPE);
|
||||
errorLogic.setCondition(!hasFuel, EnumErrorCode.NO_FUEL);
|
||||
errorLogic.setCondition(!hasResource, EnumErrorCode.NO_RESOURCE);
|
||||
errorLogic.setCondition(!hasFluidResource, EnumErrorCode.NO_RESOURCE_LIQUID);
|
||||
errorLogic.setCondition(!hasFluidSpace, EnumErrorCode.NO_SPACE_TANK);
|
||||
|
||||
return hasRecipe && hasFuel && hasResource && hasFluidResource && hasFluidSpace;
|
||||
}
|
||||
|
||||
@@ -141,7 +141,7 @@ public class TileMoistener extends TileBase implements ISidedInventory, ILiquidT
|
||||
|
||||
// Not working in broad daylight
|
||||
boolean gloomy = lightvalue <= 11;
|
||||
if (errorLogic.setCondition(!gloomy, EnumErrorCode.NOTGLOOMY)) {
|
||||
if (errorLogic.setCondition(!gloomy, EnumErrorCode.NOT_DARK)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -161,7 +161,7 @@ public class TileMoistener extends TileBase implements ISidedInventory, ILiquidT
|
||||
if (burnTime > 0 && pendingProduct == null) {
|
||||
// Not working if there is no water available.
|
||||
boolean hasLiquid = resourceTank.getFluidAmount() > 0;
|
||||
if (errorLogic.setCondition(!hasLiquid, EnumErrorCode.NORESOURCE)) {
|
||||
if (errorLogic.setCondition(!hasLiquid, EnumErrorCode.NO_RESOURCE_LIQUID)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -204,7 +204,7 @@ public class TileMoistener extends TileBase implements ISidedInventory, ILiquidT
|
||||
}
|
||||
}
|
||||
|
||||
errorLogic.setCondition(currentRecipe == null, EnumErrorCode.NORECIPE);
|
||||
errorLogic.setCondition(currentRecipe == null, EnumErrorCode.NO_RECIPE);
|
||||
}
|
||||
|
||||
private boolean tryAddPending() {
|
||||
@@ -213,7 +213,7 @@ public class TileMoistener extends TileBase implements ISidedInventory, ILiquidT
|
||||
}
|
||||
|
||||
boolean added = InventoryUtil.tryAddStack(this, pendingProduct, InventoryMoistener.SLOT_PRODUCT, 1, true);
|
||||
getErrorLogic().setCondition(!added, EnumErrorCode.NOSPACE);
|
||||
getErrorLogic().setCondition(!added, EnumErrorCode.NO_SPACE_INVENTORY);
|
||||
|
||||
if (added) {
|
||||
pendingProduct = null;
|
||||
@@ -229,7 +229,7 @@ public class TileMoistener extends TileBase implements ISidedInventory, ILiquidT
|
||||
resetRecipe();
|
||||
}
|
||||
|
||||
getErrorLogic().setCondition(currentRecipe == null, EnumErrorCode.NORECIPE);
|
||||
getErrorLogic().setCondition(currentRecipe == null, EnumErrorCode.NO_RECIPE);
|
||||
}
|
||||
|
||||
private void resetRecipe() {
|
||||
@@ -323,7 +323,7 @@ public class TileMoistener extends TileBase implements ISidedInventory, ILiquidT
|
||||
|
||||
int targetSlot = getFreeReservoirSlot(deposit);
|
||||
// We stop the whole thing, if we don't have any room anymore.
|
||||
if (errorLogic.setCondition(targetSlot < 0, EnumErrorCode.NOSPACE)) {
|
||||
if (errorLogic.setCondition(targetSlot < 0, EnumErrorCode.NO_SPACE_INVENTORY)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -343,7 +343,7 @@ public class TileMoistener extends TileBase implements ISidedInventory, ILiquidT
|
||||
// Let's look for a new resource to put into the working slot.
|
||||
int resourceSlot = getNextResourceSlot(InventoryMoistener.SLOT_RESERVOIR_1, InventoryMoistener.SLOT_RESERVOIR_1 + InventoryMoistener.SLOT_RESERVOIR_COUNT);
|
||||
// Nothing found, stop.
|
||||
if (errorLogic.setCondition(resourceSlot < 0, EnumErrorCode.NORESOURCE)) {
|
||||
if (errorLogic.setCondition(resourceSlot < 0, EnumErrorCode.NO_RESOURCE)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ public class TileRaintank extends TileBase implements ISidedInventory, ILiquidTa
|
||||
if (worldObj != null) {
|
||||
BiomeGenBase biome = worldObj.getBiomeGenForCoordsBody(xCoord, zCoord);
|
||||
isValidBiome = BiomeHelper.canRainOrSnow(biome);
|
||||
getErrorLogic().setCondition(!isValidBiome, EnumErrorCode.INVALIDBIOME);
|
||||
getErrorLogic().setCondition(!isValidBiome, EnumErrorCode.NO_RAIN_BIOME);
|
||||
}
|
||||
|
||||
super.validate();
|
||||
@@ -110,12 +110,12 @@ public class TileRaintank extends TileBase implements ISidedInventory, ILiquidTa
|
||||
|
||||
IErrorLogic errorLogic = getErrorLogic();
|
||||
|
||||
errorLogic.setCondition(!isValidBiome, EnumErrorCode.INVALIDBIOME);
|
||||
errorLogic.setCondition(!isValidBiome, EnumErrorCode.NO_RAIN_BIOME);
|
||||
|
||||
boolean hasSky = worldObj.canBlockSeeTheSky(xCoord, yCoord + 1, zCoord);
|
||||
errorLogic.setCondition(!hasSky, EnumErrorCode.NOSKY);
|
||||
errorLogic.setCondition(!hasSky, EnumErrorCode.NO_SKY_RAIN_TANK);
|
||||
|
||||
errorLogic.setCondition(!worldObj.isRaining(), EnumErrorCode.NOTRAINING);
|
||||
errorLogic.setCondition(!worldObj.isRaining(), EnumErrorCode.NOT_RAINING);
|
||||
|
||||
if (!errorLogic.hasErrors()) {
|
||||
resourceTank.fill(STACK_WATER, true);
|
||||
|
||||
@@ -165,7 +165,7 @@ public class TileSqueezer extends TilePowered implements ISocketable, ISidedInve
|
||||
}
|
||||
}
|
||||
|
||||
getErrorLogic().setCondition(currentRecipe == null, EnumErrorCode.NORECIPE);
|
||||
getErrorLogic().setCondition(currentRecipe == null, EnumErrorCode.NO_RECIPE);
|
||||
return currentRecipe != null;
|
||||
}
|
||||
|
||||
@@ -191,10 +191,10 @@ public class TileSqueezer extends TilePowered implements ISocketable, ISidedInve
|
||||
}
|
||||
|
||||
IErrorLogic errorLogic = getErrorLogic();
|
||||
errorLogic.setCondition(!hasResources, EnumErrorCode.NORESOURCE);
|
||||
errorLogic.setCondition(!hasRecipe, EnumErrorCode.NORECIPE);
|
||||
errorLogic.setCondition(!canFill, EnumErrorCode.NOSPACETANK);
|
||||
errorLogic.setCondition(!canAdd, EnumErrorCode.NOSPACE);
|
||||
errorLogic.setCondition(!hasResources, EnumErrorCode.NO_RESOURCE);
|
||||
errorLogic.setCondition(!hasRecipe, EnumErrorCode.NO_RECIPE);
|
||||
errorLogic.setCondition(!canFill, EnumErrorCode.NO_SPACE_TANK);
|
||||
errorLogic.setCondition(!canAdd, EnumErrorCode.NO_SPACE_INVENTORY);
|
||||
|
||||
return hasResources && hasRecipe && canFill && canAdd;
|
||||
}
|
||||
|
||||
@@ -140,7 +140,7 @@ public class TileStill extends TilePowered implements ISidedInventory, ILiquidTa
|
||||
|
||||
boolean hasRecipe = (currentRecipe != null);
|
||||
boolean hasTankSpace = true;
|
||||
boolean hasFluidResource = true;
|
||||
boolean hasLiquidResource = true;
|
||||
|
||||
if (hasRecipe) {
|
||||
hasTankSpace = productTank.canFill(currentRecipe.getOutput());
|
||||
@@ -148,8 +148,8 @@ public class TileStill extends TilePowered implements ISidedInventory, ILiquidTa
|
||||
int cycles = currentRecipe.getCyclesPerUnit();
|
||||
FluidStack input = currentRecipe.getInput();
|
||||
int drainAmount = cycles * input.amount;
|
||||
hasFluidResource = resourceTank.canDrain(drainAmount);
|
||||
if (hasFluidResource) {
|
||||
hasLiquidResource = resourceTank.canDrain(drainAmount);
|
||||
if (hasLiquidResource) {
|
||||
bufferedLiquid = new FluidStack(input, drainAmount);
|
||||
resourceTank.drain(drainAmount, true);
|
||||
}
|
||||
@@ -157,11 +157,11 @@ public class TileStill extends TilePowered implements ISidedInventory, ILiquidTa
|
||||
}
|
||||
|
||||
IErrorLogic errorLogic = getErrorLogic();
|
||||
errorLogic.setCondition(!hasRecipe, EnumErrorCode.NORECIPE);
|
||||
errorLogic.setCondition(!hasTankSpace, EnumErrorCode.NOSPACETANK);
|
||||
errorLogic.setCondition(!hasFluidResource, EnumErrorCode.NORESOURCE);
|
||||
errorLogic.setCondition(!hasRecipe, EnumErrorCode.NO_RECIPE);
|
||||
errorLogic.setCondition(!hasTankSpace, EnumErrorCode.NO_SPACE_TANK);
|
||||
errorLogic.setCondition(!hasLiquidResource, EnumErrorCode.NO_RESOURCE_LIQUID);
|
||||
|
||||
return hasRecipe && hasFluidResource && hasTankSpace;
|
||||
return hasRecipe && hasLiquidResource && hasTankSpace;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user