public static PropertyBool getPropertyFor(EnumFacing side) { switch (side) { case UP: return UP; case NORTH: return NORTH; case SOUTH: return SOUTH; case EAST: return EAST; case WEST: return WEST; default: throw new IllegalArgumentException(side + " is an invalid choice"); } }
@SuppressWarnings("unchecked") private static <T extends Comparable<T>> IPropertyControl<T> createPropertyControl(IProperty<T> prop, boolean isTest) { if (canUseGenericPropertyControl(prop)) { return new PropertyControl<T>(prop, isTest); } else if (prop instanceof PropertyInteger) { int min = Integer.MIN_VALUE, max = Integer.MAX_VALUE; for (int allowedVal : ((PropertyInteger) prop).getAllowedValues()) { if (allowedVal < min) { min = allowedVal; } if (allowedVal > max) { max = allowedVal; } } return (IPropertyControl<T>) new IntPropertyControl((IProperty<Integer>) prop, min, max, isTest); } else if (prop instanceof PropertyBool) { if (isTest) { return (IPropertyControl<T>) new TestBooleanPropertyControl((IProperty<Boolean>) prop); } else { return (IPropertyControl<T>) new BooleanPropertyControl((IProperty<Boolean>) prop); } } else { return new PropertyControl<T>(prop, isTest); } }
private void addVine(World worldIn, BlockPos pos, PropertyBool prop) { IBlockState iblockstate = net.minecraft.init.Blocks.VINE.getDefaultState().withProperty(prop, Boolean.valueOf(true)); this.setBlockAndNotifyAdequately(worldIn, pos, iblockstate); int i = 4; for (pos = pos.down(); isAir(worldIn, pos) && i > 0; --i) { this.setBlockAndNotifyAdequately(worldIn, pos, iblockstate); pos = pos.down(); } }
private void func_181647_a(World p_181647_1_, BlockPos p_181647_2_, PropertyBool p_181647_3_) { IBlockState iblockstate = Blocks.vine.getDefaultState().withProperty(p_181647_3_, Boolean.valueOf(true)); this.setBlockAndNotifyAdequately(p_181647_1_, p_181647_2_, iblockstate); int i = 4; for (p_181647_2_ = p_181647_2_.down(); p_181647_1_.getBlockState(p_181647_2_).getBlock().getMaterial() == Material.air && i > 0; --i) { this.setBlockAndNotifyAdequately(p_181647_1_, p_181647_2_, iblockstate); p_181647_2_ = p_181647_2_.down(); } }
private void func_181632_a(World p_181632_1_, Random p_181632_2_, BlockPos p_181632_3_, PropertyBool p_181632_4_) { if (p_181632_2_.nextInt(3) > 0 && p_181632_1_.isAirBlock(p_181632_3_)) { this.setBlockAndNotifyAdequately(p_181632_1_, p_181632_3_, Blocks.vine.getDefaultState().withProperty(p_181632_4_, Boolean.valueOf(true))); } }
private void func_181650_b(World p_181650_1_, BlockPos p_181650_2_, PropertyBool p_181650_3_) { this.func_181651_a(p_181650_1_, p_181650_2_, p_181650_3_); int i = 4; for (p_181650_2_ = p_181650_2_.down(); p_181650_1_.getBlockState(p_181650_2_).getBlock().getMaterial() == Material.air && i > 0; --i) { this.func_181651_a(p_181650_1_, p_181650_2_, p_181650_3_); p_181650_2_ = p_181650_2_.down(); } }
private boolean recheckGrownSides(World worldIn, BlockPos pos, IBlockState state) { IBlockState iblockstate = state; for (EnumFacing enumfacing : EnumFacing.Plane.HORIZONTAL) { PropertyBool propertybool = getPropertyFor(enumfacing); if (((Boolean)state.getValue(propertybool)).booleanValue() && !this.canPlaceOn(worldIn.getBlockState(pos.offset(enumfacing)).getBlock())) { IBlockState iblockstate1 = worldIn.getBlockState(pos.up()); if (iblockstate1.getBlock() != this || !((Boolean)iblockstate1.getValue(propertybool)).booleanValue()) { state = state.withProperty(propertybool, Boolean.valueOf(false)); } } } if (getNumGrownFaces(state) == 0) { return false; } else { if (iblockstate != state) { worldIn.setBlockState(pos, state, 2); } return true; } }
public static int getNumGrownFaces(IBlockState state) { int i = 0; for (PropertyBool propertybool : ALL_FACES) { if (((Boolean)state.getValue(propertybool)).booleanValue()) { ++i; } } return i; }
private boolean recheckGrownSides(World worldIn, BlockPos pos, IBlockState state) { IBlockState iblockstate = state; for (Object enumfacing0 : EnumFacing.Plane.HORIZONTAL) { EnumFacing enumfacing = (EnumFacing) enumfacing0; PropertyBool propertybool = getPropertyFor(enumfacing); if (((Boolean) state.getValue(propertybool)).booleanValue() && !this.canPlaceOn(worldIn.getBlockState(pos.offset(enumfacing)).getBlock())) { IBlockState iblockstate1 = worldIn.getBlockState(pos.up()); if (iblockstate1.getBlock() != this || !((Boolean) iblockstate1.getValue(propertybool)).booleanValue()) { state = state.withProperty(propertybool, Boolean.valueOf(false)); } } } if (getNumGrownFaces(state) == 0) { return false; } else { if (iblockstate != state) { worldIn.setBlockState(pos, state, 2); } return true; } }
public static int getNumGrownFaces(IBlockState state) { int i = 0; for (PropertyBool propertybool : ALL_FACES) { if (((Boolean) state.getValue(propertybool)).booleanValue()) { ++i; } } return i; }
private boolean recheckGrownSides(World worldIn, BlockPos pos, IBlockState state) { IBlockState iblockstate = state; for (Object enumfacing0 : EnumFacing.Plane.HORIZONTAL) { EnumFacing enumfacing = (EnumFacing) enumfacing0; PropertyBool propertybool = getPropertyFor(enumfacing); if (((Boolean)state.getValue(propertybool)).booleanValue() && !this.canPlaceOn(worldIn.getBlockState(pos.offset(enumfacing)).getBlock())) { IBlockState iblockstate1 = worldIn.getBlockState(pos.up()); if (iblockstate1.getBlock() != this || !((Boolean)iblockstate1.getValue(propertybool)).booleanValue()) { state = state.withProperty(propertybool, Boolean.valueOf(false)); } } } if (getNumGrownFaces(state) == 0) { return false; } else { if (iblockstate != state) { worldIn.setBlockState(pos, state, 2); } return true; } }
private void addVine(World worldIn, BlockPos pos, PropertyBool prop) { IBlockState iblockstate = Blocks.VINE.getDefaultState().withProperty(prop, Boolean.valueOf(true)); this.setBlockAndNotifyAdequately(worldIn, pos, iblockstate); int i = 4; for (pos = pos.down(); worldIn.getBlockState(pos).getMaterial() == Material.AIR && i > 0; --i) { this.setBlockAndNotifyAdequately(worldIn, pos, iblockstate); pos = pos.down(); } }
private void placeVine(World p_181632_1_, Random p_181632_2_, BlockPos p_181632_3_, PropertyBool p_181632_4_) { if (p_181632_2_.nextInt(3) > 0 && p_181632_1_.isAirBlock(p_181632_3_)) { this.setBlockAndNotifyAdequately(p_181632_1_, p_181632_3_, Blocks.VINE.getDefaultState().withProperty(p_181632_4_, Boolean.valueOf(true))); } }
private void addHangingVine(World worldIn, BlockPos pos, PropertyBool prop) { this.addVine(worldIn, pos, prop); int i = 4; for (pos = pos.down(); worldIn.getBlockState(pos).getMaterial() == Material.AIR && i > 0; --i) { this.addVine(worldIn, pos, prop); pos = pos.down(); } }
private boolean recheckGrownSides(World worldIn, BlockPos pos, IBlockState state) { IBlockState iblockstate = state; for (EnumFacing enumfacing : EnumFacing.Plane.HORIZONTAL) { PropertyBool propertybool = getPropertyFor(enumfacing); if (((Boolean)state.getValue(propertybool)).booleanValue() && !this.canAttachVineOn(worldIn.getBlockState(pos.offset(enumfacing)))) { IBlockState iblockstate1 = worldIn.getBlockState(pos.up()); if (iblockstate1.getBlock() != this || !((Boolean)iblockstate1.getValue(propertybool)).booleanValue()) { state = state.withProperty(propertybool, Boolean.valueOf(false)); } } } if (getNumGrownFaces(state) == 0) { return false; } else { if (iblockstate != state) { worldIn.setBlockState(pos, state, 2); } return true; } }
private void addVine(World worldIn, BlockPos pos, PropertyBool prop) { IBlockState iblockstate = Blocks.VINE.getDefaultState().withProperty(prop, Boolean.valueOf(true)); this.setBlockAndNotifyAdequately(worldIn, pos, iblockstate); int i = 4; for (pos = pos.down(); isAir(worldIn, pos) && i > 0; --i) { this.setBlockAndNotifyAdequately(worldIn, pos, iblockstate); pos = pos.down(); } }
private void addHangingVine(World worldIn, BlockPos pos, PropertyBool prop) { this.addVine(worldIn, pos, prop); int i = 4; for (pos = pos.down(); worldIn.isAirBlock(pos) && i > 0; --i) { this.addVine(worldIn, pos, prop); pos = pos.down(); } }
private void addVine(World worldIn, BlockPos pos, PropertyBool prop, boolean ender) { IBlockState iblockstate = ender ? IWTechBlocks.BLOCK_ENDER_WINE.getDefaultState().withProperty(prop, true) : Blocks.VINE.getDefaultState().withProperty(prop, true); this.setBlockAndNotifyAdequately(worldIn, pos, iblockstate); int i = 4; for (pos = pos.down(); this.isAir(worldIn, pos) && i > 0; --i) { this.setBlockAndNotifyAdequately(worldIn, pos, iblockstate); pos = pos.down(); } }