Started by
communistkarl
on
Topic category: Help with Minecraft modding (Java Edition)
How to create PlayerRelativeBlockHardness to allow for the block "owner" to be able to break the block easily while the public hardness is very high.
Player A places block. RelativeBlockHardness is set on place event -> Block is easy to break for Player A
Get the display name of whoever placed the block, then make the block unbreakable and put in "when player starts to destroy" if the display name is the same, destroy the block and spawn gem
To expand on Dansamy's response as it was a little short, what you could do is store an NBT tag on the block when it's placed by the player, that NBT tag being a string called something like "playerName" which stores the name of the player who placed it. Then when a player tries to break the block, check if the "playerName" NBT tag is equal to the player destroying it. If it is, allow them to break it. If not, either make the block unbreakable, or allow them to break the block, but respawn the block right after being broken and not drop the item.