Posted September 13, 20196 yr Creating block I override methods that take block state as parameter and do something with it(for example onBlockPlacedBy). But I don't know must I call setBlockState from World to update block state?
September 13, 20196 yr 49 minutes ago, AntonBespoiasov said: Creating block I override methods that take block state as parameter and do something with it(for example onBlockPlacedBy). But I don't know must I call setBlockState from World to update block state? Post your code. And explain what you are trying to do. 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.
September 13, 20196 yr Author 23 minutes ago, Animefan8888 said: Post your code. And explain what you are trying to do. @Override public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) { state.withProperty(BlockBed.FACING, placer.getHorizontalFacing()); calculateBedTileBorders(worldIn, pos, state); calculateBedTilePillow(worldIn, pos, state, placer.getHorizontalFacing()); notifyNeighborsOfBorderRecalculation(worldIn, pos); worldIn.setBlockState(pos, state); } calculateBedTileBorders(...) and calculateBedTilePillows(...) are functions that affect state, they don't set blcok state in world. notifyNeighborsOfBorderRecalculation(...) is a function that tells blocks around that they must call calculateBedTileBorders(...). TillingBed(block where this method is overridden) is a bed with connected textures. What I think happens there? All these methods that are called in onBlockPlacedBy(...) don't copy state but just change("mutate") it and then this block state is set in world in onBlockPlacedBy(...). Why methods that are called in onBlockPlacedBy(...) just change it and don't copy? Each of these methods has its own parameter state in it that refer to single instance of block state due to IBlockState is mutable.
September 13, 20196 yr 5 minutes ago, AntonBespoiasov said: Each of these methods has its own parameter state in it that refer to single instance of block state due to IBlockState is mutable. They might exist because there are two BlockStates for a bed. The pillow part of the bed and foot part of the bed. However, I don't know because you are looking at rather old code. 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.
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.