Merge pull request #535 from CivMC/fixbeds

Revert "Discard entities before adding NPCs"
This commit is contained in:
RedDevel2
2024-05-14 09:46:01 +02:00
committed by GitHub
2 changed files with 2 additions and 8 deletions

View File

@@ -33,7 +33,7 @@ public class NpcPlayer extends ServerPlayer {
public static NpcPlayer valueOf(Player player) {
MinecraftServer minecraftServer = MinecraftServer.getServer();
ServerLevel worldServer = ((CraftWorld) player.getWorld()).getHandle();
GameProfile gameProfile = new GameProfile(player.getUniqueId(), NpcNameGeneratorFactory.getNameGenerator().generate(player));
GameProfile gameProfile = new GameProfile(UUID.randomUUID(), NpcNameGeneratorFactory.getNameGenerator().generate(player));
ClientInformation clientInformation = ((CraftPlayer) player).getHandle().clientInformation();
for (Map.Entry<String, Property> entry: ((CraftPlayer) player).getProfile().getProperties().entries()) {

View File

@@ -12,7 +12,6 @@ import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.food.FoodData;
import net.minecraft.world.item.ItemStack;
@@ -51,12 +50,7 @@ public class NpcPlayerHelperImpl implements NpcPlayerHelper {
serverPlayer.connection.send(packet);
}
Entity oldPlayer = worldServer.getEntity(player.getUniqueId());
if (oldPlayer != null) {
oldPlayer.remove(Entity.RemovalReason.DISCARDED);
worldServer.addFreshEntity(npcPlayer);
}
worldServer.addFreshEntity(npcPlayer);
return npcPlayer.getBukkitEntity();
}