mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-30 16:28:00 +01:00
Fixed hive blocks growing out of control
This commit is contained in:
parent
64666e8e60
commit
cd1fb849f7
1 changed files with 27 additions and 7 deletions
|
@ -97,14 +97,14 @@ public class BlockHiveWall extends BlockFalling {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (type == State.DYING) {
|
} else if (type == State.DYING) {
|
||||||
if (matchedNeighbours > 1 && matchedNeighbours < 27) {
|
if (matchedNeighbours > 1 && matchedNeighbours < 17) {
|
||||||
world.setBlockState(pos, state.withProperty(STATE, State.STABLE));
|
world.setBlockState(pos, state.withProperty(STATE, State.STABLE));
|
||||||
} else {
|
} else {
|
||||||
die(world, pos, rand);
|
die(world, pos, rand);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
if (pos.getX() % 3 == 0 && pos.getZ() % 4 == 0 && world.isAirBlock(pos.down()) && UBlocks.cuccoon.canPlaceBlockAt(world, pos.down())) {
|
if (pos.getX() % 3 == 0 && pos.getZ() % 4 == 0 && isEmptySpace(world, pos.down()) && UBlocks.cuccoon.canPlaceBlockAt(world, pos.down())) {
|
||||||
world.setBlockState(pos.down(), UBlocks.cuccoon.getDefaultState());
|
world.setBlockState(pos.down(), UBlocks.cuccoon.getDefaultState());
|
||||||
} else if (!testForAxis(world, pos, axis)) {
|
} else if (!testForAxis(world, pos, axis)) {
|
||||||
world.setBlockState(pos, state.withProperty(STATE, State.GROWING));
|
world.setBlockState(pos, state.withProperty(STATE, State.GROWING));
|
||||||
|
@ -134,7 +134,22 @@ public class BlockHiveWall extends BlockFalling {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean testForAxis(World world, BlockPos pos, Axis axis) {
|
protected boolean testForAxis(World world, BlockPos pos, Axis axis) {
|
||||||
return !PosHelper.some(pos, world::isAirBlock, axis.getFacings());
|
return !PosHelper.some(pos, p -> isEmptySpace(world, p), axis.getFacings());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean isEmptySpace(World world, BlockPos pos) {
|
||||||
|
|
||||||
|
if (world.isAirBlock(pos)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
IBlockState state = world.getBlockState(pos);
|
||||||
|
|
||||||
|
return !(state.getMaterial().isLiquid()
|
||||||
|
|| state.isBlockNormalCube()
|
||||||
|
|| state.isNormalCube()
|
||||||
|
|| state.isFullCube()
|
||||||
|
|| state.isOpaqueCube());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void die(World world, BlockPos pos, Random rand) {
|
protected void die(World world, BlockPos pos, Random rand) {
|
||||||
|
@ -167,7 +182,7 @@ public class BlockHiveWall extends BlockFalling {
|
||||||
|
|
||||||
if (player.getPlayerSpecies() != Race.CHANGELING) {
|
if (player.getPlayerSpecies() != Race.CHANGELING) {
|
||||||
if (!world.isRemote) {
|
if (!world.isRemote) {
|
||||||
if (((world.isAirBlock(pos.down()) || canFallThrough(world.getBlockState(pos.down()))) && pos.getY() >= 0)) {
|
if (((isEmptySpace(world, pos.down()) || canFallThrough(world.getBlockState(pos.down()))) && pos.getY() >= 0)) {
|
||||||
EntityFallingBlock faller = new EntityFallingBlock(world, pos.getX() + 0.5D, pos.getY(), pos.getZ() + 0.5D, state);
|
EntityFallingBlock faller = new EntityFallingBlock(world, pos.getX() + 0.5D, pos.getY(), pos.getZ() + 0.5D, state);
|
||||||
onStartFalling(faller);
|
onStartFalling(faller);
|
||||||
world.spawnEntity(faller);
|
world.spawnEntity(faller);
|
||||||
|
@ -177,6 +192,11 @@ public class BlockHiveWall extends BlockFalling {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onEndFalling(World world, BlockPos pos, IBlockState fallingState, IBlockState hitState) {
|
||||||
|
world.destroyBlock(pos, true);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
|
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
|
||||||
|
|
||||||
|
@ -234,17 +254,17 @@ public class BlockHiveWall extends BlockFalling {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean exposed(World world, BlockPos pos) {
|
protected boolean exposed(World world, BlockPos pos) {
|
||||||
return PosHelper.some(pos, world::isAirBlock, EnumFacing.VALUES);
|
return PosHelper.some(pos, p -> isEmptySpace(world, p), EnumFacing.VALUES);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean canSpreadInto(World world, BlockPos pos, Axis axis) {
|
protected boolean canSpreadInto(World world, BlockPos pos, Axis axis) {
|
||||||
if (world.isBlockLoaded(pos) && world.isAirBlock(pos)) {
|
if (world.isBlockLoaded(pos) && isEmptySpace(world, pos)) {
|
||||||
boolean one = false;
|
boolean one = false;
|
||||||
|
|
||||||
for (EnumFacing facing : axis.getFacings()) {
|
for (EnumFacing facing : axis.getFacings()) {
|
||||||
BlockPos op = pos.offset(facing);
|
BlockPos op = pos.offset(facing);
|
||||||
|
|
||||||
if (!world.isAirBlock(op) && !world.getBlockState(op).getMaterial().isLiquid()) {
|
if (world.getBlockState(op).getMaterial() == UMaterials.hive) {
|
||||||
if (one) {
|
if (one) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue