-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: re-enable mob griefing after 60 ticks instead of using proximit…
…y test BREAKING CHANGE: In the previous implementation mob griefing would be disabled until the player who got close to a creeper was at least 26 blocks away from any creeper. The new logic disables mob griefing for a fixed perioud of time instead which resets every time a player gets within 3 blocks of a creeper.
- Loading branch information
Showing
6 changed files
with
24 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"replace": false, | ||
"values": ["no_creeper_griefing:install"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"replace": false, | ||
"values": ["no_creeper_griefing:uninstall"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
scoreboard objectives add creeperCountdown dummy |
19 changes: 10 additions & 9 deletions
19
datapack/data/no_creeper_griefing/functions/tick.mcfunction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
# Tag a player if they get close enough to a creeper to cause it to explode. | ||
execute as @a[gamemode=survival,tag=!nearCreeper] at @s if entity @e[type=minecraft:creeper,distance=..4,limit=1] run tag @s add nearCreeper | ||
# Decrement creeperCountdown every tick while the value is greater than zero. | ||
# This is the countdown that determines when mobGriefing will be re-enabled. | ||
execute if score #creeperCountdown creeperCountdown matches 1.. run scoreboard players remove #creeperCountdown creeperCountdown 1 | ||
|
||
# Untag a tagged player if they are far enough from any creeper to guarantee | ||
# that the creeper they were previously close to either has already exploded, or | ||
# is not going to. | ||
execute as @a[tag=nearCreeper] at @s unless entity @e[type=minecraft:creeper,distance=..25,limit=1] run tag @s remove nearCreeper | ||
# Whenever a player is within 3 blocks of a creeper reset creeperCountdown to 60 which | ||
# is the number of ticks it takes a creeper to explode. | ||
execute as @a[gamemode=survival] at @s if entity @e[type=minecraft:creeper,distance=..3,limit=1] run scoreboard players set #creeperCountdown creeperCountdown 60 | ||
|
||
# Disable mobGriefing as long as there is a player with the "nearCreeper" tag. | ||
execute if entity @a[tag=nearCreeper] run gamerule mobGriefing false | ||
execute unless entity @a[tag=nearCreeper] run gamerule mobGriefing true | ||
# If creeperCountdown is still counting down (the value is greater than zero) | ||
# disable mobGriefing. Otherwise re-enable mobGriefing. | ||
execute if score #creeperCountdown creeperCountdown matches 1.. run gamerule mobGriefing false | ||
execute unless score #creeperCountdown creeperCountdown matches 1.. run gamerule mobGriefing true |
2 changes: 2 additions & 0 deletions
2
datapack/data/no_creeper_griefing/functions/uninstall.mcfunction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
datapack disable "file/no_creeper_griefing.zip" | ||
scoreboard objectives remove creeperCountdown |