Skip to content
This repository has been archived by the owner on Sep 6, 2023. It is now read-only.

Commit

Permalink
Fix #13 - Structures aren't actually seeded
Browse files Browse the repository at this point in the history
  • Loading branch information
andantet committed Jul 14, 2020
1 parent 98f8f34 commit 89a4bd7
Show file tree
Hide file tree
Showing 17 changed files with 48 additions and 44 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
execute unless entity @s unless entity @e[type=area_effect_cloud,tag=ttb_temp,tag=init,limit=1] run summon area_effect_cloud ~ ~ ~ {Tags:["ttb_temp","init"],CustomName:'"ttb_temp"'}
execute if entity @s unless entity @e[type=area_effect_cloud,tag=ttb_temp,tag=init,limit=1] at @s run summon area_effect_cloud ~ ~ ~ {Tags:["ttb_temp","init"],CustomName:'"ttb_temp"'}
execute as @e[type=area_effect_cloud,tag=ttb_temp,tag=init,limit=1] run function ttb:util/generate_loot_table_seed_post
summon area_effect_cloud ~ ~ ~ {Tags:["ttb_temp"],CustomName:'"ttb_temp"'}
execute as @e[type=area_effect_cloud,tag=ttb_temp,distance=...1,limit=1] run function ttb:util/generate_loot_table_seed_post
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#called by util/generate_loot_table_seed
# called by util/generate_loot_table_seed

execute store result score #seed_pos_x ttb_data run data get entity @s Pos[0]
execute store result score #seed_pos_y ttb_data run data get entity @s Pos[1]
Expand All @@ -9,12 +9,11 @@ scoreboard players operation #seed_pos_x ttb_data *= #2 ttb_gamerules
scoreboard players operation #seed_pos_y ttb_data /= #2 ttb_gamerules

scoreboard players operation #seed_pos_x ttb_data -= seed ttb_data
scoreboard players operation #seed_pos_x ttb_data *= #seed_pos_y ttb_data
execute unless score #seed_pos_y ttb_data matches 0 run scoreboard players operation #seed_pos_x ttb_data *= #seed_pos_y ttb_data
scoreboard players operation #seed_pos_x ttb_data /= #seed_pos_z ttb_data

execute unless data block ~ ~ ~ LootTable run data modify block ~ ~ ~ LootTable set value "minecraft:empty"
execute store result block ~ ~ ~ LootTableSeed long 1 run scoreboard players get #seed_pos_x ttb_data
execute store result block ~ ~ ~ seed long 1 run scoreboard players get #seed_pos_x ttb_data

tag @s remove init
tag @s add ttb_remove
tellraw @a [{"nbt":"Pos","entity":"@s"},"\n",{"nbt":"x","block":"~ ~ ~"},"\n",{"score":{"objective":"ttb_data","name":"#seed_pos_x"}},"\n",{"nbt":"LootTableSeed","block":"~ ~ ~"}]
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ execute positioned ~8 0 ~8 run function ttb:world/generation/chunk/scan
execute if score border ttb_biome matches 1 run function ttb:world/generation/chunk/border

# try to spawn a structure before any chunk modifications have been done
execute if block ~ 4 ~ bedrock positioned 29999984 253 29999984 run function ttb:world/structure/chunk
execute if block ~ 4 ~ bedrock run function ttb:world/structure/chunk
# biome-based caves
function ttb:world/generation/better_biomes/check_biome

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ execute if data storage ttb:temp world.structure{orientation:'north'} run data m
execute if data storage ttb:temp world.structure{orientation:'south'} run data modify block ~ ~ ~ rotation set value "CLOCKWISE_90"
execute if data storage ttb:temp world.structure{orientation:'west'} run data modify block ~ ~ ~ rotation set value "CLOCKWISE_180"

tellraw @a[tag=ttb_debug] [[{"text":"","color":"gray","italic":true}],[{"translate":"text.ttb.debug","with":[[[{"block":"~ ~ ~","nbt":"name"}," / ",{"block":"~ ~ ~","nbt":"x"},", ",{"block":"~ ~ ~","nbt":"y"},", ",{"block":"~ ~ ~","nbt":"z"}],"\n ",[{"block":"~ ~ ~","nbt":"integrity"}," / ",{"block":"~ ~ ~","nbt":"seed"}]]]}]]

setblock ~ ~1 ~ redstone_block
fill ~ ~ ~ ~ ~1 ~ air replace #ttb:structure_artifact

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# called by world/structure/check_spawn/...

summon area_effect_cloud ~ ~ ~ {Tags:["ttb_temp"],CustomName:'"ttb_temp"'}
execute as @e[type=area_effect_cloud,tag=ttb_temp,distance=...1,limit=1] in overworld positioned 29999984 253 29999984 run function ttb:world/structure/check_spawn/append_post
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# called by world/structure/check_spawn/append

# pre
forceload add ~ ~

# run checks
setblock ~ ~ ~ yellow_shulker_box

data modify block ~ ~ ~ LootTable set from storage ttb:temp structure_spawn_table
function ttb:util/generate_loot_table_seed_post

loot replace block ~ ~ ~ container.0 mine ~ ~ ~ air{drop_contents:1b}

data modify block ~ ~ ~ Items[0].tag.ttb.world.structure.integrity set from block ~ ~ ~ Items[0].tag.AttributeModifiers[{Name:"ttb:integrity"}].Amount
data modify block ~ ~ ~ Items[0].tag.ttb.world.structure.height set from block ~ ~ ~ Items[0].tag.AttributeModifiers[{Name:"ttb:height"}].Amount
data modify storage ttb:temp world.structure.spawns append from block ~ ~ ~ Items[0].tag.ttb.world.structure

# post
setblock ~ ~ ~ air
forceload remove ~ ~
kill @s
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# called by world/structure/chunk

function ttb:world/structure/check_spawn/pre
data modify block ~ ~ ~ LootTable set value 'ttb:world/structure/check_spawn/cold'
function ttb:world/structure/check_spawn/post
data modify storage ttb:temp structure_spawn_table set value 'ttb:world/structure/check_spawn/cold'
function ttb:world/structure/check_spawn/append
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# called by world/structure/chunk

function ttb:world/structure/check_spawn/pre
data modify block ~ ~ ~ LootTable set value 'ttb:world/structure/check_spawn/ore'
function ttb:world/structure/check_spawn/post
data modify storage ttb:temp structure_spawn_table set value 'ttb:world/structure/check_spawn/ore'
function ttb:world/structure/check_spawn/append

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# called by world/structure/chunk

function ttb:world/structure/check_spawn/pre
data modify block ~ ~ ~ LootTable set value 'ttb:world/structure/check_spawn/snowy'
function ttb:world/structure/check_spawn/post
data modify storage ttb:temp structure_spawn_table set value 'ttb:world/structure/check_spawn/snowy'
function ttb:world/structure/check_spawn/append
7 changes: 1 addition & 6 deletions ttb_data/data/ttb/functions/world/structure/chunk.mcfunction
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# called by world/generation/chunk/generate

#pre
execute in overworld run forceload add ~ ~
data modify storage ttb:temp world.structure.spawns set value []

#run checks
Expand All @@ -19,8 +18,4 @@ execute if score cold ttb_biome matches 1 run function ttb:world/structure/check
# execute if score border ttb_biome matches 1 run function ttb:world/structure/check_spawn/border
function ttb:world/structure/check_spawn/ore

execute if data storage ttb:temp world.structure.spawns[0] at @s run function ttb:world/structure/spawn

#post
setblock ~ ~ ~ air
execute in overworld run forceload remove ~ ~
execute if data storage ttb:temp world.structure.spawns[0] run function ttb:world/structure/spawn
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
summon area_effect_cloud ~ ~ ~ {Tags:["ttb_temp"],CustomName:'"ttb_temp"'}
execute as @e[type=area_effect_cloud,tag=ttb_temp,distance=...1,limit=1] positioned 29999984 253 29999984 run function ttb:world/structure/dungeon/get_room_post
execute as @e[type=area_effect_cloud,tag=ttb_temp,distance=...1,limit=1] in overworld positioned 29999984 253 29999984 run function ttb:world/structure/dungeon/get_room_post
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#called by world/structure/dungeon/get_room

#pre
execute in overworld run forceload add ~ ~
forceload add ~ ~

#run checks
setblock ~ ~ ~ yellow_shulker_box
Expand All @@ -14,5 +14,5 @@ data modify storage ttb:temp world.structure.dungeon.room_result set from block

#post
setblock ~ ~ ~ air
execute in overworld run forceload remove ~ ~
forceload remove ~ ~
kill @s[type=area_effect_cloud]
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,5 @@ execute if data storage ttb:temp world.structure.spawns[0].height run data modif
execute if data storage ttb:temp world.structure.spawns[0].name at @s run function ttb:world/structure/spawn_default
execute if data storage ttb:temp world.structure.spawns[0].id at @s run function ttb:world/structure/spawn_id

tellraw @a[tag=ttb_debug] [{"nbt":"Pos","entity":"@s"}," ",{"nbt":"structure.spawns[0].name","storage":"ttb:world"},{"nbt":"structure.spawns[0].id","storage":"ttb:world"}]

data remove storage ttb:temp world.structure.spawns[0]
execute if data storage ttb:temp world.structure.spawns[0] run function ttb:world/structure/loop_spawns
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@ data modify block ~ ~ ~ name set from storage ttb:temp world.structure.spawns[0]
data modify block ~ ~ ~ integrity set from storage ttb:temp world.structure.spawns[0].integrity
data modify block ~ ~ ~ posY set from storage ttb:temp world.structure.spawns[0].shift_y

data modify block ~ ~ ~ seed set value 1L

function ttb:world/structure/activate_structure_block
execute if data storage ttb:temp world.structure.spawns[0].modifiers[{id:'replace_stone'}] run fill ~ ~ ~ ~ ~1 ~ stone keep
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# called by world/structure/loop_spawns

data modify storage ttb:temp check_string set value []
data modify storage ttb:temp check_string append from storage ttb:temp world.structure.spawns[0]
data modify storage ttb:temp check.compound set from storage ttb:temp world.structure.spawns[0]

execute if data storage ttb:temp check_string[{id:'large_wooden_snow_dungeon'}] positioned ~ ~-16 ~ run function ttb:world/structure/large_wooden_snow_dungeon/create
execute if data storage ttb:temp check.compound{id:'large_wooden_snow_dungeon'} positioned ~ ~-16 ~ run function ttb:world/structure/large_wooden_snow_dungeon/create

data remove storage ttb:temp check_string
data remove storage ttb:temp check.compound

0 comments on commit 89a4bd7

Please sign in to comment.