mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-28 07:55:41 +00:00
#766 Farm doesn't replant ender lillies on end stone
This commit is contained in:
1 parent
e0b22662aa
commit
46e57333ef
2 files changed
+40
-5
No files matched your search
@@ -37,7 +37,11 @@ public final class FarmersRegistry {
|
||||
private static void addExtraUtilities() {
|
||||
String mod = "ExtraUtilities";
|
||||
String name = "plant/ender_lilly";
|
||||
addSeed(mod, name, name);
|
||||
|
||||
SeedFarmer farmer = addSeed(mod, name, name, Blocks.end_stone, GameRegistry.findBlock(mod, "decorativeBlock1"));
|
||||
if(farmer != null) {
|
||||
farmer.setIgnoreGroundCanSustainCheck(true);
|
||||
}
|
||||
}
|
||||
|
||||
private static void addPickable(String mod, String blockName, String itemName) {
|
||||
@@ -50,14 +54,24 @@ public final class FarmersRegistry {
|
||||
}
|
||||
}
|
||||
|
||||
private static void addSeed(String mod, String blockName, String itemName) {
|
||||
private static SeedFarmer addSeed(String mod, String blockName, String itemName, Block... extraFarmland) {
|
||||
Block cropBlock = GameRegistry.findBlock(mod, blockName);
|
||||
if(cropBlock != null) {
|
||||
Item seedItem = GameRegistry.findItem(mod, itemName);
|
||||
if(seedItem != null) {
|
||||
FarmersCommune.instance.joinCommune(new SeedFarmer(cropBlock, new ItemStack(seedItem)));
|
||||
SeedFarmer farmer = new SeedFarmer(cropBlock, new ItemStack(seedItem));
|
||||
if(extraFarmland != null) {
|
||||
for(Block farmland : extraFarmland) {
|
||||
if(farmland != null) {
|
||||
farmer.addTilledBlock(farmland);
|
||||
}
|
||||
}
|
||||
}
|
||||
FarmersCommune.instance.joinCommune(farmer);
|
||||
return farmer;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static void addTiC() {
|
||||
|
||||
@@ -19,6 +19,8 @@ public class SeedFarmer implements IFarmerJoe {
|
||||
protected int grownBlockMeta;
|
||||
protected ItemStack seeds;
|
||||
protected boolean requiresFarmland = true;
|
||||
protected List<Block> tilledBlocks = new ArrayList<Block>();
|
||||
protected boolean ignoreSustainCheck = false;
|
||||
|
||||
public SeedFarmer(Block plantedBlock, ItemStack seeds) {
|
||||
this(plantedBlock, 0, 7, seeds);
|
||||
@@ -33,6 +35,19 @@ public class SeedFarmer implements IFarmerJoe {
|
||||
this.plantedBlockMeta = plantedBlockMeta;
|
||||
this.grownBlockMeta = grownBlockMeta;
|
||||
this.seeds = seeds;
|
||||
addTilledBlock(Blocks.farmland);
|
||||
}
|
||||
|
||||
public void addTilledBlock(Block block) {
|
||||
tilledBlocks.add(block);
|
||||
}
|
||||
|
||||
public boolean isIgnoreGroundCanSustainCheck() {
|
||||
return ignoreSustainCheck;
|
||||
}
|
||||
|
||||
public void setIgnoreGroundCanSustainCheck(boolean ignoreSustainCheck) {
|
||||
this.ignoreSustainCheck = ignoreSustainCheck;
|
||||
}
|
||||
|
||||
public int getPlantedBlockMeta() {
|
||||
@@ -158,7 +173,13 @@ public class SeedFarmer implements IFarmerJoe {
|
||||
}
|
||||
|
||||
protected boolean isGroundTilled(TileFarmStation farm, BlockCoord plantingLocation) {
|
||||
return farm.getBlock(plantingLocation.getLocation(ForgeDirection.DOWN)) == Blocks.farmland;
|
||||
Block target = farm.getBlock(plantingLocation.getLocation(ForgeDirection.DOWN));
|
||||
for(Block tst : tilledBlocks) {
|
||||
if(tst == target) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected boolean canPlant(World worldObj, BlockCoord bc) {
|
||||
@@ -167,7 +188,7 @@ public class SeedFarmer implements IFarmerJoe {
|
||||
IPlantable plantable = (IPlantable) getPlantedBlock();
|
||||
if(target.canPlaceBlockAt(worldObj, bc.x, bc.y, bc.z) &&
|
||||
target.canBlockStay(worldObj, bc.x, bc.y, bc.z) &&
|
||||
ground.canSustainPlant(worldObj, bc.x, bc.y - 1, bc.z, ForgeDirection.UP, plantable)) {
|
||||
(ground.canSustainPlant(worldObj, bc.x, bc.y - 1, bc.z, ForgeDirection.UP, plantable) || ignoreSustainCheck)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
Reference in new issue
Block a user