local posMin = Vec3(-301, 61, -477)
local posMax = Vec3(-265, 300, -435)

function towerFallSuppression(event)
	if event.entity.type.id ~= 'player'  then return true; end
	if event.damageSource.name ~= 'fall' then return true; end
	if event.entity.pos.x <= posMin.x    then return true; end
	if event.entity.pos.y <= posMin.y    then return true; end
	if event.entity.pos.z <= posMin.z    then return true; end
	if event.entity.pos.x >= posMax.x    then return true; end
	if event.entity.pos.y >= posMax.y    then return true; end
	if event.entity.pos.z >= posMax.z    then return true; end
	
	spell.pos = event.entity.pos
	spell:executeSilent("/playsound minecraft:entity.player.splash block @a ~ ~ ~ 1 0.8")
	return false -- cancel the fall damage
end

spell:intercept({"BeforeLivingEntityDamageEvent"}, towerFallSuppression)
