diff --git a/src/main/kotlin/org/thirdTune/apex_extra/ApexExtra.kt b/src/main/kotlin/org/thirdTune/apex_extra/ApexExtra.kt index f158310..fca11c4 100644 --- a/src/main/kotlin/org/thirdTune/apex_extra/ApexExtra.kt +++ b/src/main/kotlin/org/thirdTune/apex_extra/ApexExtra.kt @@ -1,6 +1,5 @@ package org.thirdTune.apex_extra -import net.minecraftforge.common.MinecraftForge import net.minecraftforge.fml.common.Mod import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext import org.thirdTune.apex_extra.ResManager.ITEMS @@ -24,6 +23,5 @@ class ApexExtra { ITEMS.register(FMLJavaModLoadingContext.get().modEventBus) TABS.register(FMLJavaModLoadingContext.get().modEventBus) SOUNDS.register(FMLJavaModLoadingContext.get().modEventBus) - MinecraftForge.EVENT_BUS.addListener(ClientHandler::onClientTick) } } \ No newline at end of file diff --git a/src/main/kotlin/org/thirdTune/apex_extra/ClientHandler.kt b/src/main/kotlin/org/thirdTune/apex_extra/ClientHandler.kt deleted file mode 100644 index d13e8e4..0000000 --- a/src/main/kotlin/org/thirdTune/apex_extra/ClientHandler.kt +++ /dev/null @@ -1,22 +0,0 @@ -package org.thirdTune.apex_extra - -import net.minecraft.client.Minecraft -import net.minecraft.world.entity.player.Player -import net.minecraftforge.event.TickEvent - -object ClientHandler { - var nearPlayerHighLight = false - fun onClientTick(event: TickEvent.ClientTickEvent) { - if(event.phase != TickEvent.Phase.START)return - val mc = Minecraft.getInstance() - val player = mc.player - if (nearPlayerHighLight) { - for (nearPlayer in player!!.level() - .getEntitiesOfClass(Player::class.java, player.boundingBox.inflate(10.0))) { - if (nearPlayer != player) { - nearPlayer.setGlowingTag(true) - } - } - } - } -} \ No newline at end of file diff --git a/src/main/kotlin/org/thirdTune/apex_extra/items/AllfatherEye.kt b/src/main/kotlin/org/thirdTune/apex_extra/items/AllfatherEye.kt index e9ab228..b44e46d 100644 --- a/src/main/kotlin/org/thirdTune/apex_extra/items/AllfatherEye.kt +++ b/src/main/kotlin/org/thirdTune/apex_extra/items/AllfatherEye.kt @@ -2,23 +2,30 @@ package org.thirdTune.apex_extra.items import net.minecraft.world.InteractionHand import net.minecraft.world.InteractionResultHolder +import net.minecraft.world.effect.MobEffectInstance +import net.minecraft.world.effect.MobEffects import net.minecraft.world.entity.player.Player import net.minecraft.world.item.Item import net.minecraft.world.item.ItemStack import net.minecraft.world.level.Level -import org.thirdTune.apex_extra.ClientHandler -class AllfatherEye : Item(Properties()) { - // 持续时间 (秒) - private val duration = 2 +class AllfatherEye : Item(Properties().stacksTo(1).setNoRepair()) { + companion object { + // 持续时间 (秒) + const val duration: Int = 4 - // 冷却时间 (秒) - private val cooldown = 30 + // 冷却时间 (秒) + const val cooldown = 30 + } // 显示高亮的剩余 Tick private var showTime = 0 override fun use(world: Level, player: Player, usedHand: InteractionHand): InteractionResultHolder { player.cooldowns.addCooldown(this, cooldown * 20) + for (nearPlayer in player.level() + .getEntitiesOfClass(Player::class.java, player.boundingBox.inflate(10.0))) { + nearPlayer.addEffect(MobEffectInstance(MobEffects.GLOWING, duration * 20, 0)) + } showTime = duration * 20 return super.use(world, player, usedHand) } @@ -30,9 +37,7 @@ class AllfatherEye : Item(Properties()) { slotIndex: Int, selectedIndex: Int ) { - if (showTime == 0) { - ClientHandler.nearPlayerHighLight = false - } else { + if (showTime != 0) { showTime-- }