Posted October 25, 20205 yr 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?
October 25, 20205 yr 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
October 26, 20205 yr Author I took a look at the RespawnAnchorBlock code, but it's full of functions like: func_235566_a_() It's really hard to find out what is happening exactly.
October 26, 20205 yr https://mcforge.readthedocs.io/en/latest/blocks/states/ Lots of blocks has similar attributes to what you want, e.g.composter and crops.
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.