diff --git a/src/main/kotlin/net/hareworks/hcu/items/content/components/AreaTillerComponent.kt b/src/main/kotlin/net/hareworks/hcu/items/content/components/AreaTillerComponent.kt index 40128b1..fbae4bc 100644 --- a/src/main/kotlin/net/hareworks/hcu/items/content/components/AreaTillerComponent.kt +++ b/src/main/kotlin/net/hareworks/hcu/items/content/components/AreaTillerComponent.kt @@ -43,13 +43,12 @@ import net.hareworks.hcu.items.util.ItemActionUtil * AreaTillerComponent - 広範囲一括耕地化コンポーネント * * クワを使用時に広範囲の土ブロックを一度に耕地化する。 - * Tier3以上では、水なしでも湿った状態を保つ特殊な耕地を生成する。 */ class AreaTillerComponent(private val plugin: JavaPlugin) : ToolComponent { override val key: NamespacedKey = NamespacedKey(plugin, "area_tiller") override val displayName: String = "Area Tiller" - override val maxTier: Int = 4 + override val maxTier: Int = 2 override val minTier: Int = 1 // 耕地化対象ブロック @@ -119,42 +118,6 @@ class AreaTillerComponent(private val plugin: JavaPlugin) : ToolComponent { }, PlayerItemHeldEvent::class to { event, item -> handleItemHeld(event as PlayerItemHeldEvent, item) - }, - MoistureChangeEvent::class to { event, _ -> - handleMoistureChange(event as MoistureChangeEvent) - }, - BlockBreakEvent::class to { event, _ -> - handleGenericBlockCleanup(event as BlockBreakEvent) - }, - BlockExplodeEvent::class to { event, _ -> - handleBlockExplodeCleanup(event as BlockExplodeEvent) - }, - EntityExplodeEvent::class to { event, _ -> - handleEntityExplodeCleanup(event as EntityExplodeEvent) - }, - EntityInteractEvent::class to { event, _ -> - handleEntityInteractCleanup(event as EntityInteractEvent) - }, - BlockFadeEvent::class to { event, _ -> - handleGenericBlockCleanup(event as BlockFadeEvent) - }, - BlockFromToEvent::class to { event, _ -> - handleBlockFromToCleanup(event as BlockFromToEvent) - }, - BlockPistonExtendEvent::class to { event, _ -> - handlePistonExtendCleanup(event as BlockPistonExtendEvent) - }, - BlockPistonRetractEvent::class to { event, _ -> - handlePistonRetractCleanup(event as BlockPistonRetractEvent) - }, - BlockPlaceEvent::class to { event, _ -> - handleGenericBlockCleanup(event as BlockPlaceEvent) - }, - BlockBurnEvent::class to { event, _ -> - handleGenericBlockCleanup(event as BlockBurnEvent) - }, - BlockPhysicsEvent::class to { event, _ -> - handleBlockPhysicsCleanup(event as BlockPhysicsEvent) } ) } @@ -245,7 +208,7 @@ class AreaTillerComponent(private val plugin: JavaPlugin) : ToolComponent { val blocksToTill = calculateTillableBlocks(targetBlock, n, s, e, w) if (blocksToTill.isEmpty()) return - val entities = createHighlightEntities(player, blocksToTill, tier >= 3) + val entities = createHighlightEntities(player, blocksToTill) activeHighlights[player.uniqueId] = HighlightSession( targetBlock, entities, System.currentTimeMillis(), n, s, e, w ) @@ -370,7 +333,6 @@ class AreaTillerComponent(private val plugin: JavaPlugin) : ToolComponent { processingPlayers.add(player.uniqueId) try { - val isEternallyMoist = tier >= 3 var tilledCount = 0 for (block in blocks) { @@ -390,17 +352,6 @@ class AreaTillerComponent(private val plugin: JavaPlugin) : ToolComponent { // 耕地化 block.type = Material.FARMLAND - // Tier3以上: 永続的な湿った状態 - if (isEternallyMoist) { - val farmlandData = block.blockData as? Farmland - farmlandData?.let { - it.moisture = it.maximumMoisture - block.blockData = it - } - // 永続的な湿り状態をマーク(別途Tickで維持) - markEternallyMoist(block) - } - tilledCount++ } @@ -416,18 +367,6 @@ class AreaTillerComponent(private val plugin: JavaPlugin) : ToolComponent { 0.8f + (tier * 0.1f) ) - // Tier3以上の特殊エフェクト - if (isEternallyMoist) { - blocks.forEach { block -> - player.spawnParticle( - Particle.DRIPPING_WATER, - block.location.add(0.5, 1.0, 0.5), - 3, - 0.3, 0.1, 0.3, - 0.0 - ) - } - } } } finally { // 再帰防止フラグをクリア @@ -435,120 +374,16 @@ class AreaTillerComponent(private val plugin: JavaPlugin) : ToolComponent { } } - /** - * 耕地の水分量変化(乾燥)を監視 - */ - private fun handleMoistureChange(event: MoistureChangeEvent) { - val block = event.block - - // 自己浄化: 耕地でなくなった場合、あるいは乾燥しようとしている場合 - if (block.type != Material.FARMLAND) { - removeMoistMark(block) - return - } - - // チャンクのPDCを確認して「永続的な湿り」マークがあるかチェック - if (isMarkedAsEternallyMoist(block)) { - // 水分が減るのを阻止(イベントをキャンセル) - event.isCancelled = true - - // 念のためnewStateも最大値に固定 - val data = event.newState - if (data is Farmland) { - data.moisture = data.maximumMoisture - } - } - } - - /** - * 汎用的なブロック消失クリーンアップ - */ - private fun handleGenericBlockCleanup(event: Event) { - val block = when (event) { - is BlockBreakEvent -> event.block - is BlockFadeEvent -> event.block - is BlockPlaceEvent -> event.block - is BlockBurnEvent -> event.block - else -> return - } - removeMoistMark(block) - } - - private fun handleBlockExplodeCleanup(event: BlockExplodeEvent) { - event.blockList().forEach { removeMoistMark(it) } - } - - private fun handleEntityExplodeCleanup(event: EntityExplodeEvent) { - event.blockList().forEach { removeMoistMark(it) } - } - - private fun handleEntityInteractCleanup(event: EntityInteractEvent) { - // 耕地を踏みつけた時など、耕地でなくなる可能性が高いイベント - removeMoistMark(event.block) - } - - private fun handleBlockFromToCleanup(event: BlockFromToEvent) { - // 水や溶岩が流れ込んで耕地が消える場合 - removeMoistMark(event.block) - } - - private fun handlePistonExtendCleanup(event: BlockPistonExtendEvent) { - event.blocks.forEach { removeMoistMark(it) } - } - - private fun handlePistonRetractCleanup(event: BlockPistonRetractEvent) { - event.blocks.forEach { removeMoistMark(it) } - } - - private fun handleBlockPhysicsCleanup(event: BlockPhysicsEvent) { - // 全ての物理更新時に、もし「以前耕地でマークされていたのに、今は耕地でない」なら削除 - val block = event.block - if (block.type != Material.FARMLAND) { - removeMoistMark(block) - } - } - - /** - * ブロックが永続的な湿り状態としてマークされているか確認 - */ - private fun isMarkedAsEternallyMoist(block: Block): Boolean { - val chunk = block.chunk - val pdc = chunk.persistentDataContainer - val key = NamespacedKey(plugin, "moist_${block.x}_${block.y}_${block.z}") - return pdc.has(key, PersistentDataType.BYTE) - } - - /** - * ブロックを永続的な湿り状態としてマーク - */ - private fun markEternallyMoist(block: Block) { - val chunk = block.chunk - val pdc = chunk.persistentDataContainer - val key = NamespacedKey(plugin, "moist_${block.x}_${block.y}_${block.z}") - pdc.set(key, PersistentDataType.BYTE, 1.toByte()) - } - - private fun removeMoistMark(block: Block) { - val chunk = block.chunk - val pdc = chunk.persistentDataContainer - val key = NamespacedKey(plugin, "moist_${block.x}_${block.y}_${block.z}") - if (pdc.has(key, PersistentDataType.BYTE)) { - pdc.remove(key) - } - } - /** * ハイライトエンティティを作成 */ private fun createHighlightEntities( player: Player, blocks: Set, - isEternallyMoist: Boolean ): List { if (!supportsBlockDisplay) return emptyList() val entities = mutableListOf() - val highlightColor = if (isEternallyMoist) Color.AQUA else Color.LIME for (block in blocks) { val loc = block.location.add(0.5, 0.5, 0.5) @@ -562,7 +397,7 @@ class AreaTillerComponent(private val plugin: JavaPlugin) : ToolComponent { AxisAngle4f(0f, 0f, 0f, 1f) ) e.isGlowing = true - e.glowColorOverride = highlightColor + e.glowColorOverride = Color.LIME e.brightness = Display.Brightness(15, 15) e.isVisibleByDefault = false } diff --git a/src/main/kotlin/net/hareworks/hcu/items/listeners/EventListener.kt b/src/main/kotlin/net/hareworks/hcu/items/listeners/EventListener.kt index 5730a48..06fe0ac 100644 --- a/src/main/kotlin/net/hareworks/hcu/items/listeners/EventListener.kt +++ b/src/main/kotlin/net/hareworks/hcu/items/listeners/EventListener.kt @@ -58,70 +58,6 @@ class EventListener(private val plugin: Plugin) : Listener { } } - /** - * MoistureChangeEvent - 耕地の水分変化(乾燥)を監視 - * これもアイテムに紐付かないグローバルなイベントとして処理する。 - */ - @EventHandler - fun onMoistureChange(event: MoistureChangeEvent) { - dispatchGlobalToComponents(event) - } - - @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) - fun onBlockBreakGlobal(event: BlockBreakEvent) { - dispatchGlobalToComponents(event) - } - - @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) - fun onBlockExplodeGlobal(event: BlockExplodeEvent) { - dispatchGlobalToComponents(event) - } - - @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) - fun onEntityExplodeGlobal(event: EntityExplodeEvent) { - dispatchGlobalToComponents(event) - } - - @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) - fun onEntityInteractGlobal(event: EntityInteractEvent) { - dispatchGlobalToComponents(event) - } - - @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) - fun onBlockFadeGlobal(event: BlockFadeEvent) { - dispatchGlobalToComponents(event) - } - - @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) - fun onBlockFromToGlobal(event: BlockFromToEvent) { - dispatchGlobalToComponents(event) - } - - @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) - fun onBlockPistonExtendGlobal(event: BlockPistonExtendEvent) { - dispatchGlobalToComponents(event) - } - - @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) - fun onBlockPistonRetractGlobal(event: BlockPistonRetractEvent) { - dispatchGlobalToComponents(event) - } - - @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) - fun onBlockPlaceGlobal(event: BlockPlaceEvent) { - dispatchGlobalToComponents(event) - } - - @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) - fun onBlockBurnGlobal(event: BlockBurnEvent) { - dispatchGlobalToComponents(event) - } - - @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) - fun onBlockPhysicsGlobal(event: BlockPhysicsEvent) { - dispatchGlobalToComponents(event) - } - @EventHandler fun onPlayerQuit(event: PlayerQuitEvent) { ItemActionUtil.clearScrollState(event.player) @@ -152,18 +88,7 @@ class EventListener(private val plugin: Plugin) : Listener { // Register a listener for each event type for (eventClass in registeredEvents) { // Skip events that are handled manually or globally - if (eventClass == ProjectileHitEvent::class || - eventClass == MoistureChangeEvent::class || - eventClass == EntityExplodeEvent::class || - eventClass == BlockExplodeEvent::class || - eventClass == EntityInteractEvent::class || - eventClass == BlockFadeEvent::class || - eventClass == BlockFromToEvent::class || - eventClass == BlockPistonExtendEvent::class || - eventClass == BlockPistonRetractEvent::class || - eventClass == BlockPlaceEvent::class || - eventClass == BlockBurnEvent::class || - eventClass == BlockPhysicsEvent::class) continue + if (eventClass == ProjectileHitEvent::class) continue val strategy = EventStrategyRegistry.get(eventClass) if (strategy == null) { diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 74b12fa..3ce45ff 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -75,8 +75,6 @@ components: max_range_per_tier: 1: 4 # Tier1: 4x4 2: 5 # Tier2: 5x5 - 3: 4 # Tier3: 4x4 (永続湿り耕地) - 4: 5 # Tier4: 5x5 (永続湿り耕地) items: auto_feeder: