尝试加入瞄准村民彩蛋

This commit is contained in:
Atsuihsio 2025-01-09 16:40:06 +08:00
parent ba02aa947f
commit cd06863f84

View file

@ -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<Entity> 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;