Skip to content

Commit

Permalink
Update merchant spawning code (Written by @ChickenAndTheSculkMan)
Browse files Browse the repository at this point in the history
  • Loading branch information
SwitchedCube committed Dec 21, 2024
1 parent c27acff commit cb6ec76
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 17 deletions.
2 changes: 2 additions & 0 deletions data/aeternum/function/load.mcfunction
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ scoreboard objectives add aeternum.player.level.small dummy
scoreboard objectives add aeternum.merchant.hurt_time dummy
scoreboard objectives add aeternum.merchant.noAI dummy
scoreboard objectives add aeternum.merchant.random dummy
scoreboard objectives add aeternum.merchant.timer dummy
scoreboard players set #global aeternum.merchant.timer 24000

scoreboard objectives add aeternum.gamerule.spawn_chunk_radius dummy
scoreboard objectives add aeternum.world.difficulty dummy
Expand Down
6 changes: 5 additions & 1 deletion data/aeternum/function/main.mcfunction
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,8 @@ execute as @e[type=wandering_trader] run function aeternum:tick/wandering_trader
execute as @e[type=arrow] run function aeternum:tick/arrow_tick_main

execute as @a run function aeternum:tick/player_tick
function aeternum:abilities/tick
function aeternum:abilities/tick

scoreboard players remove #global aeternum.merchant.timer 1
execute if score #global aeternum.merchant.timer matches 0 run function aeternum:merchant/marker/spawn_summon
execute if score #global aeternum.merchant.timer matches 0 run scoreboard players remove #global aeternum.merchant.timer 24000
3 changes: 3 additions & 0 deletions data/aeternum/function/merchant/marker/decide.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
spreadplayers ~ ~ 48 48 false @s
execute at @s unless entity @a[distance=..10] run function aeternum:merchant/summon
kill @s
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
kill @e[type=marker,tag=aeternum.merchant.unispawn]
execute at @r run summon marker ~ ~ ~ {Tags:["aeternum.merchant.unispawn"]}
execute as @e[type=marker,tag=aeternum.merchant.unispawn] at @s run function aeternum:merchant/test
10 changes: 10 additions & 0 deletions data/aeternum/function/merchant/quest/test.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
execute if score .merchant.rarity aeternum.global_config matches 0 as @s[type=minecraft:wandering_trader,tag=!aeternum.entity.spawned,tag=!aeternum.entity.trader_dungeon,tag=!aeternum.entity.villager.quest] at @s if predicate {"condition":"minecraft:random_chance","chance":0.0} run function aeternum:merchant/quest/summon
execute if score .merchant.rarity aeternum.global_config matches 1 as @s[type=minecraft:wandering_trader,tag=!aeternum.entity.spawned,tag=!aeternum.entity.trader_dungeon,tag=!aeternum.entity.villager.quest] at @s if predicate {"condition":"minecraft:random_chance","chance":0.1} run function aeternum:merchant/quest/summon
execute if score .merchant.rarity aeternum.global_config matches 2 as @s[type=minecraft:wandering_trader,tag=!aeternum.entity.spawned,tag=!aeternum.entity.trader_dungeon,tag=!aeternum.entity.villager.quest] at @s if predicate {"condition":"minecraft:random_chance","chance":0.2} run function aeternum:merchant/quest/summon
execute if score .merchant.rarity aeternum.global_config matches 3 as @s[type=minecraft:wandering_trader,tag=!aeternum.entity.spawned,tag=!aeternum.entity.trader_dungeon,tag=!aeternum.entity.villager.quest] at @s if predicate {"condition":"minecraft:random_chance","chance":0.3} run function aeternum:merchant/quest/summon
execute if score .merchant.rarity aeternum.global_config matches 4 as @s[type=minecraft:wandering_trader,tag=!aeternum.entity.spawned,tag=!aeternum.entity.trader_dungeon,tag=!aeternum.entity.villager.quest] at @s if predicate {"condition":"minecraft:random_chance","chance":0.4} run function aeternum:merchant/quest/summon
execute if score .merchant.rarity aeternum.global_config matches 5 as @s[type=minecraft:wandering_trader,tag=!aeternum.entity.spawned,tag=!aeternum.entity.trader_dungeon,tag=!aeternum.entity.villager.quest] at @s if predicate {"condition":"minecraft:random_chance","chance":0.5} run function aeternum:merchant/quest/summon
execute if score .merchant.rarity aeternum.global_config matches 6 as @s[type=minecraft:wandering_trader,tag=!aeternum.entity.spawned,tag=!aeternum.entity.trader_dungeon,tag=!aeternum.entity.villager.quest] at @s if predicate {"condition":"minecraft:random_chance","chance":0.6} run function aeternum:merchant/quest/summon
execute if score .merchant.rarity aeternum.global_config matches 7 as @s[type=minecraft:wandering_trader,tag=!aeternum.entity.spawned,tag=!aeternum.entity.trader_dungeon,tag=!aeternum.entity.villager.quest] at @s if predicate {"condition":"minecraft:random_chance","chance":0.7} run function aeternum:merchant/quest/summon
execute if score .merchant.rarity aeternum.global_config matches 8 as @s[type=minecraft:wandering_trader,tag=!aeternum.entity.spawned,tag=!aeternum.entity.trader_dungeon,tag=!aeternum.entity.villager.quest] at @s if predicate {"condition":"minecraft:random_chance","chance":0.8} run function aeternum:merchant/quest/summon
execute if score .merchant.rarity aeternum.global_config matches 9 as @s[type=minecraft:wandering_trader,tag=!aeternum.entity.spawned,tag=!aeternum.entity.trader_dungeon,tag=!aeternum.entity.villager.quest] at @s if predicate {"condition":"minecraft:random_chance","chance":0.9} run function aeternum:merchant/quest/summon
4 changes: 2 additions & 2 deletions data/aeternum/function/merchant/summon.mcfunction
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

execute at @s if score .merchant.alert.sound aeternum.global_config matches 1 as @a[distance=..30] run playsound minecraft:entity.wandering_trader.reappeared player @s ~ ~ ~
execute at @s if score .merchant.alert.chat aeternum.global_config matches 1 as @a[distance=..30] run tellraw @s {"translate": "aeternum.merchant.spawn"}
execute at @s if score .merchant.alert.sound aeternum.global_config matches 1 as @a[distance=..50] run playsound minecraft:entity.wandering_trader.reappeared player @s ~ ~ ~
execute at @s if score .merchant.alert.chat aeternum.global_config matches 1 as @a[distance=..50] run tellraw @s {"translate": "aeternum.merchant.spawn"}

summon wandering_trader ~ ~ ~ {NoAI:1b,DespawnDelay:48000,DeathLootTable:"minecraft:empty",DeathTime:200s,ArmorDropChances:[-10000.0f,-10000.0f,-10000.0f,-10000.0f],HandDropChances:[-10000.0f,-10000.0f],Silent:1b,CustomNameVisible:1b,CanPickUpLoot:0b,Tags:["aeternum.entity.trader_dungeon"],CustomName:'{"color":"#FF8000","italic":false,"text":"Dungeon Merchant"}'}

Expand Down
22 changes: 10 additions & 12 deletions data/aeternum/function/merchant/test.mcfunction
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
execute if score .merchant.rarity aeternum.global_config matches 0 as @s[type=minecraft:wandering_trader,tag=!aeternum.entity.spawned,tag=!aeternum.entity.trader_dungeon,tag=!aeternum.entity.villager.quest] at @s if predicate {"condition":"minecraft:random_chance","chance":0.0} run function aeternum:merchant/summon
execute if score .merchant.rarity aeternum.global_config matches 1 as @s[type=minecraft:wandering_trader,tag=!aeternum.entity.spawned,tag=!aeternum.entity.trader_dungeon,tag=!aeternum.entity.villager.quest] at @s if predicate {"condition":"minecraft:random_chance","chance":0.1} run function aeternum:merchant/summon
execute if score .merchant.rarity aeternum.global_config matches 2 as @s[type=minecraft:wandering_trader,tag=!aeternum.entity.spawned,tag=!aeternum.entity.trader_dungeon,tag=!aeternum.entity.villager.quest] at @s if predicate {"condition":"minecraft:random_chance","chance":0.2} run function aeternum:merchant/summon
execute if score .merchant.rarity aeternum.global_config matches 3 as @s[type=minecraft:wandering_trader,tag=!aeternum.entity.spawned,tag=!aeternum.entity.trader_dungeon,tag=!aeternum.entity.villager.quest] at @s if predicate {"condition":"minecraft:random_chance","chance":0.3} run function aeternum:merchant/summon
execute if score .merchant.rarity aeternum.global_config matches 4 as @s[type=minecraft:wandering_trader,tag=!aeternum.entity.spawned,tag=!aeternum.entity.trader_dungeon,tag=!aeternum.entity.villager.quest] at @s if predicate {"condition":"minecraft:random_chance","chance":0.4} run function aeternum:merchant/summon
execute if score .merchant.rarity aeternum.global_config matches 5 as @s[type=minecraft:wandering_trader,tag=!aeternum.entity.spawned,tag=!aeternum.entity.trader_dungeon,tag=!aeternum.entity.villager.quest] at @s if predicate {"condition":"minecraft:random_chance","chance":0.5} run function aeternum:merchant/summon
execute if score .merchant.rarity aeternum.global_config matches 6 as @s[type=minecraft:wandering_trader,tag=!aeternum.entity.spawned,tag=!aeternum.entity.trader_dungeon,tag=!aeternum.entity.villager.quest] at @s if predicate {"condition":"minecraft:random_chance","chance":0.6} run function aeternum:merchant/summon
execute if score .merchant.rarity aeternum.global_config matches 7 as @s[type=minecraft:wandering_trader,tag=!aeternum.entity.spawned,tag=!aeternum.entity.trader_dungeon,tag=!aeternum.entity.villager.quest] at @s if predicate {"condition":"minecraft:random_chance","chance":0.7} run function aeternum:merchant/summon
execute if score .merchant.rarity aeternum.global_config matches 8 as @s[type=minecraft:wandering_trader,tag=!aeternum.entity.spawned,tag=!aeternum.entity.trader_dungeon,tag=!aeternum.entity.villager.quest] at @s if predicate {"condition":"minecraft:random_chance","chance":0.8} run function aeternum:merchant/summon
execute if score .merchant.rarity aeternum.global_config matches 9 as @s[type=minecraft:wandering_trader,tag=!aeternum.entity.spawned,tag=!aeternum.entity.trader_dungeon,tag=!aeternum.entity.villager.quest] at @s if predicate {"condition":"minecraft:random_chance","chance":0.9} run function aeternum:merchant/summon

tag @s[type=minecraft:wandering_trader,tag=!aeternum.entity.spawned] add aeternum.entity.spawned
execute if score .merchant.rarity aeternum.global_config matches 0 at @s if predicate {"condition":"minecraft:random_chance","chance":0.0} run function aeternum:merchant/marker/decide
execute if score .merchant.rarity aeternum.global_config matches 1 at @s if predicate {"condition":"minecraft:random_chance","chance":0.1} run function aeternum:merchant/marker/decide
execute if score .merchant.rarity aeternum.global_config matches 2 at @s if predicate {"condition":"minecraft:random_chance","chance":0.2} run function aeternum:merchant/marker/decide
execute if score .merchant.rarity aeternum.global_config matches 3 at @s if predicate {"condition":"minecraft:random_chance","chance":0.3} run function aeternum:merchant/marker/decide
execute if score .merchant.rarity aeternum.global_config matches 4 at @s if predicate {"condition":"minecraft:random_chance","chance":0.4} run function aeternum:merchant/marker/decide
execute if score .merchant.rarity aeternum.global_config matches 5 at @s if predicate {"condition":"minecraft:random_chance","chance":0.5} run function aeternum:merchant/marker/decide
execute if score .merchant.rarity aeternum.global_config matches 6 at @s if predicate {"condition":"minecraft:random_chance","chance":0.6} run function aeternum:merchant/marker/decide
execute if score .merchant.rarity aeternum.global_config matches 7 at @s if predicate {"condition":"minecraft:random_chance","chance":0.7} run function aeternum:merchant/marker/decide
execute if score .merchant.rarity aeternum.global_config matches 8 at @s if predicate {"condition":"minecraft:random_chance","chance":0.8} run function aeternum:merchant/marker/decide
execute if score .merchant.rarity aeternum.global_config matches 9 at @s if predicate {"condition":"minecraft:random_chance","chance":0.9} run function aeternum:merchant/marker/decide
5 changes: 3 additions & 2 deletions data/aeternum/function/tick/wandering_trader.mcfunction
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

execute as @s[type=minecraft:wandering_trader,tag=!aeternum.entity.trader_dungeon,tag=!aeternum.entity.villager.quest,tag=!aeternum.entity.spawned] run function aeternum:merchant/test
execute as @s[type=minecraft:wandering_trader,tag=!aeternum.entity.trader_dungeon,tag=!aeternum.entity.villager.quest,tag=!aeternum.entity.spawned] run function aeternum:merchant/quest/test
execute as @s[type=minecraft:wandering_trader,tag=aeternum.entity.trader_dungeon] run function aeternum:merchant/display
execute as @s[type=minecraft:wandering_trader,tag=aeternum.entity.villager.quest] run function aeternum:merchant/quest/display
execute as @s[type=minecraft:wandering_trader,tag=aeternum.entity.villager.quest] run function aeternum:merchant/quest/display
tag @e[type=minecraft:wandering_trader,tag=!aeternum.entity.spawned] add aeternum.entity.spawned

0 comments on commit cb6ec76

Please sign in to comment.