How do you disable block updates?

Code: Pastebin
Youtube: Youtube


I want the player to be able to right click iron doors to open /close them, but block updates cause the iron door to drop its item. I would like to know how to disable them.
The recorded youtube video shows what I am talking about.

try to replace setBlock(state) with setBlock(state, false)

1 Like

Now this happens xD

The top and the bottom of the door are two different blocks you must update the state of the bottom and the state of the top at the same time. In your code you replace the top of the door with the new top state, and the bottom of the door with the new top state. So the door is now made of two top part.

You probably written this:

BlockState newTopState = world.getState(topLocation).with(openData).get();
world.setBlock(topLocation, newTopState, false);
world.setBlock(bottomLocation, newTopState, false);

You should write this:

BlockState newTopState = world.getState(topLocation).with(openData).get();
BlockState newBottomState = world.getState(bottomLocation).with(openData).get();
world.setBlock(topLocation, newTopState, false);
world.setBlock(bottomLocation, newBottomState, false);
1 Like