mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-19 03:49:31 +00:00
More shearing tweaks
* Shearing ratio is now dynamic, between 10% at empty supply slot and 100% at the configured reserve * Harvested seeds/sappling are added to the supply slot for the quarter they were harvested from, then the others in order
This commit is contained in:
1 parent
7b1745ae5c
commit
593c395ad7
3 files changed
+36
-14
No files matched your search
@@ -974,8 +974,9 @@ public final class Config {
|
||||
"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);
|
||||
"The amount of 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 part the leaves and break the others for spalings. Set this to 0 to " +
|
||||
"always shear all 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);
|
||||
|
||||
@@ -90,8 +90,10 @@ public class TileFarmStation extends AbstractPoweredTaskEntity {
|
||||
private static final int minToolSlot = 0;
|
||||
private static final int maxToolSlot = 2;
|
||||
|
||||
public static final int NUM_SUPPLY_SLOTS = 4;
|
||||
|
||||
public static final int minSupSlot = maxToolSlot + 1;
|
||||
public static final int maxSupSlot = minSupSlot + 4;
|
||||
public static final int maxSupSlot = maxToolSlot + NUM_SUPPLY_SLOTS;
|
||||
|
||||
private final BitSet lockedSlots = new BitSet();
|
||||
|
||||
@@ -416,7 +418,7 @@ public class TileFarmStation extends AbstractPoweredTaskEntity {
|
||||
PacketHandler.INSTANCE.sendToAllAround(pkt, new TargetPoint(worldObj.provider.dimensionId, bc.x, bc.y, bc.z, 64));
|
||||
for (EntityItem ei : harvest.getDrops()) {
|
||||
if(ei != null) {
|
||||
insertHarvestDrop(ei);
|
||||
insertHarvestDrop(ei, bc);
|
||||
if(!ei.isDead) {
|
||||
worldObj.spawnEntityInWorld(ei);
|
||||
}
|
||||
@@ -443,10 +445,18 @@ public class TileFarmStation extends AbstractPoweredTaskEntity {
|
||||
return inv != null && (inv.stackSize > 1 || !isSlotLocked(slot)) && inv.isItemEqual(seeds);
|
||||
}
|
||||
|
||||
public boolean isLowOnSaplings(BlockCoord bc) {
|
||||
/*
|
||||
* Returns a fuzzy boolean:
|
||||
*
|
||||
* <=0 - break no leaves for saplings
|
||||
* 50 - break half the leaves for saplings
|
||||
* 90 - break 90% of the leaves for saplings
|
||||
*/
|
||||
public int isLowOnSaplings(BlockCoord bc) {
|
||||
int slot = getSupplySlotForCoord(bc);
|
||||
ItemStack inv = inventory[slot];
|
||||
return Config.farmSaplingReserveAmount > 0 && (inv == null || (inv.stackSize < Config.farmSaplingReserveAmount));
|
||||
|
||||
return 90 * (Config.farmSaplingReserveAmount - (inv == null ? 0 : inv.stackSize)) / Config.farmSaplingReserveAmount;
|
||||
}
|
||||
|
||||
public ItemStack takeSeedFromSupplies(ItemStack stack, BlockCoord forBlock) {
|
||||
@@ -505,12 +515,12 @@ public class TileFarmStation extends AbstractPoweredTaskEntity {
|
||||
return minSupSlot + 3;
|
||||
}
|
||||
|
||||
private void insertHarvestDrop(Entity entity) {
|
||||
private void insertHarvestDrop(Entity entity, BlockCoord bc) {
|
||||
if(!worldObj.isRemote) {
|
||||
if(entity instanceof EntityItem && !entity.isDead) {
|
||||
EntityItem item = (EntityItem) entity;
|
||||
ItemStack stack = item.getEntityItem().copy();
|
||||
int numInserted = insertResult(stack);
|
||||
int numInserted = insertResult(stack, bc);
|
||||
stack.stackSize -= numInserted;
|
||||
item.setEntityItemStack(stack);
|
||||
if(stack.stackSize == 0) {
|
||||
@@ -521,13 +531,24 @@ public class TileFarmStation extends AbstractPoweredTaskEntity {
|
||||
}
|
||||
|
||||
|
||||
private int insertResult(ItemStack stack) {
|
||||
private int insertResult(ItemStack stack, BlockCoord bc) {
|
||||
|
||||
int slot = bc != null ? getSupplySlotForCoord(bc) : minSupSlot;
|
||||
int[] slots = new int[NUM_SUPPLY_SLOTS];
|
||||
int k = 0;
|
||||
for (int j = slot; j <= maxSupSlot; j++) {
|
||||
slots[k++] = j;
|
||||
}
|
||||
for (int j = minSupSlot; j < slot; j++) {
|
||||
slots[k++] = j;
|
||||
}
|
||||
|
||||
int origSize = stack.stackSize;
|
||||
stack = stack.copy();
|
||||
|
||||
int inserted = 0;
|
||||
for (int i = slotDefinition.minInputSlot; i <= slotDefinition.maxInputSlot && inserted < stack.stackSize; i++) {
|
||||
for (int j = 0; j < slots.length && inserted < stack.stackSize; j++) {
|
||||
int i = slots[j];
|
||||
ItemStack curStack = inventory[i];
|
||||
if(isItemValidForSlot(i, stack) && (curStack == null || curStack.stackSize < 16)) {
|
||||
if(curStack == null) {
|
||||
|
||||
@@ -118,8 +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;
|
||||
int noShearingPercentage = farm.isLowOnSaplings(bc);
|
||||
int shearCount = 0;
|
||||
|
||||
for (int i = 0; i < res.harvestedBlocks.size() && hasAxe; i++) {
|
||||
BlockCoord coord = res.harvestedBlocks.get(i);
|
||||
@@ -129,11 +129,11 @@ public class TreeFarmer implements IFarmerJoe {
|
||||
boolean wasSheared = false;
|
||||
boolean wasAxed = false;
|
||||
boolean wasWood = isWood(blk);
|
||||
fiftyFiftyToggle = !fiftyFiftyToggle;
|
||||
|
||||
if (blk instanceof IShearable && hasShears && (!lowOnSaplings || fiftyFiftyToggle)) {
|
||||
if (blk instanceof IShearable && hasShears && ((shearCount / res.harvestedBlocks.size() + noShearingPercentage) < 100)) {
|
||||
drops = ((IShearable)blk).onSheared(null, farm.getWorldObj(), coord.x, coord.y, coord.z, 0);
|
||||
wasSheared = true;
|
||||
shearCount += 100;
|
||||
} else {
|
||||
drops = blk.getDrops(farm.getWorldObj(), coord.x, coord.y, coord.z, farm.getBlockMeta(coord), farm.getAxeLootingValue());
|
||||
wasAxed = true;
|
||||
|
||||
Reference in new issue
Block a user