diff --git a/gm4_reeling_rods/README.md b/gm4_reeling_rods/README.md new file mode 100644 index 0000000000..cd7081bc0d --- /dev/null +++ b/gm4_reeling_rods/README.md @@ -0,0 +1,13 @@ +# Reeling Rods + +Reel in more than just fish with these rods! Yoink the chest from the chest boat and more! + +### Features +Fishing Rods can now yoink many more things! +- Pull Paintings off walls +- Reel in items from Item Frames +- Snatch leashed mobs from leash knots +- Try and fail to pull in an end crystal +Adds a new enchantment for fishing rods to take your yoinking up a notch! With it you can +- Separate chest boats and all minecart variants +- Steal items from allays diff --git a/gm4_reeling_rods/beet.yaml b/gm4_reeling_rods/beet.yaml new file mode 100644 index 0000000000..7911b62099 --- /dev/null +++ b/gm4_reeling_rods/beet.yaml @@ -0,0 +1,47 @@ +id: gm4_reeling_rods +name: Reeling Rods +version: 1.0.X + +data_pack: + load: . + overlays: + - formats: + min_inclusive: 61 + max_inclusive: 61 + directory: since_61 + - formats: + min_inclusive: 57 + max_inclusive: 61 + directory: since_57 + - formats: + min_inclusive: 48 + max_inclusive: 48 + directory: backport_48 + +pipeline: + - generate_files + - gm4.plugins.extend.module + +meta: + gm4: + versioning: + schedule_loops: [tick] + website: + description: Reel in more than just fish with these rods! Yoink the chest from the chest boat and more! + recommended: + - gm4_end_fishing + - gm4_live_catch + notes: [] + #modrinth: + #project_id: + #smithed: + #pack_id: + #planetminecraft: + #uid: + video: null + wiki: https://wiki.gm4.co/wiki/Reeling_Rods + credits: + Creator: + - runcows + #Icon Design: + #- runcows diff --git a/gm4_reeling_rods/data/gm4_reeling_rods/enchantment/reeling.json b/gm4_reeling_rods/data/gm4_reeling_rods/enchantment/reeling.json new file mode 100644 index 0000000000..d5ab45c12a --- /dev/null +++ b/gm4_reeling_rods/data/gm4_reeling_rods/enchantment/reeling.json @@ -0,0 +1,22 @@ +{ + "description":{ + "text": "Reeling" + }, + "supported_items": "minecraft:fishing_rod", + "primary_items": "minecraft:fishing_rod", + "weight": 3, + "max_level": 1, + "min_cost": { + "base": 5, + "per_level_above_first": 8 + }, + "max_cost": { + "base": 55, + "per_level_above_first": 8 + }, + "anvil_cost": 2, + "slots": [ + "any" + ], + "effects": {} +} diff --git a/gm4_reeling_rods/data/gm4_reeling_rods/function/empty_container_entity.mcfunction b/gm4_reeling_rods/data/gm4_reeling_rods/function/empty_container_entity.mcfunction new file mode 100644 index 0000000000..305869ea56 --- /dev/null +++ b/gm4_reeling_rods/data/gm4_reeling_rods/function/empty_container_entity.mcfunction @@ -0,0 +1,36 @@ +# Loops through Items[] and creates an item entity for each item, setting a slightly random motion +# @s = entity with an Items[] tag +# at @s +# run from separate + +# Assumptions + # storage gm4_reeling_rods:temp motion_vector is a Motion[] vector that reaches player + # in storage gm4_reeling_rods:temp entity_data is an Items[] array of item data objects + +# pull item data to be processed +data modify storage gm4_reeling_rods:temp item_data.Item set from storage gm4_reeling_rods:temp entity_data.Items[0] + +# randomize motion slightly.... + # this is the complicated bit +execute store result score $motionX gm4_reeling_rods.math run data get storage gm4_reeling_rods:temp motion_vector[0] 100 +execute store result score $motionY gm4_reeling_rods.math run data get storage gm4_reeling_rods:temp motion_vector[1] 100 +execute store result score $motionZ gm4_reeling_rods.math run data get storage gm4_reeling_rods:temp motion_vector[2] 100 +execute store result score $randomX gm4_reeling_rods.math run random value -10..10 +execute store result score $randomY gm4_reeling_rods.math run random value 0..10 +execute store result score $randomZ gm4_reeling_rods.math run random value -10..10 +execute store result storage gm4_reeling_rods:temp item_data.Motion[0] double 0.006 run \ + scoreboard players operation $motionX gm4_reeling_rods.math += $randomX gm4_reeling_rods.math +execute store result storage gm4_reeling_rods:temp item_data.Motion[1] double 0.006 run \ + scoreboard players operation $motionY gm4_reeling_rods.math += $randomY gm4_reeling_rods.math +execute store result storage gm4_reeling_rods:temp item_data.Motion[2] double 0.006 run \ + scoreboard players operation $motionZ gm4_reeling_rods.math += $randomZ gm4_reeling_rods.math +# scale 0.01 for same magnitude as main item, currently 0.006 to be slower + +# summon item with data +function gm4_reeling_rods:summon_item with storage gm4_reeling_rods:temp + +# remove processed item +data remove storage gm4_reeling_rods:temp entity_data.Items[0] + +# run again if needed +execute if data storage gm4_reeling_rods:temp entity_data.Items[] run function gm4_reeling_rods:empty_container_entity diff --git a/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/chest_boat/action.mcfunction b/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/chest_boat/action.mcfunction new file mode 100644 index 0000000000..b97b489c24 --- /dev/null +++ b/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/chest_boat/action.mcfunction @@ -0,0 +1,15 @@ +# Action for reeled chest_boat +# @s = chest_boat type +# at @s +# with {boat_type} +# run from fished/select_type + +data modify storage gm4_reeling_rods:temp entity_data set from entity @s +data modify storage gm4_reeling_rods:temp item_data.Item set value {id:"minecraft:chest",count:1} +execute positioned ~ ~0.75 ~ run function gm4_reeling_rods:separate +data remove storage gm4_reeling_rods:temp entity_data.UUID +data remove storage gm4_reeling_rods:temp entity_data.Passengers +$data modify storage gm4_reeling_rods:temp entity_type set value "$(boat_type)" +function gm4_reeling_rods:summon_entity with storage gm4_reeling_rods:temp +execute on passengers run function gm4_reeling_rods:fished/chest_boat/passenger_transfer +tp @s ~ -1000 ~ diff --git a/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/chest_boat/passenger_transfer.mcfunction b/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/chest_boat/passenger_transfer.mcfunction new file mode 100644 index 0000000000..3cbec803a6 --- /dev/null +++ b/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/chest_boat/passenger_transfer.mcfunction @@ -0,0 +1,7 @@ +# transfer old passenger to new boat +# @s = passengers of chest boat type +# at old chest boat type +# run from fished/chest_boat/action + +ride @s dismount +ride @s mount @e[type=#gm4:boats,distance=..0.00001,limit=1] diff --git a/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/donkey.mcfunction b/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/donkey.mcfunction new file mode 100644 index 0000000000..63fbcd675e --- /dev/null +++ b/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/donkey.mcfunction @@ -0,0 +1,12 @@ +# Action for reeled donkey +# @s = donkey +# at @s +# run from fished/selec_type + +data modify storage gm4_reeling_rods:temp entity_data set from entity @s +data modify storage gm4_reeling_rods:temp item_data set value {} +data modify storage gm4_reeling_rods:temp item_data.Item set from entity @s SaddleItem +execute if data entity @s {ChestedHorse:1b} run data modify storage gm4_reeling_rods:temp item_data.Item set value {id:"minecraft:chest",count:1} +execute positioned ~ ~0.7 ~ run function gm4_reeling_rods:separate +execute if data entity @s {ChestedHorse:1b} run return run data modify entity @s ChestedHorse set value 0b +item replace entity @s horse.saddle with minecraft:air diff --git a/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/horse.mcfunction b/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/horse.mcfunction new file mode 100644 index 0000000000..927999d4e1 --- /dev/null +++ b/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/horse.mcfunction @@ -0,0 +1,11 @@ +# Action for reeled horse +# @s = horse +# at @s +# run from fished/select_type + +data modify storage gm4_reeling_rods:temp item_data set value {} +data modify storage gm4_reeling_rods:temp item_data.Item set from entity @s SaddleItem +execute store result score $armored gm4_reeling_rods.math if data entity @s body_armor_item run data modify storage gm4_reeling_rods:temp item_data.Item set from entity @s body_armor_item +execute positioned ~ ~0.8 ~ run function gm4_reeling_rods:separate +execute if data storage gm4_reeling_rods:temp {item_data:{Item:{id:"minecraft:saddle"}}} run item replace entity @s horse.saddle with minecraft:air +execute if score $armored gm4_reeling_rods.math matches 1 run item replace entity @s armor.body with minecraft:air diff --git a/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/item_frame.mcfunction b/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/item_frame.mcfunction new file mode 100644 index 0000000000..26abbbd4f3 --- /dev/null +++ b/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/item_frame.mcfunction @@ -0,0 +1,11 @@ +# Action for reeled item frame or glow item frame +# @s = item frame or glow item frame +# at @s +# with {type} +# run from fished/select_type + +$data modify storage gm4_reeling_rods:temp item_data.Item set value {id:"$(type)",count:1} +data modify storage gm4_reeling_rods:temp item_data.Item set from entity @s Item +execute align xz positioned ~0.5 ~ ~0.5 run function gm4_reeling_rods:separate +execute unless data entity @s Item run return run kill @s +data remove entity @s Item diff --git a/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/leash_knot/action.mcfunction b/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/leash_knot/action.mcfunction new file mode 100644 index 0000000000..d1c0161790 --- /dev/null +++ b/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/leash_knot/action.mcfunction @@ -0,0 +1,14 @@ +# Action for reeled leash knot +# @s = leash knot +# at @s +# run from fished/select_type + +tag @s add gm4_reeling_rods.leash_knot + +# distance=..10 is leash distance UNTIL 1.21.6 +execute as @e[type=#gm4_reeling_rods:leashable,distance=..10] \ + if function gm4_reeling_rods:fished/leash_knot/leaded_by_knot \ + run function gm4_reeling_rods:fished/leash_knot/change_leader + + +kill @s diff --git a/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/leash_knot/change_leader.mcfunction b/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/leash_knot/change_leader.mcfunction new file mode 100644 index 0000000000..63d0f7d782 --- /dev/null +++ b/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/leash_knot/change_leader.mcfunction @@ -0,0 +1,7 @@ +# Changes a leashed entities leader from a leash knot to a tagged player +# @s = entity leaded to leash knot +# at leash knot +# run from fished/leash_knot/action + +data remove entity @s leash +data modify entity @s leash.UUID set from entity @e[type=player,tag=gm4_reeling_rods.player,distance=..45,limit=1] UUID diff --git a/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/leash_knot/leaded_by_knot.mcfunction b/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/leash_knot/leaded_by_knot.mcfunction new file mode 100644 index 0000000000..c8d23ccc6b --- /dev/null +++ b/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/leash_knot/leaded_by_knot.mcfunction @@ -0,0 +1,6 @@ +# Checks if an entity is leashed by the knot in question +# @s = a leashable entity +# at owner +# run from fished/leash_knot/action + +return run execute on leasher if entity @s[tag=gm4_reeling_rods.leash_knot] diff --git a/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/llama.mcfunction b/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/llama.mcfunction new file mode 100644 index 0000000000..e877c4ab95 --- /dev/null +++ b/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/llama.mcfunction @@ -0,0 +1,12 @@ +# Action for reeled llama or trader llama +# @s = llama or trader llama +# at @s +# run from fished/select_type + +data modify storage gm4_reeling_rods:temp entity_data set from entity @s +data modify storage gm4_reeling_rods:temp item_data set value {} +data modify storage gm4_reeling_rods:temp item_data.Item set from entity @s body_armor_item +execute if data entity @s {ChestedHorse:1b} run data modify storage gm4_reeling_rods:temp item_data.Item set value {id:"minecraft:chest",count:1} +execute positioned ~ ~1 ~ run function gm4_reeling_rods:separate +execute if data entity @s {ChestedHorse:1b} run return run data modify entity @s ChestedHorse set value 0b +item replace entity @s armor.body with minecraft:air diff --git a/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/minecart/action.mcfunction b/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/minecart/action.mcfunction new file mode 100644 index 0000000000..61edcc441f --- /dev/null +++ b/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/minecart/action.mcfunction @@ -0,0 +1,15 @@ +# Action for reeled *_minecart +# @s = *_minecart +# at @s +# with {block} +# run from fished/select_type + +data modify storage gm4_reeling_rods:temp entity_data set from entity @s +$data modify storage gm4_reeling_rods:temp item_data.Item set value {id:"$(block)",count:1} +function gm4_reeling_rods:separate +data remove storage gm4_reeling_rods:temp entity_data.UUID +data remove storage gm4_reeling_rods:temp entity_data.Passengers +data modify storage gm4_reeling_rods:temp entity_type set value "minecraft:minecart" +function gm4_reeling_rods:summon_entity with storage gm4_reeling_rods:temp +execute on passengers run function gm4_reeling_rods:fished/minecart/passenger_transfer +tp @s ~ -1000 ~ diff --git a/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/minecart/passenger_transfer.mcfunction b/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/minecart/passenger_transfer.mcfunction new file mode 100644 index 0000000000..b98fc0079a --- /dev/null +++ b/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/minecart/passenger_transfer.mcfunction @@ -0,0 +1,7 @@ +# transfer old passenger to new minecart +# @s = passengers of *_minecart +# at old *_minecart +# run from fished/minecart/action + +ride @s dismount +ride @s mount @e[type=minecraft:minecart,distance=..0.00001,limit=1] diff --git a/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/mule.mcfunction b/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/mule.mcfunction new file mode 100644 index 0000000000..210c5ecc07 --- /dev/null +++ b/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/mule.mcfunction @@ -0,0 +1,12 @@ +# Action for reeled mule +# @s = mule +# at @s +# run from fished/select_type + +data modify storage gm4_reeling_rods:temp entity_data set from entity @s +data modify storage gm4_reeling_rods:temp item_data set value {} +data modify storage gm4_reeling_rods:temp item_data.Item set from entity @s SaddleItem +execute if data entity @s {ChestedHorse:1b} run data modify storage gm4_reeling_rods:temp item_data.Item set value {id:"minecraft:chest",count:1} +execute positioned ~ ~0.8 ~ run function gm4_reeling_rods:separate +execute if data entity @s {ChestedHorse:1b} run return run data modify entity @s ChestedHorse set value 0b +item replace entity @s horse.saddle with minecraft:air diff --git a/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/painting.mcfunction b/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/painting.mcfunction new file mode 100644 index 0000000000..eda6f6985d --- /dev/null +++ b/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/painting.mcfunction @@ -0,0 +1,8 @@ +# Action for reeled painting +# @s = painting +# at @s +# run from fished/select_type + +data modify storage gm4_reeling_rods:temp item_data.Item set value {id:"minecraft:painting",count:1} +execute align xz positioned ~0.5 ~ ~0.5 run function gm4_reeling_rods:separate +kill @s diff --git a/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/pig.mcfunction b/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/pig.mcfunction new file mode 100644 index 0000000000..d4f4e1f408 --- /dev/null +++ b/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/pig.mcfunction @@ -0,0 +1,11 @@ +# Action for reeled pig +# @s = pig +# at @s +# run from fished/select_type + +# fail if no saddle +execute unless data entity @s {Saddle:1b} run return fail + +data modify entity @s Saddle set value 0b +data modify storage gm4_reeling_rods:temp item_data.Item set value {id:"minecraft:saddle",count:1} +execute positioned ~ ~0.5 ~ run function gm4_reeling_rods:separate diff --git a/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/snow_golem.mcfunction b/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/snow_golem.mcfunction new file mode 100644 index 0000000000..98701dfb16 --- /dev/null +++ b/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/snow_golem.mcfunction @@ -0,0 +1,11 @@ +# Action for reeled snow_golem +# @s = snow_golem +# at @s +# run from fished/select_type + +# fail if no Pumpkin +execute unless data entity @s {Pumpkin:1b} run return fail + +data modify entity @s Pumpkin set value 0b +data modify storage gm4_reeling_rods:temp item_data.Item set value {id:"minecraft:carved_pumpkin",count:1} +execute positioned ~ ~1.2 ~ run function gm4_reeling_rods:separate diff --git a/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/stealable/order/equipment_1.mcfunction b/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/stealable/order/equipment_1.mcfunction new file mode 100644 index 0000000000..49734f8749 --- /dev/null +++ b/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/stealable/order/equipment_1.mcfunction @@ -0,0 +1,19 @@ +# Checks slots to steal +# @s = #gm4_reeling_rods:steal_equipment +# at @s +# run from fished/stealable/steal_equipment + +# 1 +execute if items entity @s weapon.mainhand * run return run function gm4_reeling_rods:fished/stealable/steal_slot/mainhand +# 3 +execute if items entity @s armor.head * run return run function gm4_reeling_rods:fished/stealable/steal_slot/head +# 5 +execute if items entity @s armor.legs * run return run function gm4_reeling_rods:fished/stealable/steal_slot/legs +# 2 +execute if items entity @s weapon.offhand * run return run function gm4_reeling_rods:fished/stealable/steal_slot/offhand +# 4 +execute if items entity @s armor.chest * run return run function gm4_reeling_rods:fished/stealable/steal_slot/chest +# 6 +execute if items entity @s armor.feet * run return run function gm4_reeling_rods:fished/stealable/steal_slot/feet + +return fail diff --git a/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/stealable/order/equipment_2.mcfunction b/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/stealable/order/equipment_2.mcfunction new file mode 100644 index 0000000000..ac3a7ad446 --- /dev/null +++ b/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/stealable/order/equipment_2.mcfunction @@ -0,0 +1,19 @@ +# Checks slots to steal +# @s = #gm4_reeling_rods:steal_equipment +# at @s +# run from fished/stealable/steal_equipment + +# 2 +execute if items entity @s weapon.offhand * run return run function gm4_reeling_rods:fished/stealable/steal_slot/offhand +# 4 +execute if items entity @s armor.chest * run return run function gm4_reeling_rods:fished/stealable/steal_slot/chest +# 6 +execute if items entity @s armor.feet * run return run function gm4_reeling_rods:fished/stealable/steal_slot/feet +# 1 +execute if items entity @s weapon.mainhand * run return run function gm4_reeling_rods:fished/stealable/steal_slot/mainhand +# 3 +execute if items entity @s armor.head * run return run function gm4_reeling_rods:fished/stealable/steal_slot/head +# 5 +execute if items entity @s armor.legs * run return run function gm4_reeling_rods:fished/stealable/steal_slot/legs + +return fail diff --git a/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/stealable/order/equipment_3.mcfunction b/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/stealable/order/equipment_3.mcfunction new file mode 100644 index 0000000000..672d93dbcf --- /dev/null +++ b/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/stealable/order/equipment_3.mcfunction @@ -0,0 +1,19 @@ +# Checks slots to steal +# @s = #gm4_reeling_rods:steal_equipment +# at @s +# run from fished/stealable/steal_equipment + +# 3 +execute if items entity @s armor.head * run return run function gm4_reeling_rods:fished/stealable/steal_slot/head +# 5 +execute if items entity @s armor.legs * run return run function gm4_reeling_rods:fished/stealable/steal_slot/legs +# 2 +execute if items entity @s weapon.offhand * run return run function gm4_reeling_rods:fished/stealable/steal_slot/offhand +# 4 +execute if items entity @s armor.chest * run return run function gm4_reeling_rods:fished/stealable/steal_slot/chest +# 6 +execute if items entity @s armor.feet * run return run function gm4_reeling_rods:fished/stealable/steal_slot/feet +# 1 +execute if items entity @s weapon.mainhand * run return run function gm4_reeling_rods:fished/stealable/steal_slot/mainhand + +return fail diff --git a/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/stealable/order/equipment_4.mcfunction b/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/stealable/order/equipment_4.mcfunction new file mode 100644 index 0000000000..5c5c889b7a --- /dev/null +++ b/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/stealable/order/equipment_4.mcfunction @@ -0,0 +1,19 @@ +# Checks slots to steal +# @s = #gm4_reeling_rods:steal_equipment +# at @s +# run from fished/stealable/steal_equipment + +# 4 +execute if items entity @s armor.chest * run return run function gm4_reeling_rods:fished/stealable/steal_slot/chest +# 6 +execute if items entity @s armor.feet * run return run function gm4_reeling_rods:fished/stealable/steal_slot/feet +# 1 +execute if items entity @s weapon.mainhand * run return run function gm4_reeling_rods:fished/stealable/steal_slot/mainhand +# 3 +execute if items entity @s armor.head * run return run function gm4_reeling_rods:fished/stealable/steal_slot/head +# 5 +execute if items entity @s armor.legs * run return run function gm4_reeling_rods:fished/stealable/steal_slot/legs +# 2 +execute if items entity @s weapon.offhand * run return run function gm4_reeling_rods:fished/stealable/steal_slot/offhand + +return fail diff --git a/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/stealable/order/equipment_5.mcfunction b/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/stealable/order/equipment_5.mcfunction new file mode 100644 index 0000000000..0f52fa86df --- /dev/null +++ b/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/stealable/order/equipment_5.mcfunction @@ -0,0 +1,19 @@ +# Checks slots to steal +# @s = #gm4_reeling_rods:steal_equipment +# at @s +# run from fished/stealable/steal_equipment + +# 5 +execute if items entity @s armor.legs * run return run function gm4_reeling_rods:fished/stealable/steal_slot/legs +# 2 +execute if items entity @s weapon.offhand * run return run function gm4_reeling_rods:fished/stealable/steal_slot/offhand +# 4 +execute if items entity @s armor.chest * run return run function gm4_reeling_rods:fished/stealable/steal_slot/chest +# 6 +execute if items entity @s armor.feet * run return run function gm4_reeling_rods:fished/stealable/steal_slot/feet +# 1 +execute if items entity @s weapon.mainhand * run return run function gm4_reeling_rods:fished/stealable/steal_slot/mainhand +# 3 +execute if items entity @s armor.head * run return run function gm4_reeling_rods:fished/stealable/steal_slot/head + +return fail diff --git a/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/stealable/order/equipment_6.mcfunction b/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/stealable/order/equipment_6.mcfunction new file mode 100644 index 0000000000..3b8ee03c6a --- /dev/null +++ b/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/stealable/order/equipment_6.mcfunction @@ -0,0 +1,19 @@ +# Checks slots to steal +# @s = #gm4_reeling_rods:steal_equipment +# at @s +# run from fished/stealable/steal_equipment + +# 6 +execute if items entity @s armor.feet * run return run function gm4_reeling_rods:fished/stealable/steal_slot/feet +# 1 +execute if items entity @s weapon.mainhand * run return run function gm4_reeling_rods:fished/stealable/steal_slot/mainhand +# 3 +execute if items entity @s armor.head * run return run function gm4_reeling_rods:fished/stealable/steal_slot/head +# 5 +execute if items entity @s armor.legs * run return run function gm4_reeling_rods:fished/stealable/steal_slot/legs +# 2 +execute if items entity @s weapon.offhand * run return run function gm4_reeling_rods:fished/stealable/steal_slot/offhand +# 4 +execute if items entity @s armor.chest * run return run function gm4_reeling_rods:fished/stealable/steal_slot/chest + +return fail diff --git a/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/stealable/order/hands_1.mcfunction b/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/stealable/order/hands_1.mcfunction new file mode 100644 index 0000000000..7648fdaab6 --- /dev/null +++ b/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/stealable/order/hands_1.mcfunction @@ -0,0 +1,9 @@ +# Checks slots to steal +# @s = #gm4_reeling_rods:steal_hand +# at @s +# run from fished/stealable/steal_hand + +execute if items entity @s weapon.mainhand * run return run function gm4_reeling_rods:fished/stealable/steal_slot/mainhand +execute if items entity @s weapon.offhand * run return run function gm4_reeling_rods:fished/stealable/steal_slot/offhand + +return fail diff --git a/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/stealable/order/hands_2.mcfunction b/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/stealable/order/hands_2.mcfunction new file mode 100644 index 0000000000..1cf37d796c --- /dev/null +++ b/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/stealable/order/hands_2.mcfunction @@ -0,0 +1,9 @@ +# Checks slots to steal +# @s = #gm4_reeling_rods:steal_hand +# at @s +# run from fished/stealable/steal_hand + +execute if items entity @s weapon.offhand * run return run function gm4_reeling_rods:fished/stealable/steal_slot/offhand +execute if items entity @s weapon.mainhand * run return run function gm4_reeling_rods:fished/stealable/steal_slot/mainhand + +return fail diff --git a/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/stealable/steal_equipment.mcfunction b/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/stealable/steal_equipment.mcfunction new file mode 100644 index 0000000000..5509109608 --- /dev/null +++ b/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/stealable/steal_equipment.mcfunction @@ -0,0 +1,13 @@ +# Pick an order to check equipment slots for stealing +# @s = #gm4_reeling_rods:steal_equipment +# at @s +# run from fished/select_type & fished/villager/action + +execute store result score $order gm4_reeling_rods.math run random value 1..6 + +execute if score $order gm4_reeling_rods.math matches 1 run return run function gm4_reeling_rods:fished/stealable/order/equipment_1 +execute if score $order gm4_reeling_rods.math matches 2 run return run function gm4_reeling_rods:fished/stealable/order/equipment_2 +execute if score $order gm4_reeling_rods.math matches 3 run return run function gm4_reeling_rods:fished/stealable/order/equipment_3 +execute if score $order gm4_reeling_rods.math matches 4 run return run function gm4_reeling_rods:fished/stealable/order/equipment_4 +execute if score $order gm4_reeling_rods.math matches 5 run return run function gm4_reeling_rods:fished/stealable/order/equipment_5 +execute if score $order gm4_reeling_rods.math matches 6 run return run function gm4_reeling_rods:fished/stealable/order/equipment_6 diff --git a/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/stealable/steal_hand.mcfunction b/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/stealable/steal_hand.mcfunction new file mode 100644 index 0000000000..34e5a411fc --- /dev/null +++ b/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/stealable/steal_hand.mcfunction @@ -0,0 +1,9 @@ +# Pick an order to check hand slots for stealing +# @s = #gm4_reeling_rods:steal_hand +# at @s +# run from fished/select_type + +execute store result score $order gm4_reeling_rods.math run random value 1..2 + +execute if score $order gm4_reeling_rods.math matches 1 run return run function gm4_reeling_rods:fished/stealable/order/hands_1 +execute if score $order gm4_reeling_rods.math matches 2 run return run function gm4_reeling_rods:fished/stealable/order/hands_2 diff --git a/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/stealable/steal_slot/chest.mcfunction b/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/stealable/steal_slot/chest.mcfunction new file mode 100644 index 0000000000..a3303ead55 --- /dev/null +++ b/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/stealable/steal_slot/chest.mcfunction @@ -0,0 +1,14 @@ +# Steal Chest +# @s = #gm4_reeling_rods:steal_equipment +# at @s +# run from fished/stealable/order/equipment_* + +data modify storage gm4_reeling_rods:temp item_data.Item set value {} +# NEEDS UPDATING FOR 1.21.5, USE EQUIPMENT TAG +data modify storage gm4_reeling_rods:temp item_data.Item set from entity @s Inventory[{Slot:102b}] +data modify storage gm4_reeling_rods:temp item_data.Item set from entity @s ArmorItems[2] +item replace entity @s armor.chest with minecraft:air +data remove storage gm4_reeling_rods:temp item_data.Item.Slot +data modify storage gm4_reeling_rods:temp item_data.PickupDelay set value 10s +execute positioned ~ ~.7 ~ run function gm4_reeling_rods:separate +return 4 diff --git a/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/stealable/steal_slot/feet.mcfunction b/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/stealable/steal_slot/feet.mcfunction new file mode 100644 index 0000000000..3c0c239fde --- /dev/null +++ b/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/stealable/steal_slot/feet.mcfunction @@ -0,0 +1,14 @@ +# Steal Feet +# @s = #gm4_reeling_rods:steal_equipment +# at @s +# run from fished/stealable/order/equipment_* + +data modify storage gm4_reeling_rods:temp item_data.Item set value {} +# NEEDS UPDATING FOR 1.21.5, USE EQUIPMENT TAG +data modify storage gm4_reeling_rods:temp item_data.Item set from entity @s Inventory[{Slot:100b}] +data modify storage gm4_reeling_rods:temp item_data.Item set from entity @s ArmorItems[0] +item replace entity @s armor.feet with minecraft:air +data remove storage gm4_reeling_rods:temp item_data.Item.Slot +data modify storage gm4_reeling_rods:temp item_data.PickupDelay set value 10s +execute positioned ~ ~.7 ~ run function gm4_reeling_rods:separate +return 6 diff --git a/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/stealable/steal_slot/head.mcfunction b/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/stealable/steal_slot/head.mcfunction new file mode 100644 index 0000000000..2ae2999d60 --- /dev/null +++ b/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/stealable/steal_slot/head.mcfunction @@ -0,0 +1,14 @@ +# Steal Head +# @s = #gm4_reeling_rods:steal_equipment +# at @s +# run from fished/stealable/order/equipment_* + +data modify storage gm4_reeling_rods:temp item_data.Item set value {} +# NEEDS UPDATING FOR 1.21.5, USE EQUIPMENT TAG +data modify storage gm4_reeling_rods:temp item_data.Item set from entity @s Inventory[{Slot:103b}] +data modify storage gm4_reeling_rods:temp item_data.Item set from entity @s ArmorItems[3] +item replace entity @s armor.head with minecraft:air +data remove storage gm4_reeling_rods:temp item_data.Item.Slot +data modify storage gm4_reeling_rods:temp item_data.PickupDelay set value 10s +execute positioned ~ ~.7 ~ run function gm4_reeling_rods:separate +return 3 diff --git a/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/stealable/steal_slot/legs.mcfunction b/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/stealable/steal_slot/legs.mcfunction new file mode 100644 index 0000000000..dc9a210a9d --- /dev/null +++ b/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/stealable/steal_slot/legs.mcfunction @@ -0,0 +1,14 @@ +# Steal Legs +# @s = #gm4_reeling_rods:steal_equipment +# at @s +# run from fished/stealable/order/equipment_* + +data modify storage gm4_reeling_rods:temp item_data.Item set value {} +# NEEDS UPDATING FOR 1.21.5, USE EQUIPMENT TAG +data modify storage gm4_reeling_rods:temp item_data.Item set from entity @s Inventory[{Slot:101b}] +data modify storage gm4_reeling_rods:temp item_data.Item set from entity @s ArmorItems[1] +item replace entity @s armor.legs with minecraft:air +data remove storage gm4_reeling_rods:temp item_data.Item.Slot +data modify storage gm4_reeling_rods:temp item_data.PickupDelay set value 10s +execute positioned ~ ~.7 ~ run function gm4_reeling_rods:separate +return 5 diff --git a/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/stealable/steal_slot/mainhand.mcfunction b/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/stealable/steal_slot/mainhand.mcfunction new file mode 100644 index 0000000000..a8201f2a71 --- /dev/null +++ b/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/stealable/steal_slot/mainhand.mcfunction @@ -0,0 +1,14 @@ +# Steal Mainhand +# @s = #gm4_reeling_rods:steal_hand or #gm4_reeling_rods:steal_equipment +# at @s +# run from fished/stealable/order/* + +data modify storage gm4_reeling_rods:temp item_data.Item set value {} +# NEEDS UPDATING FOR 1.21.5, USE EQUIPMENT TAG +data modify storage gm4_reeling_rods:temp item_data.Item set from entity @s Inventory[{Slot:0b}] +data modify storage gm4_reeling_rods:temp item_data.Item set from entity @s HandItems[0] +item replace entity @s weapon.mainhand with minecraft:air +data remove storage gm4_reeling_rods:temp item_data.Item.Slot +data modify storage gm4_reeling_rods:temp item_data.PickupDelay set value 10s +execute positioned ~ ~.7 ~ run function gm4_reeling_rods:separate +return 1 diff --git a/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/stealable/steal_slot/offhand.mcfunction b/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/stealable/steal_slot/offhand.mcfunction new file mode 100644 index 0000000000..d69b9e8547 --- /dev/null +++ b/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/stealable/steal_slot/offhand.mcfunction @@ -0,0 +1,14 @@ +# Steal Offhand +# @s = #gm4_reeling_rods:steal_hand or #gm4_reeling_rods:steal_equipment +# at @s +# run from fished/stealable/order/* + +data modify storage gm4_reeling_rods:temp item_data.Item set value {} +# NEEDS UPDATING FOR 1.21.5, USE EQUIPMENT TAG +data modify storage gm4_reeling_rods:temp item_data.Item set from entity @s Inventory[{Slot:-106b}] +data modify storage gm4_reeling_rods:temp item_data.Item set from entity @s HandItems[1] +item replace entity @s weapon.offhand with minecraft:air +data remove storage gm4_reeling_rods:temp item_data.Item.Slot +data modify storage gm4_reeling_rods:temp item_data.PickupDelay set value 10s +execute positioned ~ ~.7 ~ run function gm4_reeling_rods:separate +return 2 diff --git a/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/strider.mcfunction b/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/strider.mcfunction new file mode 100644 index 0000000000..8c14108abd --- /dev/null +++ b/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/strider.mcfunction @@ -0,0 +1,11 @@ +# Action for reeled strider +# @s = strider +# at @s +# run from fished/select_type + +# fail if no saddle +execute unless data entity @s {Saddle:1b} run return fail + +data modify entity @s Saddle set value 0b +data modify storage gm4_reeling_rods:temp item_data.Item set value {id:"minecraft:saddle",count:1} +execute positioned ~ ~0.75 ~ run function gm4_reeling_rods:separate diff --git a/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/undead_horse.mcfunction b/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/undead_horse.mcfunction new file mode 100644 index 0000000000..eb52f02ea6 --- /dev/null +++ b/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/undead_horse.mcfunction @@ -0,0 +1,9 @@ +# Action for reeled zombie horse or skele horse +# @s = zombie horse or skele horse +# at @s +# run from fished/select_type + +data modify storage gm4_reeling_rods:temp item_data set value {} +data modify storage gm4_reeling_rods:temp item_data.Item set from entity @s SaddleItem +execute positioned ~ ~0.8 ~ run function gm4_reeling_rods:separate +execute if data storage gm4_reeling_rods:temp {item_data:{Item:{id:"minecraft:saddle"}}} run item replace entity @s horse.saddle with minecraft:air diff --git a/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/villager/action.mcfunction b/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/villager/action.mcfunction new file mode 100644 index 0000000000..ebbb642a19 --- /dev/null +++ b/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/villager/action.mcfunction @@ -0,0 +1,27 @@ +# Action for reeled villager +# @s = villager +# at @s +# run from fished/select_type + +# store mainhand data for a potential trade steal +data modify storage gm4_reeling_rods:temp entity_data set value {} +data modify storage gm4_reeling_rods:temp entity_data.mainhand set from entity @s HandItems[0] + +# try to steal +execute store result score $slot gm4_reeling_rods.math run function gm4_reeling_rods:fished/stealable/steal_equipment +# if not mainhand, return +execute unless score $slot gm4_reeling_rods.math matches 1 run return fail + +## mainhand stolen (TRADED ITEM) + +# find trade and sell it out +function gm4_reeling_rods:fished/villager/sell_out with storage gm4_reeling_rods:temp entity_data + +# adds 20 "major_negative" gossip of the player to the villager +data modify storage gm4_reeling_rods:temp entity_data.gossip.Target set from entity @a[tag=gm4_reeling_rods.player,limit=1,distance=..33] UUID +function gm4_reeling_rods:fished/villager/add_gossip with storage gm4_reeling_rods:temp entity_data.gossip + +# angry particles +particle minecraft:angry_villager ~ ~1.5 ~ 0.3 0.3 0.3 20 3 +# angry sound +playsound minecraft:entity.villager.hurt neutral @a[distance=..16] ~ ~1.5 ~ diff --git a/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/villager/add_gossip.mcfunction b/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/villager/add_gossip.mcfunction new file mode 100644 index 0000000000..7b6e1f0d03 --- /dev/null +++ b/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/villager/add_gossip.mcfunction @@ -0,0 +1,16 @@ +# adds a "major_negaive" gossip of the player to the villager +# @s = villager +# at @s +# with {Target} +# run from fished/villager/action + +$execute store success score $success gm4_reeling_rods.math run \ + data modify storage gm4_reeling_rods:temp entity_data.gossip merge from entity @s Gossips[{Type:"major_negative",Target:$(Target)}] + +execute unless score $success gm4_reeling_rods.math matches 1 run data modify storage gm4_reeling_rods:temp entity_data.gossip merge value {Type:"major_negative",Value:0} + +execute store result score $gossip_value gm4_reeling_rods.math run data get storage gm4_reeling_rods:temp entity_data.gossip.Value +execute unless score $gossip_value gm4_reeling_rods.math matches ..80 run scoreboard players set $gossip_value gm4_reeling_rods.math 100 +execute if score $gossip_value gm4_reeling_rods.math matches ..80 run scoreboard players add $gossip_value gm4_reeling_rods.math 20 +execute store result storage gm4_reeling_rods:temp entity_data.gossip.Value int 1 run scoreboard players get $gossip_value gm4_reeling_rods.math +data modify entity @s Gossips append from storage gm4_reeling_rods:temp entity_data.gossip diff --git a/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/villager/sell_out.mcfunction b/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/villager/sell_out.mcfunction new file mode 100644 index 0000000000..390fdc51d9 --- /dev/null +++ b/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/villager/sell_out.mcfunction @@ -0,0 +1,9 @@ +# sells out a trade +# @s = villager +# at @s +# with {mainhand} +# run from fished/villager/action + +# for some reason on the first item after a restock?? it fails to set uses, but succeeds after that? This double set doesn't fix that though +$data modify entity @s Offers.Recipes[{sell:$(mainhand)}] merge value {uses:0} +$data modify entity @s Offers.Recipes[{sell:$(mainhand)}].uses set from entity @s Offers.Recipes[{sell:$(mainhand)}].maxUses diff --git a/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/wolf.mcfunction b/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/wolf.mcfunction new file mode 100644 index 0000000000..fce50f0808 --- /dev/null +++ b/gm4_reeling_rods/data/gm4_reeling_rods/function/fished/wolf.mcfunction @@ -0,0 +1,11 @@ +# Action for reeled wolf +# @s = wolf +# at @s +# run from fished/select_type + +# fail if no Owner +execute unless data entity @s Owner run return fail + +data modify storage gm4_reeling_rods:temp item_data.Item set from entity @s body_armor_item +data remove entity @s body_armor_item +execute positioned ~ ~0.4 ~ run function gm4_reeling_rods:separate diff --git a/gm4_reeling_rods/data/gm4_reeling_rods/function/get_lookup.mcfunction b/gm4_reeling_rods/data/gm4_reeling_rods/function/get_lookup.mcfunction new file mode 100644 index 0000000000..274d5f13b9 --- /dev/null +++ b/gm4_reeling_rods/data/gm4_reeling_rods/function/get_lookup.mcfunction @@ -0,0 +1,5 @@ +# Adds a value from the lookup table to Y motion +# with (lookup_key) +# run from get_motion_to_player + +$scoreboard players operation $motionY gm4_reeling_rods.math += $$(lookup_key) gm4_reeling_rods.lookup diff --git a/gm4_reeling_rods/data/gm4_reeling_rods/function/get_motion_to_player.mcfunction b/gm4_reeling_rods/data/gm4_reeling_rods/function/get_motion_to_player.mcfunction new file mode 100644 index 0000000000..833856cc8f --- /dev/null +++ b/gm4_reeling_rods/data/gm4_reeling_rods/function/get_motion_to_player.mcfunction @@ -0,0 +1,44 @@ +# Gets motion vector to launch item to player +# run from separate + + +data modify storage gm4_reeling_rods:temp item_data.Motion set value [0d,0d,0d] + +# Store item pos +data modify storage gm4_reeling_rods:temp item_data.Pos set from entity @s Pos +execute store result score $itemX gm4_reeling_rods.math run data get storage gm4_reeling_rods:temp item_data.Pos[0] 1 +execute store result score $itemY gm4_reeling_rods.math run data get storage gm4_reeling_rods:temp item_data.Pos[1] 1 +execute store result score $itemZ gm4_reeling_rods.math run data get storage gm4_reeling_rods:temp item_data.Pos[2] 1 + +# Player postion is stored in $motionX... ect from store_player_pos.mcfunction + +# Get delta from item to player +scoreboard players operation $motionX gm4_reeling_rods.math -= $itemX gm4_reeling_rods.math +scoreboard players operation $motionY gm4_reeling_rods.math -= $itemY gm4_reeling_rods.math +scoreboard players operation $motionZ gm4_reeling_rods.math -= $itemZ gm4_reeling_rods.math + + +# store Motion, y to be edited after +execute store result storage gm4_reeling_rods:temp item_data.Motion[0] double 0.1 run scoreboard players get $motionX gm4_reeling_rods.math +execute store result storage gm4_reeling_rods:temp item_data.Motion[1] double 0.1 run scoreboard players get $motionY gm4_reeling_rods.math +execute store result storage gm4_reeling_rods:temp item_data.Motion[2] double 0.1 run scoreboard players get $motionZ gm4_reeling_rods.math + +# Square +scoreboard players operation $motionX gm4_reeling_rods.math *= $motionX gm4_reeling_rods.math +scoreboard players operation $motionY gm4_reeling_rods.math *= $motionY gm4_reeling_rods.math +scoreboard players operation $motionZ gm4_reeling_rods.math *= $motionZ gm4_reeling_rods.math + +# Add the squares +scoreboard players operation $lookup_key gm4_reeling_rods.math = $motionX gm4_reeling_rods.math +scoreboard players operation $lookup_key gm4_reeling_rods.math += $motionY gm4_reeling_rods.math +execute store result storage gm4_reeling_rods:temp lookup_key int 1 \ + run scoreboard players operation $lookup_key gm4_reeling_rods.math += $motionZ gm4_reeling_rods.math + +# store motion Y, scaled up +execute store result score $motionY gm4_reeling_rods.math run data get storage gm4_reeling_rods:temp item_data.Motion[1] 100 + +# Add looked up value +function gm4_reeling_rods:get_lookup with storage gm4_reeling_rods:temp + +# Store the Completed YMotion +execute store result storage gm4_reeling_rods:temp item_data.Motion[1] double 0.01 run scoreboard players get $motionY gm4_reeling_rods.math diff --git a/gm4_reeling_rods/data/gm4_reeling_rods/function/id/assign.mcfunction b/gm4_reeling_rods/data/gm4_reeling_rods/function/id/assign.mcfunction new file mode 100644 index 0000000000..fc2f0c5a20 --- /dev/null +++ b/gm4_reeling_rods/data/gm4_reeling_rods/function/id/assign.mcfunction @@ -0,0 +1,22 @@ +# assigns @s bit tags +# @s = entity to set tags +# with {bit_0, bit_1, bit_2, bit_3, bit_4, bit_5, bit_6, bit_7, bit_8, bit_9, bit_10, bit_11, bit_12, bit_13, bit_14, bit_15} +# run from id/set + +$tag @s add $(bit_0) +$tag @s add $(bit_1) +$tag @s add $(bit_2) +$tag @s add $(bit_3) +$tag @s add $(bit_4) +$tag @s add $(bit_5) +$tag @s add $(bit_6) +$tag @s add $(bit_7) +$tag @s add $(bit_8) +$tag @s add $(bit_9) +$tag @s add $(bit_10) +$tag @s add $(bit_11) +$tag @s add $(bit_12) +$tag @s add $(bit_13) +$tag @s add $(bit_14) +$tag @s add $(bit_15) +tag @s add gm4_reeling_rods.id.tagged diff --git a/gm4_reeling_rods/data/gm4_reeling_rods/function/id/clear.mcfunction b/gm4_reeling_rods/data/gm4_reeling_rods/function/id/clear.mcfunction new file mode 100644 index 0000000000..50d3d6372c --- /dev/null +++ b/gm4_reeling_rods/data/gm4_reeling_rods/function/id/clear.mcfunction @@ -0,0 +1,37 @@ +# clears all id tags off of @s +# @s = entity with tag gm4_reeling_rods.id.tagged +# run from tick + +tag @s remove gm4_reeling_rods.id.0.0 +tag @s remove gm4_reeling_rods.id.1.0 +tag @s remove gm4_reeling_rods.id.2.0 +tag @s remove gm4_reeling_rods.id.3.0 +tag @s remove gm4_reeling_rods.id.4.0 +tag @s remove gm4_reeling_rods.id.5.0 +tag @s remove gm4_reeling_rods.id.6.0 +tag @s remove gm4_reeling_rods.id.7.0 +tag @s remove gm4_reeling_rods.id.8.0 +tag @s remove gm4_reeling_rods.id.9.0 +tag @s remove gm4_reeling_rods.id.10.0 +tag @s remove gm4_reeling_rods.id.11.0 +tag @s remove gm4_reeling_rods.id.12.0 +tag @s remove gm4_reeling_rods.id.13.0 +tag @s remove gm4_reeling_rods.id.14.0 +tag @s remove gm4_reeling_rods.id.15.0 +tag @s remove gm4_reeling_rods.id.0.1 +tag @s remove gm4_reeling_rods.id.1.1 +tag @s remove gm4_reeling_rods.id.2.1 +tag @s remove gm4_reeling_rods.id.3.1 +tag @s remove gm4_reeling_rods.id.4.1 +tag @s remove gm4_reeling_rods.id.5.1 +tag @s remove gm4_reeling_rods.id.6.1 +tag @s remove gm4_reeling_rods.id.7.1 +tag @s remove gm4_reeling_rods.id.8.1 +tag @s remove gm4_reeling_rods.id.9.1 +tag @s remove gm4_reeling_rods.id.10.1 +tag @s remove gm4_reeling_rods.id.11.1 +tag @s remove gm4_reeling_rods.id.12.1 +tag @s remove gm4_reeling_rods.id.13.1 +tag @s remove gm4_reeling_rods.id.14.1 +tag @s remove gm4_reeling_rods.id.15.1 +tag @s remove gm4_reeling_rods.id.tagged diff --git a/gm4_reeling_rods/data/gm4_reeling_rods/function/id/get_next.mcfunction b/gm4_reeling_rods/data/gm4_reeling_rods/function/id/get_next.mcfunction new file mode 100644 index 0000000000..b791d423d6 --- /dev/null +++ b/gm4_reeling_rods/data/gm4_reeling_rods/function/id/get_next.mcfunction @@ -0,0 +1,17 @@ +# Gets the next id +# with {bit} +# run from id/set and self + +# Data storage gm4_reeling_rods:id next + # bit_0..15 : "gm4_reeling_rods.id.<0..15>.[0|1]" + +# change bit 0 -> 1, return nothing else to do +$execute if data storage gm4_reeling_rods:id {next:{bit_$(bit):"gm4_reeling_rods.id.$(bit).0"}} \ + run return run data modify storage gm4_reeling_rods:id next.bit_$(bit) set value "gm4_reeling_rods.id.$(bit).1" + +# change bit 1 -> 0, then go on to next bit +$data modify storage gm4_reeling_rods:id next.bit_$(bit) set value "gm4_reeling_rods.id.$(bit).0" +execute if score $bit gm4_reeling_rods.math matches 15 run return 1 +# next bit +execute store result storage gm4_reeling_rods:id bit int 1 run scoreboard players add $bit gm4_reeling_rods.math 1 +function gm4_reeling_rods:id/get_next with storage gm4_reeling_rods:id diff --git a/gm4_reeling_rods/data/gm4_reeling_rods/function/id/set.mcfunction b/gm4_reeling_rods/data/gm4_reeling_rods/function/id/set.mcfunction new file mode 100644 index 0000000000..44f018c33d --- /dev/null +++ b/gm4_reeling_rods/data/gm4_reeling_rods/function/id/set.mcfunction @@ -0,0 +1,11 @@ +# function logic for setting an id on an entity +# @s = entity to be assigned id +# at @s +# run from tick + +# get new id +execute store result storage gm4_reeling_rods:id bit int 1 run scoreboard players set $bit gm4_reeling_rods.math 0 +function gm4_reeling_rods:id/get_next with storage gm4_reeling_rods:id + +# assign new id +function gm4_reeling_rods:id/assign with storage gm4_reeling_rods:id next diff --git a/gm4_reeling_rods/data/gm4_reeling_rods/function/init.mcfunction b/gm4_reeling_rods/data/gm4_reeling_rods/function/init.mcfunction new file mode 100644 index 0000000000..44051458d7 --- /dev/null +++ b/gm4_reeling_rods/data/gm4_reeling_rods/function/init.mcfunction @@ -0,0 +1,13 @@ +execute unless score reeling_rods gm4_modules matches 1 run data modify storage gm4:log queue append value {type:"install",module:"Reeling Rods"} +execute unless score reeling_rods gm4_earliest_version < reeling_rods gm4_modules run scoreboard players operation reeling_rods gm4_earliest_version = reeling_rods gm4_modules +scoreboard players set reeling_rods gm4_modules 1 + +scoreboard objectives add gm4_reeling_rods.math dummy "gm4_reeling math" +scoreboard objectives add gm4_reeling_rods.lookup dummy "gm4_reeling lookup table" +scoreboard objectives add gm4_reeling_rods.entities dummy "gm4_reeling entity specific" +scoreboard objectives add gm4_reeling_rods.bit_count dummy "gm4_reeling_rods bit count" + +# set_lookup_table generated in generate_files.py +function gm4_reeling_rods:set_lookup_table + +schedule function gm4_reeling_rods:tick 1t diff --git a/gm4_reeling_rods/data/gm4_reeling_rods/function/is_passenger.mcfunction b/gm4_reeling_rods/data/gm4_reeling_rods/function/is_passenger.mcfunction new file mode 100644 index 0000000000..6282558dac --- /dev/null +++ b/gm4_reeling_rods/data/gm4_reeling_rods/function/is_passenger.mcfunction @@ -0,0 +1,6 @@ +# checks if @s is a passenger +# @s = entity to check +# at @s +# run from fished/select_type + +return run execute on vehicle if entity @s diff --git a/gm4_reeling_rods/data/gm4_reeling_rods/function/player/add_bit.mcfunction b/gm4_reeling_rods/data/gm4_reeling_rods/function/player/add_bit.mcfunction new file mode 100644 index 0000000000..5144711455 --- /dev/null +++ b/gm4_reeling_rods/data/gm4_reeling_rods/function/player/add_bit.mcfunction @@ -0,0 +1,15 @@ +# Adds a bit value to the marker at players location and continues +# @s = marker at players feet +# at @s +# with {bit, bit_tag} +# run from player/received_bit + +# add bit data +$data modify entity @s data.gm4_reeling_rods.id.bit_$(bit) set value "$(bit_tag)" + +# fail if not all bits +execute unless score @a[tag=gm4_reeling_rods.player,limit=1] gm4_reeling_rods.bit_count matches 16 run return fail + +# all bits received +scoreboard players set @a[tag=gm4_reeling_rods.player] gm4_reeling_rods.bit_count 0 +function gm4_reeling_rods:player/find_fished_entity with entity @s data.gm4_reeling_rods.id diff --git a/gm4_reeling_rods/data/gm4_reeling_rods/function/player/find_fished_entity.mcfunction b/gm4_reeling_rods/data/gm4_reeling_rods/function/player/find_fished_entity.mcfunction new file mode 100644 index 0000000000..8f8cf3433b --- /dev/null +++ b/gm4_reeling_rods/data/gm4_reeling_rods/function/player/find_fished_entity.mcfunction @@ -0,0 +1,17 @@ +# Finds entity the player fished +# @s = marker at players feet +# at @s +# with {bit_0, bit_1, bit_2, bit_3, bit_4, bit_5, bit_6, bit_7, bit_8, bit_9, bit_10, bit_11, bit_12, bit_13, bit_14, bit_15} +# run from player/add_bit + +# distance to fishing bobber is ..33 as 33 blocks is the farthest a fishing bobber can be from the caster +# distance from bobber to entity is ..42 as that represents a vanilla entity of 3.28 blocks tall at a max of 16x scale and then 80% of the height to find the fishing bobber +$execute as @e[type=minecraft:fishing_bobber,distance=..33] \ + if function gm4_reeling_rods:player/owns_bobber \ + at @s as @e[distance=..42, limit=1, \ + tag=$(bit_0), tag=$(bit_1), tag=$(bit_2), tag=$(bit_3), tag=$(bit_4), tag=$(bit_5), tag=$(bit_6), tag=$(bit_7), \ + tag=$(bit_8), tag=$(bit_9), tag=$(bit_10), tag=$(bit_11), tag=$(bit_12), tag=$(bit_13), tag=$(bit_14), tag=$(bit_15)\ + ] unless entity @s[tag=smithed.entity] at @s run function gm4_reeling_rods:fished/select_type + +# kill marker after +kill @s diff --git a/gm4_reeling_rods/data/gm4_reeling_rods/function/player/owns_bobber.mcfunction b/gm4_reeling_rods/data/gm4_reeling_rods/function/player/owns_bobber.mcfunction new file mode 100644 index 0000000000..4e2a119250 --- /dev/null +++ b/gm4_reeling_rods/data/gm4_reeling_rods/function/player/owns_bobber.mcfunction @@ -0,0 +1,6 @@ +# Checks if a fishing bobber belongs to the targeted owner +# @s = a fishing bobber +# at owner +# run from player/find_fished_entity + +return run execute on origin if entity @s[tag=gm4_reeling_rods.player] diff --git a/gm4_reeling_rods/data/gm4_reeling_rods/function/player/received_bit.mcfunction b/gm4_reeling_rods/data/gm4_reeling_rods/function/player/received_bit.mcfunction new file mode 100644 index 0000000000..283f5984d8 --- /dev/null +++ b/gm4_reeling_rods/data/gm4_reeling_rods/function/player/received_bit.mcfunction @@ -0,0 +1,22 @@ +# Logic for when a player receives a bit +# @s = player who received a bit +# at @s +# with {bit, bit_tag} +# run from player/bit_{bit}_{value} + +# Assumptions: + # bit and bit_tag are stored in storage gm4_reeling_rods:temp bit_data + # this score is set to 0 after all bits received +scoreboard players add @s gm4_reeling_rods.bit_count 1 + +# if marker exists proceed to player/add_bit +execute as @e[type=minecraft:marker,distance=..0.001,tag=gm4_reeling_rods.player_marker,limit=1] run \ + return run function gm4_reeling_rods:player/add_bit with storage gm4_reeling_rods:temp bit_data + +# first bit, no marker found, summon one +$summon minecraft:marker ~ ~ ~ \ + {\ + Tags:["gm4_reeling_rods.player_marker","smithed.strict","smithed.entity"],\ + data:{gm4_reeling_rods:{id:{bit_$(bit):"$(bit_tag)"}}},\ + CustomName:'{"text":"gm4_reeling_rods.player_marker"}'\ + } diff --git a/gm4_reeling_rods/data/gm4_reeling_rods/function/separate.mcfunction b/gm4_reeling_rods/data/gm4_reeling_rods/function/separate.mcfunction new file mode 100644 index 0000000000..b3f873dc2c --- /dev/null +++ b/gm4_reeling_rods/data/gm4_reeling_rods/function/separate.mcfunction @@ -0,0 +1,13 @@ +# Separates an entity that needs it +# @s = entity to be separated +# at @s +# run from fished/* & fished/*/action & fished/stealable/steal_slot/* + +function gm4_reeling_rods:get_motion_to_player +function gm4_reeling_rods:summon_item with storage gm4_reeling_rods:temp + +# return if no items +execute unless data entity @s Items[] run return 0 + +data modify storage gm4_reeling_rods:temp motion_vector set from storage gm4_reeling_rods:temp entity_data.Motion +function gm4_reeling_rods:empty_container_entity diff --git a/gm4_reeling_rods/data/gm4_reeling_rods/function/store_player_pos.mcfunction b/gm4_reeling_rods/data/gm4_reeling_rods/function/store_player_pos.mcfunction new file mode 100644 index 0000000000..56e5268f34 --- /dev/null +++ b/gm4_reeling_rods/data/gm4_reeling_rods/function/store_player_pos.mcfunction @@ -0,0 +1,9 @@ +# stores players postion +# @s = Player +# at @s +# run from player/bit_{bit}_{value} + +data modify storage gm4_reeling_rods:temp player_data.Pos set from entity @s Pos +execute store result score $motionX gm4_reeling_rods.math run data get storage gm4_reeling_rods:temp player_data.Pos[0] 1 +execute store result score $motionY gm4_reeling_rods.math run data get storage gm4_reeling_rods:temp player_data.Pos[1] 1 +execute store result score $motionZ gm4_reeling_rods.math run data get storage gm4_reeling_rods:temp player_data.Pos[2] 1 diff --git a/gm4_reeling_rods/data/gm4_reeling_rods/function/summon_entity.mcfunction b/gm4_reeling_rods/data/gm4_reeling_rods/function/summon_entity.mcfunction new file mode 100644 index 0000000000..83e23266a2 --- /dev/null +++ b/gm4_reeling_rods/data/gm4_reeling_rods/function/summon_entity.mcfunction @@ -0,0 +1,5 @@ +# Summons a generic entity with data +# with {entity_type, entity_data} +# run from fished/{minecart/chest_boat}/action + +$summon $(entity_type) ~ ~ ~ $(entity_data) diff --git a/gm4_reeling_rods/data/gm4_reeling_rods/function/summon_item.mcfunction b/gm4_reeling_rods/data/gm4_reeling_rods/function/summon_item.mcfunction new file mode 100644 index 0000000000..cf8001d5b6 --- /dev/null +++ b/gm4_reeling_rods/data/gm4_reeling_rods/function/summon_item.mcfunction @@ -0,0 +1,4 @@ +# Summons item with data +# run from separate and empty_container_entity + +$summon minecraft:item ~ ~ ~ $(item_data) diff --git a/gm4_reeling_rods/data/gm4_reeling_rods/function/tick.mcfunction b/gm4_reeling_rods/data/gm4_reeling_rods/function/tick.mcfunction new file mode 100644 index 0000000000..950803fd48 --- /dev/null +++ b/gm4_reeling_rods/data/gm4_reeling_rods/function/tick.mcfunction @@ -0,0 +1,8 @@ +# reset clear all id tags +execute as @e[tag=gm4_reeling_rods.id.tagged] run function gm4_reeling_rods:id/clear + +# set new id tags if needed +# distance from bobber to entity is ..42 as that represents a vanilla entity of 3.28 blocks tall at a max of 16x scale and then 80% of the height to find the fishing bobber +execute as @e[type=minecraft:fishing_bobber] at @s as @e[type=!#gm4_reeling_rods:ignore,distance=..42] at @s run function gm4_reeling_rods:id/set + +schedule function gm4_reeling_rods:tick 1t diff --git a/gm4_reeling_rods/data/gm4_reeling_rods/predicate/holding_reeling_rod.json b/gm4_reeling_rods/data/gm4_reeling_rods/predicate/holding_reeling_rod.json new file mode 100644 index 0000000000..cd7a1fba2e --- /dev/null +++ b/gm4_reeling_rods/data/gm4_reeling_rods/predicate/holding_reeling_rod.json @@ -0,0 +1,17 @@ +{ + "condition": "minecraft:entity_properties", + "entity": "this", + "predicate": { + "slots": { + "weapon.*": { + "predicates": { + "minecraft:enchantments": [ + { + "enchantments": "gm4_reeling_rods:reeling" + } + ] + } + } + } + } +} diff --git a/gm4_reeling_rods/data/gm4_reeling_rods/tags/entity_type/ignore.json b/gm4_reeling_rods/data/gm4_reeling_rods/tags/entity_type/ignore.json new file mode 100644 index 0000000000..79d0f04ca6 --- /dev/null +++ b/gm4_reeling_rods/data/gm4_reeling_rods/tags/entity_type/ignore.json @@ -0,0 +1,38 @@ +{ + "values": [ + "minecraft:area_effect_cloud", + "minecraft:arrow", + "minecraft:block_display", + "minecraft:breeze_wind_charge", + "minecraft:command_block_minecart", + "minecraft:dragon_fireball", + "minecraft:egg", + "minecraft:ender_pearl", + "minecraft:evoker_fangs", + "minecraft:experience_bottle", + "minecraft:experience_orb", + "minecraft:eye_of_ender", + "minecraft:falling_block", + "minecraft:fireball", + "minecraft:firework_rocket", + "minecraft:fishing_bobber", + "minecraft:interaction", + "minecraft:item", + "minecraft:item_display", + "minecraft:lightning_bolt", + "minecraft:llama_spit", + "minecraft:marker", + "minecraft:ominous_item_spawner", + "minecraft:potion", + "minecraft:shulker_bullet", + "minecraft:small_fireball", + "minecraft:snowball", + "minecraft:spawner_minecart", + "minecraft:spectral_arrow", + "minecraft:text_display", + "minecraft:tnt", + "minecraft:trident", + "minecraft:wind_charge", + "minecraft:wither_skull" + ] +} diff --git a/gm4_reeling_rods/data/gm4_reeling_rods/tags/entity_type/leashable.json b/gm4_reeling_rods/data/gm4_reeling_rods/tags/entity_type/leashable.json new file mode 100644 index 0000000000..2649426f8b --- /dev/null +++ b/gm4_reeling_rods/data/gm4_reeling_rods/tags/entity_type/leashable.json @@ -0,0 +1,39 @@ +{ + "values": [ + "#gm4:boats", + "#gm4:chest_boats", + "#gm4_reeling_rods:llamas", + "#gm4_reeling_rods:undead_horse", + "minecraft:allay", + "minecraft:armadillo", + "minecraft:axolotl", + "minecraft:bee", + "minecraft:camel", + "minecraft:cat", + "minecraft:chicken", + "minecraft:cow", + "minecraft:dolphin", + "minecraft:donkey", + "minecraft:fox", + "minecraft:frog", + "minecraft:glow_squid", + "minecraft:goat", + "minecraft:hoglin", + "minecraft:horse", + "minecraft:iron_golem", + "minecraft:mooshroom", + "minecraft:mule", + "minecraft:ocelot", + "minecraft:parrot", + "minecraft:pig", + "minecraft:polar_bear", + "minecraft:rabbit", + "minecraft:sheep", + "minecraft:sniffer", + "minecraft:snow_golem", + "minecraft:squid", + "minecraft:strider", + "minecraft:wolf", + "minecraft:zoglin" + ] +} diff --git a/gm4_reeling_rods/data/gm4_reeling_rods/tags/entity_type/llamas.json b/gm4_reeling_rods/data/gm4_reeling_rods/tags/entity_type/llamas.json new file mode 100644 index 0000000000..4560fcfee3 --- /dev/null +++ b/gm4_reeling_rods/data/gm4_reeling_rods/tags/entity_type/llamas.json @@ -0,0 +1,6 @@ +{ + "values": [ + "minecraft:llama", + "minecraft:trader_llama" + ] +} diff --git a/gm4_reeling_rods/data/gm4_reeling_rods/tags/entity_type/steal_equipment.json b/gm4_reeling_rods/data/gm4_reeling_rods/tags/entity_type/steal_equipment.json new file mode 100644 index 0000000000..83ae295d49 --- /dev/null +++ b/gm4_reeling_rods/data/gm4_reeling_rods/tags/entity_type/steal_equipment.json @@ -0,0 +1,16 @@ +{ + "values": [ + "minecraft:bogged", + "minecraft:drowned", + "minecraft:husk", + "minecraft:piglin", + "minecraft:piglin_brute", + "minecraft:player", + "minecraft:skeleton", + "minecraft:stray", + "minecraft:wither_skeleton", + "minecraft:zombie", + "minecraft:zombie_villager", + "minecraft:zombified_piglin" + ] +} diff --git a/gm4_reeling_rods/data/gm4_reeling_rods/tags/entity_type/steal_hand.json b/gm4_reeling_rods/data/gm4_reeling_rods/tags/entity_type/steal_hand.json new file mode 100644 index 0000000000..66c0801214 --- /dev/null +++ b/gm4_reeling_rods/data/gm4_reeling_rods/tags/entity_type/steal_hand.json @@ -0,0 +1,11 @@ +{ + "values": [ + "minecraft:allay", + "minecraft:fox", + "minecraft:illusioner", + "minecraft:pillager", + "minecraft:vex", + "minecraft:vindicator", + "minecraft:witch" + ] +} diff --git a/gm4_reeling_rods/data/gm4_reeling_rods/tags/entity_type/undead_horse.json b/gm4_reeling_rods/data/gm4_reeling_rods/tags/entity_type/undead_horse.json new file mode 100644 index 0000000000..ab5a10544b --- /dev/null +++ b/gm4_reeling_rods/data/gm4_reeling_rods/tags/entity_type/undead_horse.json @@ -0,0 +1,6 @@ +{ + "values": [ + "minecraft:skeleton_horse", + "minecraft:zombie_horse" + ] +} diff --git a/gm4_reeling_rods/data/minecraft/tags/enchantment/non_treasure.json b/gm4_reeling_rods/data/minecraft/tags/enchantment/non_treasure.json new file mode 100644 index 0000000000..fdf6328f6d --- /dev/null +++ b/gm4_reeling_rods/data/minecraft/tags/enchantment/non_treasure.json @@ -0,0 +1,5 @@ +{ + "values": [ + "gm4_reeling_rods:reeling" + ] +} diff --git a/gm4_reeling_rods/entities.csv b/gm4_reeling_rods/entities.csv new file mode 100644 index 0000000000..7fd852e9fb --- /dev/null +++ b/gm4_reeling_rods/entities.csv @@ -0,0 +1,34 @@ +id,needs_enchantment,can_dismount,command +#gm4_reeling_rods:llamas,TRUE,TRUE,"function gm4_reeling_rods:fished/llama" +#gm4_reeling_rods:steal_hand,TRUE,TRUE,"function gm4_reeling_rods:fished/stealable/steal_hand" +#gm4_reeling_rods:steal_equipment,TRUE,TRUE,"function gm4_reeling_rods:fished/stealable/steal_equipment" +#gm4_reeling_rods:undead_horse,TRUE,TRUE,"function gm4_reeling_rods:fished/undead_horse" +minecraft:donkey,TRUE,TRUE,"function gm4_reeling_rods:fished/donkey" +minecraft:horse,TRUE,TRUE,"function gm4_reeling_rods:fished/horse" +minecraft:mule,TRUE,TRUE,"function gm4_reeling_rods:fished/mule" +minecraft:pig,TRUE,TRUE,"function gm4_reeling_rods:fished/pig" +minecraft:snow_golem,TRUE,TRUE,"function gm4_reeling_rods:fished/snow_golem" +minecraft:strider,TRUE,TRUE,"function gm4_reeling_rods:fished/strider" +minecraft:villager,TRUE,TRUE,"function gm4_reeling_rods:fished/villager/action" +minecraft:wolf,TRUE,TRUE,"function gm4_reeling_rods:fished/wolf" +minecraft:shulker,FALSE,TRUE,"execute facing entity @a[tag=gm4_reeling_rods.player,distance=..33,limit=1] eyes run tp @s ^ ^ ^1" +minecraft:chest_minecart,TRUE,FALSE,"function gm4_reeling_rods:fished/minecart/action {block:'minecraft:chest'}" +minecraft:furnace_minecart,TRUE,FALSE,"function gm4_reeling_rods:fished/minecart/action {block:'minecraft:furnace'}" +minecraft:hopper_minecart,TRUE,FALSE,"function gm4_reeling_rods:fished/minecart/action {block:'minecraft:hopper'}" +minecraft:tnt_minecart,TRUE,FALSE,"function gm4_reeling_rods:fished/minecart/action {block:'minecraft:tnt'}" +minecraft:chest_boat,TRUE,FALSE,"function gm4_reeling_rods:fished/chest_boat/action {boat_type:'minecraft:boat'}" +minecraft:acacia_chest_boat,TRUE,FALSE,"function gm4_reeling_rods:fished/chest_boat/action {boat_type:'minecraft:acacia_boat'}" +minecraft:bamboo_chest_raft,TRUE,FALSE,"function gm4_reeling_rods:fished/chest_boat/action {boat_type:'minecraft:bamboo_raft'}" +minecraft:birch_chest_boat,TRUE,FALSE,"function gm4_reeling_rods:fished/chest_boat/action {boat_type:'minecraft:birch_boat'}" +minecraft:cherry_chest_boat,TRUE,FALSE,"function gm4_reeling_rods:fished/chest_boat/action {boat_type:'minecraft:cherry_boat'}" +minecraft:dark_oak_chest_boat,TRUE,FALSE,"function gm4_reeling_rods:fished/chest_boat/action {boat_type:'minecraft:dark_oak_boat'}" +minecraft:jungle_chest_boat,TRUE,FALSE,"function gm4_reeling_rods:fished/chest_boat/action {boat_type:'minecraft:jungle_boat'}" +minecraft:mangrove_chest_boat,TRUE,FALSE,"function gm4_reeling_rods:fished/chest_boat/action {boat_type:'minecraft:mangrove_boat'}" +minecraft:oak_chest_boat,TRUE,FALSE,"function gm4_reeling_rods:fished/chest_boat/action {boat_type:'minecraft:oak_boat'}" +minecraft:pale_oak_chest_boat,TRUE,FALSE,"function gm4_reeling_rods:fished/chest_boat/action {boat_type:'minecraft:pale_oak_boat'}" +minecraft:spruce_chest_boat,TRUE,FALSE,"function gm4_reeling_rods:fished/chest_boat/action {boat_type:'minecraft:spruce_boat'}" +minecraft:end_crystal,FALSE,FALSE,"damage @s 1" +minecraft:glow_item_frame,FALSE,FALSE,"function gm4_reeling_rods:fished/item_frame {type:'minecraft:glow_item_frame'}" +minecraft:item_frame,FALSE,FALSE,"function gm4_reeling_rods:fished/item_frame {type:'minecraft:item_frame'}" +minecraft:leash_knot,FALSE,FALSE,"function gm4_reeling_rods:fished/leash_knot/action" +minecraft:painting,FALSE,FALSE,"function gm4_reeling_rods:fished/painting" diff --git a/gm4_reeling_rods/generate_files.py b/gm4_reeling_rods/generate_files.py new file mode 100644 index 0000000000..d0bd4265fa --- /dev/null +++ b/gm4_reeling_rods/generate_files.py @@ -0,0 +1,157 @@ +from typing import List +from beet import Context, Advancement, Function, DataPack +import math +from pathlib import Path +from gm4.utils import CSV + +def beet_default(ctx: Context): + """NOTE: generates files + - set_lookup_table + - advancements and reward functions for every bit state of an entity's tagged id + - fishing/select_type and overlays of it + """ + create_lookup_file(ctx) + create_bit_advancements(ctx) + + entity_list = CSV.from_file(Path('gm4_reeling_rods','entities.csv')) + + create_select_type(ctx, entity_list) +''' +My goal for right now is to go to the maximum scope and then have things cut back. +Push this idea as far as I can, then reign it in. + + Hand & Armor Yoinking + Treat this as an action. If an entity is in one of the tags, don't list them separately in the csv + + Yoinked item height. + Previously, in manually defined yoinking, the item height was hard coded per entity + This is not possible with a generic item yoink + Right now the yoinked item is .7 block above entity origin + + Specific Entities + Villagers: + Does the armor theft cause reputational damage to player? + Currently, no. Easy to change though + Illagers: + Can have armor on them through commands (not dispensed), but doesn't render + Probably shouldn't theft armor that can't be applied by players, that's the realm of datapackers + Using hand item theft function + Player: + Technically working for < 1.21.5, but for 1.21.5 it can be collapsed + + Nugget idea? + Try to use drop chances for armor and if it fails drop armor material? + What about datapack armor?... I worry about compatibility + Probably want to implement drop chances one way though + + + \\ ---[ REJECTED FOR A REASON ]--- \\ + Enderman : + Steal held block + ISSUE: Block state stored, not item data. + Could setblock with the block state, then get drop from breaking + Could map block type to item, but that's far too much work and not maintainable + Pufferfish : + Puff up a bit + ISSUE: Setting PuffState has issues. Set once is fine. Once it deflates a bit, setting again flashes and then reverts. + Probably an MC bug, should make an issue for it if it doesn't exist + Sheep : + Shear? + ISSUE: Would need to map from Color Byte to string. Annoying. Maybe revisit + Wandering Trader : Doesn't hold items. Maybe revist + Theft Trades? + Steal llamas? +''' + +def create_lookup_file(ctx: Context): + lookup_keys = [0] + for dx in range(0,34): + for dy in range(0,34): + for dz in range(0,34): + potenital_key = (dx * dx) + (dy * dy) + (dz * dz) + if (math.sqrt(potenital_key) > 33): # ignore values out of fishing bobber range + continue + if potenital_key in lookup_keys: # ignore if already found + continue + lookup_keys.append(potenital_key) + lookup_keys.sort() + strList: List[str] = [] + for key in lookup_keys: + value = math.floor(100*(0.08*math.sqrt(math.sqrt(key)))) + strList.append(f"scoreboard players set ${key} gm4_reeling_rods.lookup {value}") + ctx.data["gm4_reeling_rods:set_lookup_table"] = Function(strList) + +def create_bit_advancements(ctx: Context): + for bit in range(16): + for value in range(2): + # default adv + ctx.data[f"gm4_reeling_rods:fished/bit_{bit}_{value}"] = Advancement({ + "criteria":{ + "fishing_rod_hooked":{ + "trigger":"minecraft:fishing_rod_hooked", + "conditions":{ + "entity":{ + "nbt": "{" + f"Tags:[\"gm4_reeling_rods.id.{bit}.{value}\"]" + "}" + } + } + } + }, + "rewards":{ + "function": f"gm4_reeling_rods:player/bit_{bit}_{value}" + } + }) + ctx.data[f"gm4_reeling_rods:player/bit_{bit}_{value}"] = Function([ + f"# player adv logic for getting bit {bit} at value {value}", + f"# run from advancement fished/bit_{bit}_{value}\n", + f"advancement revoke @s only gm4_reeling_rods:fished/bit_{bit}_{value}\n", + "execute if entity @s[gamemode=adventure] run return fail\n", + "data modify storage gm4_reeling_rods:temp bit_data set value {bit_tag:\"" + f"gm4_reeling_rods.id.{bit}.{value}\", bit:\"{bit}\"" + "}", + "data remove storage gm4_reeling_rods:temp enchanted", + "execute if predicate gm4_reeling_rods:holding_reeling_rod run data modify storage gm4_reeling_rods:temp enchanted set value 1", + "function gm4_reeling_rods:store_player_pos", + "tag @s add gm4_reeling_rods.player", + "function gm4_reeling_rods:player/received_bit with storage gm4_reeling_rods:temp bit_data", + "tag @s remove gm4_reeling_rods.player" + ]) + +def create_select_type(ctx: Context, entities: CSV): + selectFuncBase: List[List[str]] = [["# non-dismount entities"],["# dismountable entities, action after failed dismount"]] + selectFuncSince61: List[List[str]] = [["# non-dismount entities"],["# dismountable entities, action after failed dismount"]] + selectFuncBackport48: List[List[str]] = [["# non-dismount entities"],["# dismountable entities, action after failed dismount"]] + for entity in entities: + since_61 = "pale_oak" in entity['id'] + backport_48 = "minecraft:chest_boat" in entity['id'] + since_57 = "_chest_boat" in entity['id'] or "_chest_raft" in entity['id'] + + order = 1 if entity['can_dismount'] == "TRUE" else 0 # other action before or after dismounting logic + writeTo = [selectFuncSince61] if since_61 else [selectFuncBackport48] if backport_48 else [selectFuncBase, selectFuncSince61] if since_57 else [selectFuncBackport48, selectFuncBase, selectFuncSince61] + # since_61 gets since_61, since_57, else + # base gets since_57, else + # backport_48 gets backport_48, else + for write in writeTo: + command = f"execute if entity @s[type={entity['id']}] run return run " + if entity['needs_enchantment'] == "TRUE": + command = command + "execute if data storage gm4_reeling_rods:temp enchanted run " + command = command + entity['command'] + write[order].append(command) + finalSelectFunction(selectFuncBase, ctx.data.overlays["since_57"]) # should just be ctx.data when moved to 1.21.5, these overlays are gonna be a nightmare to update.,., Figure it out later + finalSelectFunction(selectFuncSince61, ctx.data.overlays["since_61"]) + finalSelectFunction(selectFuncBackport48, ctx.data.overlays["backport_48"]) + +def finalSelectFunction(strings: List[List[str]], output_pack: DataPack): + finalFunction: List[str] = [ + "# GENERATED from generate_files.py", + "# Selects the right entity type or dismounts the entity", + "# @s = fished entity", + "# at @s", + "# run from player/find_fished_entity\n" + ] + # entities that don't dismount + for line in strings[0]: + finalFunction.append(line) + # dismount logic + finalFunction.append("\n# dismounting logic\nexecute if function gm4_reeling_rods:is_passenger run return run ride @s dismount\n") + # entities that do dismount, only runs if not dismounting + for line in strings[1]: + finalFunction.append(line) + output_pack["gm4_reeling_rods:fished/select_type"] = Function(finalFunction)