use of net.minecraft.block.properties.PropertyBool in project MorePlanets by SteveKunG.
the class BlockVinesMP method updateTick.
@Override
public void updateTick(World world, BlockPos pos, IBlockState state, Random rand) {
if (!world.isRemote) {
if (world.rand.nextInt(4) == 0) {
int i = 4;
int j = 5;
boolean flag = false;
label62: for (int k = -i; k <= i; ++k) {
for (int l = -i; l <= i; ++l) {
for (int i1 = -1; i1 <= 1; ++i1) {
if (world.getBlockState(pos.add(k, i1, l)).getBlock() == this) {
--j;
if (j <= 0) {
flag = true;
break label62;
}
}
}
}
}
EnumFacing enumfacing1 = EnumFacing.random(rand);
BlockPos blockpos1 = pos.up();
if (enumfacing1 == EnumFacing.UP && pos.getY() < 255 && world.isAirBlock(blockpos1)) {
if (!flag) {
IBlockState iblockstate2 = state;
for (EnumFacing enumfacing3 : EnumFacing.Plane.HORIZONTAL) {
if (rand.nextBoolean() || !this.canAttachVineOn(world.getBlockState(blockpos1.offset(enumfacing3)))) {
iblockstate2 = iblockstate2.withProperty(getPropertyFor(enumfacing3), Boolean.valueOf(false));
}
}
if (iblockstate2.getValue(NORTH).booleanValue() || iblockstate2.getValue(EAST).booleanValue() || iblockstate2.getValue(SOUTH).booleanValue() || iblockstate2.getValue(WEST).booleanValue()) {
world.setBlockState(blockpos1, iblockstate2, 2);
}
}
} else if (enumfacing1.getAxis().isHorizontal() && !state.getValue(getPropertyFor(enumfacing1)).booleanValue()) {
if (!flag) {
BlockPos blockpos3 = pos.offset(enumfacing1);
if (world.getBlockState(blockpos3).getMaterial() == Material.AIR) {
EnumFacing enumfacing2 = enumfacing1.rotateY();
EnumFacing enumfacing4 = enumfacing1.rotateYCCW();
boolean flag1 = state.getValue(getPropertyFor(enumfacing2)).booleanValue();
boolean flag2 = state.getValue(getPropertyFor(enumfacing4)).booleanValue();
BlockPos blockpos4 = blockpos3.offset(enumfacing2);
BlockPos blockpos = blockpos3.offset(enumfacing4);
if (flag1 && this.canAttachVineOn(world.getBlockState(blockpos4))) {
world.setBlockState(blockpos3, this.getDefaultState().withProperty(getPropertyFor(enumfacing2), Boolean.valueOf(true)), 2);
} else if (flag2 && this.canAttachVineOn(world.getBlockState(blockpos))) {
world.setBlockState(blockpos3, this.getDefaultState().withProperty(getPropertyFor(enumfacing4), Boolean.valueOf(true)), 2);
} else if (flag1 && world.isAirBlock(blockpos4) && this.canAttachVineOn(world.getBlockState(pos.offset(enumfacing2)))) {
world.setBlockState(blockpos4, this.getDefaultState().withProperty(getPropertyFor(enumfacing1.getOpposite()), Boolean.valueOf(true)), 2);
} else if (flag2 && world.isAirBlock(blockpos) && this.canAttachVineOn(world.getBlockState(pos.offset(enumfacing4)))) {
world.setBlockState(blockpos, this.getDefaultState().withProperty(getPropertyFor(enumfacing1.getOpposite()), Boolean.valueOf(true)), 2);
} else if (this.canAttachVineOn(world.getBlockState(blockpos3.up()))) {
world.setBlockState(blockpos3, this.getDefaultState(), 2);
}
} else if (world.getBlockState(blockpos3).getMaterial().isOpaque() && world.getBlockState(blockpos3).isFullCube()) {
world.setBlockState(pos, state.withProperty(getPropertyFor(enumfacing1), Boolean.valueOf(true)), 2);
}
}
} else {
if (pos.getY() > 1) {
BlockPos blockpos2 = pos.down();
IBlockState iblockstate = world.getBlockState(blockpos2);
Block block = iblockstate.getBlock();
if (iblockstate.getMaterial() == Material.AIR) {
IBlockState iblockstate1 = state;
for (EnumFacing enumfacing : EnumFacing.Plane.HORIZONTAL) {
if (rand.nextBoolean()) {
iblockstate1 = iblockstate1.withProperty(getPropertyFor(enumfacing), Boolean.valueOf(false));
}
}
if (iblockstate1.getValue(NORTH).booleanValue() || iblockstate1.getValue(EAST).booleanValue() || iblockstate1.getValue(SOUTH).booleanValue() || iblockstate1.getValue(WEST).booleanValue()) {
world.setBlockState(blockpos2, iblockstate1, 2);
}
} else if (block == this) {
IBlockState iblockstate3 = iblockstate;
for (EnumFacing enumfacing5 : EnumFacing.Plane.HORIZONTAL) {
PropertyBool propertybool = getPropertyFor(enumfacing5);
if (rand.nextBoolean() && state.getValue(propertybool).booleanValue()) {
iblockstate3 = iblockstate3.withProperty(propertybool, Boolean.valueOf(true));
}
}
if (iblockstate3.getValue(NORTH).booleanValue() || iblockstate3.getValue(EAST).booleanValue() || iblockstate3.getValue(SOUTH).booleanValue() || iblockstate3.getValue(WEST).booleanValue()) {
world.setBlockState(blockpos2, iblockstate3, 2);
}
}
}
}
}
}
}
use of net.minecraft.block.properties.PropertyBool in project Almura by AlmuraDev.
the class MixinBlockVine method updateTick.
/**
* @author Dockter - Mike Howe
* @reason Don't tick vines in Orilla
*/
// TODO: There must be a better way to do this.
@Overwrite
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand) {
if (!worldIn.isRemote) {
if (// Specifically for Orilla only at the moment.
worldIn.rand.nextInt(4) == 0 && !worldIn.getWorldInfo().getWorldName().equalsIgnoreCase("orilla")) {
int i = 4;
int j = 5;
boolean flag = false;
label181: for (int k = -4; k <= 4; ++k) {
for (int l = -4; l <= 4; ++l) {
for (int i1 = -1; i1 <= 1; ++i1) {
if (worldIn.getBlockState(pos.add(k, i1, l)).getBlock() == this) {
--j;
if (j <= 0) {
flag = true;
break label181;
}
}
}
}
}
EnumFacing enumfacing1 = EnumFacing.random(rand);
BlockPos blockpos2 = pos.up();
if (enumfacing1 == EnumFacing.UP && pos.getY() < 255 && worldIn.isAirBlock(blockpos2)) {
IBlockState iblockstate2 = state;
for (EnumFacing enumfacing2 : EnumFacing.Plane.HORIZONTAL) {
if (rand.nextBoolean() && this.canAttachTo(worldIn, blockpos2, enumfacing2.getOpposite())) {
iblockstate2 = iblockstate2.withProperty(getPropertyFor(enumfacing2), Boolean.valueOf(true));
} else {
iblockstate2 = iblockstate2.withProperty(getPropertyFor(enumfacing2), Boolean.valueOf(false));
}
}
if (((Boolean) iblockstate2.getValue(NORTH)).booleanValue() || ((Boolean) iblockstate2.getValue(EAST)).booleanValue() || ((Boolean) iblockstate2.getValue(SOUTH)).booleanValue() || ((Boolean) iblockstate2.getValue(WEST)).booleanValue()) {
worldIn.setBlockState(blockpos2, iblockstate2, 2);
}
} else if (enumfacing1.getAxis().isHorizontal() && !((Boolean) state.getValue(getPropertyFor(enumfacing1))).booleanValue()) {
if (!flag) {
BlockPos blockpos4 = pos.offset(enumfacing1);
IBlockState iblockstate3 = worldIn.getBlockState(blockpos4);
Block block1 = iblockstate3.getBlock();
if (block1.getMaterial(iblockstate3) == Material.AIR) {
EnumFacing enumfacing3 = enumfacing1.rotateY();
EnumFacing enumfacing4 = enumfacing1.rotateYCCW();
boolean flag1 = ((Boolean) state.getValue(getPropertyFor(enumfacing3))).booleanValue();
boolean flag2 = ((Boolean) state.getValue(getPropertyFor(enumfacing4))).booleanValue();
BlockPos blockpos = blockpos4.offset(enumfacing3);
BlockPos blockpos1 = blockpos4.offset(enumfacing4);
if (flag1 && this.canAttachTo(worldIn, blockpos.offset(enumfacing3), enumfacing3)) {
worldIn.setBlockState(blockpos4, this.getDefaultState().withProperty(getPropertyFor(enumfacing3), Boolean.valueOf(true)), 2);
} else if (flag2 && this.canAttachTo(worldIn, blockpos1.offset(enumfacing4), enumfacing4)) {
worldIn.setBlockState(blockpos4, this.getDefaultState().withProperty(getPropertyFor(enumfacing4), Boolean.valueOf(true)), 2);
} else if (flag1 && worldIn.isAirBlock(blockpos) && this.canAttachTo(worldIn, blockpos, enumfacing1)) {
worldIn.setBlockState(blockpos, this.getDefaultState().withProperty(getPropertyFor(enumfacing1.getOpposite()), Boolean.valueOf(true)), 2);
} else if (flag2 && worldIn.isAirBlock(blockpos1) && this.canAttachTo(worldIn, blockpos1, enumfacing1)) {
worldIn.setBlockState(blockpos1, this.getDefaultState().withProperty(getPropertyFor(enumfacing1.getOpposite()), Boolean.valueOf(true)), 2);
}
} else if (iblockstate3.getBlockFaceShape(worldIn, blockpos4, enumfacing1) == BlockFaceShape.SOLID) {
worldIn.setBlockState(pos, state.withProperty(getPropertyFor(enumfacing1), Boolean.valueOf(true)), 2);
}
}
} else {
if (pos.getY() > 1) {
BlockPos blockpos3 = pos.down();
IBlockState iblockstate = worldIn.getBlockState(blockpos3);
Block block = iblockstate.getBlock();
if (block.getMaterial(iblockstate) == Material.AIR) {
IBlockState iblockstate1 = state;
for (EnumFacing enumfacing : EnumFacing.Plane.HORIZONTAL) {
if (rand.nextBoolean()) {
iblockstate1 = iblockstate1.withProperty(getPropertyFor(enumfacing), Boolean.valueOf(false));
}
}
if (((Boolean) iblockstate1.getValue(NORTH)).booleanValue() || ((Boolean) iblockstate1.getValue(EAST)).booleanValue() || ((Boolean) iblockstate1.getValue(SOUTH)).booleanValue() || ((Boolean) iblockstate1.getValue(WEST)).booleanValue()) {
worldIn.setBlockState(blockpos3, iblockstate1, 2);
}
} else if (block == this) {
IBlockState iblockstate4 = iblockstate;
for (EnumFacing enumfacing5 : EnumFacing.Plane.HORIZONTAL) {
PropertyBool propertybool = getPropertyFor(enumfacing5);
if (rand.nextBoolean() && ((Boolean) state.getValue(propertybool)).booleanValue()) {
iblockstate4 = iblockstate4.withProperty(propertybool, Boolean.valueOf(true));
}
}
if (((Boolean) iblockstate4.getValue(NORTH)).booleanValue() || ((Boolean) iblockstate4.getValue(EAST)).booleanValue() || ((Boolean) iblockstate4.getValue(SOUTH)).booleanValue() || ((Boolean) iblockstate4.getValue(WEST)).booleanValue()) {
worldIn.setBlockState(blockpos3, iblockstate4, 2);
}
}
}
}
}
}
}
Aggregations