Skip to content

Commit

Permalink
Make Magicol moon phase and seed dependent
Browse files Browse the repository at this point in the history
  • Loading branch information
Bloo-dev committed Nov 14, 2023
1 parent 332eb4e commit 286c842
Show file tree
Hide file tree
Showing 16 changed files with 111 additions and 38 deletions.
2 changes: 1 addition & 1 deletion gm4_zauber_cauldrons/beet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ meta:

schedule_loops:
- main
- cauldron/extra_items/crack_bottle
- cauldron/extra_items/process_bottled_vex_items
website:
description: Powerful potions, Wormholes, portable Beacons and special armour that makes you stronger! Zauber Cauldrons adds an entire magic branch to the game.
recommended:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,26 @@
execute store result storage gm4_zauber_cauldrons:temp/item/bottled_vex gm4_zauber_cauldrons.vex_count int 1 run scoreboard players get @s gm4_zc_fullness

# read coordinates
execute store result storage gm4_zauber_cauldrons:temp/item/bottled_vex gm4_zauber_cauldrons.cauldron_pos.x int 1 run data get entity @s Pos[0]
execute store result storage gm4_zauber_cauldrons:temp/item/bottled_vex gm4_zauber_cauldrons.cauldron_pos.y int 1 run data get entity @s Pos[1]
execute store result storage gm4_zauber_cauldrons:temp/item/bottled_vex gm4_zauber_cauldrons.cauldron_pos.z int 1 run data get entity @s Pos[2]
execute store result score $cauldron_x gm4_zc_data run data get entity @s Pos[0]
execute store result score $cauldron_y gm4_zc_data run data get entity @s Pos[1]
execute store result score $cauldron_z gm4_zc_data run data get entity @s Pos[2]
execute store result storage gm4_zauber_cauldrons:temp/item/bottled_vex gm4_zauber_cauldrons.cauldron_pos.x int 1 run scoreboard players get $cauldron_x gm4_zc_data
execute store result storage gm4_zauber_cauldrons:temp/item/bottled_vex gm4_zauber_cauldrons.cauldron_pos.y int 1 run scoreboard players get $cauldron_y gm4_zc_data
execute store result storage gm4_zauber_cauldrons:temp/item/bottled_vex gm4_zauber_cauldrons.cauldron_pos.z int 1 run scoreboard players get $cauldron_z gm4_zc_data

# read dimension
execute store result storage gm4_zauber_cauldrons:temp/item/bottled_vex gm4_zauber_cauldrons.cauldron_pos.dimension int 1 run scoreboard players get @e[type=marker,tag=gm4_dimension,distance=0..,limit=1] gm4_dimension

# calculate and store preferred moon phase
scoreboard players operation $cauldron_x gm4_zc_data /= #256 gm4_zc_moon_phase
scoreboard players operation $cauldron_y gm4_zc_data /= #256 gm4_zc_moon_phase
scoreboard players operation $cauldron_z gm4_zc_data /= #256 gm4_zc_moon_phase
scoreboard players operation $cauldron_x gm4_zc_data += $cauldron_y gm4_zc_data
scoreboard players operation $cauldron_x gm4_zc_data += $cauldron_z gm4_zc_data
scoreboard players operation $cauldron_x gm4_zc_data += $magicol_offset gm4_zc_moon_phase
scoreboard players operation $cauldron_x gm4_zc_data %= #8 gm4_zc_moon_phase
execute store result storage gm4_zauber_cauldrons:temp/item/bottled_vex gm4_zauber_cauldrons.preferred_moon_phase int 1 run scoreboard players get $cauldron_x gm4_zc_data

# spawn item
loot spawn ~ ~.2 ~ loot gm4_zauber_cauldrons:items/bottled_vex

Expand All @@ -22,5 +35,10 @@ execute align xyz as @e[type=item,dx=0,dy=0,dz=0] run data modify entity @s Pick
# reset storage
data remove storage gm4_zauber_cauldrons:temp/item/bottled_vex gm4_zauber_cauldrons

# reset fake players
scoreboard players reset $cauldron_x gm4_zc_data
scoreboard players reset $cauldron_y gm4_zc_data
scoreboard players reset $cauldron_z gm4_zc_data

# store success
scoreboard players set $bottled_possessed_items gm4_zc_data 1

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# @s = none
# at world spawn
# scheduled every 48t

# get current moon phase
execute store result score $current gm4_zc_moon_phase run time query day
scoreboard players operation $current gm4_zc_moon_phase %= #8 gm4_zc_moon_phase

# release vexes from bottled vexes
execute as @e[type=item,nbt={Item:{tag:{gm4_zauber_cauldrons:{item:"bottled_vex"}}}}] at @s run function gm4_zauber_cauldrons:cauldron/extra_items/release_from_bottle/crack_bottle

# reschedule
schedule function gm4_zauber_cauldrons:cauldron/extra_items/process_bottled_vex_items 48t

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# @s = bottled vex item
# run from cauldron/extra_items/process_bottled_vex_items
# at @s

# initialize newly thrown bottles
execute unless score @s gm4_zc_bottled_vex_escape_timer matches 0.. run scoreboard players set @s gm4_zc_bottled_vex_escape_timer 3

# decrease timer
execute if score @s gm4_zc_bottled_vex_escape_timer matches 0.. run scoreboard players remove @s gm4_zc_bottled_vex_escape_timer 1
execute if score @s gm4_zc_bottled_vex_escape_timer matches 0.. run particle minecraft:block glass ~ ~ ~ 0.1 0.1 0.1 0 1

# play sound
execute if score @s gm4_zc_bottled_vex_escape_timer matches 0.. run playsound minecraft:block.glass.break block @a[distance=..8] ~ ~ ~ 0.1 1.9

# break free
execute if score @s gm4_zc_bottled_vex_escape_timer matches 1 run function gm4_zauber_cauldrons:cauldron/extra_items/release_from_bottle/prepare_release
execute if score @s gm4_zc_bottled_vex_escape_timer matches ..0 run function gm4_zauber_cauldrons:cauldron/extra_items/release_from_bottle/release
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# @s = bottled vex item
# run from cauldron/extra_items/release_from_bottle/crack_bottle
# at @s

# load data from item
data modify storage gm4_zauber_cauldrons:temp/cauldron/extra_items bottled_vex set from entity @s Item.tag.gm4_zauber_cauldrons
execute store result score @s gm4_zc_moon_phase run data get storage gm4_zauber_cauldrons:temp/cauldron/extra_items bottled_vex.preferred_moon_phase
execute store result score @s gm4_zc_fullness run data get storage gm4_zauber_cauldrons:temp/cauldron/extra_items bottled_vex.vex_count

# unless it is the vex's preferred moon phase, start release one tick early
execute unless score @s gm4_zc_moon_phase = $current gm4_zc_moon_phase run function gm4_zauber_cauldrons:cauldron/extra_items/release_from_bottle/release
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# @s = bottled vex item
# run from cauldron/extra_items/release_from_bottle/prepare_release
# at @s

# release vex and kill bottled vex item
function gm4_zauber_cauldrons:cauldron/extra_items/create_possessed_items
playsound minecraft:block.glass.break block @a[distance=..8] ~ ~ ~ 1 1.3
particle minecraft:block glass ~ ~ ~ 0.12 0.12 0.12 0 16
kill @s
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# confirms the liquid id to be 'magicol' before displaying particles
# @s = zauber cauldron with valid structure
# at @s align xyz
# run via function tag #gm4_zauber_cauldrons:cauldron/liquid/cauldron_particles from cauldron/structure/valid

# check liquid id unless another expansion already displayed a particle
execute unless score $displayed_liquid_particle gm4_zc_data matches 1.. if data storage gm4_zauber_cauldrons:temp/cauldron/ingredients liquid{id:"magicol"} run function gm4_zauber_cauldrons:cauldron/liquid/magicol/particles
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
# particles displayed over a cauldron when it is filled with magicol
# @s = zauber cauldron with valid structure
# at @s align xyz
# run via function tag #gm4_zauber_cauldrons:cauldron/liquid/cauldron_particles from cauldron/structure/valid
# run from gm4_zauber_cauldrons:cauldron/liquid/magicol/check_liquid_id

# if liquid id is magicol, display particles
# display enchant particles for players with full zauber armor during the correct moon phase
execute store result score $preferred gm4_zc_moon_phase run data get storage gm4_zauber_cauldrons:temp/cauldron/ingredients liquid.magicol.moon_phase
execute if score $preferred gm4_zc_moon_phase = $current gm4_zc_moon_phase run particle enchant ~.5 ~.75 ~.5 0.1 0.1 0.1 0.4 6 normal @a[distance=..8,advancements={gm4_zauber_cauldrons:equipment/has_full_armor=true}]
scoreboard players reset $preferred gm4_zc_moon_phase

# if liquid id is magicol, display particles
# generated with the help of bolt
for color_data in ctx.meta['magicol_colors']:
execute unless score $displayed_particle gm4_zc_data matches 1.. store success score $displayed_particle gm4_zc_data if data storage gm4_zauber_cauldrons:temp/cauldron/ingredients liquid{id:"magicol",magicol:{color:color_data['color']}} run summon area_effect_cloud ~.5 ~.75 ~.5 {Particle:"entity_effect",Radius:0.1f,Duration:10,Color:int(color_data['particle_color'])}
execute unless score $displayed_magicol_particle gm4_zc_data matches 1.. store success score $displayed_magicol_particle gm4_zc_data if data storage gm4_zauber_cauldrons:temp/cauldron/ingredients liquid{id:"magicol",magicol:{color:color_data['color']}} run summon area_effect_cloud ~.5 ~.75 ~.5 {Particle:"entity_effect",Radius:0.1f,Duration:10,Color:int(color_data['particle_color'])}

# set flag
scoreboard players set $displayed_liquid_particle gm4_zc_data 1

# reset fake player
scoreboard players reset $displayed_particle gm4_zc_data
scoreboard players reset $displayed_magicol_particle gm4_zc_data
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ execute unless score $recipe_success gm4_zc_data matches 1.. if score $has_water
# magicol
execute unless score $recipe_success gm4_zc_data matches 1.. if score $has_water gm4_zc_data matches 1 if data storage gm4_zauber_cauldrons:temp/cauldron/ingredients items[{Count:1b,tag:{gm4_zauber_cauldrons:{item:"bottled_vex"}}}] if data storage gm4_zauber_cauldrons:temp/cauldron/ingredients items[{Count:1b,tag:{gm4_zauber_cauldrons:{item:"enchanted_prismarine_shard"}}}] run function gm4_zauber_cauldrons:recipes/magicol/select_color

#

# reset fake players and storage
scoreboard players reset $recipe_success gm4_zc_data
scoreboard players reset $has_bottle gm4_zc_fullness
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ data modify storage gm4_zauber_cauldrons:temp/cauldron/ingredients liquid set fr
execute if score $has_water gm4_zc_data matches 1 run particle minecraft:poof ~.5 ~.5 ~.5 .005 .2 .005 .0005 4
execute if score $has_powder_snow gm4_zc_data matches 1 run particle minecraft:dripping_water ~.5 ~0.88 ~.5 0.14 0 0.14 1 1
execute if score @s gm4_zc_liquid_level matches 1..3 run function #gm4_zauber_cauldrons:cauldron/liquid/cauldron_particles
scoreboard players reset $displayed_liquid_particle gm4_zc_data

# check for recipes if at least one item is found inside
execute if score @s gm4_zc_fullness matches 1.. positioned ~.5 ~.5 ~.5 run function gm4_zauber_cauldrons:cauldron/recipe_checks
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
scoreboard objectives add gm4_entity_version dummy
scoreboard objectives add gm4_zc_bottled_vex_escape_timer dummy
scoreboard objectives add gm4_zc_chorus dummy
scoreboard objectives add gm4_zc_crystal dummy
scoreboard objectives add gm4_zc_data dummy
Expand All @@ -7,17 +8,18 @@ scoreboard objectives add gm4_zc_flowers dummy
scoreboard objectives add gm4_zc_fullness dummy
scoreboard objectives add gm4_zc_id dummy
scoreboard objectives add gm4_zc_liquid_level dummy
scoreboard objectives add gm4_zc_rabtarget dummy
scoreboard objectives add gm4_zc_moon_phase dummy
scoreboard objectives add gm4_zc_no_explode dummy
function gm4_zauber_cauldrons:recipes/flowers/initiate_flower_types
function gm4_zauber_cauldrons:recipes/chorus/initiate_chorus_amounts
scoreboard objectives add gm4_zc_rabtarget dummy
execute unless score $seed gm4_zc_flowers matches -2147483648..2147483647 run function gm4_zauber_cauldrons:recipes/flowers/initiate_flower_types
execute unless score seed gm4_zc_chorus matches -2147483648..2147483647 run function gm4_zauber_cauldrons:recipes/chorus/initiate_chorus_amounts
execute unless score $magicol_offset gm4_zc_moon_phase matches -2147483648..2147483647 run function gm4_zauber_cauldrons:recipes/magicol/initiate_moon_phase_offset
scoreboard players set #modulo gm4_zc_fullness 3
scoreboard players set #8 gm4_zc_moon_phase 8
scoreboard players set #256 gm4_zc_moon_phase 256
team add gm4_hide_name
team modify gm4_hide_name nametagVisibility never

# This module includes the gm4_forceload library. If you didn't get this pack from our website, make sure you have the gm4_forceload library installed!
# This module includes the gm4_player_heads library. If you didn't get this pack from our website, make sure you have the gm4_player_heads library installed!

# register skulls
execute unless data storage gm4_player_heads:register heads[{id:"gm4_zauber_cauldrons:crystal/instant_damage/v0"}] run data modify storage gm4_player_heads:register heads append value {id:"gm4_zauber_cauldrons:crystal/instant_damage/v0",name:'[Drop to Fix Item] gm4_zauber_cauldrons:crystal/instant_damage/v0',value:'ewogICJ0aW1lc3RhbXAiIDogMTYyNzU4NzQ1MDY4OCwKICAicHJvZmlsZUlkIiA6ICJmMGIzYmRkMjEwNDg0Y2VlYjZhNTQyYmZiOGEyNTdiMiIsCiAgInByb2ZpbGVOYW1lIiA6ICJBbm9uaW1ZVFQiLAogICJzaWduYXR1cmVSZXF1aXJlZCIgOiB0cnVlLAogICJ0ZXh0dXJlcyIgOiB7CiAgICAiU0tJTiIgOiB7CiAgICAgICJ1cmwiIDogImh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOTUxN2E0NDE1NDI5NzQ2OTZjNjcxYWI3MmQ1ZmQwMTVhNTI5ZTVmZjVhZjRhYTEwNDM4MWY1ZjllYWYyM2EwYSIsCiAgICAgICJtZXRhZGF0YSIgOiB7CiAgICAgICAgIm1vZGVsIiA6ICJzbGltIgogICAgICB9CiAgICB9CiAgfQp9',item:{CustomModelData:3420054,gm4_zauber_cauldrons:{item:"crystal",type:"instant_damage"},HideFlags:1,display:{Name:'{"italic":false,"translate":"item.gm4.zauber_cauldrons.crystal.instant_damage","fallback":"Crystal of Harming"}',Lore:['{"italic":false,"color":"red","translate":"potion.withAmplifier","with":[{"translate":"effect.minecraft.instant_damage"},{"translate":"potion.potency.1"}]}']}}}
execute unless data storage gm4_player_heads:register heads[{id:"gm4_zauber_cauldrons:crystal/instant_health/v0"}] run data modify storage gm4_player_heads:register heads append value {id:"gm4_zauber_cauldrons:crystal/instant_health/v0",name:'[Drop to Fix Item] gm4_zauber_cauldrons:crystal/instant_health/v0',value:'ewogICJ0aW1lc3RhbXAiIDogMTYyNzU4Nzc2NjExMSwKICAicHJvZmlsZUlkIiA6ICI2NGExOGZiZmQ0YWY0Yzg0YjliN2FjZmNlNDRmMTAzZCIsCiAgInByb2ZpbGVOYW1lIiA6ICJieVJPTkFMX1lUIiwKICAic2lnbmF0dXJlUmVxdWlyZWQiIDogdHJ1ZSwKICAidGV4dHVyZXMiIDogewogICAgIlNLSU4iIDogewogICAgICAidXJsIiA6ICJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzIxY2Y1YmM2OTJjZmQwZjI3YzkzNTUyOWJjNjE1ZmRjYjc0ZmZkZWJlYWFlY2JkOTU3OGFhOGUwMzFjNDRjYmYiLAogICAgICAibWV0YWRhdGEiIDogewogICAgICAgICJtb2RlbCIgOiAic2xpbSIKICAgICAgfQogICAgfQogIH0KfQ==',item:{CustomModelData:3420055,gm4_zauber_cauldrons:{item:"crystal",type:"instant_health"},HideFlags:1,display:{Name:'{"italic":false,"translate":"item.gm4.zauber_cauldrons.crystal.instant_health","fallback":"Crystal of Healing"}',Lore:['{"italic":false,"color":"blue","translate":"potion.withAmplifier","with":[{"translate":"effect.minecraft.instant_health"},{"translate":"potion.potency.1"}]}', '{"italic":false,"color":"red","translate":"potion.withAmplifier","with":[{"translate":"effect.minecraft.nausea"},{"translate":"potion.potency.0"}]}']}}}
Expand All @@ -40,7 +42,7 @@ scoreboard players set zauber_cauldrons gm4_modules 1
schedule function gm4_zauber_cauldrons:main 1t

# start vex in a bottle release meachanism
schedule function gm4_zauber_cauldrons:cauldron/extra_items/crack_bottle 2t
schedule function gm4_zauber_cauldrons:cauldron/extra_items/process_bottled_vex_items 2t

# guidebook
execute if score gm4_guidebook load.status matches 1 run summon marker ~ 5366.749169930782 ~ {CustomName:'"gm4_zauber_cauldrons_guide"',Tags:["gm4_guide"],data:{type:"module",id:"zauber_cauldrons",page_count:14,line_count:1,module_name:"Zauber Cauldrons"}}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# no @s.
# at world spawn
# called by init

# generates a random moon_phase_offset based on the world seed on module installation
random reset gm4_zauber_cauldrons:bottled_vex/moon_phase_offset 0 true true
execute store result score $magicol_offset gm4_zc_data run random value 0..7 gm4_zauber_cauldrons:bottled_vex/moon_phase_offset
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"values": [
"gm4_zauber_cauldrons:cauldron/liquid/magicol/particles"
"gm4_zauber_cauldrons:cauldron/liquid/magicol/check_liquid_id"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ execute if block ~ ~ ~ minecraft:water_cauldron[level=2] run scoreboard players
execute if block ~ ~ ~ minecraft:water_cauldron[level=3] run scoreboard players set @s gm4_zc_liquid_level 3
# set liquid type
data modify entity @s data.gm4_zauber_cauldrons.liquid set value {id:"magicol",magicol:{color:"{{color}}"}}
data modify entity @s data.gm4_zauber_cauldrons.liquid.magicol.moon_phase set from storage gm4_zauber_cauldrons:temp/cauldron/ingredients items[{Count:1b,tag:{gm4_zauber_cauldrons:{item:"bottled_vex"}}}].tag.gm4_zauber_cauldrons.preferred_moon_phase

# visuals
summon minecraft:item_display ~ ~.0781 ~ {item:{id:"minecraft:{{color}}_concrete_powder",Count:1b,tag:{CustomModelData:{{custom_model_data}}}},item_display:"fixed",transformation:[1.984f,0f,0f,0f,0f,0f,0f,0f,0f,0f,1.984f,0f,0f,0f,0f,1f],Tags:["gm4_zc_liquid","gm4_zc_magicol","gm4_zc_{{color}}_magicol"]}
Expand Down

0 comments on commit 286c842

Please sign in to comment.