Posted September 28, 20214 yr Hi everyone, I am almost done with my mod that I only need for myself, I just can't grasp how to code one thing. I need to code it so when a block is placed by a player, a structure appears instead of the block. I suppose I am meant to use the onBlockAdded method, but I can't understand, how it works. Could someone show me how to code it please? Also, how do I map the structure? Do i use XYZ coordinates? It would be really helpful if you could give me an example of such code and I would change the values to match the structure. Again, this mod is for my purposes only, I will not upload it anywhere if you are afraid of you doing someone else's work. Thank you for the response!
September 28, 20214 yr Author 6 minutes ago, Luis_ST said: are you sure you have update to 1.17? I just need the algorithm for now, if I still can't figure it out, I will update everything to 1.17
September 28, 20214 yr You have two options. You could manually create the structure by placing blocks individually based on the location of the player-placed block (Yes using x, y, z coordinates). Or you could load the structure using an nbt structure file based on the location of the player-placed block. I suppose it mostly depends on how large and complex the structure is. If it is fairly complex or large, Id go with the second option.
September 29, 20214 yr Author 2 hours ago, ForgetFunsize said: You have two options. You could manually create the structure by placing blocks individually based on the location of the player-placed block (Yes using x, y, z coordinates). Or you could load the structure using an nbt structure file based on the location of the player-placed block. I suppose it mostly depends on how large and complex the structure is. If it is fairly complex or large, Id go with the second option. It's not large or complex at all, so the first option works for me. Could you show me how to code that? Or explain in detail?
September 29, 20214 yr 1 hour ago, askod333 said: It's not large or complex at all, so the first option works for me. Could you show me how to code that? Or explain in detail? In your EntityPlaceEvent, you would manually place the blocks for your structure based on the placed block position. Such as world.setBlockAndUpdate(pos, Blocks.WHATEVER_BLOCK.defaultBlockState());. pos being the position you want to set the block. You would call this for as many blocks as you need until your structure is complete.
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.