Skip to content

Commit

Permalink
Add cartokill datapack to kill nearby cartographers when trading. Pre…
Browse files Browse the repository at this point in the history
…vents server crash.
  • Loading branch information
totemo committed Jul 6, 2018
1 parent 8477ca4 commit ef5c0aa
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 0 deletions.
1 change: 1 addition & 0 deletions cartokill/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Use difference between actual no. of trades and stored trade count to detect
# player closing the trade window. cartokill.kills is success count of kill.
scoreboard objectives add cartokill.trade minecraft.custom:minecraft.traded_with_villager
scoreboard objectives add cartokill.oldtr dummy
scoreboard objectives add cartokill.kills dummy

# Const objective may already be defined by coords datapack. Aint no thang.
scoreboard objectives add const dummy
scoreboard players set 0 const 0

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Initialise to 0.
scoreboard players add @a cartokill.oldtr 0
execute as @a if score @s cartokill.trade > @s cartokill.oldtr run function io.totemo.cartokill:cartokill-trade
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
execute at @s as @s store success score @s cartokill.kills run kill @e[type=villager,nbt={Profession:1,Career:2},distance=..7]
execute if score @s cartokill.kills > 0 const run tellraw @s [{"color":"red","text":"To prevent a server crash, nearby cartographers have been killed. Sorry."}]

# Remember the new trade count.
execute as @s store result score @s cartokill.oldtr run scoreboard players get @s cartokill.trade

6 changes: 6 additions & 0 deletions cartokill/src/data/minecraft/tags/functions/load.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"values": [
"io.totemo.cartokill:cartokill-load"
]
}

6 changes: 6 additions & 0 deletions cartokill/src/data/minecraft/tags/functions/tick.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"values": [
"io.totemo.cartokill:cartokill-tick"
]
}

6 changes: 6 additions & 0 deletions cartokill/src/pack.mcmeta
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"pack": {
"pack_format": 1,
"description":"Kill nearby cartographers after trading to prevent server crash in pre6."
}
}

0 comments on commit ef5c0aa

Please sign in to comment.