1

I am making a map where if you jump on a pressure plate you get 1 paper, how can i make it so when I get 1 paper the scoreboard counts it and then displays it and also how do i make it so if I drop 1 paper, it then shows one less in the scoreboard

  • 1
    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 Mar 27 '16 at 17:03
  • So you want a scoreboard to correspond to the number of pieces of paper in the player's inventory? Or am I misunderstanding? – Unionhawk Mar 27 '16 at 17:31
2

You can use CommandStats to count the number of items in a player's inventory.

The /clear command will return an "AffectedItems" value equal to the number of items that were cleared. You can set the maximum amount to 0 to prevent items from being removed, which will then return the total number of items that player had in their inventory.

This is also multiplayer-friendly since each player can have their own score and stat assigned, and /execute can be used to cause players to run commands to trigger their own stat.

Prerequisites

Objective to store the "AffectedItems" value.

/scoreboard objectives add PaperCount dummy

Set that to display on the sidebar.

/scoreboard objectives setdisplay sidebar PaperCount

CommandStat to apply to players, who will target their own "PaperCount" score when running commands that return an "AffectedItems" value. If new players are able to join at any time, you may need to run this on a clock.

/stats entity @a set AffectedItems @a[c=1] PaperCount

In order for CommandStats to modify a target's score, that target must be tracked on the scoreboard prior. If new players are able to join at any time, you may need to run this on a clock.

/scoreboard players add @a PaperCount 0

Clock commands

The following must be run on a clock.

  1. Cause players to clear 0 paper from their own inventories.

    /execute @a ~ ~ ~ /clear @a[c=1] minecraft:paper 0 0
    

The player will then have a "PaperCount" score equal to the number of paper they had in their inventory.

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.