Hello! I tried to make a block-placer plugin, and now I have a problem: If for example a seed is placed, it can be in the air, on stone,... So I tried to make a block-update by replacing and placing the block next to it. But if there is a chest, all items will drop. Any Idea for a fix or better block-update? EDIT: Just fixed it by changing the Data of a nearby block and changing it Back
Well when you set the type add a true at the end. Like so Block#setType (Material.whatever,true); That will apply physics to the object aka do a block update
Could it be something else stopping the physics from being applied, World Guard for example? According to the API it should apply physics, https://hub.spigotmc.org/javadocs/s...ck.html#setType(org.bukkit.Material, boolean)
Maybe do something like this, I don't really know Code (Text): Block b = (Block) Bukkit.getServer().getWorld(WORLD).getBlockAt(COORDS); b.update();
Nope, doesn't work, too. I tried updating to the newest spigot version, but no change. And I also tried making a completly new Server... no change.
*sigh* I will give you a method from one of my private plugins. It works 100% for me on 1.11 but it should technically work across some other versions as well. Hopefully this solves your issue. (If it doesnt help, try setting the boolean to true in the setType(Material,Boolean) just above using this method, maybe) Code (Text): public void forceUpdate(org.bukkit.block.Block block) { ((CraftWorld)block.getWorld()).getHandle().applyPhysics( new BlockPosition(block.getX(), block.getY(), block.getZ()), CraftMagicNumbers.getBlock(block).fromLegacyData(block.getData()).getBlock(), true); } That should work. Worked for me when I used it.
Sorry for annoying you, but I found this snippet 20mins ago in the internet and tried it (also yours), but it didn't work. Tried it in 1.11 too.
Are you using a command or an event? If it's an event be sure of use the @EventHandler (priority = EventPriority.HIGHEST)
I know, I'm using an event. I'm making a Block-Placer plugin... And everything worked except that. But I found a solution to fix it. Just change the data of a nearby block and change it back. That causes a block update. Thanks.