Jump to content

[1.16.3] Getting unique block information


FelixTFD

Recommended Posts

Hi!

 

I have a problem with the BlockEvent#EntityPlaceEvent. Not a problem with the event or how to subscribe to it, that works perfectly fine. So I check the block the player places if that block is a specific block then it goes to second if statement (I know I could use one but this way it is more clear what is happening in the code. Gonna use one if statement later) the second if statement should check if that block has enough charges or not. Now in my mod there is only one block that has a "public int charge" in it's class. I have no idea how to check for that value. I was thinking about something like getInstanceAtLocationOfSpecificBlock() but there is no such function. Any ideas how to manage this?

Link to comment
Share on other sites

You cannot just put an int variable in your block class, this will not work, as only one instance of your block class exists in the game. To do what you want you have to use blockstate properties or a tile entity. Take a look at the vanilla RespawnAnchorBlock, which is a block that can be charged multiple times

Check out the port of the BetterEnd fabric mod (WIP): https://www.curseforge.com/minecraft/mc-mods/betterend-forge-port

Link to comment
Share on other sites

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.