mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-24 05:44:24 +00:00
Prevent farms from accidentally destroying anything but farmland.
This commit is contained in:
1 parent
7ae094ab72
commit
3bb0acc04c
2 files changed
+25
-9
No files matched your search
@@ -10,19 +10,20 @@
|
||||
******************************************************************************/
|
||||
package forestry.farming.logic;
|
||||
|
||||
import forestry.api.farming.IFarmHousing;
|
||||
import forestry.api.farming.IFarmLogic;
|
||||
import forestry.core.config.Defaults;
|
||||
import forestry.core.config.ForestryBlock;
|
||||
import forestry.core.render.SpriteSheet;
|
||||
import forestry.core.utils.Vect;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import forestry.api.farming.IFarmHousing;
|
||||
import forestry.api.farming.IFarmLogic;
|
||||
import forestry.core.config.Defaults;
|
||||
import forestry.core.render.SpriteSheet;
|
||||
import forestry.core.utils.Vect;
|
||||
import java.util.HashSet;
|
||||
|
||||
public abstract class FarmLogic implements IFarmLogic {
|
||||
|
||||
@@ -30,6 +31,8 @@ public abstract class FarmLogic implements IFarmLogic {
|
||||
|
||||
boolean isManual;
|
||||
|
||||
static HashSet<Block> breakable = new HashSet<Block>();
|
||||
|
||||
public FarmLogic(IFarmHousing housing) {
|
||||
this.housing = housing;
|
||||
}
|
||||
@@ -39,6 +42,20 @@ public abstract class FarmLogic implements IFarmLogic {
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean canBreakGround(Block block) {
|
||||
if (breakable.isEmpty()) {
|
||||
breakable.add(Blocks.dirt);
|
||||
breakable.add(Blocks.grass);
|
||||
breakable.add(Blocks.farmland);
|
||||
breakable.add(Blocks.mycelium);
|
||||
breakable.add(Blocks.soul_sand);
|
||||
breakable.add(Blocks.water);
|
||||
breakable.add(Blocks.flowing_water);
|
||||
breakable.add(ForestryBlock.soil.block());
|
||||
}
|
||||
return breakable.contains(block);
|
||||
}
|
||||
|
||||
protected World getWorld() {
|
||||
return housing.getWorld();
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@ import forestry.core.utils.BlockUtil;
|
||||
import forestry.core.utils.StackUtils;
|
||||
import forestry.core.utils.Vect;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -79,8 +78,8 @@ public abstract class FarmLogicHomogeneous extends FarmLogic {
|
||||
for (int i = 0; i < extent; i++) {
|
||||
Vect position = translateWithOffset(x, yGround, z, direction, i);
|
||||
|
||||
ItemStack block = getAsItemStack(position);
|
||||
if (isAcceptedGround(block))
|
||||
ItemStack stack = getAsItemStack(position);
|
||||
if (isAcceptedGround(stack) || !canBreakGround(getBlock(position)))
|
||||
continue;
|
||||
|
||||
produce.addAll(BlockUtil.getBlockItemStack(getWorld(), position));
|
||||
|
||||
Reference in new issue
Block a user