Skip to content

Commit

Permalink
🐛 fix(ClientHandler): 解决了扫人失效的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
wangziwenhk committed Aug 2, 2024
1 parent b263128 commit df6d4dd
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 33 deletions.
2 changes: 0 additions & 2 deletions src/main/kotlin/org/thirdTune/apex_extra/ApexExtra.kt
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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)
}
}
22 changes: 0 additions & 22 deletions src/main/kotlin/org/thirdTune/apex_extra/ClientHandler.kt

This file was deleted.

23 changes: 14 additions & 9 deletions src/main/kotlin/org/thirdTune/apex_extra/items/AllfatherEye.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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<ItemStack> {
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)
}
Expand All @@ -30,9 +37,7 @@ class AllfatherEye : Item(Properties()) {
slotIndex: Int,
selectedIndex: Int
) {
if (showTime == 0) {
ClientHandler.nearPlayerHighLight = false
} else {
if (showTime != 0) {
showTime--
}

Expand Down

0 comments on commit df6d4dd

Please sign in to comment.