Skip to content

Commit

Permalink
Whoops I forgot to push this last night but fixes #271
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbegt committed Sep 26, 2016
1 parent 9472640 commit ba8ef00
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 4 deletions.
2 changes: 1 addition & 1 deletion settings.gradle
Expand Up @@ -16,4 +16,4 @@ include 'api'
include 'services:webservice'
*/

rootProject.name = 'natura'
rootProject.name = 'Natura-1.10'
Expand Up @@ -28,6 +28,7 @@
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.IStringSerializable;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
Expand Down Expand Up @@ -100,8 +101,58 @@ public int damageDropped(IBlockState state)
@Override
public boolean canPlaceBlockAt(World worldIn, BlockPos pos)
{
Block ground = worldIn.getBlockState(pos.down()).getBlock();
return ground == Blocks.SOUL_SAND || ground == Blocks.NETHERRACK || ground == NaturaNether.netherTaintedSoil;
Block block = worldIn.getBlockState(pos).getBlock();

if (block == null || block.isReplaceable(worldIn, pos))
{
IBlockState soilBlockState = worldIn.getBlockState(pos.down());
Block netherSoil = soilBlockState.getBlock();

if (netherSoil != null)
if (canGrowOnBlock(netherSoil) || netherSoil.canSustainPlant(soilBlockState, worldIn, pos.down(), EnumFacing.UP, this))
return true;

IBlockState ceilingBlockState = worldIn.getBlockState(pos.up());
Block netherCeiling = ceilingBlockState.getBlock();

if (netherCeiling != null)
if (canGrowOnBlock(netherCeiling) || netherCeiling.canSustainPlant(ceilingBlockState, worldIn, pos.up(), EnumFacing.DOWN, this))
return true;
}
return false;
}

@Override
public boolean canBlockStay(World worldIn, BlockPos pos, IBlockState state)
{
switch (state.getValue(FOLIAGE))
{
case BLOODWOOD:
IBlockState ceilingBlockState = worldIn.getBlockState(pos.up());
Block netherCeiling = ceilingBlockState.getBlock();

if (netherCeiling == null)
return false;

return canGrowOnBlock(netherCeiling) || netherCeiling.canSustainPlant(ceilingBlockState, worldIn, pos.up(), EnumFacing.DOWN, this);
case DARKWOOD:
case FUSEWOOD:
case GHOSTWOOD:
IBlockState soilBlockState = worldIn.getBlockState(pos.down());
Block netherSoil = soilBlockState.getBlock();

if (netherSoil == null)
return false;

return canGrowOnBlock(netherSoil) || netherSoil.canSustainPlant(soilBlockState, worldIn, pos.down(), EnumFacing.UP, this);
default:
return true;
}
}

public boolean canGrowOnBlock(Block block)
{
return block == Blocks.SOUL_SAND || block == Blocks.NETHERRACK || block == NaturaNether.netherTaintedSoil;
}

@Nonnull
Expand Down
Expand Up @@ -207,7 +207,7 @@ BlockPos findGround(World world, BlockPos pos)
{
IBlockState state = world.getBlockState(pos);
Block block = state.getBlock();
if ((block == Blocks.NETHERRACK) || block.canSustainPlant(state, world, pos.down(), EnumFacing.UP, (IPlantable) this.berryBush))
if ((block == Blocks.NETHERRACK) || block.canSustainPlant(state, world, pos.down(), EnumFacing.UP, (IPlantable) this.berryBush.getBlock()))
{
if (!this.isOpaqueCube(world, pos, pos.up()))
{
Expand Down

0 comments on commit ba8ef00

Please sign in to comment.