From cd06863f8406481de75fd1f2e75a30b46da1fef6 Mon Sep 17 00:00:00 2001 From: Atsuihsio <842960157@qq.com> Date: Thu, 9 Jan 2025 16:40:06 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=9D=E8=AF=95=E5=8A=A0=E5=85=A5=E7=9E=84?= =?UTF-8?q?=E5=87=86=E6=9D=91=E6=B0=91=E5=BD=A9=E8=9B=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../event/PlayerEventHandler.java | 25 ++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/atsuishio/superbwarfare/event/PlayerEventHandler.java b/src/main/java/com/atsuishio/superbwarfare/event/PlayerEventHandler.java index 729ad30f7..53717e809 100644 --- a/src/main/java/com/atsuishio/superbwarfare/event/PlayerEventHandler.java +++ b/src/main/java/com/atsuishio/superbwarfare/event/PlayerEventHandler.java @@ -7,9 +7,7 @@ import com.atsuishio.superbwarfare.init.ModSounds; import com.atsuishio.superbwarfare.init.ModTags; import com.atsuishio.superbwarfare.network.ModVariables; import com.atsuishio.superbwarfare.network.message.SimulationDistanceMessage; -import com.atsuishio.superbwarfare.tools.GunInfo; -import com.atsuishio.superbwarfare.tools.GunsTool; -import com.atsuishio.superbwarfare.tools.SoundTool; +import com.atsuishio.superbwarfare.tools.*; import net.minecraft.core.BlockPos; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; @@ -18,8 +16,11 @@ import net.minecraft.sounds.SoundSource; import net.minecraft.util.Mth; import net.minecraft.world.effect.MobEffectInstance; import net.minecraft.world.effect.MobEffects; +import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EquipmentSlot; +import net.minecraft.world.entity.npc.AbstractVillager; import net.minecraft.world.entity.player.Player; +import net.minecraft.world.entity.schedule.Activity; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; import net.minecraftforge.event.AnvilUpdateEvent; @@ -29,6 +30,8 @@ import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.network.PacketDistributor; +import java.util.List; + @Mod.EventBusSubscriber public class PlayerEventHandler { @@ -88,6 +91,7 @@ public class PlayerEventHandler { handleSpecialWeaponAmmo(player); handleBocekPulling(player); isProne(player); + aimAtVillager(player); } handleGround(player); @@ -97,6 +101,21 @@ public class PlayerEventHandler { } } + public static void aimAtVillager(Player player) { + if (player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables()).zoom) { + Entity entity = TraceTool.findLookingEntity(player, 10); + if (entity instanceof AbstractVillager villager) { + List gunner = SeekTool.seekLivingEntities(villager, villager.level(), 16, 120); + for (var e : gunner) { + if (e == player) { + // TODO 让村民恐慌并生气涨价 + villager.getBrain().addActivity(Activity.PANIC, ); + } + } + } + } + } + public static boolean isProne(Player player) { Level level = player.level(); if (player.getBbHeight() <= 1) return true;