diff --git a/gm4_reeling_rods/beet.yaml b/gm4_reeling_rods/beet.yaml index eb23cedbfe..78be719423 100644 --- a/gm4_reeling_rods/beet.yaml +++ b/gm4_reeling_rods/beet.yaml @@ -8,6 +8,7 @@ data_pack: pipeline: - generate_files - gm4.plugins.extend.module + - gm4.plugins.include.lib_hooked_entity require: - bolt @@ -15,7 +16,8 @@ require: meta: gm4: versioning: - schedule_loops: [tick] + required: + lib_hooked_entity: 1.0.0 website: description: Steal Villager's wares, scratch up your foes! Fishing rods have never been more useful! recommended: diff --git a/gm4_reeling_rods/data/gm4_hooked_entity/tags/function/on_hooked_entity.json b/gm4_reeling_rods/data/gm4_hooked_entity/tags/function/on_hooked_entity.json new file mode 100644 index 0000000000..2447647461 --- /dev/null +++ b/gm4_reeling_rods/data/gm4_hooked_entity/tags/function/on_hooked_entity.json @@ -0,0 +1,5 @@ +{ + "values": [ + "gm4_reeling_rods:hooked_entity/select_type" + ] +} diff --git a/gm4_reeling_rods/data/gm4_hooked_entity/tags/function/pre_hook_on_player.json b/gm4_reeling_rods/data/gm4_hooked_entity/tags/function/pre_hook_on_player.json new file mode 100644 index 0000000000..3926e78f1d --- /dev/null +++ b/gm4_reeling_rods/data/gm4_hooked_entity/tags/function/pre_hook_on_player.json @@ -0,0 +1,5 @@ +{ + "values": [ + "gm4_reeling_rods:get_player_data" + ] +} diff --git a/gm4_reeling_rods/data/gm4_reeling_rods/function/barbed/apply.mcfunction b/gm4_reeling_rods/data/gm4_reeling_rods/function/barbed/apply.mcfunction index db41e7b658..b0931eabd5 100644 --- a/gm4_reeling_rods/data/gm4_reeling_rods/function/barbed/apply.mcfunction +++ b/gm4_reeling_rods/data/gm4_reeling_rods/function/barbed/apply.mcfunction @@ -7,7 +7,7 @@ # immediate damage (amount scales with enchantment level) execute store result score $show_death_messages gm4_reeling_rods.barbed_damage_timer run gamerule show_death_messages gamerule show_death_messages false -$damage @s $(damage) cactus by @p[tag=gm4_reeling_rods.player] +$damage @s $(damage) cactus by @p[tag=gm4_hooked_entity.player] playsound minecraft:entity.player.attack.crit player @a[distance=..16] ~ ~ ~ 1 1.82 # handle death (@e only selects entities which are alive) diff --git a/gm4_reeling_rods/data/gm4_reeling_rods/function/barbed/on_scratch_death.mcfunction b/gm4_reeling_rods/data/gm4_reeling_rods/function/barbed/on_scratch_death.mcfunction index eb1bcf8554..63d6fbd650 100644 --- a/gm4_reeling_rods/data/gm4_reeling_rods/function/barbed/on_scratch_death.mcfunction +++ b/gm4_reeling_rods/data/gm4_reeling_rods/function/barbed/on_scratch_death.mcfunction @@ -4,9 +4,9 @@ # run from barbed/apply # death message -execute if entity @s[type=player] run tellraw @a ["",{"translate":"text.gm4.reeling_rods.death.scratch","fallback":"%s was scratched to death by %s",with:[{"selector":"@s"},{"selector":"@p[tag=gm4_reeling_rods.player]"}]}] +execute if entity @s[type=player] run tellraw @a ["",{"translate":"text.gm4.reeling_rods.death.scratch","fallback":"%s was scratched to death by %s",with:[{"selector":"@s"},{"selector":"@p[tag=gm4_hooked_entity.player]"}]}] execute unless entity @s[type=player] on owner run tag @s add gm4_reeling_rods.owner -execute unless entity @s[type=player] run tellraw @p[tag=gm4_reeling_rods.owner] ["",{"translate":"text.gm4.reeling_rods.death.scratch","fallback":"%s was scratched to death by %s",with:[{"selector":"@s"},{"selector":"@p[tag=gm4_reeling_rods.player]"}]}] +execute unless entity @s[type=player] run tellraw @p[tag=gm4_reeling_rods.owner] ["",{"translate":"text.gm4.reeling_rods.death.scratch","fallback":"%s was scratched to death by %s",with:[{"selector":"@s"},{"selector":"@p[tag=gm4_hooked_entity.player]"}]}] execute unless entity @s[type=player] on owner run tag @s remove gm4_reeling_rods.owner # reset barbed state diff --git a/gm4_reeling_rods/data/gm4_reeling_rods/function/barbed/schedule_bleeding.mcfunction b/gm4_reeling_rods/data/gm4_reeling_rods/function/barbed/schedule_bleeding.mcfunction index f5a1b11deb..bfca5332b7 100644 --- a/gm4_reeling_rods/data/gm4_reeling_rods/function/barbed/schedule_bleeding.mcfunction +++ b/gm4_reeling_rods/data/gm4_reeling_rods/function/barbed/schedule_bleeding.mcfunction @@ -4,7 +4,7 @@ # run from barbed/apply # store attacker uuid and period -data modify storage gm4_reeling_rods:temp enchanted.barbed.attacker_uuid set from entity @a[limit=1,tag=gm4_reeling_rods.player] UUID +data modify storage gm4_reeling_rods:temp enchanted.barbed.attacker_uuid set from entity @a[limit=1,tag=gm4_hooked_entity.player] UUID execute store result score @s gm4_reeling_rods.barbed_attacker_uuid0 run data get storage gm4_reeling_rods:temp enchanted.barbed.attacker_uuid[0] execute store result score @s gm4_reeling_rods.barbed_attacker_uuid1 run data get storage gm4_reeling_rods:temp enchanted.barbed.attacker_uuid[1] execute store result score @s gm4_reeling_rods.barbed_attacker_uuid2 run data get storage gm4_reeling_rods:temp enchanted.barbed.attacker_uuid[2] diff --git a/gm4_reeling_rods/data/gm4_reeling_rods/function/player/find_hooked_entity.mcfunction b/gm4_reeling_rods/data/gm4_reeling_rods/function/get_player_data.mcfunction similarity index 59% rename from gm4_reeling_rods/data/gm4_reeling_rods/function/player/find_hooked_entity.mcfunction rename to gm4_reeling_rods/data/gm4_reeling_rods/function/get_player_data.mcfunction index add3c5e232..3e888cc55b 100644 --- a/gm4_reeling_rods/data/gm4_reeling_rods/function/player/find_hooked_entity.mcfunction +++ b/gm4_reeling_rods/data/gm4_reeling_rods/function/get_player_data.mcfunction @@ -1,10 +1,9 @@ -# Finds the entity the player hooked +# Gets data for later logic # @s = player who fished # 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/received_bit +# run from #gm4_hooked_entity:pre_hook_on_player -# store fishing rod & caster properties +execute store success score $adventure gm4_reeling_rods.math if entity @s[gamemode=adventure] 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.reeling set value 1 execute if predicate gm4_reeling_rods:holding_barbed_rod/level_1 run data modify storage gm4_reeling_rods:temp enchanted.barbed set value {period: 31,damage:3} @@ -16,16 +15,3 @@ 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 - -tag @s add gm4_reeling_rods.player - -# 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, type=!#gm4_reeling_rods:ignore, \ - scores={$(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)}\ - ] unless entity @s[tag=smithed.entity] unless data entity @s {Invulnerable:1b} \ - run function gm4_reeling_rods:hooked_entity/select_type - -tag @s remove gm4_reeling_rods.player diff --git a/gm4_reeling_rods/data/gm4_reeling_rods/function/hooked_entity/end_crystal.mcfunction b/gm4_reeling_rods/data/gm4_reeling_rods/function/hooked_entity/end_crystal.mcfunction index 2d8b8e5acc..84c3966e9c 100644 --- a/gm4_reeling_rods/data/gm4_reeling_rods/function/hooked_entity/end_crystal.mcfunction +++ b/gm4_reeling_rods/data/gm4_reeling_rods/function/hooked_entity/end_crystal.mcfunction @@ -3,4 +3,4 @@ # at bobber in @s # run from hooked_entity/select_type -damage @s 1 minecraft:player_attack by @p[tag=gm4_reeling_rods.player] +damage @s 1 minecraft:player_attack by @p[tag=gm4_hooked_entity.player] diff --git a/gm4_reeling_rods/data/gm4_reeling_rods/function/hooked_entity/leash_knot/change_leader.mcfunction b/gm4_reeling_rods/data/gm4_reeling_rods/function/hooked_entity/leash_knot/change_leader.mcfunction index b05ffcb826..0d4106801d 100644 --- a/gm4_reeling_rods/data/gm4_reeling_rods/function/hooked_entity/leash_knot/change_leader.mcfunction +++ b/gm4_reeling_rods/data/gm4_reeling_rods/function/hooked_entity/leash_knot/change_leader.mcfunction @@ -4,4 +4,4 @@ # run from hooked_entity/leash_knot/action data remove entity @s leash -data modify entity @s leash.UUID set from entity @p[tag=gm4_reeling_rods.player] UUID +data modify entity @s leash.UUID set from entity @p[tag=gm4_hooked_entity.player] UUID diff --git a/gm4_reeling_rods/data/gm4_reeling_rods/function/hooked_entity/select_type.mcfunction b/gm4_reeling_rods/data/gm4_reeling_rods/function/hooked_entity/select_type.mcfunction index 4ce4eb8462..54670b0134 100644 --- a/gm4_reeling_rods/data/gm4_reeling_rods/function/hooked_entity/select_type.mcfunction +++ b/gm4_reeling_rods/data/gm4_reeling_rods/function/hooked_entity/select_type.mcfunction @@ -1,7 +1,13 @@ -# Selects the right entity type or dismounts the entity. +# Dispatch function for logic on hooked entity # @s = hooked entity # at bobber in entity -# run from player/find_hooked_entity +# run from #gm4_hooked_entity:on_hooked_entity + +# fails +execute if score $adventure gm4_reeling_rods.math matches 1 run return fail +execute if entity @s[type=#gm4_reeling_rods:ignore] run return fail +execute if entity @s[tag=smithed.entity] run return fail +execute if data entity @s {Invulnerable:1b} run return fail # apply barbed damage execute if data storage gm4_reeling_rods:temp enchanted.barbed if data entity @s Health unless entity @s[type=player,gamemode=creative] \ diff --git a/gm4_reeling_rods/data/gm4_reeling_rods/function/hooked_entity/shulker.mcfunction b/gm4_reeling_rods/data/gm4_reeling_rods/function/hooked_entity/shulker.mcfunction index fff2b7575b..e9b05cca41 100644 --- a/gm4_reeling_rods/data/gm4_reeling_rods/function/hooked_entity/shulker.mcfunction +++ b/gm4_reeling_rods/data/gm4_reeling_rods/function/hooked_entity/shulker.mcfunction @@ -3,4 +3,4 @@ # at bobber in @s # run from hooked_entity/select_type -execute at @s facing entity @a[tag=gm4_reeling_rods.player,distance=..33,limit=1] eyes if block ^ ^ ^1 #gm4:replaceable run tp @s ^ ^ ^1 +execute at @s facing entity @a[tag=gm4_hooked_entity.player,distance=..33,limit=1] eyes if block ^ ^ ^1 #gm4:replaceable run tp @s ^ ^ ^1 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 deleted file mode 100644 index 2b12ec093b..0000000000 --- a/gm4_reeling_rods/data/gm4_reeling_rods/function/id/clear.mcfunction +++ /dev/null @@ -1,21 +0,0 @@ -# clears id of @s -# @s = entity with tag gm4_reeling_rods.id.tagged -# run from id/loop - -scoreboard players reset @s gm4_reeling_rods.id_bit.0 -scoreboard players reset @s gm4_reeling_rods.id_bit.1 -scoreboard players reset @s gm4_reeling_rods.id_bit.2 -scoreboard players reset @s gm4_reeling_rods.id_bit.3 -scoreboard players reset @s gm4_reeling_rods.id_bit.4 -scoreboard players reset @s gm4_reeling_rods.id_bit.5 -scoreboard players reset @s gm4_reeling_rods.id_bit.6 -scoreboard players reset @s gm4_reeling_rods.id_bit.7 -scoreboard players reset @s gm4_reeling_rods.id_bit.8 -scoreboard players reset @s gm4_reeling_rods.id_bit.9 -scoreboard players reset @s gm4_reeling_rods.id_bit.10 -scoreboard players reset @s gm4_reeling_rods.id_bit.11 -scoreboard players reset @s gm4_reeling_rods.id_bit.12 -scoreboard players reset @s gm4_reeling_rods.id_bit.13 -scoreboard players reset @s gm4_reeling_rods.id_bit.14 -scoreboard players reset @s gm4_reeling_rods.id_bit.15 -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 deleted file mode 100644 index 12c42af8c9..0000000000 --- a/gm4_reeling_rods/data/gm4_reeling_rods/function/id/get_next.mcfunction +++ /dev/null @@ -1,57 +0,0 @@ -# Gets the next id -# @s = entity to be assigned id -# at @s -# run from id/set - -## Binary Counter -# change bit 0 -> 1, return nothing else to do -# change bit 1 -> 0, then go on to next bit - -# bit.0 -execute if score $next gm4_reeling_rods.id_bit.0 matches 0 run return run scoreboard players set $next gm4_reeling_rods.id_bit.0 1 -scoreboard players set $next gm4_reeling_rods.id_bit.0 0 -# bit.1 -execute if score $next gm4_reeling_rods.id_bit.1 matches 0 run return run scoreboard players set $next gm4_reeling_rods.id_bit.1 1 -scoreboard players set $next gm4_reeling_rods.id_bit.1 0 -# bit.2 -execute if score $next gm4_reeling_rods.id_bit.2 matches 0 run return run scoreboard players set $next gm4_reeling_rods.id_bit.2 1 -scoreboard players set $next gm4_reeling_rods.id_bit.2 0 -# bit.3 -execute if score $next gm4_reeling_rods.id_bit.3 matches 0 run return run scoreboard players set $next gm4_reeling_rods.id_bit.3 1 -scoreboard players set $next gm4_reeling_rods.id_bit.3 0 -# bit.4 -execute if score $next gm4_reeling_rods.id_bit.4 matches 0 run return run scoreboard players set $next gm4_reeling_rods.id_bit.4 1 -scoreboard players set $next gm4_reeling_rods.id_bit.4 0 -# bit.5 -execute if score $next gm4_reeling_rods.id_bit.5 matches 0 run return run scoreboard players set $next gm4_reeling_rods.id_bit.5 1 -scoreboard players set $next gm4_reeling_rods.id_bit.5 0 -# bit.6 -execute if score $next gm4_reeling_rods.id_bit.6 matches 0 run return run scoreboard players set $next gm4_reeling_rods.id_bit.6 1 -scoreboard players set $next gm4_reeling_rods.id_bit.6 0 -# bit.7 -execute if score $next gm4_reeling_rods.id_bit.7 matches 0 run return run scoreboard players set $next gm4_reeling_rods.id_bit.7 1 -scoreboard players set $next gm4_reeling_rods.id_bit.7 0 -# bit.8 -execute if score $next gm4_reeling_rods.id_bit.8 matches 0 run return run scoreboard players set $next gm4_reeling_rods.id_bit.8 1 -scoreboard players set $next gm4_reeling_rods.id_bit.8 0 -# bit.9 -execute if score $next gm4_reeling_rods.id_bit.9 matches 0 run return run scoreboard players set $next gm4_reeling_rods.id_bit.9 1 -scoreboard players set $next gm4_reeling_rods.id_bit.9 0 -# bit.10 -execute if score $next gm4_reeling_rods.id_bit.10 matches 0 run return run scoreboard players set $next gm4_reeling_rods.id_bit.10 1 -scoreboard players set $next gm4_reeling_rods.id_bit.10 0 -# bit.11 -execute if score $next gm4_reeling_rods.id_bit.11 matches 0 run return run scoreboard players set $next gm4_reeling_rods.id_bit.11 1 -scoreboard players set $next gm4_reeling_rods.id_bit.11 0 -# bit.12 -execute if score $next gm4_reeling_rods.id_bit.12 matches 0 run return run scoreboard players set $next gm4_reeling_rods.id_bit.12 1 -scoreboard players set $next gm4_reeling_rods.id_bit.12 0 -# bit.13 -execute if score $next gm4_reeling_rods.id_bit.13 matches 0 run return run scoreboard players set $next gm4_reeling_rods.id_bit.13 1 -scoreboard players set $next gm4_reeling_rods.id_bit.13 0 -# bit.14 -execute if score $next gm4_reeling_rods.id_bit.14 matches 0 run return run scoreboard players set $next gm4_reeling_rods.id_bit.14 1 -scoreboard players set $next gm4_reeling_rods.id_bit.14 0 -# bit.15 -execute if score $next gm4_reeling_rods.id_bit.15 matches 0 run return run scoreboard players set $next gm4_reeling_rods.id_bit.15 1 -scoreboard players set $next gm4_reeling_rods.id_bit.15 0 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 deleted file mode 100644 index 0bf1187a05..0000000000 --- a/gm4_reeling_rods/data/gm4_reeling_rods/function/id/set.mcfunction +++ /dev/null @@ -1,26 +0,0 @@ -# set an id on an entity -# @s = entity to be assigned id -# at @s -# run from id/select_entities - -# get new id -function gm4_reeling_rods:id/get_next - -# assign new id -scoreboard players operation @s gm4_reeling_rods.id_bit.0 = $next gm4_reeling_rods.id_bit.0 -scoreboard players operation @s gm4_reeling_rods.id_bit.1 = $next gm4_reeling_rods.id_bit.1 -scoreboard players operation @s gm4_reeling_rods.id_bit.2 = $next gm4_reeling_rods.id_bit.2 -scoreboard players operation @s gm4_reeling_rods.id_bit.3 = $next gm4_reeling_rods.id_bit.3 -scoreboard players operation @s gm4_reeling_rods.id_bit.4 = $next gm4_reeling_rods.id_bit.4 -scoreboard players operation @s gm4_reeling_rods.id_bit.5 = $next gm4_reeling_rods.id_bit.5 -scoreboard players operation @s gm4_reeling_rods.id_bit.6 = $next gm4_reeling_rods.id_bit.6 -scoreboard players operation @s gm4_reeling_rods.id_bit.7 = $next gm4_reeling_rods.id_bit.7 -scoreboard players operation @s gm4_reeling_rods.id_bit.8 = $next gm4_reeling_rods.id_bit.8 -scoreboard players operation @s gm4_reeling_rods.id_bit.9 = $next gm4_reeling_rods.id_bit.9 -scoreboard players operation @s gm4_reeling_rods.id_bit.10 = $next gm4_reeling_rods.id_bit.10 -scoreboard players operation @s gm4_reeling_rods.id_bit.11 = $next gm4_reeling_rods.id_bit.11 -scoreboard players operation @s gm4_reeling_rods.id_bit.12 = $next gm4_reeling_rods.id_bit.12 -scoreboard players operation @s gm4_reeling_rods.id_bit.13 = $next gm4_reeling_rods.id_bit.13 -scoreboard players operation @s gm4_reeling_rods.id_bit.14 = $next gm4_reeling_rods.id_bit.14 -scoreboard players operation @s gm4_reeling_rods.id_bit.15 = $next gm4_reeling_rods.id_bit.15 -tag @s add gm4_reeling_rods.id.tagged diff --git a/gm4_reeling_rods/data/gm4_reeling_rods/function/init.mcfunction b/gm4_reeling_rods/data/gm4_reeling_rods/function/init.mcfunction index fde93b9391..832f265534 100644 --- a/gm4_reeling_rods/data/gm4_reeling_rods/function/init.mcfunction +++ b/gm4_reeling_rods/data/gm4_reeling_rods/function/init.mcfunction @@ -10,26 +10,6 @@ scoreboard objectives add gm4_reeling_rods.barbed_attacker_uuid0 dummy scoreboard objectives add gm4_reeling_rods.barbed_attacker_uuid1 dummy scoreboard objectives add gm4_reeling_rods.barbed_attacker_uuid2 dummy scoreboard objectives add gm4_reeling_rods.barbed_attacker_uuid3 dummy -scoreboard objectives add gm4_reeling_rods.rods_cast minecraft.used:minecraft.fishing_rod -# id -scoreboard objectives add gm4_reeling_rods.id_bit.0 dummy -scoreboard objectives add gm4_reeling_rods.id_bit.1 dummy -scoreboard objectives add gm4_reeling_rods.id_bit.2 dummy -scoreboard objectives add gm4_reeling_rods.id_bit.3 dummy -scoreboard objectives add gm4_reeling_rods.id_bit.4 dummy -scoreboard objectives add gm4_reeling_rods.id_bit.5 dummy -scoreboard objectives add gm4_reeling_rods.id_bit.6 dummy -scoreboard objectives add gm4_reeling_rods.id_bit.7 dummy -scoreboard objectives add gm4_reeling_rods.id_bit.8 dummy -scoreboard objectives add gm4_reeling_rods.id_bit.9 dummy -scoreboard objectives add gm4_reeling_rods.id_bit.10 dummy -scoreboard objectives add gm4_reeling_rods.id_bit.11 dummy -scoreboard objectives add gm4_reeling_rods.id_bit.12 dummy -scoreboard objectives add gm4_reeling_rods.id_bit.13 dummy -scoreboard objectives add gm4_reeling_rods.id_bit.14 dummy -scoreboard objectives add gm4_reeling_rods.id_bit.15 dummy # set_lookup_table is generated in generate_files.py function gm4_reeling_rods:set_lookup_table - -schedule function gm4_reeling_rods:tick 5t diff --git a/gm4_reeling_rods/data/gm4_reeling_rods/function/player/cast_line.mcfunction b/gm4_reeling_rods/data/gm4_reeling_rods/function/player/cast_line.mcfunction deleted file mode 100644 index bee0f7935c..0000000000 --- a/gm4_reeling_rods/data/gm4_reeling_rods/function/player/cast_line.mcfunction +++ /dev/null @@ -1,7 +0,0 @@ -# sets rods_cast to 0 and schedules id loop -# @s = player, scores={gm4_reeling_rods.rods_cast=1..} -# at @s -# run from tick - -scoreboard players set @s gm4_reeling_rods.rods_cast 0 -function gm4_reeling_rods:id/loop 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 deleted file mode 100644 index 8bd8354fe9..0000000000 --- a/gm4_reeling_rods/data/gm4_reeling_rods/function/player/received_bit.mcfunction +++ /dev/null @@ -1,17 +0,0 @@ -# Logic for when a player receives a bit -# @s = player who received a bit -# at @s -# with {bit, UUID} -# run from player/bit_{bit}_{value} - -$data modify storage gm4_reeling_rods:players "$(UUID)".bit_$(bit) set from storage gm4_reeling_rods:temp bit_data.bit_score - -# fail if not all bits -$execute store result score $bit_count gm4_reeling_rods.math run data get storage gm4_reeling_rods:players "$(UUID)" -execute unless score $bit_count gm4_reeling_rods.math matches 16 run return fail - -# all bits received -$function gm4_reeling_rods:player/find_hooked_entity with storage gm4_reeling_rods:players "$(UUID)" - -# clear storage -$data remove storage gm4_reeling_rods:players "$(UUID)" diff --git a/gm4_reeling_rods/data/gm4_reeling_rods/function/reeling/bee.mcfunction b/gm4_reeling_rods/data/gm4_reeling_rods/function/reeling/bee.mcfunction index c7117f8d7e..87f5f7cbc0 100644 --- a/gm4_reeling_rods/data/gm4_reeling_rods/function/reeling/bee.mcfunction +++ b/gm4_reeling_rods/data/gm4_reeling_rods/function/reeling/bee.mcfunction @@ -9,7 +9,7 @@ execute unless data entity @s {HasNectar:1b} run return fail # Steal data modify storage gm4_reeling_rods:temp item_data set value {} data modify entity @s HasNectar set value 0b -data modify entity @s angry_at set from entity @p[tag=gm4_reeling_rods.player] UUID +data modify entity @s angry_at set from entity @p[tag=gm4_hooked_entity.player] UUID execute store result score $anger_end_time gm4_reeling_rods.math run time query gametime scoreboard players add $anger_end_time gm4_reeling_rods.math 300 execute store result entity @s anger_end_time long 1 run scoreboard players get $anger_end_time gm4_reeling_rods.math diff --git a/gm4_reeling_rods/data/gm4_reeling_rods/function/reeling/villager/action.mcfunction b/gm4_reeling_rods/data/gm4_reeling_rods/function/reeling/villager/action.mcfunction index 104fe35583..2d32bcc451 100644 --- a/gm4_reeling_rods/data/gm4_reeling_rods/function/reeling/villager/action.mcfunction +++ b/gm4_reeling_rods/data/gm4_reeling_rods/function/reeling/villager/action.mcfunction @@ -18,7 +18,7 @@ execute unless score $slot gm4_reeling_rods.math matches 1 run return fail function gm4_reeling_rods:reeling/villager/sell_out with storage gm4_reeling_rods:temp entity_data # add 20 "major_negative" gossip of the player to the villager -data modify storage gm4_reeling_rods:temp entity_data.gossip.Target set from entity @p[tag=gm4_reeling_rods.player] UUID +data modify storage gm4_reeling_rods:temp entity_data.gossip.Target set from entity @p[tag=gm4_hooked_entity.player] UUID function gm4_reeling_rods:reeling/villager/add_gossip with storage gm4_reeling_rods:temp entity_data.gossip # feedback diff --git a/gm4_reeling_rods/data/gm4_reeling_rods/function/tick.mcfunction b/gm4_reeling_rods/data/gm4_reeling_rods/function/tick.mcfunction deleted file mode 100644 index dfcd00fbc3..0000000000 --- a/gm4_reeling_rods/data/gm4_reeling_rods/function/tick.mcfunction +++ /dev/null @@ -1,5 +0,0 @@ -# checks if players have cast a line, then will assign ids to entities around bobber -execute as @a[scores={gm4_reeling_rods.rods_cast=1..}] run function gm4_reeling_rods:player/cast_line - -# 5 ticks is good enough response time -schedule function gm4_reeling_rods:tick 5t 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 index dbb3066de7..038fe7aaed 100644 --- 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 @@ -1,39 +1,13 @@ { "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:lingering_potion", - "minecraft:llama_spit", - "minecraft:marker", - "minecraft:ominous_item_spawner", - "minecraft:splash_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" + "minecraft:wind_charge" ] } diff --git a/gm4_reeling_rods/generate_files.py b/gm4_reeling_rods/generate_files.py index f599decd72..ec22569041 100644 --- a/gm4_reeling_rods/generate_files.py +++ b/gm4_reeling_rods/generate_files.py @@ -1,4 +1,4 @@ -from beet import Context, Advancement, Function +from beet import Context, Function import math from pathlib import Path from gm4.utils import CSV, CSVRow @@ -7,11 +7,9 @@ def beet_default(ctx: Context): """ - generates set_lookup_table.mcfunction - - generates advancements and reward functions for every bit state of an entity's scoreboard id - reads csv to ctx.meta for hooked_entity/select_type.mcfunction """ create_lookup_file(ctx) - create_bit_advancements(ctx) entity_list = CSV.from_file(Path('gm4_reeling_rods','entities.csv')) dismountable_entities: list[CSVRow] = [] @@ -35,38 +33,4 @@ def create_lookup_file(ctx: Context): for x, y, z in product(range(0, 34), range(0, 34), range(0, 34)) }.items() if math.sqrt(key) <= 33 ] - ) - -def create_bit_advancements(ctx: Context): - for bit in range(16): - for value in range(2): - ctx.data[f"gm4_reeling_rods:fished/bit_{bit}_{value}"] = Advancement({ - "criteria":{ - "fishing_rod_hooked":{ - "trigger":"minecraft:fishing_rod_hooked", - "conditions":{ - "entity": [ - { - "condition": "minecraft:entity_scores", - "entity": "this", - "scores": { - f"gm4_reeling_rods.id_bit.{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}. Generated by generate_files.py.", - 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_score:\"" + f"gm4_reeling_rods.id_bit.{bit}={value}\", bit:\"{bit}\"" + "}", - "data modify storage gm4_reeling_rods:temp bit_data.UUID set from entity @s UUID", - "function gm4_reeling_rods:player/received_bit with storage gm4_reeling_rods:temp bit_data" - ]) + ) diff --git a/lib_brewing/README.md b/lib_brewing/README.md index 02b0f4aa72..3f37ca98da 100644 --- a/lib_brewing/README.md +++ b/lib_brewing/README.md @@ -107,4 +107,4 @@ execute if entity @s[nbt={data:{gm4_brewing:{previous_items:[{Slot:3b,id:"minecr ## License -This library, and the contents of the `lib_brewing` directory on the [github repository](https://github.com/Gamemode4Dev/GM4_data packs), is licensed under the MIT License. +This library, and the contents of the `lib_brewing` directory on the [github repository](https://github.com/Gamemode4Dev/GM4_Datapacks), is licensed under the MIT License. diff --git a/lib_forceload/README.md b/lib_forceload/README.md index 2cec526c7c..1f1f3a63f4 100644 --- a/lib_forceload/README.md +++ b/lib_forceload/README.md @@ -42,4 +42,4 @@ The overworld dimension has a repeating command block running the function tag ` The overworld dimension has a armour stand with the static uuid `344d47-4-4-4-f04ce104d`. This can be used with loot tables that utilize the `match_tool` predicate which require an entity with a mainhand slot. ## License -This library, and the contents of the `lib_forceload` directory on the [github repository](https://github.com/Gamemode4Dev/GM4_data packs), is licensed under the MIT License. +This library, and the contents of the `lib_forceload` directory on the [github repository](https://github.com/Gamemode4Dev/GM4_Datapacks), is licensed under the MIT License. diff --git a/lib_hooked_entity/LICENSE.md b/lib_hooked_entity/LICENSE.md new file mode 100644 index 0000000000..c11a3935b8 --- /dev/null +++ b/lib_hooked_entity/LICENSE.md @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2026 Gamemode 4 Development + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/lib_hooked_entity/README.md b/lib_hooked_entity/README.md new file mode 100644 index 0000000000..d6bd154fba --- /dev/null +++ b/lib_hooked_entity/README.md @@ -0,0 +1,26 @@ +# lib_hooked_entity +lib_hooked_entity is a mcfunction library that enables running functions on the entity that a player hooked with a fishing rod. Without a library like this, this operation is not possible to do accurately. Furthermore, logic enabled by this library only triggers with the `fishing_rod_hooked` advancement trigger. + +## Usage +Usage of this library is achieved by adding functions to the provided function tags: `#gm4_hooked_entity:on_hooked_entity`, `#gm4_hooked_entity:pre_hook_on_player`, `#gm4_hooked_entity:post_hook_on_player` + +### Function Tags in order of execution: + +#### `#gm4_hooked_entity:pre_hook_on_player` +Run before selection of the hooked entity. Think of this as what will run any time the player triggers the `fishing_rod_hooked` advancement trigger, it is run as the player and at the player. The intention of this is to access the player in any way you need to before logic is run on the hooked entity. + +#### `#gm4_hooked_entity:on_hooked_entity` +Run as the entity hooked by the player, at the fishing bobber. During this, the relevant player is tagged with `gm4_hooked_entity.player` in case you need to select them during this time frame. + +#### `#gm4_hooked_entity:post_hook_on_player` +Very similar to the `#gm4_hooked_entity:pre_hook_on_player`, just run after `#gm4_hooked_entity:on_hooked_entity`. + +## Technical Details +This library operates by assigning a 16 bit binary ID in the form of scores on every entity that can be hooked by a fishing rod bobber, but only within 42 blocks of any fishing bobber. When a player uses the fishing rod and triggers `fishing_rod_hooked` they will receive 16 advancements which are used to reconstruct the binary ID of the entity. From there the scores are used in a macro function to select the entity directly. + +This method is only necessary due to 2 reasons +- `execute on` is unable to select the entity a fishing bobber is hooked into +- The height that the fishing bobber sits in an entity is dependent on that entity's hitbox height which cannot be known in advance of selection. (With the exceptions of paintings and item frames) + +## License +This library, and the contents of the `lib_hooked_entity` directory on the [github repository](https://github.com/Gamemode4Dev/GM4_Datapacks), is licensed under the MIT License. diff --git a/lib_hooked_entity/beet.yaml b/lib_hooked_entity/beet.yaml new file mode 100644 index 0000000000..fb109b2416 --- /dev/null +++ b/lib_hooked_entity/beet.yaml @@ -0,0 +1,22 @@ +id: gm4_hooked_entity +name: Gamemode 4 Hooked Entity Selection +version: 1.0.X +description: Allows other datapacks to run functions on the entity that a player hooked with a fishing rod. + +data_pack: + load: + data: data + +pipeline: + - generate + - gm4.plugins.extend.library + +meta: + gm4: + versioning: + schedule_loops: [tick] + smithed: + pack_id: gm4_lib_hooked_entity + credits: + Creator: + - runcows diff --git a/lib_hooked_entity/data/gm4_hooked_entity/function/id/clear.mcfunction b/lib_hooked_entity/data/gm4_hooked_entity/function/id/clear.mcfunction new file mode 100644 index 0000000000..b5ee07de71 --- /dev/null +++ b/lib_hooked_entity/data/gm4_hooked_entity/function/id/clear.mcfunction @@ -0,0 +1,21 @@ +# clears id of @s +# @s = entity with tag gm4_hooked_entity.id.tagged +# run from id/loop + +scoreboard players reset @s gm4_hooked_entity.id_bit.0 +scoreboard players reset @s gm4_hooked_entity.id_bit.1 +scoreboard players reset @s gm4_hooked_entity.id_bit.2 +scoreboard players reset @s gm4_hooked_entity.id_bit.3 +scoreboard players reset @s gm4_hooked_entity.id_bit.4 +scoreboard players reset @s gm4_hooked_entity.id_bit.5 +scoreboard players reset @s gm4_hooked_entity.id_bit.6 +scoreboard players reset @s gm4_hooked_entity.id_bit.7 +scoreboard players reset @s gm4_hooked_entity.id_bit.8 +scoreboard players reset @s gm4_hooked_entity.id_bit.9 +scoreboard players reset @s gm4_hooked_entity.id_bit.10 +scoreboard players reset @s gm4_hooked_entity.id_bit.11 +scoreboard players reset @s gm4_hooked_entity.id_bit.12 +scoreboard players reset @s gm4_hooked_entity.id_bit.13 +scoreboard players reset @s gm4_hooked_entity.id_bit.14 +scoreboard players reset @s gm4_hooked_entity.id_bit.15 +tag @s remove gm4_hooked_entity.id.tagged diff --git a/lib_hooked_entity/data/gm4_hooked_entity/function/id/get_next.mcfunction b/lib_hooked_entity/data/gm4_hooked_entity/function/id/get_next.mcfunction new file mode 100644 index 0000000000..6ae67de8aa --- /dev/null +++ b/lib_hooked_entity/data/gm4_hooked_entity/function/id/get_next.mcfunction @@ -0,0 +1,57 @@ +# Gets the next id +# @s = entity to be assigned id +# at @s +# run from id/set + +## Binary Counter +# change bit 0 -> 1, return nothing else to do +# change bit 1 -> 0, then go on to next bit + +# bit.0 +execute if score $next gm4_hooked_entity.id_bit.0 matches 0 run return run scoreboard players set $next gm4_hooked_entity.id_bit.0 1 +scoreboard players set $next gm4_hooked_entity.id_bit.0 0 +# bit.1 +execute if score $next gm4_hooked_entity.id_bit.1 matches 0 run return run scoreboard players set $next gm4_hooked_entity.id_bit.1 1 +scoreboard players set $next gm4_hooked_entity.id_bit.1 0 +# bit.2 +execute if score $next gm4_hooked_entity.id_bit.2 matches 0 run return run scoreboard players set $next gm4_hooked_entity.id_bit.2 1 +scoreboard players set $next gm4_hooked_entity.id_bit.2 0 +# bit.3 +execute if score $next gm4_hooked_entity.id_bit.3 matches 0 run return run scoreboard players set $next gm4_hooked_entity.id_bit.3 1 +scoreboard players set $next gm4_hooked_entity.id_bit.3 0 +# bit.4 +execute if score $next gm4_hooked_entity.id_bit.4 matches 0 run return run scoreboard players set $next gm4_hooked_entity.id_bit.4 1 +scoreboard players set $next gm4_hooked_entity.id_bit.4 0 +# bit.5 +execute if score $next gm4_hooked_entity.id_bit.5 matches 0 run return run scoreboard players set $next gm4_hooked_entity.id_bit.5 1 +scoreboard players set $next gm4_hooked_entity.id_bit.5 0 +# bit.6 +execute if score $next gm4_hooked_entity.id_bit.6 matches 0 run return run scoreboard players set $next gm4_hooked_entity.id_bit.6 1 +scoreboard players set $next gm4_hooked_entity.id_bit.6 0 +# bit.7 +execute if score $next gm4_hooked_entity.id_bit.7 matches 0 run return run scoreboard players set $next gm4_hooked_entity.id_bit.7 1 +scoreboard players set $next gm4_hooked_entity.id_bit.7 0 +# bit.8 +execute if score $next gm4_hooked_entity.id_bit.8 matches 0 run return run scoreboard players set $next gm4_hooked_entity.id_bit.8 1 +scoreboard players set $next gm4_hooked_entity.id_bit.8 0 +# bit.9 +execute if score $next gm4_hooked_entity.id_bit.9 matches 0 run return run scoreboard players set $next gm4_hooked_entity.id_bit.9 1 +scoreboard players set $next gm4_hooked_entity.id_bit.9 0 +# bit.10 +execute if score $next gm4_hooked_entity.id_bit.10 matches 0 run return run scoreboard players set $next gm4_hooked_entity.id_bit.10 1 +scoreboard players set $next gm4_hooked_entity.id_bit.10 0 +# bit.11 +execute if score $next gm4_hooked_entity.id_bit.11 matches 0 run return run scoreboard players set $next gm4_hooked_entity.id_bit.11 1 +scoreboard players set $next gm4_hooked_entity.id_bit.11 0 +# bit.12 +execute if score $next gm4_hooked_entity.id_bit.12 matches 0 run return run scoreboard players set $next gm4_hooked_entity.id_bit.12 1 +scoreboard players set $next gm4_hooked_entity.id_bit.12 0 +# bit.13 +execute if score $next gm4_hooked_entity.id_bit.13 matches 0 run return run scoreboard players set $next gm4_hooked_entity.id_bit.13 1 +scoreboard players set $next gm4_hooked_entity.id_bit.13 0 +# bit.14 +execute if score $next gm4_hooked_entity.id_bit.14 matches 0 run return run scoreboard players set $next gm4_hooked_entity.id_bit.14 1 +scoreboard players set $next gm4_hooked_entity.id_bit.14 0 +# bit.15 +execute if score $next gm4_hooked_entity.id_bit.15 matches 0 run return run scoreboard players set $next gm4_hooked_entity.id_bit.15 1 +scoreboard players set $next gm4_hooked_entity.id_bit.15 0 diff --git a/gm4_reeling_rods/data/gm4_reeling_rods/function/id/loop.mcfunction b/lib_hooked_entity/data/gm4_hooked_entity/function/id/loop.mcfunction similarity index 65% rename from gm4_reeling_rods/data/gm4_reeling_rods/function/id/loop.mcfunction rename to lib_hooked_entity/data/gm4_hooked_entity/function/id/loop.mcfunction index 2fc18e92c5..6647f19fa5 100644 --- a/gm4_reeling_rods/data/gm4_reeling_rods/function/id/loop.mcfunction +++ b/lib_hooked_entity/data/gm4_hooked_entity/function/id/loop.mcfunction @@ -2,7 +2,7 @@ # run from player/cast_line and scheduled from id/select_entities # assign new ids if there's a bobber -execute as @e[type=minecraft:fishing_bobber] at @s run return run function gm4_reeling_rods:id/select_entities +execute as @e[type=minecraft:fishing_bobber] at @s run return run function gm4_hooked_entity:id/select_entities # no fishing bobber, clear ids -execute as @e[tag=gm4_reeling_rods.id.tagged] run function gm4_reeling_rods:id/clear +execute as @e[tag=gm4_hooked_entity.id.tagged] run function gm4_hooked_entity:id/clear diff --git a/gm4_reeling_rods/data/gm4_reeling_rods/function/id/select_entities.mcfunction b/lib_hooked_entity/data/gm4_hooked_entity/function/id/select_entities.mcfunction similarity index 66% rename from gm4_reeling_rods/data/gm4_reeling_rods/function/id/select_entities.mcfunction rename to lib_hooked_entity/data/gm4_hooked_entity/function/id/select_entities.mcfunction index 7f0071927d..e5d3e3574e 100644 --- a/gm4_reeling_rods/data/gm4_reeling_rods/function/id/select_entities.mcfunction +++ b/lib_hooked_entity/data/gm4_hooked_entity/function/id/select_entities.mcfunction @@ -5,7 +5,7 @@ # 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=!#gm4_reeling_rods:ignore,tag=!gm4_reeling_rods.id.tagged,distance=..42] at @s run function gm4_reeling_rods:id/set +execute as @e[type=!#gm4_hooked_entity:ignore,tag=!gm4_hooked_entity.id.tagged,distance=..42] at @s run function gm4_hooked_entity:id/set # schedule again, since bobber still exists -schedule function gm4_reeling_rods:id/loop 2t +schedule function gm4_hooked_entity:id/loop 2t diff --git a/lib_hooked_entity/data/gm4_hooked_entity/function/id/set.mcfunction b/lib_hooked_entity/data/gm4_hooked_entity/function/id/set.mcfunction new file mode 100644 index 0000000000..c2147e4b34 --- /dev/null +++ b/lib_hooked_entity/data/gm4_hooked_entity/function/id/set.mcfunction @@ -0,0 +1,26 @@ +# set an id on an entity +# @s = entity to be assigned id +# at @s +# run from id/select_entities + +# get new id +function gm4_hooked_entity:id/get_next + +# assign new id +scoreboard players operation @s gm4_hooked_entity.id_bit.0 = $next gm4_hooked_entity.id_bit.0 +scoreboard players operation @s gm4_hooked_entity.id_bit.1 = $next gm4_hooked_entity.id_bit.1 +scoreboard players operation @s gm4_hooked_entity.id_bit.2 = $next gm4_hooked_entity.id_bit.2 +scoreboard players operation @s gm4_hooked_entity.id_bit.3 = $next gm4_hooked_entity.id_bit.3 +scoreboard players operation @s gm4_hooked_entity.id_bit.4 = $next gm4_hooked_entity.id_bit.4 +scoreboard players operation @s gm4_hooked_entity.id_bit.5 = $next gm4_hooked_entity.id_bit.5 +scoreboard players operation @s gm4_hooked_entity.id_bit.6 = $next gm4_hooked_entity.id_bit.6 +scoreboard players operation @s gm4_hooked_entity.id_bit.7 = $next gm4_hooked_entity.id_bit.7 +scoreboard players operation @s gm4_hooked_entity.id_bit.8 = $next gm4_hooked_entity.id_bit.8 +scoreboard players operation @s gm4_hooked_entity.id_bit.9 = $next gm4_hooked_entity.id_bit.9 +scoreboard players operation @s gm4_hooked_entity.id_bit.10 = $next gm4_hooked_entity.id_bit.10 +scoreboard players operation @s gm4_hooked_entity.id_bit.11 = $next gm4_hooked_entity.id_bit.11 +scoreboard players operation @s gm4_hooked_entity.id_bit.12 = $next gm4_hooked_entity.id_bit.12 +scoreboard players operation @s gm4_hooked_entity.id_bit.13 = $next gm4_hooked_entity.id_bit.13 +scoreboard players operation @s gm4_hooked_entity.id_bit.14 = $next gm4_hooked_entity.id_bit.14 +scoreboard players operation @s gm4_hooked_entity.id_bit.15 = $next gm4_hooked_entity.id_bit.15 +tag @s add gm4_hooked_entity.id.tagged diff --git a/lib_hooked_entity/data/gm4_hooked_entity/function/load.mcfunction b/lib_hooked_entity/data/gm4_hooked_entity/function/load.mcfunction new file mode 100644 index 0000000000..b9bf91c219 --- /dev/null +++ b/lib_hooked_entity/data/gm4_hooked_entity/function/load.mcfunction @@ -0,0 +1,22 @@ +scoreboard objectives add gm4_hooked_entity.math dummy +scoreboard objectives add gm4_hooked_entity.rods_cast minecraft.used:minecraft.fishing_rod + +# id +scoreboard objectives add gm4_hooked_entity.id_bit.0 dummy +scoreboard objectives add gm4_hooked_entity.id_bit.1 dummy +scoreboard objectives add gm4_hooked_entity.id_bit.2 dummy +scoreboard objectives add gm4_hooked_entity.id_bit.3 dummy +scoreboard objectives add gm4_hooked_entity.id_bit.4 dummy +scoreboard objectives add gm4_hooked_entity.id_bit.5 dummy +scoreboard objectives add gm4_hooked_entity.id_bit.6 dummy +scoreboard objectives add gm4_hooked_entity.id_bit.7 dummy +scoreboard objectives add gm4_hooked_entity.id_bit.8 dummy +scoreboard objectives add gm4_hooked_entity.id_bit.9 dummy +scoreboard objectives add gm4_hooked_entity.id_bit.10 dummy +scoreboard objectives add gm4_hooked_entity.id_bit.11 dummy +scoreboard objectives add gm4_hooked_entity.id_bit.12 dummy +scoreboard objectives add gm4_hooked_entity.id_bit.13 dummy +scoreboard objectives add gm4_hooked_entity.id_bit.14 dummy +scoreboard objectives add gm4_hooked_entity.id_bit.15 dummy + +schedule function gm4_hooked_entity:tick 5t diff --git a/lib_hooked_entity/data/gm4_hooked_entity/function/player/cast_line.mcfunction b/lib_hooked_entity/data/gm4_hooked_entity/function/player/cast_line.mcfunction new file mode 100644 index 0000000000..8fdff4f419 --- /dev/null +++ b/lib_hooked_entity/data/gm4_hooked_entity/function/player/cast_line.mcfunction @@ -0,0 +1,7 @@ +# sets rods_cast to 0 and schedules id loop +# @s = player, scores={gm4_hooked_entity.rods_cast=1..} +# at @s +# run from tick + +scoreboard players set @s gm4_hooked_entity.rods_cast 0 +function gm4_hooked_entity:id/loop diff --git a/lib_hooked_entity/data/gm4_hooked_entity/function/player/find_hooked_entity.mcfunction b/lib_hooked_entity/data/gm4_hooked_entity/function/player/find_hooked_entity.mcfunction new file mode 100644 index 0000000000..eea453b179 --- /dev/null +++ b/lib_hooked_entity/data/gm4_hooked_entity/function/player/find_hooked_entity.mcfunction @@ -0,0 +1,19 @@ +# Finds the entity the player hooked +# @s = player who fished +# 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/received_bit + +function #gm4_hooked_entity:pre_hook_on_player +tag @s add gm4_hooked_entity.player + +# 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_hooked_entity:player/owns_bobber \ + at @s as @e[\ + distance=..42, limit=1, type=!#gm4_hooked_entity:ignore, \ + scores={$(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 function #gm4_hooked_entity:on_hooked_entity + +tag @s remove gm4_hooked_entity.player +function #gm4_hooked_entity:post_hook_on_player diff --git a/gm4_reeling_rods/data/gm4_reeling_rods/function/player/owns_bobber.mcfunction b/lib_hooked_entity/data/gm4_hooked_entity/function/player/owns_bobber.mcfunction similarity index 64% rename from gm4_reeling_rods/data/gm4_reeling_rods/function/player/owns_bobber.mcfunction rename to lib_hooked_entity/data/gm4_hooked_entity/function/player/owns_bobber.mcfunction index da45021cf7..1a056a0673 100644 --- a/gm4_reeling_rods/data/gm4_reeling_rods/function/player/owns_bobber.mcfunction +++ b/lib_hooked_entity/data/gm4_hooked_entity/function/player/owns_bobber.mcfunction @@ -3,4 +3,4 @@ # at owner # run from player/find_hooked_entity -return run execute on origin if entity @s[tag=gm4_reeling_rods.player] +return run execute on origin if entity @s[tag=gm4_hooked_entity.player] diff --git a/lib_hooked_entity/data/gm4_hooked_entity/function/player/received_bit.mcfunction b/lib_hooked_entity/data/gm4_hooked_entity/function/player/received_bit.mcfunction new file mode 100644 index 0000000000..44de845a7c --- /dev/null +++ b/lib_hooked_entity/data/gm4_hooked_entity/function/player/received_bit.mcfunction @@ -0,0 +1,17 @@ +# Logic for when a player receives a bit +# @s = player who received a bit +# at @s +# with {bit, UUID} +# run from player/bits/bit_{bit}_{value} + +$data modify storage gm4_hooked_entity:players "$(UUID)".bit_$(bit) set from storage gm4_hooked_entity:temp bit_data.bit_score + +# fail if not all bits +$execute store result score $bit_count gm4_hooked_entity.math run data get storage gm4_hooked_entity:players "$(UUID)" +execute unless score $bit_count gm4_hooked_entity.math matches 16 run return fail + +# all bits received +$function gm4_hooked_entity:player/find_hooked_entity with storage gm4_hooked_entity:players "$(UUID)" + +# clear storage +$data remove storage gm4_hooked_entity:players "$(UUID)" diff --git a/lib_hooked_entity/data/gm4_hooked_entity/function/tick.mcfunction b/lib_hooked_entity/data/gm4_hooked_entity/function/tick.mcfunction new file mode 100644 index 0000000000..4bb2c68ae3 --- /dev/null +++ b/lib_hooked_entity/data/gm4_hooked_entity/function/tick.mcfunction @@ -0,0 +1,5 @@ +# checks if players have cast a line, then will assign ids to entities around bobber +execute as @a[scores={gm4_hooked_entity.rods_cast=1..}] run function gm4_hooked_entity:player/cast_line + +# schedule again +schedule function gm4_hooked_entity:tick 3t diff --git a/lib_hooked_entity/data/gm4_hooked_entity/tags/entity_type/ignore.json b/lib_hooked_entity/data/gm4_hooked_entity/tags/entity_type/ignore.json new file mode 100644 index 0000000000..97792c2b13 --- /dev/null +++ b/lib_hooked_entity/data/gm4_hooked_entity/tags/entity_type/ignore.json @@ -0,0 +1,30 @@ +{ + "values": [ + "minecraft:area_effect_cloud", + "minecraft:arrow", + "minecraft:block_display", + "minecraft:dragon_fireball", + "minecraft:egg", + "minecraft:ender_pearl", + "minecraft:evoker_fangs", + "minecraft:experience_bottle", + "minecraft:experience_orb", + "minecraft:eye_of_ender", + "minecraft:firework_rocket", + "minecraft:fishing_bobber", + "minecraft:interaction", + "minecraft:item_display", + "minecraft:lightning_bolt", + "minecraft:lingering_potion", + "minecraft:llama_spit", + "minecraft:marker", + "minecraft:ominous_item_spawner", + "minecraft:splash_potion", + "minecraft:small_fireball", + "minecraft:snowball", + "minecraft:spectral_arrow", + "minecraft:text_display", + "minecraft:trident", + "minecraft:wither_skull" + ] +} diff --git a/lib_hooked_entity/data/gm4_hooked_entity/tags/function/on_hooked_entity.json b/lib_hooked_entity/data/gm4_hooked_entity/tags/function/on_hooked_entity.json new file mode 100644 index 0000000000..86dde3df2a --- /dev/null +++ b/lib_hooked_entity/data/gm4_hooked_entity/tags/function/on_hooked_entity.json @@ -0,0 +1,3 @@ +{ + "values": [] +} diff --git a/lib_hooked_entity/data/gm4_hooked_entity/tags/function/post_hook_on_player.json b/lib_hooked_entity/data/gm4_hooked_entity/tags/function/post_hook_on_player.json new file mode 100644 index 0000000000..86dde3df2a --- /dev/null +++ b/lib_hooked_entity/data/gm4_hooked_entity/tags/function/post_hook_on_player.json @@ -0,0 +1,3 @@ +{ + "values": [] +} diff --git a/lib_hooked_entity/data/gm4_hooked_entity/tags/function/pre_hook_on_player.json b/lib_hooked_entity/data/gm4_hooked_entity/tags/function/pre_hook_on_player.json new file mode 100644 index 0000000000..86dde3df2a --- /dev/null +++ b/lib_hooked_entity/data/gm4_hooked_entity/tags/function/pre_hook_on_player.json @@ -0,0 +1,3 @@ +{ + "values": [] +} diff --git a/lib_hooked_entity/generate.py b/lib_hooked_entity/generate.py new file mode 100644 index 0000000000..7767e4581a --- /dev/null +++ b/lib_hooked_entity/generate.py @@ -0,0 +1,34 @@ +from beet import Context, Advancement, Function + +def beet_default(ctx: Context): + for bit in range(16): + for value in range(2): + ctx.data[f"gm4_hooked_entity:bit_{bit}_{value}"] = Advancement({ + "criteria":{ + "fishing_rod_hooked":{ + "trigger":"minecraft:fishing_rod_hooked", + "conditions":{ + "entity": [ + { + "condition": "minecraft:entity_scores", + "entity": "this", + "scores": { + f"gm4_hooked_entity.id_bit.{bit}": value + } + } + ] + } + } + }, + "rewards":{ + "function": f"gm4_hooked_entity:player/bits/bit_{bit}_{value}" + } + }) + ctx.data[f"gm4_hooked_entity:player/bits/bit_{bit}_{value}"] = Function([ + f"# player adv logic for getting bit {bit} at value {value}. Generated by generate.py.", + f"# run from advancement bit_{bit}_{value}\n", + f"advancement revoke @s only gm4_hooked_entity:bit_{bit}_{value}\n", + "data modify storage gm4_hooked_entity:temp bit_data set value {bit_score:\"" + f"gm4_hooked_entity.id_bit.{bit}={value}\", bit:\"{bit}\"" + "}", + "data modify storage gm4_hooked_entity:temp bit_data.UUID set from entity @s UUID", + "function gm4_hooked_entity:player/received_bit with storage gm4_hooked_entity:temp bit_data" + ]) diff --git a/lib_lore/README.md b/lib_lore/README.md index af6c249744..a293ca4a19 100644 --- a/lib_lore/README.md +++ b/lib_lore/README.md @@ -119,4 +119,4 @@ Please note that the `example_pack` must be started by calling `#load:load`, as - These operations are technically not limited to lore, but can also be used for any type of list. ## License -This library, and the contents of the `lib_lore` directory on the [github repository](https://github.com/Gamemode4Dev/GM4_data packs), is licensed under the MIT License. +This library, and the contents of the `lib_lore` directory on the [github repository](https://github.com/Gamemode4Dev/GM4_Datapacks), is licensed under the MIT License. diff --git a/lib_machines/README.md b/lib_machines/README.md index 80a17ffdc0..dc2cb858a1 100644 --- a/lib_machines/README.md +++ b/lib_machines/README.md @@ -85,4 +85,4 @@ execute if entity @s[tag=IDENTIFIER] run function MODULE_NAMESPACE:machine/destr ``` ## License -This library, and the contents of the `lib_machines` directory on the [github repository](https://github.com/Gamemode4Dev/GM4_data packs), is licensed under the MIT License. +This library, and the contents of the `lib_machines` directory on the [github repository](https://github.com/Gamemode4Dev/GM4_Datapacks), is licensed under the MIT License. diff --git a/lib_potion_tracking/README.md b/lib_potion_tracking/README.md index cfedcd516b..8759afa729 100644 --- a/lib_potion_tracking/README.md +++ b/lib_potion_tracking/README.md @@ -42,4 +42,4 @@ execute if data storage gm4_potion_tracking:temp entity_data.Item.components."mi ``` ## License -This library, and the contents of the `lib_potion_tracking` directory on the [github repository](https://github.com/Gamemode4Dev/GM4_data packs), is licensed under the MIT License. +This library, and the contents of the `lib_potion_tracking` directory on the [github repository](https://github.com/Gamemode4Dev/GM4_Datapacks), is licensed under the MIT License. diff --git a/lib_trees/README.md b/lib_trees/README.md index 73a2abc470..30757d8f97 100644 --- a/lib_trees/README.md +++ b/lib_trees/README.md @@ -80,4 +80,4 @@ kill @s ``` ## License -This library, and the contents of the `lib_trees` directory on the [github repository](https://github.com/Gamemode4Dev/GM4_data packs), is licensed under the MIT License. +This library, and the contents of the `lib_trees` directory on the [github repository](https://github.com/Gamemode4Dev/GM4_Datapacks), is licensed under the MIT License.