READ ME: Please read my reply after this post. This post can be helpful but my second reply is much better with redesigned commands.
I had hopped into my testing world and hopefully, this fixes your problem. I had used two repeating command blocks set to always active. The two commands inside the command blocks are as follows:
/execute if block 12 63 -3 minecraft:stone if block 12 65 -3 minecraft:cobblestone if entity @e[type=minecraft:item,x=12,y=64,z=-3,name="Coal"] run summon minecraft:item 12 64 -3 {Item:{id:"minecraft:diamond",Count:1b}}
This command is searching for a block at 12,63,-3 that is also a stone block (Block underneath the item). Then it searches for a block at 12 65 -3 that is also a cobblestone block (Block above item) and then it searches for a dropped item at 12,64,-3 (The block in between the two blocks) and checks to see if that item is also Coal (The "name=" searches for the default item name, so instead of typing "minecraft:coal", you would type "Coal"). If the command detects all 3 of those blocks and items in those places at the same time, then it will summon a diamond at the coodinates of the coal that was dropped (12,64,-3). (Please change coordinates, blocks, and items to fit your needs)
The second command is as follows:
/execute if entity @e[type=item,x=12,y=64,z=-3,name="Diamond"] run kill @e[type=item,limit=1,name="Coal"]
All this command is doing is seaching to see if a diamond has successfully summoned at the coordinates (12,64,-3) and then runs the kill command to kill the coal that was dropped. Once again, change coordinates, blocks, and items to fit your needs.
Please let me know if this fixes your problem. Thank you!
EDIT: If you place the command blocks beneath or near the blocks you are using for the trading interface, you could use relative positioning for the coordinates. For example, if the block underneath the item is a stone block that is directly above the command block searching for the stone block, then the coordinates it can search for could be ~ ~1 ~ which is searching for a block that has the same x and z coordinate but the same y+1 (Above it). I dont know if this helps you at all in addition to the rest of this reply
I am sorry, but I found this subject to be much more interesting than I first thought. I put together a much more versatile command that I think you will prefer over the first reply I had made. Once again, we are using two repeating command blocks set to always active with the following commands:
execute at @e[type=item,name="Coal"] if block ~ ~-1 ~ minecraft:stone if block ~ ~1 ~ minecraft:cobblestone run summon minecraft:item ~ ~ ~ {Item:{id:"minecraft:diamond",Count:1b}}
execute as @e[type=item,name="Diamond"] at @s if entity @s if block ~ ~-1 ~ minecraft:stone if block ~ ~1 ~ minecraft:cobblestone run kill @e[type=item,limit=1,name="Coal"]
These commands are much alike my previous ones, however, it will work relative to the dropped items position. This means that you are not limited to certain coordinates. The command is executing at the coordinates of the dropped Coal and searching for a block below and above the coal (Stone above and Cobblestone below). The things you will have to change in the commands are:
The @e selectors
You will have to change the "name=" of the item it is executing as. Be sure to use the actual listed name of the item! (Ex. Instead of "minecraft:experience_bottle" you have to use "Bottle O' Enchanting")
The block searches
You can specify any blocks for the above and below blocks by changing the minecraft:stone and minecraft:cobbestone. I have also tested to see if it works if both the above and below blocks were the same and it still works perfectly fine.
I hope this reply is better than the first one I had posted, and I once again give my apologies for making multiple replies, but I am sure it was worth it for the better commands. Enjoy! (P.S. Your English is perfect as far as I can see)
I'm trying to make a datapack and I'm now practicing with command blocks.
For it to work I'd need the following commands:
(I know programming so I will give the algorithm to see if you can understand)
If dropped_item is on a block and under another_block: (I believe it's made with executes and for that I'd need a scoreboard for the item?)
kill item
summon another_item (in the same coordinates) (It may be better to first execute thesummon new_item at the item and then delete the old one?)
Thank you!
I'm pretty sure this will require repeating > chain > chain command blocks. But if your solution is better, I'd really appreciate it.
Here's the correction you requested in your signature. : )
1. /execute as @e[type=item,nbt={OnGround:1b},nbt=!{Item:{id:"minecraft:(type of item u summon)"}}] at @s if block ~ ~-1 ~ (block the item is on) if block ~ ~-2 ~ (another block) run summon item ~ ~ ~ {Item:{id:"minecraft:(type of item u summon)",Count:(number of item, if u don't give one, it won't summon)}}
2. /execute as @e[type=item,nbt={OnGround:1b},nbt=!{Item:{id:"minecraft:(type of item u summon)"}}] at @s if block ~ ~-1 ~ (block the item is on) if block ~ ~-2 ~ (another block) run kill @s
You know programming, so I don't need to explain.
BUT, if you're trying to explain stuff to us using pseudo code, please indent. It's better for my/our brain.
And yes, summon first before you kill.
Edit: Looks like I'm too late ._. Screw that read-only maintenance...
I am sorry, but I found this subject to be much more interesting than I first thought. I put together a much more versatile command that I think you will prefer over the first reply I had made. Once again, we are using two repeating command blocks set to always active with the following commands:
execute at @e[type=item,name="Coal"] if block ~ ~-1 ~ minecraft:stone if block ~ ~1 ~ minecraft:cobblestone run summon minecraft:item ~ ~ ~ {Item:{id:"minecraft:diamond",Count:1b}}
execute as @e[type=item,name="Diamond"] at @s if entity @s if block ~ ~-1 ~ minecraft:stone if block ~ ~1 ~ minecraft:cobblestone run kill @e[type=item,limit=1,name="Coal"]
These commands are much alike my previous ones, however, it will work relative to the dropped items position. This means that you are not limited to certain coordinates. The command is executing at the coordinates of the dropped Coal and searching for a block below and above the coal (Stone above and Cobblestone below). The things you will have to change in the commands are:
The @e selectors
You will have to change the "name=" of the item it is executing as. Be sure to use the actual listed name of the item! (Ex. Instead of "minecraft:experience_bottle" you have to use "Bottle O' Enchanting")
The block searches
You can specify any blocks for the above and below blocks by changing the minecraft:stone and minecraft:cobbestone. I have also tested to see if it works if both the above and below blocks were the same and it still works perfectly fine.
I hope this reply is better than the first one I had posted, and I once again give my apologies for making multiple replies, but I am sure it was worth it for the better commands. Enjoy! (P.S. Your English is perfect as far as I can see)
Thank you so much!
It's exactly what I needed! Also, sorry for not responding, I thought I'd be getting notifications but they never came and I just checked to see.
Here's the correction you requested in your signature. : )
1. /execute as @e[type=item,nbt={OnGround:1b},nbt=!{Item:{id:"minecraft:(type of item u summon)"}}] at @s if block ~ ~-1 ~ (block the item is on) if block ~ ~-2 ~ (another block) run summon item ~ ~ ~ {Item:{id:"minecraft:(type of item u summon)",Count:(number of item, if u don't give one, it won't summon)}}
2. /execute as @e[type=item,nbt={OnGround:1b},nbt=!{Item:{id:"minecraft:(type of item u summon)"}}] at @s if block ~ ~-1 ~ (block the item is on) if block ~ ~-2 ~ (another block) run kill @s
You know programming, so I don't need to explain.
BUT, if you're trying to explain stuff to us using pseudo code, please indent. It's better for my/our brain.
And yes, summon first before you kill.
Edit: Looks like I'm too late ._. Screw that read-only maintenance...
Thank you for the corrections, it really helps!
Rollback Post to RevisionRollBack
Psst!, If I have grammar or spelling errors, correct me. You will help improve my English.
I'm trying to make a datapack and i'm now practicing with command blocks.
For it to work I'd need the following commands:
I know programming so I will give the algorythm to see if you can help me.
If dropped_item is on block and under another_block: (I believe it's made with executes and for that i'd need a scoreboard for the item?)
kill item
summon another_item (in the same coordinates) (It may be better to first execute the summon new_item at the item and then delete the old one?)
Thank you!
I'm pretty sure this will require repeating > chain > chain command blocks. But if your solution is better, I'd really apreciate it.
Psst!, If I have grammar or spelling errors, correct me. You will help improve my English.
READ ME: Please read my reply after this post. This post can be helpful but my second reply is much better with redesigned commands.
I had hopped into my testing world and hopefully, this fixes your problem. I had used two repeating command blocks set to always active. The two commands inside the command blocks are as follows:
This command is searching for a block at 12,63,-3 that is also a stone block (Block underneath the item). Then it searches for a block at 12 65 -3 that is also a cobblestone block (Block above item) and then it searches for a dropped item at 12,64,-3 (The block in between the two blocks) and checks to see if that item is also Coal (The "name=" searches for the default item name, so instead of typing "minecraft:coal", you would type "Coal"). If the command detects all 3 of those blocks and items in those places at the same time, then it will summon a diamond at the coodinates of the coal that was dropped (12,64,-3). (Please change coordinates, blocks, and items to fit your needs)
The second command is as follows:
All this command is doing is seaching to see if a diamond has successfully summoned at the coordinates (12,64,-3) and then runs the kill command to kill the coal that was dropped. Once again, change coordinates, blocks, and items to fit your needs.
Please let me know if this fixes your problem. Thank you!
EDIT: If you place the command blocks beneath or near the blocks you are using for the trading interface, you could use relative positioning for the coordinates. For example, if the block underneath the item is a stone block that is directly above the command block searching for the stone block, then the coordinates it can search for could be ~ ~1 ~ which is searching for a block that has the same x and z coordinate but the same y+1 (Above it). I dont know if this helps you at all in addition to the rest of this reply
I am sorry, but I found this subject to be much more interesting than I first thought. I put together a much more versatile command that I think you will prefer over the first reply I had made. Once again, we are using two repeating command blocks set to always active with the following commands:
These commands are much alike my previous ones, however, it will work relative to the dropped items position. This means that you are not limited to certain coordinates. The command is executing at the coordinates of the dropped Coal and searching for a block below and above the coal (Stone above and Cobblestone below). The things you will have to change in the commands are:
I hope this reply is better than the first one I had posted, and I once again give my apologies for making multiple replies, but I am sure it was worth it for the better commands. Enjoy! (P.S. Your English is perfect as far as I can see)
Here's the correction you requested in your signature. : )
1. /execute as @e[type=item,nbt={OnGround:1b},nbt=!{Item:{id:"minecraft:(type of item u summon)"}}] at @s if block ~ ~-1 ~ (block the item is on) if block ~ ~-2 ~ (another block) run summon item ~ ~ ~ {Item:{id:"minecraft:(type of item u summon)",Count:(number of item, if u don't give one, it won't summon)}}
2. /execute as @e[type=item,nbt={OnGround:1b},nbt=!{Item:{id:"minecraft:(type of item u summon)"}}] at @s if block ~ ~-1 ~ (block the item is on) if block ~ ~-2 ~ (another block) run kill @s
You know programming, so I don't need to explain.
BUT, if you're trying to explain stuff to us using pseudo code, please indent. It's better for my/our brain.
And yes, summon first before you kill.
Edit: Looks like I'm too late ._. Screw that read-only maintenance...
Thank you so much!
It's exactly what I needed! Also, sorry for not responding, I thought I'd be getting notifications but they never came and I just checked to see.
Thank you for the corrections, it really helps!
Psst!, If I have grammar or spelling errors, correct me. You will help improve my English.