How to create PlayerRelativeBlockHardness to allow for the block "owner" to be able to break the block easily

Started by communistkarl on

Topic category: Help with Minecraft modding (Java Edition)

Active 4 years ago
Joined Apr 2020
Points:
608

User statistics:

  • Modifications: 0
  • Forum topics: 2
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 0
How to create PlayerRelativeBlockHardness to allow for the block "owner" to be able to break the block easily

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

Active 1 week ago
Joined Sep 2016
Points:
951

User statistics:

  • Modifications: 4
  • Forum topics: 9
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 336
Get the display name of…
Sun, 08/23/2020 - 14:52

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

Active 1 year ago
Joined Jun 2020
Points:
690

User statistics:

  • Modifications: 0
  • Forum topics: 2
  • Wiki pages: 0
  • MCreator plugins: 1
  • Comments: 137
To expand on Dansamy's…
Sun, 08/23/2020 - 19:26

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.