Fix feast spawn

The feast now cannot be blocked by trees or other things
This commit is contained in:
TDSTOS
2026-04-14 05:01:23 +02:00
parent b48ccef3ac
commit da23a13357
2 changed files with 44 additions and 15 deletions

View File

@@ -111,6 +111,12 @@ class FeastManager(
PLATFORM_RADIUS, true, 1, Material.GRASS_BLOCK
)
// ── 1b. Alles oberhalb der Plattform bis zur Weltgrenze freischneiden ──
WorldEditUtils.clearColumnAbove(
world, centerLoc,
PLATFORM_RADIUS, platformY + 1
)
// ── 2. Enchanting Table + Kisten platzieren (nach WorldEdit-Commit) ────
Bukkit.getScheduler().runTaskLater( plugin, { ->
// Enchanting Table genau in der Mitte
@@ -127,7 +133,6 @@ class FeastManager(
val chestBlock = world.getBlockAt( cx, platformY + 1, cz )
chestBlock.type = Material.CHEST
// State erst im nächsten Tick lesen — Block-Commit braucht einen Tick
Bukkit.getScheduler().runTaskLater( plugin, { ->
val freshBlock = world.getBlockAt( cx, platformY + 1, cz )
if ( freshBlock.type != Material.CHEST ) return@runTaskLater
@@ -234,10 +239,10 @@ class FeastManager(
)
listOf(
ArmorEntry( Material.DIAMOND_HELMET, 0.65, Enchantment.PROTECTION, 3 ),
ArmorEntry( Material.DIAMOND_CHESTPLATE, 0.75, Enchantment.PROTECTION, 3 ),
ArmorEntry( Material.DIAMOND_LEGGINGS, 0.70, Enchantment.PROTECTION, 3 ),
ArmorEntry( Material.DIAMOND_BOOTS, 0.65, Enchantment.FEATHER_FALLING, 3 ),
ArmorEntry( Material.IRON_HELMET, 0.65, Enchantment.PROTECTION, 1 ),
ArmorEntry( Material.DIAMOND_CHESTPLATE, 0.75, Enchantment.PROTECTION, 1 ),
ArmorEntry( Material.IRON_LEGGINGS, 0.70, Enchantment.PROTECTION, 1 ),
ArmorEntry( Material.DIAMOND_BOOTS, 0.65, Enchantment.FEATHER_FALLING, 1 ),
).forEach { ( material, chance, enchant, maxLevel ) ->
if ( rng.nextDouble() < chance )
{
@@ -252,15 +257,12 @@ class FeastManager(
}
}
// ── Diamantschwert ────────────────────────────────────────────────────
// ── Schwerter ────────────────────────────────────────────────────
if ( rng.nextDouble() < 0.85 )
{
items.add(ItemStack( Material.DIAMOND_SWORD ).also { sword ->
sword.editMeta { meta ->
meta.addEnchant( Enchantment.SHARPNESS, rng.nextInt( 3 ) + 1, true )
}
})
}
items.add(ItemStack( Material.IRON_SWORD ))
if ( rng.nextDouble() < 0.65 )
items.add(ItemStack( Material.DIAMOND_SWORD ))
// ── Suppen (immer vorhanden, 6-10 Stück) ─────────────────────────────
repeat(rng.nextInt( 5 ) + 6) { items.add(ItemStack( Material.MUSHROOM_STEW )) }
@@ -293,8 +295,8 @@ class FeastManager(
// ── Goldener Apfel (50 % Chance) ──────────────────────────────────────
if ( rng.nextDouble() < 0.50 ) items.add(ItemStack( Material.GOLDEN_APPLE ))
// ── Verzauberter Goldener Apfel (10 % — sehr selten) ──────────────────
if ( rng.nextDouble() < 0.10 ) items.add(ItemStack( Material.ENCHANTED_GOLDEN_APPLE ))
// ── Verzauberter Goldener Apfel (5 % — sehr selten) ──────────────────
if ( rng.nextDouble() < 0.05 ) items.add(ItemStack( Material.ENCHANTED_GOLDEN_APPLE ))
return items.shuffled()
}

View File

@@ -59,4 +59,31 @@ object WorldEditUtils {
e.printStackTrace()
}
fun clearColumnAbove(
world: World,
centerLocation: Location,
radius: Int,
fromY: Int
) = try {
val maxY = world.maxHeight
val height = ( maxY - fromY ).coerceAtLeast( 1 )
val startLoc = centerLocation.clone().also { it.y = fromY.toDouble() }
val editSession = WorldEdit.getInstance().newEditSessionBuilder()
.world( BukkitAdapter.adapt( world ) ).maxBlocks( -1 ).build()
editSession.sideEffectApplier = SideEffectSet.defaults()
editSession.makeCylinder(
BukkitAdapter.asBlockVector( startLoc ),
BukkitAdapter.asBlockState( ItemStack( Material.AIR ) ),
radius.toDouble(), height, true
)
editSession.commit()
editSession.close()
} catch ( e: Exception ) {
e.printStackTrace()
}
}