EverythingGames Posted October 30, 2015 Posted October 30, 2015 I need to be able to have an item that cannot break any blocks - that can be achieved with events or overriding the Item class' methods. However, the server is still telling the client to render the break animation (the block's break stages), and the client is also still spawning block-break particles. Is there a way to cancel everything before the block is broken (kind of like when the block is first clicked) so that it looks seamless as though the player had not clicked at all? I know ItemSword does this, although I cannot find any place where ItemSword is referenced in the Call Hierarchy (besides where instances of it are created for registration). If someone could please elaborate on how I would get this done, I would appreciate it Thanks. Quote Development of Plugins [2012 - 2014] Development of Mods [2012 - Current]
jeffryfisher Posted October 30, 2015 Posted October 30, 2015 Did you look inside the vanilla ItemSword class? It has this method in it (overriding the default behavior in class Item): public float getStrVsBlock(ItemStack stack, Block block) { if (block == Blocks.web) { return 15.0F; } else { Material material = block.getMaterial(); return material != Material.plants && material != Material.vine && material != Material.coral && material != Material.leaves && material != Material.gourd ? 1.0F : 1.5F; } } Quote The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.
EverythingGames Posted October 30, 2015 Author Posted October 30, 2015 Did you look inside the vanilla ItemSword class? It has this method in it (overriding the default behavior in class Item): public float getStrVsBlock(ItemStack stack, Block block) { if (block == Blocks.web) { return 15.0F; } else { Material material = block.getMaterial(); return material != Material.plants && material != Material.vine && material != Material.coral && material != Material.leaves && material != Material.gourd ? 1.0F : 1.5F; } } This works when you return 0.0F - if you are in survival. My item does not need to be able to interact with blocks (or blocks with inventory / other capabilities on left / right click). diesieben07 gave the perfect solution, MouseEvents. This stops vanilla packets from being sent and rendering / particles from being spawned on the client. Perfect solution, considering the personal MouseListener I wrote for Forge is uninterrupted by canceling vanilla Mouse actions. Thanks for the help. Quote Development of Plugins [2012 - 2014] Development of Mods [2012 - Current]
Recommended Posts
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.