Posted November 17, 20204 yr Hello. I want to use the replaceBlock function, to change the block when it's right clicked with a certain item. I have it @Override onBlockActivated, then check the item in the player's hand. The problem I've run into i getting the other blocks state. I've tried creating a variable in the other block with this.getDefaultState, but when I use it somewhere else, I get an unclassified usage. So I made a new variable, that simply is the same as the other one, only this one is created inside the block being replace's class. However, it says that the variable in the other class needs to be static, but when I make it static, this.getDefaultState doesn't work. How would I get the other blocks state into my block? Here's my @Override code: @Override public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) { if (player.getHeldItemMainhand().getItem() == RegistryHandler.WRENCH.get()) { RightCurvedBelt.replaceBlock(state, NEWSTATE, worldIn, pos, getHarvestLevel(state)); } And here's the 2 variables I've tried to make public static final BlockState RSTATE = this.getDefaultState(); private static final BlockState NEWSTATE = RightCurvedBelt.RSTATE; Edited November 17, 20204 yr by MrInfinity
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.