Jump to content

[1.14.4][SOLVED] TileEntity isn't replacing the block placed.


max2461

Recommended Posts

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 by max2461
Link to comment
Share on other sites

43 minutes ago, max2461 said:

public boolean hasTileEntity() {

I think this is the wrong method use the one that has the BlockState parameter.

  • Thanks 2

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.

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.