Fix #879 Fix #957 Improve error messages, add habitat locator hint

This commit is contained in:
mezz committed 2015-11-09 01:32:42 -08:00
1 parent e73e18a3c7
commit 14bdab069e
32 files changed
+217 -148

No files matched your search

@@ -166,14 +166,14 @@ public class BeekeepingLogic implements IBeekeepingLogic, IStreamable {
IBeeHousingInventory beeInventory = housing.getBeeInventory();
boolean hasSpace = addPendingProducts(beeInventory, spawn);
errorLogic.setCondition(!hasSpace, EnumErrorCode.NOSPACE);
errorLogic.setCondition(!hasSpace, EnumErrorCode.NO_SPACE_INVENTORY);
ItemStack queenStack = beeInventory.getQueen();
// check if we're breeding
if (ForestryItem.beePrincessGE.isItemEqual(queenStack)) {
boolean hasDrone = BeeManager.beeRoot.isDrone(beeInventory.getDrone());
errorLogic.setCondition(!hasDrone, EnumErrorCode.NODRONE);
errorLogic.setCondition(!hasDrone, EnumErrorCode.NO_DRONE);
setActive(false); // not active (no bee FX) when we are breeding
return !errorLogic.hasErrors();
@@ -195,7 +195,7 @@ public class BeekeepingLogic implements IBeekeepingLogic, IStreamable {
this.queenStack = queenStack;
}
if (errorLogic.setCondition(queen == null, EnumErrorCode.NOQUEEN)) {
if (errorLogic.setCondition(queen == null, EnumErrorCode.NO_QUEEN)) {
setActive(false);
beeProgress = 0;
return false;
@@ -207,7 +207,7 @@ public class BeekeepingLogic implements IBeekeepingLogic, IStreamable {
}
boolean hasFlowers = hasFlowersCache.hasFlowers(queen, housing);
errorLogic.setCondition(!hasFlowers, EnumErrorCode.NOFLOWER);
errorLogic.setCondition(!hasFlowers, EnumErrorCode.NO_FLOWER);
boolean canWork = !errorLogic.hasErrors();
setActive(canWork);
@@ -45,6 +45,7 @@ import forestry.api.core.EnumHumidity;
import forestry.api.core.EnumTemperature;
import forestry.api.core.IErrorState;
import forestry.api.genetics.AlleleManager;
import forestry.api.genetics.EnumTolerance;
import forestry.api.genetics.IAllele;
import forestry.api.genetics.IAlleleTolerance;
import forestry.api.genetics.IChromosome;
@@ -256,48 +257,87 @@ public class Bee extends IndividualLiving implements IBee {
IBeeModifier beeModifier = BeeManager.beeRoot.createBeeHousingModifier(housing);
// / Rain needs tolerant flyers
if (world.isRaining() && !genome.getTolerantFlyer() && BiomeHelper.canRainOrSnow(biome) && !beeModifier.isSealed()) {
errorStates.add(EnumErrorCode.ISRAINING);
if (world.isRaining() && BiomeHelper.canRainOrSnow(biome) && !canFlyInRain(beeModifier)) {
errorStates.add(EnumErrorCode.IS_RAINING);
}
// / Night or darkness requires nocturnal species
if (world.isDaytime()) {
if (!canWorkDuringDay()) {
errorStates.add(EnumErrorCode.NOTNIGHT);
errorStates.add(EnumErrorCode.NOT_NIGHT);
}
} else {
if (!canWorkAtNight(beeModifier)) {
errorStates.add(EnumErrorCode.NOT_DAY);
}
} else if (!canWorkAtNight() && !beeModifier.isSelfLighted()) {
errorStates.add(EnumErrorCode.NOTDAY);
}
if (housing.getBlockLightValue() > Constants.APIARY_MIN_LEVEL_LIGHT) {
if (!canWorkDuringDay()) {
errorStates.add(EnumErrorCode.NOTGLOOMY);
errorStates.add(EnumErrorCode.NOT_GLOOMY);
}
} else {
if (!canWorkAtNight(beeModifier)) {
errorStates.add(EnumErrorCode.NOT_BRIGHT);
}
} else if (!canWorkAtNight() && !beeModifier.isSelfLighted()) {
errorStates.add(EnumErrorCode.NOTLUCID);
}
// / No sky, except if in hell
if (biome != null && !BiomeHelper.isBiomeHellish(biome) && !housing.canBlockSeeTheSky() && !genome.getCaveDwelling() && !beeModifier.isSunlightSimulated()) {
errorStates.add(EnumErrorCode.NOSKY);
// / Check for the sky, except if in hell
if (biome != null && !BiomeHelper.isBiomeHellish(biome)) {
if (!housing.canBlockSeeTheSky() && !canWorkUnderground(beeModifier)) {
errorStates.add(EnumErrorCode.NO_SKY);
}
}
// / And finally climate check
if (!isSuitableClimate(housing.getTemperature(), housing.getHumidity())) {
errorStates.add(EnumErrorCode.INVALIDBIOME);
IAlleleBeeSpecies species = genome.getPrimary();
{
EnumTemperature actualTemperature = housing.getTemperature();
EnumTemperature beeBaseTemperature = species.getTemperature();
EnumTolerance beeToleranceTemperature = genome.getToleranceTemp();
if (!AlleleManager.climateHelper.isWithinLimits(actualTemperature, beeBaseTemperature, beeToleranceTemperature)) {
if (beeBaseTemperature.ordinal() > actualTemperature.ordinal()) {
errorStates.add(EnumErrorCode.TOO_COLD);
} else {
errorStates.add(EnumErrorCode.TOO_HOT);
}
}
}
{
EnumHumidity actualHumidity = housing.getHumidity();
EnumHumidity beeBaseHumidity = species.getHumidity();
EnumTolerance beeToleranceHumidity = genome.getToleranceHumid();
if (!AlleleManager.climateHelper.isWithinLimits(actualHumidity, beeBaseHumidity, beeToleranceHumidity)) {
if (beeBaseHumidity.ordinal() > actualHumidity.ordinal()) {
errorStates.add(EnumErrorCode.TOO_ARID);
} else {
errorStates.add(EnumErrorCode.TOO_HUMID);
}
}
}
return errorStates;
}
private boolean canWorkAtNight() {
return genome.getPrimary().isNocturnal() || genome.getNocturnal();
private boolean canWorkAtNight(IBeeModifier beeModifier) {
return genome.getPrimary().isNocturnal() || genome.getNocturnal() || beeModifier.isSelfLighted();
}
private boolean canWorkDuringDay() {
return !genome.getPrimary().isNocturnal() || genome.getNocturnal();
}
private boolean canWorkUnderground(IBeeModifier beeModifier) {
return genome.getCaveDwelling() || beeModifier.isSunlightSimulated();
}
private boolean canFlyInRain(IBeeModifier beeModifier) {
return genome.getTolerantFlyer() || beeModifier.isSealed();
}
private boolean isSuitableBiome(BiomeGenBase biome) {
if (biome == null) {
return false;
@@ -105,11 +105,11 @@ public class ItemInventoryHabitatLocator extends ItemInventory implements IError
ItemStack specimen = getStackInSlot(SLOT_SPECIMEN);
if (!BeeManager.beeRoot.isMember(specimen)) {
errorStates.add(EnumErrorCode.NOTHINGANALYZE);
errorStates.add(EnumErrorCode.NO_SPECIMEN);
}
if (!isEnergy(getStackInSlot(SLOT_ENERGY))) {
errorStates.add(EnumErrorCode.NOHONEY);
errorStates.add(EnumErrorCode.NO_HONEY);
}
return errorStates.build();
@@ -38,7 +38,7 @@ public class TriggerMissingDrone extends Trigger {
}
IErrorLogicSource apiary = (IErrorLogicSource) tile;
return apiary.getErrorLogic().contains(EnumErrorCode.NODRONE);
return apiary.getErrorLogic().contains(EnumErrorCode.NO_DRONE);
}
}
@@ -38,6 +38,6 @@ public class TriggerMissingQueen extends Trigger {
}
IErrorLogicSource apiary = (IErrorLogicSource) tile;
return apiary.getErrorLogic().contains(EnumErrorCode.NOQUEEN);
return apiary.getErrorLogic().contains(EnumErrorCode.NO_QUEEN);
}
}
@@ -23,62 +23,74 @@ public enum EnumErrorCode implements IErrorState {
WRONGSTACKSIZE("wrongStacksize"), // Only single items can be used here.
@Deprecated
NODISPOSAL("noDisposal"), // Insufficient space to dispose of waste products.
@Deprecated
INVALIDBIOME("invalidBiome"), // Machine or inhabitants cannot work in this biome.
// Bees
INVALIDBIOME("invalidBiome"), // Machine or inhabitants cannot work in this biome.
ISRAINING("isRaining"), // Operation is only possible when it is not raining.
NOTRAINING("notRaining"), // Operation is only possible when it is raining.
NOTGLOOMY("notGloomy"), // A lower light level is required for operation.
NOTLUCID("notLucid"), // A higher light level is required for operation
NOTDAY("notDay"), // Operation is only possible during the day.
NOTNIGHT("notNight"), // Operation is only possible during the night.
NOFLOWER("noFlower"), // Hive members are not finding the right flowers.
NOQUEEN("noQueen"), // Supply this hive with a queen or a princess and a drone.
NODRONE("noDrone"), // Mating requires a drone present.
NOSKY("noSky"), // Clear the area above the machine.
TOO_HOT("tooHot"), // The bees are melting in the heat here and unable to work. Use the habitat locator to find a cooler climate.
TOO_COLD("tooCold"), // The bees are huddled together to survive the freezing cold here. Use the habitat locator to find a warmer climate.
TOO_HUMID("tooHumid"), // The damp climate here has made the bees' wings too damp to fly. Use the habitat locator to find a dryer climate.
TOO_ARID("tooArid", "invalidBiome"), // The dry climate here has made the bees parched and unable do work. Use the habitat locator to find a wetter climate.
IS_RAINING("isRaining"), // Only tolerant fliers can work in the rain.
NOT_GLOOMY("notGloomy"), // The bees can only work in darkness.
NOT_BRIGHT("notLucid"), // The bees have trouble navigating in the dark.
NOT_DAY("notDay"), // The bees can only work during the daytime.
NOT_NIGHT("notNight"), // The bees can only work during the night.
NO_FLOWER("noFlower"), // Hive members are not finding the right flowers. Use the Beealyzer to discover their flower preference.
NO_QUEEN("noQueen"), // Supply this hive with a queen or a princess and a drone.
NO_DRONE("noDrone"), // Mating requires a drone present.
NO_SKY("noSky"), // The hive requires direct sunlight from above.
// Machines
NORESOURCE("noResource"), // More resources need to be supplied for operation.
NORECIPE("noRecipe"), // No matching recipe was found for the supplied resources.
NOSPACE("noSpace"), // Empty this machine's inventory.
NOSPACETANK("noSpaceTank", "noLiquid"), // Empty this machine's liquid tank.
NO_RESOURCE("noResource"), // More resources need to be supplied for operation.
NO_RESOURCE_INVENTORY("noResourceInventory", "noResource"), // Resources need to be added to the machine's inventory to craft this recipe.
NO_RESOURCE_LIQUID("noResourceLiquid", "noLiquid"), // More liquid resources need to be supplied for operation.
NO_RECIPE("noRecipe"), // No matching recipe was found for the supplied resources.
NO_SPACE_INVENTORY("noSpace"), // Empty this machine's inventory.
NO_SPACE_TANK("noSpaceTank", "noLiquid"), // Empty this machine's liquid tank.
NO_POWER("noPower"), // This machine requires RF energy from an engine to function.
NO_REDSTONE("noRedstone", "disabled"), // This machine requires a redstone signal to activate it.
DISABLED_BY_REDSTONE("disabledRedstone", "disabled"), // This machine is being disabled by a redstone signal.
NOT_DARK("notDark", "notGloomy"), // A lower light level is required for operation.
// Rain Tank
NOT_RAINING("notRaining"), // Operation is only possible when it is raining.
NO_RAIN_BIOME("noRainBiome", "notRaining"), // This location never receives rain.
NO_SKY_RAIN_TANK("noSkyRainTank", "noSky"), // Clear the area above this machine so it can gather rain.
// Alyzer
NOHONEY("noHoney"), // This gadget requires honey drops or honeydew for operation.
NOTHINGANALYZE("noSpecimen"), // Supply specimen to analyze.
NO_HONEY("noHoney"), // This gadget requires honey drops or honeydew for operation.
NO_SPECIMEN("noSpecimen"), // Supply specimen to analyze.
// Engines
FORCEDCOOLDOWN("forcedCooldown"), // Engine has overheated and is forced into cooldown.
NOFUEL("noFuel"), // (Biogas & Peat-fired) Replenish this machine's fuel supplies.
NOHEAT("noHeat"), // (Biogas engine) Refill the heating tank.
NOENERGYNET("noEnergyNet"), // Your world is barren of any electricity. (Install IndustrialCraft\u00b2.)
FORCED_COOLDOWN("forcedCooldown"), // Engine has overheated and is forced into cooldown.
NO_FUEL("noFuel"), // (Biogas & Peat-fired) Replenish this machine's fuel supplies.
NO_HEAT("noHeat"), // (Biogas engine) Refill the heating tank.
NO_ENERGY_NET("noEnergyNet"), // Your world is barren of any electricity. (Install IndustrialCraft\u00b2.)
// Trade Station
NOSTAMPS("noStamps"), // The trade station requires more stamps to pay postage.
NOPAPER("noPaper"), // The trade station requires more paper to send letters.
NOSUPPLIES("noSupplies", "noResource"), // The trade station requires more supplies to send.
NOTRADE("noTrade", "noResource"), // The trade station requires items to Send and Receive.
NO_STAMPS("noStamps"), // The trade station requires more stamps to pay postage.
NO_PAPER("noPaper"), // The trade station requires more paper to send letters.
NO_SUPPLIES("noSupplies", "noResource"), // The trade station requires more supplies to send.
NO_TRADE("noTrade", "noResource"), // The trade station requires items to Send and Receive.
// Trade Station naming
NOTALPHANUMERIC("notAlphaNumeric"), // Given string must consist of letters and numbers only.
NOTUNIQUE("notUnique"), // Given string must be unique in this world. Choose a different one.
NOT_ALPHANUMERIC("notAlphaNumeric"), // A Trade Station name must consist of letters and numbers only.
NOT_UNIQUE("notUnique"), // Trade Station names must be unique and this name is already taken.
// Letters
NOTPOSTPAID("notPostpaid", "noStamps"), // Apply more stamps to pay the postal service.
NORECIPIENT("noRecipient"), // You need to address your letter to a recipient to send it.
NOT_POST_PAID("notPostpaid", "noStamps"), // Apply more stamps to pay the postal service.
NO_RECIPIENT("noRecipient"), // You need to address your letter to a recipient to send it.
// Circuit Boards
NOCIRCUITBOARD("noCircuitBoard"), // Insert a circuit board to solder the selected tubes onto it.
NOCIRCUITLAYOUT("noCircuitLayout"), // No layouts available due to the current game settings.
CIRCUITMISMATCH("circuitMismatch"), // Amount of tubes does not match size of circuit board.
NO_CIRCUIT_BOARD("noCircuitBoard"), // Insert a circuit board to solder the selected tubes onto it.
NO_CIRCUIT_LAYOUT("noCircuitLayout"), // No layouts available due to the current game settings.
CIRCUIT_MISMATCH("circuitMismatch"), // Amount of tubes does not match size of circuit board.
NOFERTILIZER("noFertilizer"),
NOFARMLAND("noFarmland"),
NOLIQUID("noLiquid"),
NOPOWER("noPower"), // This machine requires RF power to do work.
NOREDSTONE("noRedstone", "disabled"), // This machine requires a redstone signal to activate it.
DISABLED("disabledRedstone", "disabled") // This machine is being disabled by a redstone signal.
// Farms
NO_FERTILIZER("noFertilizer"), // Farms require fertilizer for function. Compost is insufficient.
NO_FARMLAND("noFarmland"), // Smooth sandstone, bricks or stone bricks create a platform the farm will build on.
NO_LIQUID_FARM("noLiquid") // Depending on rainfall, temperature and humidity farms need to be supplied with varying amounts of water.
;
private final String name;
@@ -109,11 +109,11 @@ public abstract class ItemInventoryAlyzer extends ItemInventory implements IErro
ImmutableSet.Builder<IErrorState> errorStates = ImmutableSet.builder();
if (!hasSpecimen()) {
errorStates.add(EnumErrorCode.NOTHINGANALYZE);
errorStates.add(EnumErrorCode.NO_SPECIMEN);
}
if (!isEnergy(getStackInSlot(SLOT_ENERGY))) {
errorStates.add(EnumErrorCode.NOHONEY);
errorStates.add(EnumErrorCode.NO_HONEY);
}
return errorStates.build();
@@ -165,13 +165,13 @@ public class ItemInventorySolderingIron extends ItemInventory implements IErrorS
ImmutableSet.Builder<IErrorState> errorStates = ImmutableSet.builder();
if (layouts.getCurrent() == CircuitRegistry.DUMMY_LAYOUT) {
errorStates.add(EnumErrorCode.NOCIRCUITLAYOUT);
errorStates.add(EnumErrorCode.NO_CIRCUIT_LAYOUT);
}
ItemStack blankCircuitBoard = getStackInSlot(blankSlot);
if (blankCircuitBoard == null) {
errorStates.add(EnumErrorCode.NOCIRCUITBOARD);
errorStates.add(EnumErrorCode.NO_CIRCUIT_BOARD);
} else {
EnumCircuitBoardType type = EnumCircuitBoardType.values()[blankCircuitBoard.getItemDamage()];
@@ -183,11 +183,11 @@ public class ItemInventorySolderingIron extends ItemInventory implements IErrorS
}
if (circuitCount != type.getSockets()) {
errorStates.add(EnumErrorCode.CIRCUITMISMATCH);
errorStates.add(EnumErrorCode.CIRCUIT_MISMATCH);
} else {
int count = getCircuitCount();
if (count != type.getSockets()) {
errorStates.add(EnumErrorCode.NOCIRCUITLAYOUT);
errorStates.add(EnumErrorCode.NO_CIRCUIT_LAYOUT);
}
}
}
@@ -37,6 +37,7 @@ import forestry.core.config.ForestryBlock;
import forestry.core.config.ForestryItem;
import forestry.core.fluids.Fluids;
import forestry.core.gui.ContainerDummy;
import forestry.core.inventory.InventoryPlain;
import forestry.core.utils.ItemStackUtil;
import forestry.core.utils.Log;
@@ -182,9 +182,9 @@ public class TileAnalyzer extends TilePowered implements ISidedInventory, ILiqui
}
}
getErrorLogic().setCondition(!hasSpecimen, EnumErrorCode.NOTHINGANALYZE);
getErrorLogic().setCondition(!hasResource, EnumErrorCode.NORESOURCE);
getErrorLogic().setCondition(!hasSpace, EnumErrorCode.NOSPACE);
getErrorLogic().setCondition(!hasSpecimen, EnumErrorCode.NO_SPECIMEN);
getErrorLogic().setCondition(!hasResource, EnumErrorCode.NO_RESOURCE_LIQUID);
getErrorLogic().setCondition(!hasSpace, EnumErrorCode.NO_SPACE_INVENTORY);
return hasSpecimen && hasResource && hasSpace;
}
@@ -118,10 +118,10 @@ public abstract class TileEngine extends TileBase implements IEnergyConnection,
}
IErrorLogic errorLogic = getErrorLogic();
errorLogic.setCondition(forceCooldown, EnumErrorCode.FORCEDCOOLDOWN);
errorLogic.setCondition(forceCooldown, EnumErrorCode.FORCED_COOLDOWN);
boolean enabledRedstone = isRedstoneActivated();
errorLogic.setCondition(!enabledRedstone, EnumErrorCode.NOREDSTONE);
errorLogic.setCondition(!enabledRedstone, EnumErrorCode.NO_REDSTONE);
// Determine targeted tile
TileEntity tile = worldObj.getTileEntity(xCoord + getOrientation().offsetX, yCoord + getOrientation().offsetY, zCoord + getOrientation().offsetZ);
@@ -103,7 +103,7 @@ public abstract class TilePowered extends TileBase implements IRenderableTile, I
IErrorLogic errorLogic = getErrorLogic();
boolean disabled = isRedstoneActivated();
errorLogic.setCondition(disabled, EnumErrorCode.DISABLED);
errorLogic.setCondition(disabled, EnumErrorCode.DISABLED_BY_REDSTONE);
if (disabled) {
return;
}
@@ -118,13 +118,13 @@ public abstract class TilePowered extends TileBase implements IRenderableTile, I
int energyPerWorkCycle = getEnergyPerWorkCycle();
boolean consumedEnergy = energyManager.consumeEnergyToDoWork(ticksPerWorkCycle, energyPerWorkCycle);
if (consumedEnergy) {
errorLogic.setCondition(false, EnumErrorCode.NOPOWER);
errorLogic.setCondition(false, EnumErrorCode.NO_POWER);
workCounter++;
noPowerTime = 0;
} else {
noPowerTime++;
if (noPowerTime > 4) {
errorLogic.setCondition(true, EnumErrorCode.NOPOWER);
errorLogic.setCondition(true, EnumErrorCode.NO_POWER);
}
}
}
@@ -93,10 +93,10 @@ public class TileEngineBiogas extends TileEngine implements ISidedInventory, ILi
IErrorLogic errorLogic = getErrorLogic();
boolean hasHeat = getHeatLevel() > 0.2 || heatingTank.getFluidAmount() > 0;
errorLogic.setCondition(!hasHeat, EnumErrorCode.NOHEAT);
errorLogic.setCondition(!hasHeat, EnumErrorCode.NO_HEAT);
boolean hasFuel = burnTime > 0 || fuelTank.getFluidAmount() > 0;
errorLogic.setCondition(!hasFuel, EnumErrorCode.NOFUEL);
errorLogic.setCondition(!hasFuel, EnumErrorCode.NO_FUEL);
}
/**
@@ -152,7 +152,7 @@ public class TileEngineElectric extends TileEngine implements ISocketable, IInve
IErrorLogic errorLogic = getErrorLogic();
// No work to be done if IC2 is unavailable.
if (errorLogic.setCondition(ic2EnergySink == null, EnumErrorCode.NOENERGYNET)) {
if (errorLogic.setCondition(ic2EnergySink == null, EnumErrorCode.NO_ENERGY_NET)) {
return;
}
@@ -174,7 +174,7 @@ public class TileEngineElectric extends TileEngine implements ISocketable, IInve
}
boolean canUseEnergy = ic2EnergySink.canUseEnergy(euConfig.euForCycle);
errorLogic.setCondition(!canUseEnergy, EnumErrorCode.NOFUEL);
errorLogic.setCondition(!canUseEnergy, EnumErrorCode.NO_FUEL);
}
@Override
@@ -102,7 +102,7 @@ public class TileEnginePeat extends TileEngine implements ISidedInventory {
int fuelSlot = getFuelSlot();
boolean hasFuel = fuelSlot >= 0 && determineBurnDuration(getInternalInventory().getStackInSlot(fuelSlot)) > 0;
getErrorLogic().setCondition(!hasFuel, EnumErrorCode.NOFUEL);
getErrorLogic().setCondition(!hasFuel, EnumErrorCode.NO_FUEL);
}
@Override
@@ -127,7 +127,7 @@ public class TileGenerator extends TileBase implements ISidedInventory, ILiquidT
IErrorLogic errorLogic = getErrorLogic();
// No work to be done if IC2 is unavailable.
if (errorLogic.setCondition(ic2EnergySource == null, EnumErrorCode.NOENERGYNET)) {
if (errorLogic.setCondition(ic2EnergySource == null, EnumErrorCode.NO_ENERGY_NET)) {
return;
}
@@ -148,7 +148,7 @@ public class TileGenerator extends TileBase implements ISidedInventory, ILiquidT
}
boolean hasFuel = resourceTank.getFluidAmount() > 0;
errorLogic.setCondition(!hasFuel, EnumErrorCode.NOFUEL);
errorLogic.setCondition(!hasFuel, EnumErrorCode.NO_FUEL);
}
public boolean isWorking() {
@@ -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
@@ -292,12 +292,12 @@ public class FarmController extends RectangularMultiblockControllerBase implemen
if (hasPower) {
noPowerTime = 0;
getErrorLogic().setCondition(false, EnumErrorCode.NOPOWER);
getErrorLogic().setCondition(false, EnumErrorCode.NO_POWER);
} else {
if (noPowerTime <= 4) {
noPowerTime++;
} else {
getErrorLogic().setCondition(true, EnumErrorCode.NOPOWER);
getErrorLogic().setCondition(true, EnumErrorCode.NO_POWER);
}
}
@@ -469,12 +469,12 @@ public class FarmController extends RectangularMultiblockControllerBase implemen
if (!pendingProduce.isEmpty()) {
boolean added = inventory.tryAddPendingProduce(pendingProduce);
errorLogic.setCondition(!added, EnumErrorCode.NOSPACE);
errorLogic.setCondition(!added, EnumErrorCode.NO_SPACE_INVENTORY);
return added;
}
boolean hasFertilizer = fertilizerManager.maintainFertilizer(inventory);
if (errorLogic.setCondition(!hasFertilizer, EnumErrorCode.NOFERTILIZER)) {
if (errorLogic.setCondition(!hasFertilizer, EnumErrorCode.NO_FERTILIZER)) {
return false;
}
@@ -527,9 +527,9 @@ public class FarmController extends RectangularMultiblockControllerBase implemen
}
if (stage == Stage.CULTIVATE) {
errorLogic.setCondition(!farmWorkStatus.hasFarmland, EnumErrorCode.NOFARMLAND);
errorLogic.setCondition(!farmWorkStatus.hasFertilizer, EnumErrorCode.NOFERTILIZER);
errorLogic.setCondition(!farmWorkStatus.hasLiquid, EnumErrorCode.NOLIQUID);
errorLogic.setCondition(!farmWorkStatus.hasFarmland, EnumErrorCode.NO_FARMLAND);
errorLogic.setCondition(!farmWorkStatus.hasFertilizer, EnumErrorCode.NO_FERTILIZER);
errorLogic.setCondition(!farmWorkStatus.hasLiquid, EnumErrorCode.NO_LIQUID_FARM);
}
// alternate between cultivation and harvest.
@@ -754,7 +754,7 @@ public class FarmController extends RectangularMultiblockControllerBase implemen
// Check fertilizer
Boolean hasFertilizer = fertilizerManager.hasFertilizer(fertilizerConsumption);
if (errorLogic.setCondition(!hasFertilizer, EnumErrorCode.NOFERTILIZER)) {
if (errorLogic.setCondition(!hasFertilizer, EnumErrorCode.NO_FERTILIZER)) {
return false;
}
@@ -764,7 +764,7 @@ public class FarmController extends RectangularMultiblockControllerBase implemen
FluidStack requiredLiquid = Fluids.WATER.getFluid(waterConsumption);
boolean hasLiquid = requiredLiquid.amount == 0 || hasLiquid(requiredLiquid);
if (errorLogic.setCondition(!hasLiquid, EnumErrorCode.NOLIQUID)) {
if (errorLogic.setCondition(!hasLiquid, EnumErrorCode.NO_LIQUID_FARM)) {
return false;
}
@@ -133,11 +133,11 @@ public class ItemInventoryLetter extends ItemInventory implements IErrorSource,
ImmutableSet.Builder<IErrorState> errorStates = ImmutableSet.builder();
if (!letter.hasRecipient()) {
errorStates.add(EnumErrorCode.NORECIPIENT);
errorStates.add(EnumErrorCode.NO_RECIPIENT);
}
if (!letter.isProcessed() && !letter.isPostPaid()) {
errorStates.add(EnumErrorCode.NOTPOSTPAID);
errorStates.add(EnumErrorCode.NOT_POST_PAID);
}
return errorStates.build();
@@ -132,24 +132,24 @@ public class TileTrader extends TileBase {
IErrorLogic errorLogic = getErrorLogic();
errorLogic.setCondition(!hasPostageMin(3), EnumErrorCode.NOSTAMPS);
errorLogic.setCondition(!hasPaperMin(2), EnumErrorCode.NOPAPER);
errorLogic.setCondition(!hasPostageMin(3), EnumErrorCode.NO_STAMPS);
errorLogic.setCondition(!hasPaperMin(2), EnumErrorCode.NO_PAPER);
IInventory inventory = getInternalInventory();
ItemStack tradeGood = inventory.getStackInSlot(TradeStation.SLOT_TRADEGOOD);
errorLogic.setCondition(tradeGood == null, EnumErrorCode.NOTRADE);
errorLogic.setCondition(tradeGood == null, EnumErrorCode.NO_TRADE);
boolean hasRequest = hasItemCount(TradeStation.SLOT_EXCHANGE_1, TradeStation.SLOT_EXCHANGE_COUNT, null, 1);
errorLogic.setCondition(!hasRequest, EnumErrorCode.NOTRADE);
errorLogic.setCondition(!hasRequest, EnumErrorCode.NO_TRADE);
if (tradeGood != null) {
boolean hasSupplies = hasItemCount(TradeStation.SLOT_SEND_BUFFER, TradeStation.SLOT_SEND_BUFFER_COUNT, tradeGood, tradeGood.stackSize);
errorLogic.setCondition(!hasSupplies, EnumErrorCode.NOSUPPLIES);
errorLogic.setCondition(!hasSupplies, EnumErrorCode.NO_SUPPLIES);
}
if (inventory instanceof TradeStation && updateOnInterval(200)) {
boolean canReceivePayment = ((TradeStation) inventory).canReceivePayment();
errorLogic.setCondition(!canReceivePayment, EnumErrorCode.NOSPACE);
errorLogic.setCondition(!canReceivePayment, EnumErrorCode.NO_SPACE_INVENTORY);
}
}
@@ -161,7 +161,7 @@ public class TileTrader extends TileBase {
IErrorLogic errorLogic = getErrorLogic();
return !errorLogic.contains(EnumErrorCode.NOTALPHANUMERIC) && !errorLogic.contains(EnumErrorCode.NOTUNIQUE);
return !errorLogic.contains(EnumErrorCode.NOT_ALPHANUMERIC) && !errorLogic.contains(EnumErrorCode.NOT_UNIQUE);
}
/**
@@ -289,10 +289,10 @@ public class TileTrader extends TileBase {
IErrorLogic errorLogic = getErrorLogic();
boolean hasValidTradeAddress = PostManager.postRegistry.isValidTradeAddress(worldObj, address);
errorLogic.setCondition(!hasValidTradeAddress, EnumErrorCode.NOTALPHANUMERIC);
errorLogic.setCondition(!hasValidTradeAddress, EnumErrorCode.NOT_ALPHANUMERIC);
boolean hasUniqueTradeAddress = PostManager.postRegistry.isAvailableTradeAddress(worldObj, address);
errorLogic.setCondition(!hasUniqueTradeAddress, EnumErrorCode.NOTUNIQUE);
errorLogic.setCondition(!hasUniqueTradeAddress, EnumErrorCode.NOT_UNIQUE);
if (hasValidTradeAddress & hasUniqueTradeAddress) {
this.address = address;