Skip to content

Commit

Permalink
Hotfix: Make destroying custom carts drop the correct item (Gamemode4…
Browse files Browse the repository at this point in the history
…Dev#951)

- fixes liquid minecarts and tunnel bores
- ender hopper minecarts seemed to not be affected
  • Loading branch information
BPR02 authored Feb 6, 2024
1 parent 6a7772c commit a7930df
Show file tree
Hide file tree
Showing 8 changed files with 172 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# destroys the liquid_minecart
# @s = liquid_minecart marker
# located at @s
# run from gm4_liquid_minecarts:machine/verify_destroy

# drop item
scoreboard players set $dropped_item gm4_machine_data 0
execute as @e[type=item,distance=..3,nbt={Age:0s,Item:{id:"minecraft:minecart",Count:1b,tag:{display:{Name:'{"text":"Liquid Minecart","italic":false}'}}}},limit=1,sort=nearest] at @s run function gm4_liquid_minecarts:machine/destroy_cart/drop_item

# scan hoppers if no item was broken
execute if score $dropped_item gm4_machine_data matches 0 run function gm4_liquid_minecarts:machine/destroy_cart/scan_hoppers

# kill marker
kill @s
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# searches for hoppers with invalid items
# @s = liquid_minecart marker
# located at @s
# run from gm4_liquid_minecarts:machine/destroy_cart

# find hopper with the invalid item
scoreboard players set $found_item gm4_machine_data 0
execute if score $found_item gm4_machine_data matches 0 positioned ~00 ~00 ~00 if block ~ ~ ~ hopper{Items:[{id:"minecraft:minecart",tag:{display:{Name:'{"text":"Liquid Minecart","italic":false}'}}}]} run function gm4_liquid_minecarts:machine/destroy_cart/update_hopper
execute if score $found_item gm4_machine_data matches 0 positioned ~01 ~00 ~00 if block ~ ~ ~ hopper{Items:[{id:"minecraft:minecart",tag:{display:{Name:'{"text":"Liquid Minecart","italic":false}'}}}]} run function gm4_liquid_minecarts:machine/destroy_cart/update_hopper
execute if score $found_item gm4_machine_data matches 0 positioned ~-1 ~00 ~00 if block ~ ~ ~ hopper{Items:[{id:"minecraft:minecart",tag:{display:{Name:'{"text":"Liquid Minecart","italic":false}'}}}]} run function gm4_liquid_minecarts:machine/destroy_cart/update_hopper
execute if score $found_item gm4_machine_data matches 0 positioned ~00 ~00 ~01 if block ~ ~ ~ hopper{Items:[{id:"minecraft:minecart",tag:{display:{Name:'{"text":"Liquid Minecart","italic":false}'}}}]} run function gm4_liquid_minecarts:machine/destroy_cart/update_hopper
execute if score $found_item gm4_machine_data matches 0 positioned ~01 ~00 ~01 if block ~ ~ ~ hopper{Items:[{id:"minecraft:minecart",tag:{display:{Name:'{"text":"Liquid Minecart","italic":false}'}}}]} run function gm4_liquid_minecarts:machine/destroy_cart/update_hopper
execute if score $found_item gm4_machine_data matches 0 positioned ~-1 ~00 ~01 if block ~ ~ ~ hopper{Items:[{id:"minecraft:minecart",tag:{display:{Name:'{"text":"Liquid Minecart","italic":false}'}}}]} run function gm4_liquid_minecarts:machine/destroy_cart/update_hopper
execute if score $found_item gm4_machine_data matches 0 positioned ~00 ~00 ~-1 if block ~ ~ ~ hopper{Items:[{id:"minecraft:minecart",tag:{display:{Name:'{"text":"Liquid Minecart","italic":false}'}}}]} run function gm4_liquid_minecarts:machine/destroy_cart/update_hopper
execute if score $found_item gm4_machine_data matches 0 positioned ~01 ~00 ~-1 if block ~ ~ ~ hopper{Items:[{id:"minecraft:minecart",tag:{display:{Name:'{"text":"Liquid Minecart","italic":false}'}}}]} run function gm4_liquid_minecarts:machine/destroy_cart/update_hopper
execute if score $found_item gm4_machine_data matches 0 positioned ~-1 ~00 ~-1 if block ~ ~ ~ hopper{Items:[{id:"minecraft:minecart",tag:{display:{Name:'{"text":"Liquid Minecart","italic":false}'}}}]} run function gm4_liquid_minecarts:machine/destroy_cart/update_hopper

execute if score $found_item gm4_machine_data matches 0 positioned ~00 ~-1 ~00 if block ~ ~ ~ hopper{Items:[{id:"minecraft:minecart",tag:{display:{Name:'{"text":"Liquid Minecart","italic":false}'}}}]} run function gm4_liquid_minecarts:machine/destroy_cart/update_hopper
execute if score $found_item gm4_machine_data matches 0 positioned ~01 ~-1 ~00 if block ~ ~ ~ hopper{Items:[{id:"minecraft:minecart",tag:{display:{Name:'{"text":"Liquid Minecart","italic":false}'}}}]} run function gm4_liquid_minecarts:machine/destroy_cart/update_hopper
execute if score $found_item gm4_machine_data matches 0 positioned ~-1 ~-1 ~00 if block ~ ~ ~ hopper{Items:[{id:"minecraft:minecart",tag:{display:{Name:'{"text":"Liquid Minecart","italic":false}'}}}]} run function gm4_liquid_minecarts:machine/destroy_cart/update_hopper
execute if score $found_item gm4_machine_data matches 0 positioned ~00 ~-1 ~01 if block ~ ~ ~ hopper{Items:[{id:"minecraft:minecart",tag:{display:{Name:'{"text":"Liquid Minecart","italic":false}'}}}]} run function gm4_liquid_minecarts:machine/destroy_cart/update_hopper
execute if score $found_item gm4_machine_data matches 0 positioned ~01 ~-1 ~01 if block ~ ~ ~ hopper{Items:[{id:"minecraft:minecart",tag:{display:{Name:'{"text":"Liquid Minecart","italic":false}'}}}]} run function gm4_liquid_minecarts:machine/destroy_cart/update_hopper
execute if score $found_item gm4_machine_data matches 0 positioned ~-1 ~-1 ~01 if block ~ ~ ~ hopper{Items:[{id:"minecraft:minecart",tag:{display:{Name:'{"text":"Liquid Minecart","italic":false}'}}}]} run function gm4_liquid_minecarts:machine/destroy_cart/update_hopper
execute if score $found_item gm4_machine_data matches 0 positioned ~00 ~-1 ~-1 if block ~ ~ ~ hopper{Items:[{id:"minecraft:minecart",tag:{display:{Name:'{"text":"Liquid Minecart","italic":false}'}}}]} run function gm4_liquid_minecarts:machine/destroy_cart/update_hopper
execute if score $found_item gm4_machine_data matches 0 positioned ~01 ~-1 ~-1 if block ~ ~ ~ hopper{Items:[{id:"minecraft:minecart",tag:{display:{Name:'{"text":"Liquid Minecart","italic":false}'}}}]} run function gm4_liquid_minecarts:machine/destroy_cart/update_hopper
execute if score $found_item gm4_machine_data matches 0 positioned ~-1 ~-1 ~-1 if block ~ ~ ~ hopper{Items:[{id:"minecraft:minecart",tag:{display:{Name:'{"text":"Liquid Minecart","italic":false}'}}}]} run function gm4_liquid_minecarts:machine/destroy_cart/update_hopper

execute if score $found_item gm4_machine_data matches 0 positioned ~00 ~-2 ~00 if block ~ ~ ~ hopper{Items:[{id:"minecraft:minecart",tag:{display:{Name:'{"text":"Liquid Minecart","italic":false}'}}}]} run function gm4_liquid_minecarts:machine/destroy_cart/update_hopper
execute if score $found_item gm4_machine_data matches 0 positioned ~01 ~-2 ~00 if block ~ ~ ~ hopper{Items:[{id:"minecraft:minecart",tag:{display:{Name:'{"text":"Liquid Minecart","italic":false}'}}}]} run function gm4_liquid_minecarts:machine/destroy_cart/update_hopper
execute if score $found_item gm4_machine_data matches 0 positioned ~-1 ~-2 ~00 if block ~ ~ ~ hopper{Items:[{id:"minecraft:minecart",tag:{display:{Name:'{"text":"Liquid Minecart","italic":false}'}}}]} run function gm4_liquid_minecarts:machine/destroy_cart/update_hopper
execute if score $found_item gm4_machine_data matches 0 positioned ~00 ~-2 ~01 if block ~ ~ ~ hopper{Items:[{id:"minecraft:minecart",tag:{display:{Name:'{"text":"Liquid Minecart","italic":false}'}}}]} run function gm4_liquid_minecarts:machine/destroy_cart/update_hopper
execute if score $found_item gm4_machine_data matches 0 positioned ~01 ~-2 ~01 if block ~ ~ ~ hopper{Items:[{id:"minecraft:minecart",tag:{display:{Name:'{"text":"Liquid Minecart","italic":false}'}}}]} run function gm4_liquid_minecarts:machine/destroy_cart/update_hopper
execute if score $found_item gm4_machine_data matches 0 positioned ~-1 ~-2 ~01 if block ~ ~ ~ hopper{Items:[{id:"minecraft:minecart",tag:{display:{Name:'{"text":"Liquid Minecart","italic":false}'}}}]} run function gm4_liquid_minecarts:machine/destroy_cart/update_hopper
execute if score $found_item gm4_machine_data matches 0 positioned ~00 ~-2 ~-1 if block ~ ~ ~ hopper{Items:[{id:"minecraft:minecart",tag:{display:{Name:'{"text":"Liquid Minecart","italic":false}'}}}]} run function gm4_liquid_minecarts:machine/destroy_cart/update_hopper
execute if score $found_item gm4_machine_data matches 0 positioned ~01 ~-2 ~-1 if block ~ ~ ~ hopper{Items:[{id:"minecraft:minecart",tag:{display:{Name:'{"text":"Liquid Minecart","italic":false}'}}}]} run function gm4_liquid_minecarts:machine/destroy_cart/update_hopper
execute if score $found_item gm4_machine_data matches 0 positioned ~-1 ~-2 ~-1 if block ~ ~ ~ hopper{Items:[{id:"minecraft:minecart",tag:{display:{Name:'{"text":"Liquid Minecart","italic":false}'}}}]} run function gm4_liquid_minecarts:machine/destroy_cart/update_hopper

# if no hoppers found, find hopper minecarts with the invalid item
execute if score $found_item gm4_machine_data matches 0 as @e[type=hopper_minecart,distance=..3,nbt={Items:[{id:"minecraft:minecart",tag:{display:{Name:'{"text":"Liquid Minecart","italic":false}'}}}]}] run function gm4_liquid_minecarts:machine/destroy_cart/update_hopper_minecart
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# updates hoppers with invalid items
# @s = liquid_minecart marker
# located at the hopper with an invalid item
# run from gm4_liquid_minecarts:machine/destroy_cart/scan_hoppers

# replace correct slot with proper item
data modify storage gm4_machines:temp Items set from block ~ ~ ~ Items
execute if data storage gm4_machines:temp Items[{Slot:0b,tag:{display:{Name:'{"text":"Liquid Minecart","italic":false}'}}}] run loot replace block ~ ~ ~ container.0 loot gm4_liquid_minecarts:entities/liquid_minecart
execute if data storage gm4_machines:temp Items[{Slot:1b,tag:{display:{Name:'{"text":"Liquid Minecart","italic":false}'}}}] run loot replace block ~ ~ ~ container.1 loot gm4_liquid_minecarts:entities/liquid_minecart
execute if data storage gm4_machines:temp Items[{Slot:2b,tag:{display:{Name:'{"text":"Liquid Minecart","italic":false}'}}}] run loot replace block ~ ~ ~ container.2 loot gm4_liquid_minecarts:entities/liquid_minecart
execute if data storage gm4_machines:temp Items[{Slot:3b,tag:{display:{Name:'{"text":"Liquid Minecart","italic":false}'}}}] run loot replace block ~ ~ ~ container.3 loot gm4_liquid_minecarts:entities/liquid_minecart
execute if data storage gm4_machines:temp Items[{Slot:4b,tag:{display:{Name:'{"text":"Liquid Minecart","italic":false}'}}}] run loot replace block ~ ~ ~ container.4 loot gm4_liquid_minecarts:entities/liquid_minecart

# clean up
data remove storage gm4_machines:temp Items
scoreboard players set $found_item gm4_machine_data 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# updates hopper minecarts with invalid items
# @s = hopper minecart with invalid item
# located at @s
# run from gm4_liquid_minecarts:machine/destroy_cart/scan_hoppers

# replace correct slot with proper item
data modify storage gm4_machines:temp Items set from entity @s Items
execute if data storage gm4_machines:temp Items[{Slot:0b,tag:{display:{Name:'{"text":"Liquid Minecart","italic":false}'}}}] run loot replace entity @s container.0 loot gm4_liquid_minecarts:entities/liquid_minecart
execute if data storage gm4_machines:temp Items[{Slot:1b,tag:{display:{Name:'{"text":"Liquid Minecart","italic":false}'}}}] run loot replace entity @s container.1 loot gm4_liquid_minecarts:entities/liquid_minecart
execute if data storage gm4_machines:temp Items[{Slot:2b,tag:{display:{Name:'{"text":"Liquid Minecart","italic":false}'}}}] run loot replace entity @s container.2 loot gm4_liquid_minecarts:entities/liquid_minecart
execute if data storage gm4_machines:temp Items[{Slot:3b,tag:{display:{Name:'{"text":"Liquid Minecart","italic":false}'}}}] run loot replace entity @s container.3 loot gm4_liquid_minecarts:entities/liquid_minecart
execute if data storage gm4_machines:temp Items[{Slot:4b,tag:{display:{Name:'{"text":"Liquid Minecart","italic":false}'}}}] run loot replace entity @s container.4 loot gm4_liquid_minecarts:entities/liquid_minecart

# clean up
data remove storage gm4_machines:temp Items
scoreboard players set $found_item gm4_machine_data 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# destroys the tunnel_bore
# @s = tunnel_bore marker
# located at @s
# run from gm4_tunnel_bores:machine/verify_destroy

tag @s add gm4_destroyed_bore_storage

# drop item
scoreboard players set $dropped_item gm4_machine_data 0
execute as @e[type=item,distance=..3,nbt={Age:0s,Item:{id:"minecraft:furnace_minecart",Count:1b,tag:{display:{Name:'{"translate":"item.gm4.minecart.bore","fallback":"Minecart with Piston"}'}}}},limit=1,sort=nearest] at @s run function gm4_tunnel_bores:machine/destroy_cart/drop_item

# scan hoppers if no item was broken
execute if score $dropped_item gm4_machine_data matches 0 run function gm4_tunnel_bores:machine/destroy_cart/scan_hoppers

# kill marker
kill @s
Loading

0 comments on commit a7930df

Please sign in to comment.