Posted August 14, 20169 yr hello everyone, I created a block with PropertyInteger of 0 - 4, and almost everything works fine. But when leave the world and join again, the block is set on 4, dosn´t matter which value was there before. example: Before relog: anyblock:0 .After relog: anyblock:4 Which methods defines the value? thanks for the answer
August 14, 20169 yr Are yiu using metadata to specify what blockstate it is? VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
August 14, 20169 yr Author public class BlockMold extends Block { public static final PropertyInteger MOLD_STATE = PropertyInteger.create("mold_state", 0, 4); protected static final AxisAlignedBB AABB_BOTTOM_HALF = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 0.5D, 1.0D); public BlockMold(String uname) { super(Material.IRON); this.setCreativeTab(Main.planttech); this.setUnlocalizedName(uname); this.setHardness(0.8F); this.setTickRandomly(true); this.setDefaultState(this.blockState.getBaseState().withProperty(MOLD_STATE, 0)); } @Override protected BlockStateContainer createBlockState() { return new BlockStateContainer(this, new IProperty[] { MOLD_STATE }); } @Override public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos) { return state; } @Override public int getMetaFromState(final IBlockState state) { return 0; } @Override public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) { return AABB_BOTTOM_HALF; } @Override public boolean isOpaqueCube(IBlockState state) { return false; } @Override public BlockRenderLayer getBlockLayer() { return BlockRenderLayer.CUTOUT; } @Override public boolean isFullCube(IBlockState state) { return false; } @Override public boolean isFullyOpaque(IBlockState state) { return false; } @Override public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) { System.out.println(this.getMetaFromState(state)); if(state.getValue(MOLD_STATE) != 4) { if(heldItem != null) { if(heldItem.isItemEqual(new ItemStack(Moditems.plantophen)) && !plantophen) { if(state.getValue(MOLD_STATE) == 0) { worldIn.setBlockState(pos, this.blockState.getBaseState().withProperty(MOLD_STATE, 1)); if(!playerIn.isCreative()) { if(heldItem.stackSize > 1) { heldItem.stackSize--; } else if(heldItem.stackSize == 1) { playerIn.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, null);; } } } if(state.getValue(MOLD_STATE) == 2) { worldIn.setBlockState(pos, this.blockState.getBaseState().withProperty(MOLD_STATE, 3)); if(!playerIn.isCreative()) { if(heldItem.stackSize > 1) { heldItem.stackSize--; } else if(heldItem.stackSize == 1) { playerIn.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, null);; } } } } if(heldItem.isItemEqual(new ItemStack(Moditems.plantodur)) && !plantodur) { if(state.getValue(MOLD_STATE) == 0) { worldIn.setBlockState(pos, this.blockState.getBaseState().withProperty(MOLD_STATE, 2)); if(!playerIn.isCreative()) { if(heldItem.stackSize > 1) { heldItem.stackSize--; } else if(heldItem.stackSize == 1) { playerIn.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, null);; } } } if(state.getValue(MOLD_STATE) == 1) { worldIn.setBlockState(pos, this.blockState.getBaseState().withProperty(MOLD_STATE, 3)); if(!playerIn.isCreative()) { if(heldItem.stackSize > 1) { heldItem.stackSize--; } else if(heldItem.stackSize == 1) { playerIn.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, null);; } } } } } } else { worldIn.setBlockState(pos, this.blockState.getBaseState().withProperty(MOLD_STATE, 0)); if(!worldIn.isRemote) { worldIn.spawnEntityInWorld(new EntityItem(worldIn, pos.getX()+ 0.5D , pos.getY() + 1.0D, pos.getZ() + 0.5D, new ItemStack(Items.ELYTRA))); } } return super.onBlockActivated(worldIn, pos, state, playerIn, hand, heldItem, side, hitX, hitY, hitZ); } @Override public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand) { if(state.getValue(MOLD_STATE) == 3) { System.out.println("test2 "); worldIn.setBlockState(pos, this.blockState.getBaseState().withProperty(MOLD_STATE, 4)); } } }
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.