Merge pull request #1074 from Obbi89/BOP-1.10.2-5.0.x

Use canSustainPlant to check for fertility instead of own implementation
This commit is contained in:
Adubbz 2017-07-19 11:45:14 +10:00 committed by GitHub
commit db6476dbbf
1 changed files with 15 additions and 18 deletions

View File

@ -30,10 +30,13 @@ import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty; import net.minecraft.block.properties.IProperty;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks; import net.minecraft.init.Blocks;
import net.minecraft.item.ItemSeeds;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.EnumPlantType; import net.minecraftforge.common.EnumPlantType;
import net.minecraftforge.common.IPlantable;
public class BlockQuery public class BlockQuery
{ {
@ -287,24 +290,18 @@ public class BlockQuery
} }
else else
{ {
// Otherwise fall back to the vanilla code // Otherwise fall back to the Forge's canSustainPlant
switch (this.plantType) return block.canSustainPlant(state, world, pos, EnumFacing.UP, new IPlantable() {
{ @Override
case Desert: return block == Blocks.SAND || block == Blocks.HARDENED_CLAY || block == Blocks.STAINED_HARDENED_CLAY || block == Blocks.DIRT; public EnumPlantType getPlantType(IBlockAccess world, BlockPos pos) {
case Nether: return block == Blocks.SOUL_SAND; return plantType;
case Crop: return block == Blocks.FARMLAND || block == BOPBlocks.farmland_0 || block == BOPBlocks.farmland_1; }
case Cave: return block.isSideSolid(state, world, pos, EnumFacing.UP);
case Plains: return block == Blocks.GRASS || block == Blocks.DIRT || block == Blocks.FARMLAND || block == BOPBlocks.farmland_0 || block == BOPBlocks.farmland_1 || block == Blocks.MYCELIUM; @Override
case Water: return state.getMaterial() == Material.WATER && ((Integer)state.getValue(BlockLiquid.LEVEL)) == 0; public IBlockState getPlant(IBlockAccess world, BlockPos pos) {
case Beach: return world.getBlockState(pos);
boolean isBeach = block == Blocks.GRASS || block == Blocks.DIRT || block == Blocks.SAND || block == Blocks.MYCELIUM; }
boolean hasWater = (world.getBlockState(pos.east()).getMaterial() == Material.WATER || });
world.getBlockState(pos.west()).getMaterial() == Material.WATER ||
world.getBlockState(pos.north()).getMaterial() == Material.WATER ||
world.getBlockState(pos.south()).getMaterial() == Material.WATER);
return isBeach && hasWater;
}
return false;
} }
} }
} }