mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-21 04:32:18 +00:00
commit
a645601803
3 files changed
+26
-2
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
|
||||
@@ -28,9 +29,9 @@ public class CocoaFarmer extends CustomSeedFarmer
|
||||
@Override
|
||||
protected boolean plant(TileFarmStation farm, World worldObj, BlockCoord bc)
|
||||
{
|
||||
worldObj.setBlock(bc.x, bc.y, bc.z, Blocks.air, 0, 1 | 2);
|
||||
int dir = getPlantDirection(worldObj,bc);
|
||||
if (dir<0) return false;
|
||||
worldObj.setBlock(bc.x, bc.y, bc.z, Blocks.air, 0, 1 | 2);
|
||||
worldObj.setBlock(bc.x, bc.y, bc.z, getPlantedBlock(), Direction.facingToDirection[dir], 1 | 2);
|
||||
farm.actionPerformed(false);
|
||||
return true;
|
||||
|
||||
@@ -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