diff --git a/Makefile b/Makefile index 58e2a82..45310ea 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,8 @@ DIST := $(shell realpath $(DISTRELATIVE)) export DIST build: src -clean: src +clean: + rm -f dist/* src: $(MAKE) -C $@ $(MAKECMDGOALS) @@ -11,8 +12,9 @@ src: dev-init: # ubuntu only apt install -y python3 openjdk-21-jre-headless -test: build +test: clean build mkdir -p test/world/datapacks/ + rm -f test/world/datapacks/* cp dist/* test/world/datapacks/ cd test && java -Xmx1024M -Xms1024M -jar server.jar nogui diff --git a/src/Makefile b/src/Makefile index 3c54f0b..c34e4f3 100644 --- a/src/Makefile +++ b/src/Makefile @@ -6,11 +6,11 @@ $(SUBDIRS): @echo "packaging $@" @cd $@; zip -rq "$(DIST)/$@.zip" * -clean: - @for d in $(SUBDIRS) ; do \ - echo "removing $$d.zip" ; \ - rm -f "$(DIST)/$$d.zip" ; \ - done +#clean: +# @for d in $(SUBDIRS) ; do \ +# echo "removing $$d.zip" ; \ +# rm -f "$(DIST)/$$d.zip" ; \ +# done test: build diff --git a/src/better_death_drops/data/better_death_drops/advancement/better_death_drops.json b/src/better_death_drops/data/better_death_drops/advancement/better_death_drops.json new file mode 100644 index 0000000..7ad4d06 --- /dev/null +++ b/src/better_death_drops/data/better_death_drops/advancement/better_death_drops.json @@ -0,0 +1,22 @@ +{ + "display": { + "icon": { + "id": "minecraft:skeleton_skull" + }, + "title": "Better Death Drops", + "description": "Increases item despawn time and highlights items through walls.", + "show_toast": false, + "announce_to_chat": false + }, + "criteria": { + "tick": { + "trigger": "minecraft:tick" + } + }, + "requirements": [ + [ + "tick" + ] + ], + "parent": "minecraft:root" +} \ No newline at end of file diff --git a/src/better_death_drops/data/better_death_drops/function/internal/chat/decr_time.mcfunction b/src/better_death_drops/data/better_death_drops/function/internal/chat/decr_time.mcfunction new file mode 100644 index 0000000..de7f3a0 --- /dev/null +++ b/src/better_death_drops/data/better_death_drops/function/internal/chat/decr_time.mcfunction @@ -0,0 +1,8 @@ +scoreboard players remove despawn_time bdd_vars 1 + +execute if score despawn_time bdd_vars matches ..4 run scoreboard players set despawn_time bdd_vars 5 + +# Updates the despawn time in ticks. +function better_death_drops:internal/convert_despawn_time_to_raw + +function better_death_drops:options \ No newline at end of file diff --git a/src/better_death_drops/data/better_death_drops/function/internal/chat/incr_time.mcfunction b/src/better_death_drops/data/better_death_drops/function/internal/chat/incr_time.mcfunction new file mode 100644 index 0000000..42868e2 --- /dev/null +++ b/src/better_death_drops/data/better_death_drops/function/internal/chat/incr_time.mcfunction @@ -0,0 +1,12 @@ +scoreboard players add despawn_time bdd_vars 1 + +#1200 ticks is one minute. +#-32767 is the max number to tick down from + + +execute if score despawn_time bdd_vars matches 30.. run scoreboard players set despawn_time bdd_vars 30 + +# Updates the despawn time in ticks. +function better_death_drops:internal/convert_despawn_time_to_raw + +function better_death_drops:options \ No newline at end of file diff --git a/src/better_death_drops/data/better_death_drops/function/internal/chat/toggle_despawn.mcfunction b/src/better_death_drops/data/better_death_drops/function/internal/chat/toggle_despawn.mcfunction new file mode 100644 index 0000000..1b8d8c8 --- /dev/null +++ b/src/better_death_drops/data/better_death_drops/function/internal/chat/toggle_despawn.mcfunction @@ -0,0 +1,6 @@ +scoreboard players add item_despawning bdd_vars 1 + +# if the glow is two or more, reset to 0. +execute if score item_despawning bdd_vars matches 2.. run scoreboard players set item_despawning bdd_vars 0 + +function better_death_drops:options \ No newline at end of file diff --git a/src/better_death_drops/data/better_death_drops/function/internal/chat/toggle_glow.mcfunction b/src/better_death_drops/data/better_death_drops/function/internal/chat/toggle_glow.mcfunction new file mode 100644 index 0000000..f3d894b --- /dev/null +++ b/src/better_death_drops/data/better_death_drops/function/internal/chat/toggle_glow.mcfunction @@ -0,0 +1,6 @@ +scoreboard players add glow bdd_vars 1 + +# if the glow is two or more, reset to 0. +execute if score glow bdd_vars matches 2.. run scoreboard players set glow bdd_vars 0 + +function better_death_drops:options \ No newline at end of file diff --git a/src/better_death_drops/data/better_death_drops/function/internal/convert_despawn_time_to_raw.mcfunction b/src/better_death_drops/data/better_death_drops/function/internal/convert_despawn_time_to_raw.mcfunction new file mode 100644 index 0000000..cff2285 --- /dev/null +++ b/src/better_death_drops/data/better_death_drops/function/internal/convert_despawn_time_to_raw.mcfunction @@ -0,0 +1,3 @@ +scoreboard players operation despawn_time_raw bdd_vars = despawn_time bdd_vars +scoreboard players remove despawn_time_raw bdd_vars 5 +scoreboard players operation despawn_time_raw bdd_vars *= CONST_ticks_in_minute bdd_vars \ No newline at end of file diff --git a/src/better_death_drops/data/better_death_drops/function/internal/init.mcfunction b/src/better_death_drops/data/better_death_drops/function/internal/init.mcfunction new file mode 100644 index 0000000..63d690c --- /dev/null +++ b/src/better_death_drops/data/better_death_drops/function/internal/init.mcfunction @@ -0,0 +1,16 @@ + +scoreboard players add CONST_ticks_in_minute bdd_vars 1200 + +scoreboard players add despawn_time bdd_vars 30 +scoreboard players add item_despawning bdd_vars 1 +scoreboard players add glow bdd_vars 1 + +# The value below zero for the Age nbt. 6000 = -6000 ticks. +scoreboard players add despawn_time_raw bdd_vars 6000 + +# Stop this from getting called again. +scoreboard players add init bdd_vars 1 + +#tellraw @a [{"text": "Better Death Drops", "color": "dark_green", "bold":true}, {"text": " initialised.", "color": "gray", "bold":false}] +#tellraw @a [{"text": "Settings configurable with ", "color": "gray"},{"text": "/function better_death_drops:options", "color": "yellow", "clickEvent": {"action": "suggest_command", "value": "/function better_death_drops:options"}}] +#tellraw @a {"text": "(Click command to get started.)", "color": "gray"} \ No newline at end of file diff --git a/src/better_death_drops/data/better_death_drops/function/internal/load.mcfunction b/src/better_death_drops/data/better_death_drops/function/internal/load.mcfunction new file mode 100644 index 0000000..29fd4d0 --- /dev/null +++ b/src/better_death_drops/data/better_death_drops/function/internal/load.mcfunction @@ -0,0 +1,6 @@ +# Creates the scoreboard. +scoreboard objectives add bdd_deaths deathCount "BetterDeathDrop Deaths" +scoreboard objectives add bdd_vars dummy "BetterDeathDrop Variables" + +# Create initial variables +execute unless score init bdd_vars matches 1 run function better_death_drops:internal/init \ No newline at end of file diff --git a/src/better_death_drops/data/better_death_drops/function/internal/modify_items.mcfunction b/src/better_death_drops/data/better_death_drops/function/internal/modify_items.mcfunction new file mode 100644 index 0000000..4c62682 --- /dev/null +++ b/src/better_death_drops/data/better_death_drops/function/internal/modify_items.mcfunction @@ -0,0 +1,5 @@ +execute if score glow bdd_vars matches 1 run data merge entity @s {Glowing:1b} + +# If item despawning is disabled, set age to limit (which disables despawning behaviours.) +execute if score item_despawning bdd_vars matches 0 run data merge entity @s {Age:-32768} +execute if score item_despawning bdd_vars matches 1 store result entity @s Age int -1.0 run scoreboard players get despawn_time_raw bdd_vars diff --git a/src/better_death_drops/data/better_death_drops/function/internal/on_death.mcfunction b/src/better_death_drops/data/better_death_drops/function/internal/on_death.mcfunction new file mode 100644 index 0000000..5f42e22 --- /dev/null +++ b/src/better_death_drops/data/better_death_drops/function/internal/on_death.mcfunction @@ -0,0 +1,3 @@ +execute as @e[type=item, distance=..5] at @s run function better_death_drops:internal/modify_items + +scoreboard players set @s bdd_deaths 0 \ No newline at end of file diff --git a/src/better_death_drops/data/better_death_drops/function/internal/tick.mcfunction b/src/better_death_drops/data/better_death_drops/function/internal/tick.mcfunction new file mode 100644 index 0000000..46747c9 --- /dev/null +++ b/src/better_death_drops/data/better_death_drops/function/internal/tick.mcfunction @@ -0,0 +1,4 @@ +scoreboard players add @a bdd_deaths 0 + +# Selects everyone who has died and runs the ondeath function. +execute as @a[scores={bdd_deaths=1}] at @s run function better_death_drops:internal/on_death \ No newline at end of file diff --git a/src/better_death_drops/data/better_death_drops/function/options.mcfunction b/src/better_death_drops/data/better_death_drops/function/options.mcfunction new file mode 100644 index 0000000..172979c --- /dev/null +++ b/src/better_death_drops/data/better_death_drops/function/options.mcfunction @@ -0,0 +1,14 @@ +tellraw @s [{"text":" ", "color": "gray"}] +tellraw @s [{"text":"----------------------------", "color": "gray"}] +tellraw @s [{"text": "Better Death Drops", "color": "dark_green", "bold":true}] + +# Glow option +execute if score glow bdd_vars matches 0 run tellraw @s [{"text": "Items Glow: "}, {"text": "[Disabled]", "color":"red", "bold": true, "underlined": true, "click_event": {"action": "run_command", "command": "/function better_death_drops:internal/chat/toggle_glow"}}] +execute if score glow bdd_vars matches 1 run tellraw @s [{"text": "Items Glow: "}, {"text": "[Enabled]", "color":"green", "bold": true, "underlined": true, "click_event": {"action": "run_command", "command": "/function better_death_drops:internal/chat/toggle_glow"}}] + +# Despawning option +execute if score item_despawning bdd_vars matches 0 run tellraw @s [{"text": "Despawn Items: "}, {"text": "[Disabled]", "color":"red", "bold": true, "underlined": true, "click_event": {"action": "run_command", "command": "/function better_death_drops:internal/chat/toggle_despawn"}}] +execute if score item_despawning bdd_vars matches 1 run tellraw @s [{"text": "Despawn Items: "}, {"text": "[Enabled]", "color":"green", "bold": true, "underlined": true, "click_event": {"action": "run_command", "command": "/function better_death_drops:internal/chat/toggle_despawn"}}] + +# Despawn duration option +execute if score item_despawning bdd_vars matches 1 run tellraw @s [{"text": "Despawn Duration: "},{"text": "[-] ", "color": "dark_aqua", "click_event": {"action": "run_command", "command": "/function better_death_drops:internal/chat/decr_time"}}, {"score": {"name":"despawn_time","objective": "bdd_vars"}}, {"text":" mins. "}, {"text": "[+] ", "color": "dark_aqua", "click_event": {"action": "run_command", "command": "/function better_death_drops:internal/chat/incr_time"}}] \ No newline at end of file diff --git a/src/better_death_drops/data/minecraft/tags/function/load.json b/src/better_death_drops/data/minecraft/tags/function/load.json new file mode 100644 index 0000000..e70fddb --- /dev/null +++ b/src/better_death_drops/data/minecraft/tags/function/load.json @@ -0,0 +1,5 @@ +{ + "values": [ + "better_death_drops:internal/load" + ] +} \ No newline at end of file diff --git a/src/better_death_drops/data/minecraft/tags/function/tick.json b/src/better_death_drops/data/minecraft/tags/function/tick.json new file mode 100644 index 0000000..d6deca5 --- /dev/null +++ b/src/better_death_drops/data/minecraft/tags/function/tick.json @@ -0,0 +1,5 @@ +{ + "values": [ + "better_death_drops:internal/tick" + ] +} \ No newline at end of file diff --git a/src/better_death_drops/pack.mcmeta b/src/better_death_drops/pack.mcmeta new file mode 100644 index 0000000..e124a38 --- /dev/null +++ b/src/better_death_drops/pack.mcmeta @@ -0,0 +1,9 @@ +{ + "pack": { + "pack_format": 61, + "supported_formats": {"min_inclusive": 61, "max_inclusive": 88}, + "min_format": 61, + "max_format": 88, + "description": [{"text":"Better Death Drops","color":"gold"}] + } +} \ No newline at end of file