mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-21 20:52:42 +00:00
CustomSeedFarmer can disable TreeFarmer
Only used for cocoa beans currently but might prove useful - if the seed item is in that quadrant it won't chop trees even with an axe
This commit is contained in:
1 parent
6dcbe62db2
commit
cfaa3a9a91
3 files changed
+25
-1
No files matched your search
@@ -17,6 +17,7 @@ public class CocoaFarmer extends CustomSeedFarmer
|
||||
{
|
||||
super(Blocks.cocoa, new ItemStack(Items.dye,1,3));
|
||||
this.requiresFarmland = false;
|
||||
this.disableTreeFarm = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -22,6 +22,7 @@ public class CustomSeedFarmer implements IFarmerJoe {
|
||||
protected boolean requiresFarmland = true;
|
||||
protected List<Block> tilledBlocks = new ArrayList<Block>();
|
||||
protected boolean ignoreSustainCheck = false;
|
||||
protected boolean disableTreeFarm;
|
||||
|
||||
public CustomSeedFarmer(Block plantedBlock, ItemStack seeds) {
|
||||
this(plantedBlock, 0, 7, seeds);
|
||||
@@ -207,4 +208,8 @@ public class CustomSeedFarmer implements IFarmerJoe {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean doesDisableTreeFarm()
|
||||
{
|
||||
return disableTreeFarm;
|
||||
}
|
||||
}
|
||||
@@ -16,8 +16,14 @@ import crazypants.util.Lang;
|
||||
public class FarmersCommune implements IFarmerJoe {
|
||||
|
||||
public static FarmersCommune instance = new FarmersCommune();
|
||||
private static List<ItemStack> disableTrees = new ArrayList<ItemStack>();
|
||||
|
||||
public static void joinCommune(IFarmerJoe joe) {
|
||||
if (joe instanceof CustomSeedFarmer)
|
||||
{
|
||||
CustomSeedFarmer customSeedFarmer = (CustomSeedFarmer) joe;
|
||||
if (customSeedFarmer.doesDisableTreeFarm()) disableTrees.add(customSeedFarmer.getSeeds());
|
||||
}
|
||||
instance.farmers.add(joe);
|
||||
}
|
||||
|
||||
@@ -43,7 +49,8 @@ public class FarmersCommune implements IFarmerJoe {
|
||||
@Override
|
||||
public IHarvestResult harvestBlock(TileFarmStation farm, BlockCoord bc, Block block, int meta) {
|
||||
for (IFarmerJoe joe : farmers) {
|
||||
if(joe.canHarvest(farm, bc, block, meta)) {
|
||||
if (ignoreTreeHarvest(farm, bc, joe)) continue;
|
||||
if (joe.canHarvest(farm, bc, block, meta)) {
|
||||
return joe.harvestBlock(farm, bc, block, meta);
|
||||
}
|
||||
}
|
||||
@@ -69,4 +76,15 @@ public class FarmersCommune implements IFarmerJoe {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean ignoreTreeHarvest(TileFarmStation farm, BlockCoord bc, IFarmerJoe joe)
|
||||
{
|
||||
ItemStack stack = farm.getSeedTypeInSuppliesFor(bc);
|
||||
if (!(joe instanceof TreeFarmer) || stack == null) return false;
|
||||
for (ItemStack disableTreeStack : disableTrees)
|
||||
{
|
||||
if (disableTreeStack.isItemEqual(stack)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user