I want to make a system in my map that gives you different amounts of money for killing a mob based on how strong a mob is. The mobs are given custom names according to how strong they are and what they do, so I want to detect based on these custom names. I can't detect based on what kind of mob they are, like having every zombie give you $1, because there are several different custom names for most mobs.
I've already looked everywhere online for a solution to this, but they all only work for a specific unique mob that is the only mob with that name. I need a solution that detects by name and not unique mob. Is there any good and efficient way to do this???
If I understood correctly, you will have multiple zombies with the same name. well... a good system would give each mob it's own scoreboard value and one command for testing each mob.
if you are working with 1.12 then have a testfor with the mobs score (if you have 1000 mobs you got to have 1000 testfors...) and invert the comparator output.
Well, actually, I changed my mind with the whole names thing, because it turned out to be too laggy, without even getting it to work. But, I still want to be able to detect when mobs die, because I want it to count when a Creeper blows up and kills mobs. Is there any way I can do that instead?
Well, actually, I changed my mind with the whole names thing, because it turned out to be too laggy, without even getting it to work. But, I still want to be able to detect when mobs die, because I want it to count when a Creeper blows up and kills mobs. Is there any way I can do that instead?
If you have access to the world file (which you should),
I prefer making a custom DeathLootTable. If they die, they have a 100% to drop a custom item. If you detect the item, it means that the mob died.
If you just want commands, here are 2 methods I suggest:
1. If that's just a singleton (like a boss mob, which only has one per game), simply:
In 1.12-, /testfor @e[...] {...}
In 1.13+, /execute if ...
Make a comparator attached to the command block, then use a NOT gate to activate another command block you want.
2. If there's more than 2 of them, and their custom name is defined when they spawn, it'll a bit complicated:
First, in the /summon command, make them have another invisible entity(for example, a Marker and Invisible armor stand) riding it using Passengers. add a tag for this entity (In the example below, I used the tag name "trump")
Second, use these commands repeatedly:
In 1.12-, /execute @e[name=...] ~ ~1.5 ~ scoreboard players set @e[tag=trump,c=1,r=1] ??? 3 /scoreboard players remove @e[tag=trump,score_???_min=0] ??? 1 /execute @e[tag=trump,score_???=-1] ~ ~ ~ <the command you want...>
(the above command is stackable) /kill @e[tag=trump,score_???=-1]
In 1.13+ (This one I'm rly not sure, cuz I haven't touch a lot of 1.13 commands), /execute as(or/and at if you want it to drop sth special?) @e[limit=1,sort=nearest,tag=trump,nbt={RootVehicle:{}}] run <the command you want...>
(the above command is stackable) /kill @e[limit=1,sort=nearest,tag=trump,nbt={RootVehicle:{}}]
That's all. I haven't tested them yet so it might (and somehow likely) not work.
Remember to do the setup yourself (setting up scoreboards, edit your current command etc.)
If you have access to the world file (which you should),
I prefer making a custom DeathLootTable. If they die, they have a 100% to drop a custom item. If you detect the item, it means that the mob died.
That's really smart, actually! However, I don't have access to the world file, as I am making this my on my friend's server.
That's really smart, actually! However, I don't have access to the world file, as I am making this my on my friend's server.
Exactly what I was thinking. That's why I ask if you have access to the world file
Now, looks like you need to either:
1. Follow those instructions, ugh..
2. Make the loot table in another single player world, then ask your friend to put it inside the world file.
Alright, well I had my friend send me the world file so I could tamper with it and it sadly works exactly the same, because apparently mobs don't drop loot when it's not a player kill. Unless I did something wrong and don't now what code to put in the loot table files?
Alright, well I had my friend send me the world file so I could tamper with it and it sadly works exactly the same, because apparently mobs don't drop loot when it's not a player kill. Unless I did something wrong and don't now what code to put in the loot table files?
Wait so you're doing this on a server and NOT using Spigot? That just seems like a bad idea in itself, as Spigot has EntityDeathEvent which would really help you.
Wait so you're doing this on a server and NOT using Spigot? That just seems like a bad idea in itself, as Spigot has EntityDeathEvent which would really help you.
I'd rather stay vanilla. And, like I said, I'm assuming I might have done something wrong in the loot table code; is there any way to set it up to drop an item even when a player didn't kill it?
If you make something with command blocks, you should stay vanilla. Spigot just messes up with commands. If you have spigot, you should do plugins instead of commands. He asked help with commands.
I want to make a system in my map that gives you different amounts of money for killing a mob based on how strong a mob is. The mobs are given custom names according to how strong they are and what they do, so I want to detect based on these custom names. I can't detect based on what kind of mob they are, like having every zombie give you $1, because there are several different custom names for most mobs.
I've already looked everywhere online for a solution to this, but they all only work for a specific unique mob that is the only mob with that name. I need a solution that detects by name and not unique mob. Is there any good and efficient way to do this???
If I understood correctly, you will have multiple zombies with the same name. well... a good system would give each mob it's own scoreboard value and one command for testing each mob.
if you are working with 1.12 then have a testfor with the mobs score (if you have 1000 mobs you got to have 1000 testfors...) and invert the comparator output.
With 1.13, execute if unless could help a little.
Well, actually, I changed my mind with the whole names thing, because it turned out to be too laggy, without even getting it to work. But, I still want to be able to detect when mobs die, because I want it to count when a Creeper blows up and kills mobs. Is there any way I can do that instead?
I dont think thats possible without mods
If you have access to the world file (which you should),
I prefer making a custom DeathLootTable. If they die, they have a 100% to drop a custom item. If you detect the item, it means that the mob died.
If you just want commands, here are 2 methods I suggest:
1. If that's just a singleton (like a boss mob, which only has one per game), simply:
In 1.12-, /testfor @e[...] {...}
In 1.13+, /execute if ...
Make a comparator attached to the command block, then use a NOT gate to activate another command block you want.
2. If there's more than 2 of them, and their custom name is defined when they spawn, it'll a bit complicated:
First, in the /summon command, make them have another invisible entity(for example, a Marker and Invisible armor stand) riding it using Passengers. add a tag for this entity (In the example below, I used the tag name "trump")
Second, use these commands repeatedly:
In 1.12-,
/execute @e[name=...] ~ ~1.5 ~ scoreboard players set @e[tag=trump,c=1,r=1] ??? 3
/scoreboard players remove @e[tag=trump,score_???_min=0] ??? 1
/execute @e[tag=trump,score_???=-1] ~ ~ ~ <the command you want...>
(the above command is stackable)
/kill @e[tag=trump,score_???=-1]
In 1.13+ (This one I'm rly not sure, cuz I haven't touch a lot of 1.13 commands),
/execute as(or/and at if you want it to drop sth special?) @e[limit=1,sort=nearest,tag=trump,nbt={RootVehicle:{}}] run <the command you want...>
(the above command is stackable)
/kill @e[limit=1,sort=nearest,tag=trump,nbt={RootVehicle:{}}]
That's all. I haven't tested them yet so it might (and somehow likely) not work.
Remember to do the setup yourself (setting up scoreboards, edit your current command etc.)
That's really smart, actually! However, I don't have access to the world file, as I am making this my on my friend's server.
Exactly what I was thinking. That's why I ask if you have access to the world file
Now, looks like you need to either:
1. Follow those instructions, ugh..
2. Make the loot table in another single player world, then ask your friend to put it inside the world file.
Alright, well I had my friend send me the world file so I could tamper with it and it sadly works exactly the same, because apparently mobs don't drop loot when it's not a player kill. Unless I did something wrong and don't now what code to put in the loot table files?
Wait so you're doing this on a server and NOT using Spigot? That just seems like a bad idea in itself, as Spigot has EntityDeathEvent which would really help you.
I'd rather stay vanilla. And, like I said, I'm assuming I might have done something wrong in the loot table code; is there any way to set it up to drop an item even when a player didn't kill it?
If you make something with command blocks, you should stay vanilla. Spigot just messes up with commands. If you have spigot, you should do plugins instead of commands. He asked help with commands.
Okay, so I figured it out.
You need to go into the loot tables and modify the loot table for every mob that you're checking to this:
You'll need to create a scoreboard value paper, and make it dummy. Then, run this command in a repeat command block:
And chain these commands after it in chain command blocks:
Honestly, it's a lot simpler than I thought it would be!
Glad that you know.
So is it done?