-3

So I'm making a minecraft map, and what I need help with is this: the player puts 4 nether stars in a chest. Then they get teleported to a new area. I need to have it set up so that they can't put any random items in the chest and teleport away, and I don't know what commands I need to use to have this happen.

Basically, I need the chest to

  1. detect the nether stars when they are put in the chest
  2. teleport the player to a new location after the items are detected, and
  3. destroy the items once the player is teleported to the new area.

Could someone please help me with all of the commands I will need to use if this is even possible?

  • 2
    Have you made any attempt to solve this yourself? Arqade works better when askers show effort to solve their own problems; we see that you have a problem you've worked on, and answerers respond to that. You also get a more specific answer that's tailored exactly to the part you're stuck, and Arqade gets a very specific question. Everybody wins! – Frank Jun 12 '18 at 3:10
1

Here is a solution which has three steps. Use the testforblock command to test for the nether stars, then the tp command to teleport the player, then the setblock command to reset the chest contents.

A nice thing about this system, it doesn't care if there are other items in the chest. They will be eliminated whenever the chest has 4 nether stars placed into it.

Command blocks:

The first is a Repeat Unconditional Always Active block with command:

testforblock <x1> <y1> <z1> minecraft:chest -1 {Items:[{id:"minecraft:nether_star",Count:4b}]}

The second is a Chain Conditional Always Active block with command:

tp @p[x=x1,y=y1,z=z1] <x2> <y2> <z2>

The third is a Chain Conditional Always Active block with command:

setblock <x1> <y1> <z1> minecraft:chest     

Replace <x1> <y1> <z1> with the coordinates of the chest. In the second command, replace x1, y1, and z1 with the coordinates of the chest and replace <x2> <y2> <z2> with the coordinates that the player is to be teleported to.

The command blocks have to be loaded in order to function. They can either be placed near the chest, preferably in the same chunk, or they can be placed in the spawn chunks where they will always be loaded.

System weaknesses:

The player has to put a stack of exactly 4 nether stars into the chest for this to work. If the 4 stars are split into multiple stacks or the player places a stack larger then 4, it will not function.

If a player places 4 stars into the chest while there is another player closer to the chest, the player closest to the chest will be teleported instead of the player who put the stars into the chest.

  • Yes, thank you for your help. This is what I needed. Would it work with @a instead? There will only be one player. – A Hardwick Jun 20 '18 at 2:32
  • Yes, if there is only one player then @a will work. – IronAnvil Jun 20 '18 at 3:49
0

Or you can always use code. In code, you can just make a scheduled task (Bukkit/Spigot) or Tick event (Forge) to check the target chest every, say, 5 seconds. If there are 3 nether stars there, and nothing else, it will teleport the player(s). If there are rubbish inside there, the code will just remove the rubbish items from the chest and put it back inside the inventory of the player who put it there in the first place (and send a message to them if preferable).

0

Put a hopper running into the chest and fill each slot of the chest with 1 nether star. Make sure they can't open the chest in any way so put a line of hoppers going down into a chest and place an observer facing into the chest, and then place redstone coming out of the observer going into a command block.

/give @p minecraft:command_block

and put this text in the command block...

/tp @p <x axis> <y axis> <z axis>

If there are four players put the same command in four command blocks and put redstone one block away from each, and put repeaters going into the command blocks.

What it does is if it’s not a nether star it’ll get stuck in the final hopper but if it is it will stack with one of the nether stars and send a signal to the observer which teleports the players into your chosen location to tp to.

  • 1
    "What is does is if its not a nether star it'll get stuck in the final hopper" - wouldn't this mean that the whole system breaks if the player puts too many non-nether-star items in, since all available slots would then fill up and no expected nether star would be able to pass through? – Skylinerw Jun 12 '18 at 4:03
0

To detect the nether star, in my opinion it is best to make an item sorter. This can be made to only accept one type of item (in your case a nether star). If you place a repeater against a hopper, it will generate a signal whenever there is an item going through it. You can use this item to control a command block.

The command to teleport someone to a given location (if you know the coordinates) is /tp @p <x> <y> <z>, with @p denoting the player who is the closest to the command block. You replace <x> <y> and <z> by the coordinates you want the player to teleport to. To clear the inventory of a player, you use the following command: /clear @p. In the same way as the last command, it will clear the inventory of the player who is the closest to the command block.

Source: https://minecraft.gamepedia.com and a 5 minute Google search

-1

You can create an item sorter, what is not netherstars will get put into a dispenser that fires directly into lava at set intervals

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.