From 4988a16aeb1935d07f52bf6f7839b4a0d1158c32 Mon Sep 17 00:00:00 2001 From: HenryLoenwind Date: Wed, 18 Mar 2015 22:44:03 +0100 Subject: [PATCH] Shear less when low on saplings * New config setting for sapling reserve amount. * When there are less than reserver amount saplings, only half the leaves will be sheard, the other half will be harvested for saplings. --- src/main/java/crazypants/enderio/config/Config.java | 5 +++++ .../crazypants/enderio/machine/farm/TileFarmStation.java | 4 ++-- .../crazypants/enderio/machine/farm/farmers/TreeFarmer.java | 5 ++++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/main/java/crazypants/enderio/config/Config.java b/src/main/java/crazypants/enderio/config/Config.java index 9b172485..bc453e76 100644 --- a/src/main/java/crazypants/enderio/config/Config.java +++ b/src/main/java/crazypants/enderio/config/Config.java @@ -289,6 +289,7 @@ public final class Config { "ThermalExpansion:tool.hoeInvar" }; public static List farmHoes = new ArrayList(); + public static int farmSaplingReserveAmount = 8; public static int magnetPowerUsePerSecondRF = 1; public static int magnetPowerCapacityRF = 100000; @@ -972,6 +973,10 @@ public final class Config { hoeStrings = config.get(sectionFarm.name, "farmHoes", hoeStrings, "Use this to specify items that can be hoes in the farming station. Use the registry name (eg. modid:name).").getStringList(); + farmSaplingReserveAmount = config.get(sectionFarm.name, "farmSaplingReserveAmount", farmSaplingReserveAmount, + "The amount saplings the farm has to have in reserve to switch to shearing all leaves. If there are less " + + "saplings in store, it will only shear half the leaves. Set this to 0 to always shear leaves.").getInt(farmSaplingReserveAmount); + combustionGeneratorUseOpaqueModel = config.get(sectionAesthetic.name, "combustionGeneratorUseOpaqueModel", combustionGeneratorUseOpaqueModel, "If set to true: fluid will not be shown in combustion generator tanks. Improves FPS. ").getBoolean(combustionGeneratorUseOpaqueModel); diff --git a/src/main/java/crazypants/enderio/machine/farm/TileFarmStation.java b/src/main/java/crazypants/enderio/machine/farm/TileFarmStation.java index aeb4c81e..9b43b352 100644 --- a/src/main/java/crazypants/enderio/machine/farm/TileFarmStation.java +++ b/src/main/java/crazypants/enderio/machine/farm/TileFarmStation.java @@ -443,10 +443,10 @@ public class TileFarmStation extends AbstractPoweredTaskEntity { return inv != null && (inv.stackSize > 1 || !isSlotLocked(slot)) && inv.isItemEqual(seeds); } - public boolean needSeeds(BlockCoord bc) { + public boolean isLowOnSaplings(BlockCoord bc) { int slot = getSupplySlotForCoord(bc); ItemStack inv = inventory[slot]; - return (inv == null || (inv.stackSize == 1 && isSlotLocked(slot))); + return Config.farmSaplingReserveAmount > 0 && (inv == null || (inv.stackSize < Config.farmSaplingReserveAmount)); } public ItemStack takeSeedFromSupplies(ItemStack stack, BlockCoord forBlock) { diff --git a/src/main/java/crazypants/enderio/machine/farm/farmers/TreeFarmer.java b/src/main/java/crazypants/enderio/machine/farm/farmers/TreeFarmer.java index 235db310..fb038d8c 100644 --- a/src/main/java/crazypants/enderio/machine/farm/farmers/TreeFarmer.java +++ b/src/main/java/crazypants/enderio/machine/farm/farmers/TreeFarmer.java @@ -118,6 +118,8 @@ public class TreeFarmer implements IFarmerJoe { // avoid calling this in a loop boolean hasShears = farm.hasShears(); + boolean lowOnSaplings = farm.isLowOnSaplings(bc); + boolean fiftyFiftyToggle = false; for (int i = 0; i < res.harvestedBlocks.size() && hasAxe; i++) { BlockCoord coord = res.harvestedBlocks.get(i); @@ -127,8 +129,9 @@ public class TreeFarmer implements IFarmerJoe { boolean wasSheared = false; boolean wasAxed = false; boolean wasWood = isWood(blk); + fiftyFiftyToggle = !fiftyFiftyToggle; - if (blk instanceof IShearable && hasShears) { + if (blk instanceof IShearable && hasShears && (!lowOnSaplings || fiftyFiftyToggle)) { drops = ((IShearable)blk).onSheared(null, farm.getWorldObj(), coord.x, coord.y, coord.z, 0); wasSheared = true; } else {