Fixed plant sustainability for white sand/mud, fixed cattails being able to grow on top of each other

This commit is contained in:
Forstride 2019-07-28 06:38:55 -04:00
parent 19c5032dc4
commit 02404340cc
4 changed files with 49 additions and 5 deletions

View file

@ -10,6 +10,7 @@ package biomesoplenty.common.block;
import biomesoplenty.api.item.BOPItems;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.material.Material;
import net.minecraft.entity.Entity;
import net.minecraft.util.Direction;
import net.minecraft.util.IItemProvider;
@ -55,7 +56,12 @@ public class MudBlock extends Block
case Cave: return false;
case Plains: return false;
case Water: return false;
case Beach: return true;
case Beach:
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 hasWater;
}
return false;
}

View file

@ -39,9 +39,7 @@ public class WatersidePlantBlock extends PlantBlockBOP
public boolean isValidPosition(BlockState state, IWorldReader worldReader, BlockPos pos)
{
BlockState soil = worldReader.getBlockState(pos.down());
if (soil.getBlock() == this)
return true;
else if (soil.canSustainPlant(worldReader, pos.down(), Direction.UP, this))
if (soil.canSustainPlant(worldReader, pos.down(), Direction.UP, this))
{
BlockPos blockpos = pos.down();
Iterator var7 = Direction.Plane.HORIZONTAL.iterator();

View file

@ -0,0 +1,40 @@
package biomesoplenty.common.block;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.SandBlock;
import net.minecraft.block.material.Material;
import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockReader;
import net.minecraftforge.common.PlantType;
public class WhiteSandBlock extends SandBlock
{
public WhiteSandBlock(int p_i48338_1_, Block.Properties properties)
{
super(p_i48338_1_, properties);
}
@Override
public boolean canSustainPlant(BlockState state, IBlockReader world, BlockPos pos, Direction facing, net.minecraftforge.common.IPlantable plantable)
{
PlantType type = plantable.getPlantType(world, pos.offset(facing));
switch (type) {
case Desert: return true;
case Nether: return false;
case Crop: return false;
case Cave: return true;
case Plains: return false;
case Water: return false;
case Beach:
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 hasWater;
}
return false;
}
}

View file

@ -30,7 +30,7 @@ public class ModBlocks
public static void init()
{
//Terrain
white_sand = registerBlock(new SandBlock(0xF3F1E4, Block.Properties.create(Material.SAND, MaterialColor.QUARTZ).hardnessAndResistance(0.5F).sound(SoundType.SAND).harvestLevel(0).harvestTool(ToolType.SHOVEL)), "white_sand");
white_sand = registerBlock(new WhiteSandBlock(0xF3F1E4, Block.Properties.create(Material.SAND, MaterialColor.QUARTZ).hardnessAndResistance(0.5F).sound(SoundType.SAND).harvestLevel(0).harvestTool(ToolType.SHOVEL)), "white_sand");
white_sandstone = registerBlock(new Block(Block.Properties.create(Material.ROCK, MaterialColor.QUARTZ).hardnessAndResistance(0.8F)), "white_sandstone");
chiseled_white_sandstone = registerBlock(new Block(Block.Properties.create(Material.ROCK, MaterialColor.QUARTZ).hardnessAndResistance(0.8F)), "chiseled_white_sandstone");
cut_white_sandstone = registerBlock(new Block(Block.Properties.create(Material.ROCK, MaterialColor.QUARTZ).hardnessAndResistance(0.8F)), "cut_white_sandstone");