Posted August 29, 20196 yr So i have been fighting with this for a while now and have tried fixing it in a multitude of different ways... I know its registering because under "Block Entities" i see my block. But when i place the block, nothing happens besides the normal block getting placed, and when i try to use: Quote /data get block (position of block) it comes back and says: Quote "[CHAT] The target block is not a block entity" "ShelfingTile" Class: public class ShelfingTile extends TileEntity implements ITickableTileEntity{ public ShelfingTile(){ super(SHELFING_TILE); } @Override public void tick() { MainCore.LOGGER.debug("TileEntityTick"); } } "Registry Events" Class Code Snippit: private static Item.Properties GetNewItemProperties(){ Item.Properties properties = new Item.Properties(); return properties; } private static BlockItem GetBlockItem(Block block,String reg_name){ BlockItem blockitem = new BlockItem(block,GetNewItemProperties()); blockitem.setRegistryName(reg_name); return blockitem; } @SubscribeEvent public static void RegisterBlock(final RegistryEvent.Register<Block> event) { event.getRegistry().registerAll ( CoreRegistry.SHELFING = new Shelfing(), ); } @SubscribeEvent public static void RegisterItem(final RegistryEvent.Register<Item> event) { event.getRegistry().registerAll ( GetBlockItem(CoreRegistry.SHELFING,Shelfing.reg_name), ); } @SubscribeEvent public static void RegisterTileEntity(final RegistryEvent.Register<TileEntityType<?>> event) { event.getRegistry().registerAll ( TileEntityType.Builder.create(ShelfingTile::new,CoreRegistry.SHELFING).build(null).setRegistryName(Shelfing.reg_name) ); } "CoreRegistry" Code Snippits: @ObjectHolder("MaxM") //ModID public class CoreRegistry{ @ObjectHolder("shelfing") //Shelfing Blocks Registry Name public static Block SHELFING; @ObjectHolder("shelfing") public static TileEntityType<ShelfingTile> SHELFING_TILE; } Enitre Block Class: public class Shelfing extends Block{ public static String reg_name = "shelfing"; public static final DirectionProperty FACING = HorizontalBlock.HORIZONTAL_FACING; protected static final VoxelShape SHAPE = Block.makeCuboidShape(0.0D, 0.0D, 0.0D, 16.0D, 16.0D, 16.0D); private static Block.Properties GetNewBlockProperties(){ float hardness = 1.5f; float resistance = 2.0f; Block.Properties properties = Properties.create(Material.WOOD); properties.sound(SoundType.WOOD); properties.hardnessAndResistance(hardness,resistance); return properties; } public Shelfing() { super(GetNewBlockProperties());setRegistryName(reg_name); this.setDefaultState(this.stateContainer.getBaseState().with(FACING, Direction.NORTH)); } @Override public boolean hasTileEntity() { return true; } @Override public TileEntity createTileEntity(BlockState state, IBlockReader world) { return new ShelfingTile(); } public BlockState getStateForPlacement(BlockItemUseContext context) { return this.getDefaultState().with(FACING, context.getPlacementHorizontalFacing().getOpposite()); } public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { return SHAPE; } public boolean isSolid(BlockState state) { return false; } public boolean allowsMovement(BlockState state, IBlockReader worldIn, BlockPos pos, PathType type) { return false; } @Override public BlockState rotate(BlockState state, Rotation rot) { return state.with(FACING, rot.rotate(state.get(FACING))); } @Override public BlockState mirror(BlockState state, Mirror mirrorIn) { return state.rotate(mirrorIn.toRotation(state.get(FACING))); } protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) { builder.add(FACING); } public BlockRenderLayer getRenderLayer() { return BlockRenderLayer.CUTOUT; } } Edited August 29, 20196 yr by max2461
August 29, 20196 yr 43 minutes ago, max2461 said: public boolean hasTileEntity() { I think this is the wrong method use the one that has the BlockState parameter. 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 29, 20196 yr Author 33 minutes ago, Animefan8888 said: I think this is the wrong method use the one that has the BlockState parameter. Thank you very much, you are correct. I needed to override IForgeBlock#hasTileEntity. You are a life saver!
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.