How to make a "1 player only" use block

Started by ShinobiAaronYT on

Topic category: Help with modding (Java Edition)

Last seen on 01:22, 2. Jan 2023
Joined Jan 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How to make a "1 player only" use block
Wed, 01/05/2022 - 01:38 (edited)

Hello all,

Im trying to create a block with a GUI that can only be used by the person who first right clicks it. The If statement that i created doesn't seem to work, i'm fairly new to the modding world so im trying my best. I have a Global variable that is called "myplayerplacedsafeblock" which changes in the first procedure i created. That procedure changes the string to say "the players name" and changes the block state to the second form so that it can test if your the same person who placed the block. Yet it isn't working at all and i need help. (i dont understand how to post pictures)

my code:

}

Event trigger - triggered by external call

or when (global trigger): {no additional trigger}

if    get (display) name of [event/target entity] = get global: [myplayerplacedsafeblock]

do  open screen for [event/target enitity] pass location x: [x] y: [y] z: [z] Gui: {SafeGUI}

else  close any GUI open for [event/target entity]

}

Edited by ShinobiAaronYT on Wed, 01/05/2022 - 01:38
Last seen on 04:28, 26. Jan 2024
Joined Oct 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
this could work:  { if get…
Wed, 01/05/2022 - 17:21

this could work:

 {

if get nbt logic tag "hasOwner" of block at x y z if it has block entity = true

  do

      if get nbt text tag "owner" of block at x y z if block has block entity = get (display) name of event/target entity

         do Open Screen for event target entity pass location  x y z GUI: []

        else send  message "You are not the owner of this block!"  to event/target entity show in action bar: true

  else set nbt logic tag "hasOwner" of block at x y z to true if it has block entity

         set nbt text tag "owner" of block at x y z to get (display) name of event/target entity

         Open Screen for event target entity pass location  x y z GUI: []

 }

Last seen on 04:28, 26. Jan 2024
Joined Oct 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
and btw activate block tile…
Wed, 01/05/2022 - 17:21

and btw activate block tile entity on the block settings