oneofthem999 Posted June 11, 2016 Posted June 11, 2016 So I was trying to test out the idea of using blocks that checks whether or not a custom potion effect is active on the player when the player steps on the block. The KillBlock in this scenario should kill the player when the player steps on the block, if the player does not have a custom potion effect. The NeutralizationBlock should remove all potion effects the player has when stepped on. The Aura Potion is a generic potion that just add a speed 2 potion effect. Really, its just filler, since the idea was to learn how to create a custom potion. I wanted to be able to access the potion in one of the creative mode tabs, so I created a food item that grants the potion effect. However, the KillBlock and NeutralizationBlock does not work as expected. When stepped on, no effect takes place. A session of debugging determined that the onEntityCollidedWithBlock method didn't trigger at all, leading me to think that the method does not do what I originally thought it did. How do I improve the code such that the KillBlock and NeutralizationBlock will trigger when stepped on? Here's the NeutralizationBlock code: http://pastebin.com/6Jk0zJCQ And the KillBlock code: http://pastebin.com/5cJBD4UG The AuraPotionItemFood code: http://pastebin.com/EZDUyTY8 The AuraPotionEventHook code: http://pastebin.com/yDbPd2vg The AuraPotion code: http://pastebin.com/dxQugajB And finally, the Main code: http://pastebin.com/ZDrWZah3 Thank you in advance. Quote
Choonster Posted June 11, 2016 Posted June 11, 2016 Entities can only collide with your block if it has a collision bounding box smaller than a full cube. Block#onEntityCollidedWithBlock will never be called if your block has the default bounding box. Either give your blocks a bounding box with a maximum y coordinate slightly less than 1 (look at BlockSoulSand for an example) or override Block#onEntityWalking instead. Note that flying or sneaking players don't trigger walking. Quote Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.
Draco18s Posted June 11, 2016 Posted June 11, 2016 onEntityWalking also is not guaranteed to trigger for every block the player steps on. Quote Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
oneofthem999 Posted June 11, 2016 Author Posted June 11, 2016 The blocks work as expected now. Thank you very much everyone! Quote
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.