MistaOmega Posted June 6, 2020 Posted June 6, 2020 (edited) What's popping gamers, It's ya boi Bernie back at it with another stupid question because I'm incapable of developing things. Right, so this time I've wanted to go off and design a pickaxe that could break blocks in an AOE, and I've (somewhat) done that in the following code: https://github.com/MistaOmega/Opes/blob/master/src/main/java/mistaomega/opes/tools/CaelestisPickaxe.java Now the issue I've come across is this will only behave properly when hit from above the block it will break all other blocks in an area from the block broken, The block that the player breaks behaves as a corner, I will sort it to be center but I kinda wanted it basically working before that. So the question I have for you is how should I go about modifying the code to work with it based on the direction the block was broken from, as in if hit from the side, the values I use should be different, how would I go about getting said values ❤️ My current though is subscribing to the playerInteractEvent, but I always ended up with a null case, plus I'm not 100% sure what I can do with that direction value example of PIE code (player Interact would be a void method in this case) @SubscribeEvent playerInteract (PlayerInteractEvent e){ currentFace = e.getFace(); } **Where currentFace is a direction value set at the top of the pickaxe class.** Thank you all ❤️ Edited June 6, 2020 by MistaOmega Quote
TheGreyGhost Posted June 6, 2020 Posted June 6, 2020 Howdy To be honest I'm really not sure what gameplay effect you're trying to achieve. Could you explain further? eg If player hits the block from the top or the bottom, then the blocks to the east, west, north, and south are also broken If player hits the block on the west face, then the blocks to the north, south, up, and down are also broken etc 24 minutes ago, MistaOmega said: My current though is subscribing to the playerInteractEvent, but I always ended up with a null case I don't understand what you mean "null case"? You mean that no direction is defined? I'm surprised by that if you're subscribing to LeftClickBlock. If it's not working, you might be able to figure out which face is being clicked by Raytracing where the player is looking. Try ToolCommons.rayTraceFromEntity. -TGG Quote
MistaOmega Posted June 6, 2020 Author Posted June 6, 2020 3 minutes ago, TheGreyGhost said: Howdy To be honest I'm really not sure what gameplay effect you're trying to achieve. Could you explain further? eg If player hits the block from the top or the bottom, then the blocks to the east, west, north, and south are also broken If player hits the block on the west face, then the blocks to the north, south, up, and down are also broken etc I don't understand what you mean "null case"? You mean that no direction is defined? I'm surprised by that if you're subscribing to LeftClickBlock. If it's not working, you might be able to figure out which face is being clicked by Raytracing where the player is looking. Try ToolCommons.rayTraceFromEntity. -TGG Howdy! I think you've got the right idea, the basis being that when I break a block a 3x3 area around that blockface is destroyed, does that make sense? And yeah, a direction isn't defined so it displays null. So the idea of using raytracing from a player can return the side of the block I'm looking at? If so, awesome I'll look into it. Thank you. Quote
Draco18s Posted June 6, 2020 Posted June 6, 2020 (edited) Use the BlockBreakEvent Get the player's lookVec Do some vector math Break some more blocks (you may wish to do so by first firing off new BlockBreakEvents so that your pickaxe can't break blocks that are in protected areas (other mods cancelling the event, if so, don't break the block) and you will need to insure that when your own event handler is fired again for these positions that you don't do anything). Edited June 6, 2020 by Draco18s 1 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.
MistaOmega Posted June 6, 2020 Author Posted June 6, 2020 (edited) 3 hours ago, Draco18s said: Use the BlockBreakEvent Get the player's lookVec Do some vector math Break some more blocks (you may wish to do so by first firing off new BlockBreakEvents so that your pickaxe can't break blocks that are in protected areas (other mods cancelling the event, if so, don't break the block) and you will need to insure that when your own event handler is fired again for these positions that you don't do anything). Vector math for the RayTrace I assume here. Correct? I'm experienced (ish) with it from back in my A-Level math days, treating eyePos of player as the origin I assume again. Thanks for the help, appreciate it as always ❤️ Edited June 6, 2020 by MistaOmega Quote
TheGreyGhost Posted June 7, 2020 Posted June 7, 2020 Hi Vanilla already has raytrace coded for you. No need to rewrite. Actually depending on the gameplay mechanics you want, you could just just use the player's look vec instead. i.e. if you are looking mostly down, your effect spreads out sideways even if you hit the side of the block instead of the top. The Direction class has methods to figure out which direction the player is facing based on the lookvec. -TGG 1 Quote
Draco18s Posted June 7, 2020 Posted June 7, 2020 There is no need to raytrace at all, you already know what block the player is looking at: they just broke it. You need to use a cross product to find the perpendicular vectors to that vector so that you can identify the four orthogonally adjacent blocks, and from there, you can identify the four diagonals. 1 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.
MistaOmega Posted June 7, 2020 Author Posted June 7, 2020 Got it I'll mess around until I've got something working, thank you both for the help! 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.