r/MinecraftCommands • u/Rareek • Feb 21 '20
Help | Bedrock Help with server
I was wondering if anybody could help me set up a shop and kill counter on my "server" Help would be greatly appreciated.
1
Upvotes
View all comments
Show parent comment
1
u/[deleted] Feb 22 '20 edited Feb 22 '20
Okay so I can't exactly tell if you're actually using loot tables to do this or just hoping that each player has a bee nest on them. Even if you use commands to give players bee nests this won't be nearly as reliable or effective. It needs to be a loot table. This also means that it has nothing to do with what the player has in their inventory. When they die (even without bee nests on them) they will drop one because of the loot table.
Setting up the player's loot table is kind of a sneaky hidden trick that I was recently made aware of. Inside the entities folder of a behavior pack lives the file "player.json". In this file there's a sneaky line of code that can be modified to control what the player drops when they die. Look for the following code:
Change the 'empty' portion to whatever you want to name the loot table. I called it "playerDrops".
Now you can proceed like normal and create and save a regular loot table file in the regular loot table location naming the loot table document the same thing that you picked for the name (such as "playerDrops"). This file should be saved inside the behavior pack folder, then "loot_tables", and then further in the folder "entities".
Here's the code that I used for my player drop:
I recommend picking an item (such as a dragon egg) that has a low chance of ever being found in entity form in the game. Dragon egg is a good candidate because there can only be one of them. Because of the code to come, every time a dragon egg (or in your case bee nest) is found as an item dropped on the ground it will instantly be deleted and add to the score of the nearest player. This means that no player would ever be able to acquire a bee nest again because it'd just get deleted as soon as you knocked one off the tree and add to the score of the player as a kill.
As for the code to count kills let's first set up the scoreboard. Enter these into chat, they don't have to be in a command block
Now place a repeating, always active, unconditional block:
You can change the r=30 (effective radius of the command from the dropped item) to whatever you want.
Next place a chain block connected to the previous block, unconditional, always active:
This way the item will be killed regardless of the player being near. This is useful in scenarios where a player dies on their own to like mobs and then returns to their dropped stuff (though technically if you put the condition in the loot table to where the item won't drop unless killed by a player or pet this shouldn't happen). If the item wasn't constantly deleted then the player who nears their stuff will have a kill added to their score which isn't what we want. So you need to add a radius.
Finally, the last two notes
@Plagiatus maybe you should add this write up or a "quote" most of it to an article?