Jump to content

[1.17] How do I make a placed block create a structure?


Recommended Posts

Posted

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!

Posted
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

Posted

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.

Posted
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?

Posted
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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.