让流浪商人也感到恐慌
This commit is contained in:
parent
9882b065cd
commit
a4fb286a17
2 changed files with 9 additions and 5 deletions
|
@ -18,7 +18,7 @@ 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.Villager;
|
||||
import net.minecraft.world.entity.npc.AbstractVillager;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.event.AnvilUpdateEvent;
|
||||
|
@ -101,7 +101,7 @@ 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 Villager villager) {
|
||||
if (entity instanceof AbstractVillager villager) {
|
||||
List<Entity> entities = SeekTool.seekLivingEntities(villager, villager.level(), 16, 120);
|
||||
for (var e : entities) {
|
||||
if (e == player) {
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.atsuishio.superbwarfare.network.message;
|
|||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.ai.gossip.GossipType;
|
||||
import net.minecraft.world.entity.npc.AbstractVillager;
|
||||
import net.minecraft.world.entity.npc.Villager;
|
||||
import net.minecraft.world.entity.schedule.Activity;
|
||||
import net.minecraftforge.network.NetworkEvent;
|
||||
|
@ -31,10 +32,13 @@ public class AimVillagerMessage {
|
|||
if (sender == null) return;
|
||||
|
||||
Entity entity = sender.level().getEntity(message.villagerId);
|
||||
if (entity instanceof Villager villager) {
|
||||
villager.getBrain().setActiveActivityIfPossible(Activity.PANIC);
|
||||
villager.getGossips().add(sender.getUUID(), GossipType.MINOR_NEGATIVE, 10);
|
||||
if (entity instanceof AbstractVillager abstractVillager) {
|
||||
if (entity instanceof Villager villager) {
|
||||
villager.getGossips().add(sender.getUUID(), GossipType.MINOR_NEGATIVE, 10);
|
||||
}
|
||||
abstractVillager.getBrain().setActiveActivityIfPossible(Activity.PANIC);
|
||||
}
|
||||
|
||||
});
|
||||
context.get().setPacketHandled(true);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue