add better death drops datapack as a possible alternative to graves

This commit is contained in:
=
2025-12-09 23:59:41 +00:00
parent 34680d2efa
commit bc95f03bec
17 changed files with 133 additions and 7 deletions

View File

@@ -3,7 +3,8 @@ DIST := $(shell realpath $(DISTRELATIVE))
export DIST export DIST
build: src build: src
clean: src clean:
rm -f dist/*
src: src:
$(MAKE) -C $@ $(MAKECMDGOALS) $(MAKE) -C $@ $(MAKECMDGOALS)
@@ -11,8 +12,9 @@ src:
dev-init: # ubuntu only dev-init: # ubuntu only
apt install -y python3 openjdk-21-jre-headless apt install -y python3 openjdk-21-jre-headless
test: build test: clean build
mkdir -p test/world/datapacks/ mkdir -p test/world/datapacks/
rm -f test/world/datapacks/*
cp dist/* test/world/datapacks/ cp dist/* test/world/datapacks/
cd test && java -Xmx1024M -Xms1024M -jar server.jar nogui cd test && java -Xmx1024M -Xms1024M -jar server.jar nogui

View File

@@ -6,11 +6,11 @@ $(SUBDIRS):
@echo "packaging $@" @echo "packaging $@"
@cd $@; zip -rq "$(DIST)/$@.zip" * @cd $@; zip -rq "$(DIST)/$@.zip" *
clean: #clean:
@for d in $(SUBDIRS) ; do \ # @for d in $(SUBDIRS) ; do \
echo "removing $$d.zip" ; \ # echo "removing $$d.zip" ; \
rm -f "$(DIST)/$$d.zip" ; \ # rm -f "$(DIST)/$$d.zip" ; \
done # done
test: build test: build

View File

@@ -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"
}

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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"}

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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"}}]

View File

@@ -0,0 +1,5 @@
{
"values": [
"better_death_drops:internal/load"
]
}

View File

@@ -0,0 +1,5 @@
{
"values": [
"better_death_drops:internal/tick"
]
}

View File

@@ -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"}]
}
}