#block entity

1 messages · Page 1 of 1 (latest)

gaunt torrent
#

guys. im trying to do a block entity like in the tutorial, but it tells me i need to implement getCodec() and createBlockEntity(), but those functions are not in the tutorial. if i implement them they just have the "todo" thingy

wild flax
#

First, separete class and files. Don't put they together

#

Second Alt + Enter on class TestBlock and implement all

royal relic
# gaunt torrent guys. im trying to do a block entity like in the tutorial, but it tells me i nee...

At the createBlockEntity() just create a new BlockEntity to the heap like (or however you do it in Kotlin)

return new MyBlockEntity(pos, state);

-->

    @Nullable
    @Override
    public BlockEntity createBlockEntity(BlockPos pos, BlockState state) {
        return new MyBlockEntity(pos, state);
    }

For the codec, just create a default one since it seems you dont need a special codec (or however you do it in Kotlin)

return createCodec(MyBlock::new);
-->
    @Override
    protected MapCodec<? extends BlockWithEntity> getCodec() {
        return createCodec(MyBlock::new);
    }

wild flax
#

My BlockEnitity