mirror of
https://github.com/FancyInnovations/FancyPlugins.git
synced 2025-12-06 07:43:36 +00:00
fancynpcs: Try to fix npcs disappearing
This commit is contained in:
@@ -17,6 +17,7 @@ import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.RemoteChatSession;
|
||||
import net.minecraft.network.protocol.Packet;
|
||||
import net.minecraft.network.protocol.game.*;
|
||||
import net.minecraft.network.syncher.SynchedEntityData;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
@@ -105,6 +106,7 @@ public class Npc_1_21_1 extends Npc {
|
||||
return;
|
||||
}
|
||||
|
||||
List<Packet<? super ClientGamePacketListener>> packets = new ArrayList<>();
|
||||
|
||||
if (npc instanceof ServerPlayer npcPlayer) {
|
||||
EnumSet<ClientboundPlayerInfoUpdatePacket.Action> actions = EnumSet.noneOf(ClientboundPlayerInfoUpdatePacket.Action.class);
|
||||
@@ -115,7 +117,7 @@ public class Npc_1_21_1 extends Npc {
|
||||
}
|
||||
|
||||
ClientboundPlayerInfoUpdatePacket playerInfoPacket = new ClientboundPlayerInfoUpdatePacket(actions, getEntry(npcPlayer, serverPlayer));
|
||||
serverPlayer.connection.send(playerInfoPacket);
|
||||
packets.add(playerInfoPacket);
|
||||
|
||||
if (data.isSpawnEntity()) {
|
||||
npc.setPos(data.getLocation().x(), data.getLocation().y(), data.getLocation().z());
|
||||
@@ -135,7 +137,7 @@ public class Npc_1_21_1 extends Npc {
|
||||
Vec3.ZERO,
|
||||
data.getLocation().getYaw()
|
||||
);
|
||||
serverPlayer.connection.send(addEntityPacket);
|
||||
packets.add(addEntityPacket);
|
||||
|
||||
isVisibleForPlayer.put(player.getUniqueId(), true);
|
||||
|
||||
@@ -148,6 +150,9 @@ public class Npc_1_21_1 extends Npc {
|
||||
}, removeNpcsFromPlayerlistDelay, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
||||
ClientboundBundlePacket bundlePacket = new ClientboundBundlePacket(packets);
|
||||
serverPlayer.connection.send(bundlePacket);
|
||||
|
||||
update(player);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user