Fix feast spawn
The feast now cannot be blocked by trees or other things
This commit is contained in:
@@ -111,6 +111,12 @@ class FeastManager(
|
|||||||
PLATFORM_RADIUS, true, 1, Material.GRASS_BLOCK
|
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) ────
|
// ── 2. Enchanting Table + Kisten platzieren (nach WorldEdit-Commit) ────
|
||||||
Bukkit.getScheduler().runTaskLater( plugin, { ->
|
Bukkit.getScheduler().runTaskLater( plugin, { ->
|
||||||
// Enchanting Table genau in der Mitte
|
// Enchanting Table genau in der Mitte
|
||||||
@@ -127,7 +133,6 @@ class FeastManager(
|
|||||||
val chestBlock = world.getBlockAt( cx, platformY + 1, cz )
|
val chestBlock = world.getBlockAt( cx, platformY + 1, cz )
|
||||||
chestBlock.type = Material.CHEST
|
chestBlock.type = Material.CHEST
|
||||||
|
|
||||||
// State erst im nächsten Tick lesen — Block-Commit braucht einen Tick
|
|
||||||
Bukkit.getScheduler().runTaskLater( plugin, { ->
|
Bukkit.getScheduler().runTaskLater( plugin, { ->
|
||||||
val freshBlock = world.getBlockAt( cx, platformY + 1, cz )
|
val freshBlock = world.getBlockAt( cx, platformY + 1, cz )
|
||||||
if ( freshBlock.type != Material.CHEST ) return@runTaskLater
|
if ( freshBlock.type != Material.CHEST ) return@runTaskLater
|
||||||
@@ -234,10 +239,10 @@ class FeastManager(
|
|||||||
)
|
)
|
||||||
|
|
||||||
listOf(
|
listOf(
|
||||||
ArmorEntry( Material.DIAMOND_HELMET, 0.65, Enchantment.PROTECTION, 3 ),
|
ArmorEntry( Material.IRON_HELMET, 0.65, Enchantment.PROTECTION, 1 ),
|
||||||
ArmorEntry( Material.DIAMOND_CHESTPLATE, 0.75, Enchantment.PROTECTION, 3 ),
|
ArmorEntry( Material.DIAMOND_CHESTPLATE, 0.75, Enchantment.PROTECTION, 1 ),
|
||||||
ArmorEntry( Material.DIAMOND_LEGGINGS, 0.70, Enchantment.PROTECTION, 3 ),
|
ArmorEntry( Material.IRON_LEGGINGS, 0.70, Enchantment.PROTECTION, 1 ),
|
||||||
ArmorEntry( Material.DIAMOND_BOOTS, 0.65, Enchantment.FEATHER_FALLING, 3 ),
|
ArmorEntry( Material.DIAMOND_BOOTS, 0.65, Enchantment.FEATHER_FALLING, 1 ),
|
||||||
).forEach { ( material, chance, enchant, maxLevel ) ->
|
).forEach { ( material, chance, enchant, maxLevel ) ->
|
||||||
if ( rng.nextDouble() < chance )
|
if ( rng.nextDouble() < chance )
|
||||||
{
|
{
|
||||||
@@ -252,15 +257,12 @@ class FeastManager(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ── Diamantschwert ────────────────────────────────────────────────────
|
// ── Schwerter ────────────────────────────────────────────────────
|
||||||
if ( rng.nextDouble() < 0.85 )
|
if ( rng.nextDouble() < 0.85 )
|
||||||
{
|
items.add(ItemStack( Material.IRON_SWORD ))
|
||||||
items.add(ItemStack( Material.DIAMOND_SWORD ).also { sword ->
|
|
||||||
sword.editMeta { meta ->
|
if ( rng.nextDouble() < 0.65 )
|
||||||
meta.addEnchant( Enchantment.SHARPNESS, rng.nextInt( 3 ) + 1, true )
|
items.add(ItemStack( Material.DIAMOND_SWORD ))
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// ── Suppen (immer vorhanden, 6-10 Stück) ─────────────────────────────
|
// ── Suppen (immer vorhanden, 6-10 Stück) ─────────────────────────────
|
||||||
repeat(rng.nextInt( 5 ) + 6) { items.add(ItemStack( Material.MUSHROOM_STEW )) }
|
repeat(rng.nextInt( 5 ) + 6) { items.add(ItemStack( Material.MUSHROOM_STEW )) }
|
||||||
@@ -293,8 +295,8 @@ class FeastManager(
|
|||||||
// ── Goldener Apfel (50 % Chance) ──────────────────────────────────────
|
// ── Goldener Apfel (50 % Chance) ──────────────────────────────────────
|
||||||
if ( rng.nextDouble() < 0.50 ) items.add(ItemStack( Material.GOLDEN_APPLE ))
|
if ( rng.nextDouble() < 0.50 ) items.add(ItemStack( Material.GOLDEN_APPLE ))
|
||||||
|
|
||||||
// ── Verzauberter Goldener Apfel (10 % — sehr selten) ──────────────────
|
// ── Verzauberter Goldener Apfel (5 % — sehr selten) ──────────────────
|
||||||
if ( rng.nextDouble() < 0.10 ) items.add(ItemStack( Material.ENCHANTED_GOLDEN_APPLE ))
|
if ( rng.nextDouble() < 0.05 ) items.add(ItemStack( Material.ENCHANTED_GOLDEN_APPLE ))
|
||||||
|
|
||||||
return items.shuffled()
|
return items.shuffled()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,4 +59,31 @@ object WorldEditUtils {
|
|||||||
e.printStackTrace()
|
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()
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user