Skip to content

Commit

Permalink
prevent placing lobby bases too close to the worldborder and too clos…
Browse files Browse the repository at this point in the history
…e to eachother
  • Loading branch information
L_glandieres authored and L_glandieres committed Mar 30, 2024
1 parent d528794 commit 8078e16
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@

# Cancel lobby villager placement if too close to worldborder or too close to others bases


# Worldborder proximity :
execute store result score @s pos.x run data get entity @s Pos[0]
execute store result score @s pos.z run data get entity @s Pos[2]

scoreboard players operation WBGap data = WBbyTwo data
scoreboard players operation WBGap data -= 2 const

scoreboard players operation -WBGap data = -WBbyTwo data
scoreboard players operation -WBGap data += 2 const

execute if score @s pos.x > WBGap data run tag @s add worldborder_obstruction
execute if score @s pos.x < -WBGap data run tag @s add worldborder_obstruction
execute if score @s pos.z > WBGap data run tag @s add worldborder_obstruction
execute if score @s pos.z < -WBGap data run tag @s add worldborder_obstruction

execute if entity @s[tag=worldborder_obstruction] run tellraw @a[tag=player_place_base] ["",{"text":"[BS] ","color":"gold"},{"translate":"blazing_scaffolding.base.near_worldborder","color":"red"}]
execute if entity @s[tag=worldborder_obstruction] run kill @s

# other bases proximity
execute if entity @e[type=villager,tag=respawn_villager, distance=..20] run tag @s add base_obstruction

execute if entity @s[tag=base_obstruction] run tellraw @a[tag=player_place_base] ["",{"text":"[BS] ","color":"gold"},{"translate":"blazing_scaffolding.base.near_other_bases","color":"red"}]
execute if entity @s[tag=base_obstruction] run kill @s

#confirmation message
execute if entity @s[tag=!worldborder_obstruction,tag=!base_obstruction] run tellraw @a[tag=player_place_base] ["",{"text":"[BS] ","color":"gold"},{"translate":"blazing_scaffolding.base.placement_set"}]
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
$execute as @e[type=marker,tag=villager.spawner.$(color)] at @s run function scaffolding_rush:villager/summon/$(color)

$tag @e[type=marker,tag=villager.spawner.$(color)] add processed

execute if score #lobby.active data matches 1 run tag @s add player_place_base
execute if score #lobby.active data matches 1 as @e[type=marker,tag=processed] at @s run function scaffolding_rush:villager/check_placement
tag @s remove player_place_base

$execute as @e[type=marker,tag=processed] at @s run function scaffolding_rush:villager/summon/$(color)

$execute if score #lobby.active data matches 1 \
as @e[tag=$(color)_villager,tag=respawn_villager] \
Expand Down

0 comments on commit 8078e16

Please sign in to comment.