5

Command block - help combine two commands

EmpathyHeals's Avatar EmpathyHeals2/10/18 6:46 am history
3/9/2018 1:30 pm
ShelLuser's Avatar ShelLuser
I have a few exchanges on my server where a player tosses in an item to get something else. At one place I have a clunky redstone converter that takes in 16 enderpearls and gives back a "hug," which is a lilypad with custom name and lore. Another redstone converter takes in 16 rotten flesh and gives back a "kiss," which is a fern with custom name and lore. Somewhere else players can toss in these hugs and kisses into a dispenser and get reward like enchanting books and other nice items.

I want to get rid of this big and slow redstone converters that give the custom hugs and kisses and replace it with something else. Unfortunately the Essential trade signs can't be loaded with custom items, just regular lilypads and ferns.

I went to a command block generator that helped me make commands to summon villagers, and allowed me to choose what players could sell and buy from the villager. This command, too, unfortunately, only allowed me to put in regular lilypads and ferns, and did not provide an option for me to customize the name and lore. I therefore have two set of commands, the first set for the hugs includes the command for the villager and the command to give me the hug, the lilypad with the custom name and lore. The second set of commands also includes the command for the villager and the command that gives me the kiss, the fern with the custom name and lore.

I could use some help combining these two set of commands so each villager gives out a hug or a kiss (and 16 bottles o'enchanting) as trade for the enderpearls or rotten flesh. Here is the pastebin of the commands https://pastebin.com/AzdssG1y and I will also paste them below.

If this can't be done, dones anyone know of a plugin that handles custom item in trades?

Thanks for any help!!
Emp

PS. I don't know much about command block commands so feel free to take out anything that's not needed, like the repair cost.

PPS. Oh, and my server is still 1.11.2, although I hope to upgrade over the next week or two. Feel free to help with commands that work in command blocks in both versions or just the 1.11.2 version I guess if the villager will work even after the upgrade.

PPPS. If you help please provide commands through pastebin link. For some reason forums tend to mess up formatting of commands that make them not work in the command blocks. I don't know if it's the case on PMC but I do know I've had trouble running commands copied off the Enjin forums.


Commands:

1) Hug villager Squeeze - Trade 16 Ender Pearls for 1 Hug (lilypad) and 16 bottles o'enchanting:

/summon villager ~-189.5 ~49 ~366.55 {Invulnerable:1,PersistenceRequired:1,NoAI:1,Rotation:[-0.2f,-117.4f],CustomName:Squeeze,Offers:{Recipes:[{buy:{id:waterlily,Count:1},buyB:{id:experience_bottle,Count:16},sell:{id:ender_pearl,Count:16},maxUses:9999999}]}}


/give empathyheals 111 1 {display:{Name:Hug,Lore:["A hug from Empathy.","Come play and learn on Empathy!","IP 162.220.63.5:25745"]},RepairCost:1000}



2) Kiss villager Pucker - Trade 16 Rotten Flesh for 1 Kiss (fern) and 16 bottles o'enchanting:

/summon villager ~-189.5 ~49 ~353.39 {Invulnerable:1,PersistenceRequired:1,NoAI:1,Rotation:[15f,-40f],CustomName:Pucker,Offers:{Recipes:[{buy:{id:tallgrass,Damage:2,Count:1},buyB:{id:experience_bottle,Count:16},sell:{id:rotten_flesh,Count:16},maxUses:9999999}]}}


/give empathyheals 31 1 2 {display:{Name:Kiss,Lore:["A kiss from Empathy.","Come play and learn on Empathy!","IP 162.220.63.5:25745"]},RepairCost:1000}
Posted by EmpathyHeals's Avatar
EmpathyHeals
Level 42 : Master Zombie
120

Create an account or sign in to comment.

14

1
02/27/2018 1:49 pm
Level 42 : Master Zombie
EmpathyHeals
EmpathyHeals's Avatar
Hmm, these villagers worked well for a time and now Squeeze is constipated. He refuses to trade or give back the Endpearls a player put in the trade window. What's worse, I killed him using the minecraft:kill command and the new villager I spawned from the command block is a) refusing to trade too and b) holding 16 endpearls like the one who I killed. And will not let them be removed.

Here is a video clip, when I hold my mouse over the endpearls or exp or hugs I am clicking several times and nothing happens. Any help is appreciated to fix it.

gyazo.com/002f3f8e9d9bfa23f31529f8dbc0c143
1
03/09/2018 1:30 pm
Level 57 : Grandmaster Engineer
ShelLuser
ShelLuser's Avatar
Sorry for a late response. Been off the grid for a while due to work and other issues. Expect a PM later on too. But since we started this in public we also should see it through in public (for random readers).

Lemme check the video and think this through. A new villager should work.
4
02/10/2018 1:00 pm
Level 57 : Grandmaster Engineer
ShelLuser
ShelLuser's Avatar
And this is exactly why I'm not a fan of command generators. Most were set up by people who don't even realize how the whole thing works or they never bothered to keep it up to date. I really enjoyed reading this (it's much different from most other questions) so let's see how far we can take it.

First: this is perfectly possible, no worries. Second: this is also why I mentioned in my commands guide blog that the key to solving puzzles like these is to keep track of basics. In this case I suggest to check out the data values on villagers and work your way up from there. So just build the command in parts. For example: if you check then you'll notice buy:{} (TAG_Compound), the id being a String and... tag:{}, I quote: "Additional information about the item.". tag:{} is your key into customizing items within villager trades.

But no worries, I'm also going to give this a decent try :) I read your comment about the commands, I'll double check my message afterwards to ensure that they will work after copying.

I am a little confused about the trades though. 16 rotten flesh for one kiss, but where are the bottles of enchanting coming in? See, you make it sound as if you get 2 items for one trade, but that's not how this works. At best you get to offer two items for one item in return.

So this is what I'm doing: trade 16 ender pearls + 16 bottles o'enchanting for 1 Hug. Then: trade 16 rotten flesh + 16 bottles o'enchanting for 1 Kiss.

I think I got it: one villager ('Squeeze') gives either 1 Hug or 16 bottles of enchanting in exchange for 16 ender pearls. The other villager ('Pucker') gives 1 Kiss or 16 bottles of enchanting in exchange for 16 rotten flesh.

If this turns out to be wrong just let me know, then we can change it (I'll save the commands in my redstone world for now).

I hope you don't mind but I want to add a little more than just the answer to this. Maybe a useful tip: what I always do when creating these commands (by using that wiki page I linked to) is to simply open a text editor (like notepad, or metapad, etc.) and then just typing out the command in "parts". You'll always know that the command requires an opening and a closing. For example: Offers:{} (open and closing bracket), Trades: [{buy:{},sell:{}}] all opening and closing stuff. I usually type it out as shown here, and then fill in the contents later. So I place the opening and closing on a different line and start typing.

Oh, I would suggest leaving AI on. If you set it up right you don't have to worry about their trades changing and from my experience it can be more fun because they will also look at you and such. But that's your choice. I'll just copy your setup (noai & rotation) for now.

Squeeze - 16 ender pearls gives either 1 Hug or 16 bottles o'enchanting. So first I start by typing out the command structure. I know we'll have 2 trades, I'm going to make this a farmer and set his trades to maximum so that no vanilla trades can slip in. So:

summon minecraft:villager ~ ~1 ~ {
CustomName:"Squeeze",Invulnerable:1,PersistenceRequired:1,Profession:0,Career:1,CareerLevel:6,Offers:{Recipes:[
{buy:{},buyB:{},sell:{}},
{buy:{},buyB:{},sell:{}}
]}
}

(this is without the AI and rotation as you can see, it's just to give an impression of how I'd start building commands like these).

Also: always type out your names. Don't use id:rotten_flesh because that is going to go bad some day. Spell it out: id:"minecraft:rotten_flesh".

So here is Squeeze:

summon minecraft:villager ~ ~1 ~ {CustomName:"Squeeze",Invulnerable:1,PersistenceRequired:1,Profession:0,Career:1,CareerLevel:6,Offers:{Recipes:[{buy:{id:"minecraft:ender_pearl",Count:16},sell:{id:"minecraft:experience_bottle",Count:16}},{buy:{id:"minecraft:ender_pearl",Count:16},sell:{id:"minecraft:waterlily",Count:1,tag:{display:{Name:"Hug",Lore:"A hug from Empathy.","Come play and learn on Empathy!","IP 162.220.63.5:25745"]}}}}]}}

And here we have Pucker (I like that name, it's funny), I made him a Priest so that he's different from Squeeze:

summon minecraft:villager ~ ~1 ~ {CustomName:"Pucker",Invulnerable:1,PersistenceRequired:1,Profession:2,Career:1,CareerLevel:6,Offers:{Recipes:[{buy:{id:"minecraft:rotten_flesh",Count:16},sell:{id:"minecraft:experience_bottle",Count:16}},{buy:{id:"minecraft:ender_pearl",Count:16},sell:{id:"minecraft:tallgrass",Damage:2,Count:1,tag:{display:{Name:"Kiss",Lore:"A kiss from Empathy.","Come play and learn on Empathy!","IP 162.220.63.5:25745"]}}}}]}}

So far, so good. This is basically what you asked for I think.

But....

May I suggest something a bit more out of the ordinary? Why not make those custom items look more customized?

So I'm going to extract the items in a give command:

/give @p minecraft:waterlily 1 0 {display:{Name:"Hug",Lore:["A hug from Empathy.","Come play and learn on Empathy!","IP 162.220.63.5:25745"]}}

It is fun, but... also a bit "meh". Why not enchant it and make it a bit more special?

/give @p minecraft:waterlily 1 0 {ench:[{id:1,lvl:1}],HideFlags:1,display:{Name:"Hug",Lore:["A hug from Empathy.","Come play and learn on Empathy!","IP 162.220.63.5:25745"]}}

So, just add: "ench:[{id:1,lvl:1}],HideFlags:1" to the villager commands if you'd want this. Without the quotes of course and you can put it right in front of display:{}.

Hope this helps! If you upgrade your server to 1.12 then be sure to look into functions. Those can do even more cool stuff with this, it would easily allow you to add color codes to the Lore and name so that you get a really special customized item. Feel free to drop me a PM if you're interested in that, I'd be happy to give some hints on how to easily set it up.

Hope this helped!
3
02/10/2018 10:18 pm
Level 42 : Master Zombie
EmpathyHeals
EmpathyHeals's Avatar
Wow thank you so much SheLuster, not only for the commands but for the tutorial! That's great, love to also learn something! I just returned to this and saw your reply and wanted to send a quick thank you. I am going to look though it more thoroughly and try the commands now. Just a few quick things:

I was told to put the AI off as otherwise it may roam around or leave the area and I didn't want the villager to go far. But if all it would do is look at you but not go anywhere then I will leave it on.

Also, I did originally want the villagers to give either one hug or kiss *and* bottles o'enchanting, but I think a hug or kiss *or* bottles o'enchanting might be best. The stuff in the exchanges changes over time and sometimes people may or may not want to exhange the hugs and kisses for what's in them. This way they also have a chance to get exp which is always useful. But, this is also something I can tweak over time, like lower the amount of exp or add another item.

I will try to add the enchants. Looks fun. What I'm not sure of is whether the exchange that takes in hugs and kisses to give other stuff will still take them. Some players already have hugs and kisses from the redstone converters and I would hate to make them obsolete. If the exchange does take them then I would not mind having them enchanted. Will test.

Thanks!!
Emp
2
02/10/2018 11:41 pm
Level 57 : Grandmaster Engineer
ShelLuser
ShelLuser's Avatar
Happy to help!

One thing though: you're right that leaving AI intact will make them walk around. I usually seal them in a bit which prevents that. And yeah, you can't get 2 rewards. You can only sell 2 items (buy:{} & buyB:{}) for one reward (sell:{}). Hope it works out, if not then just let us know.
2
02/11/2018 12:01 amhistory
Level 42 : Master Zombie
EmpathyHeals
EmpathyHeals's Avatar
Hi, thanks!! A few things...

Squeeze works fine. Thank you!!

Is there any way to kill them as server owner? I thought they despawned but they didn't, they walked off, and now I found them but before I spawn more I want to get rid of these ones. I can't kill them as they are invincible, but can I use a command to get rid of them?

If I do turn off AI and they don't walk off, will they stay even if chunks aren't loaded or will they despawn?

Finally, Pucker had ender_pearl in the second buy ID but I changed that to rotten_flesh and it was fixed. What I can't figure out, though, is how to get it to trade the kind of fern I need. I want the green kind, not the deadbush kind, but for some reason the tallgrass you wrote in the command gives deadbush.




What makes things more confusing is that tallgrass is listed for three things in this list but deadbush for the one it is giving me, even though the command has tallgrass not deadbush: minecraft-ids.grahamedgecombe.com/
31
Dead Shrub
(minecraft:tallgrass)
31:1
Grass
(minecraft:tallgrass)
31:2
Fern
(minecraft:tallgrass)
32
Dead Bush
(minecraft:deadbush)
2
02/11/2018 2:10 am
Level 57 : Grandmaster Engineer
ShelLuser
ShelLuser's Avatar
Killing them as server owner, absolutely: /kill @e[type=Villager,name=Pucker], of course you can exchange the name if need be.

Turning off AI should have no effect on despawning. By default any named entity won't despawn (which is why you might want to be careful with letting users randomly name animals with nametags).

As to Pucker: oops, you're fully right! My bad. Good to hear that you could fix that yourself. As you saw I basically copied Squeeze and customized it further, but obviously didn't pay enough attention.

Fern: use the Damage entry. See: /give @p tallgrass 1 2. You don't really get a deadbush but you get "Dead Shrub" which is somewhat of a mini variant of deadbush.

So for the sell:{} section you'd use this:

sell:{id:"minecraft:tallgrass",Damage:2,Count:1,tag:{display:{Name:"Kiss",Lore:["A kiss from Empathy.","Come play and learn on Empathy!","IP 162.220.63.5:25745"]}}}

So include Damage:2.

Hope this works out.
1
02/13/2018 6:33 pmhistory
Level 42 : Master Zombie
EmpathyHeals
EmpathyHeals's Avatar
Unfortunately those pesky /kill commands keep failing for me. I get "Error: Player not found." I am thinking that the reason the other machine is not finding the commands identical and not taking them in trade is because the commands lack the RepairCost. I want to put it back and see if they work, but I would like to get rid of the old villagers first.

Update: found the solution, it's /minecraft:kill that is needed in the command, and it works. Source: https://hub.spigotmc.org/jira/browse/SPIGOT-340


3
02/12/2018 12:44 amhistory
Level 42 : Master Zombie
EmpathyHeals
EmpathyHeals's Avatar
Please see this post on my forum annoncing these villagers: empathyheals.enjin.com/forum/m/21228992/viewthread/31648735-introducing-squeeze-pucker-under-construction/page/1 and providing thanks to you SheLuster.

Any idea why my exchange machines which are done with redstone and set to only take these custom hugs and kisses will not take the new ones? I made them identical hoping the old ones player had that they got from the machines would not be obsolete. I guess I will try the enchanted type to make them extra cool if I can't get these to work, but any chance you have an idea how to make these new ones work like the old ones? I would hate to make the old ones obsolete or have to replace players' ones with new ones if I don't have to.

Thanks!!
Emp
1
02/11/2018 9:16 pm
Level 42 : Master Zombie
EmpathyHeals
EmpathyHeals's Avatar
Great it works!!
4
02/10/2018 1:07 pm
Level 57 : Grandmaster Engineer
ShelLuser
ShelLuser's Avatar
As promised I copy/pasted my commands to test and I see what you mean. Weird. So here's the paste you asked for: pastebin.com/kgp5E3fi
3
02/10/2018 1:13 pm
Level 11 : Journeyman Architect
Boxic
Boxic's Avatar
I'm not the OP, but props to you for laying all this out for them, pretty cool of you.
Planet Minecraft

Website

© 2010 - 2024
www.planetminecraft.com

Welcome