Don't bypass the blockstate and don't bypass it with wrong parameters
This commit is contained in:
Henry Loenwind 2017-01-22 11:08:40 +01:00
parent 25cb2ee6f4
commit 5ac38b686a
2 changed files with 4 additions and 4 deletions

View file

@ -163,7 +163,7 @@ public class BlockBOPDirt extends Block implements IBOPBlock, ISustainsPlantType
{ {
IBlockState upState = world.getBlockState(pos.up()); IBlockState upState = world.getBlockState(pos.up());
// if there's not enough light then there's no chance of this block becoming grassy // if there's not enough light then there's no chance of this block becoming grassy
if (world.getLightFromNeighbors(pos.up()) < 4 || upState.getBlock().getLightOpacity(upState) > 2) {return;} if (world.getLightFromNeighbors(pos.up()) < 4 || upState.getLightOpacity(world, pos.up()) > 2) {return;}
int numNearbyGrassSpreadingBlocks = 0; int numNearbyGrassSpreadingBlocks = 0;
BlockPos pos1; BlockPos pos1;

View file

@ -194,7 +194,7 @@ public class BlockBOPGrass extends BlockGrass implements IBOPBlock, ISustainsPla
{ {
// if this block is covered, then turn it back to dirt (IE kill the grass) // if this block is covered, then turn it back to dirt (IE kill the grass)
if (world.getLightFromNeighbors(pos.up()) < 4 && world.getBlockState(pos.up()).getBlock().getLightOpacity(world.getBlockState(pos.up())) > 2) if (world.getLightFromNeighbors(pos.up()) < 4 && world.getBlockState(pos.up()).getLightOpacity(world, pos.up()) > 2)
{ {
world.setBlockState(pos, getDirtBlockState(state)); world.setBlockState(pos, getDirtBlockState(state));
} }
@ -208,14 +208,14 @@ public class BlockBOPGrass extends BlockGrass implements IBOPBlock, ISustainsPla
// pick a random nearby position, and get the block, block state, and block above // pick a random nearby position, and get the block, block state, and block above
BlockPos pos1 = pos.add(rand.nextInt(xzSpread * 2 + 1) - xzSpread, rand.nextInt(downSpread + upSpread + 1) - downSpread, rand.nextInt(xzSpread * 2 + 1) - xzSpread); BlockPos pos1 = pos.add(rand.nextInt(xzSpread * 2 + 1) - xzSpread, rand.nextInt(downSpread + upSpread + 1) - downSpread, rand.nextInt(xzSpread * 2 + 1) - xzSpread);
IBlockState target = world.getBlockState(pos1); IBlockState target = world.getBlockState(pos1);
Block blockAboveTarget = world.getBlockState(pos1.up()).getBlock(); IBlockState blockAboveTarget = world.getBlockState(pos1.up());
// see if this type of grass can spread to the target block // see if this type of grass can spread to the target block
IBlockState targetGrass = spreadsToGrass(state, target); IBlockState targetGrass = spreadsToGrass(state, target);
if (targetGrass == null) {break;} if (targetGrass == null) {break;}
// if there's enough light, turn the block to the relevant grass block // if there's enough light, turn the block to the relevant grass block
if (world.getLightFromNeighbors(pos1.up()) >= 4 && blockAboveTarget.getLightOpacity(target) <= 2) if (world.getLightFromNeighbors(pos1.up()) >= 4 && blockAboveTarget.getLightOpacity(world, pos1.up()) <= 2)
{ {
world.setBlockState(pos1, targetGrass); world.setBlockState(pos1, targetGrass);
} }