9
0
mirror of https://github.com/BX-Team/DivineMC.git synced 2025-12-19 14:59:25 +00:00
Files
DivineMC/patches/server/0007-Fix-entity-serialization.patch
NONPLAYT e420391f43 Updated Upstream (Purpur)
Upstream has released updates that appear to apply and compile correctly

Purpur Changes:
PurpurMC/Purpur@8a1e23d Updated Upstream (Paper)
PurpurMC/Purpur@42d0290 return empty itemstack to PlayerBookTooLargeEvent if book is not being held
PurpurMC/Purpur@1f589eb Updated Upstream (Paper)
PurpurMC/Purpur@ea2835b Updated Upstream (Paper)
2023-11-09 22:25:41 +03:00

46 lines
2.6 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com>
Date: Fri, 31 Mar 2023 00:39:40 +0300
Subject: [PATCH] Fix entity serialization
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index d61d7ae47285d9779221011212f871c4ef7de830..24cc1369b6561b8fb99f26253f7ba05be0a5d49b 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -2330,15 +2330,6 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
}
}
- // Paper start - Entity serialization api
- public boolean serializeEntity(CompoundTag compound) {
- List<Entity> pass = new java.util.ArrayList<>(this.getPassengers());
- this.passengers = ImmutableList.of();
- boolean result = save(compound);
- this.passengers = ImmutableList.copyOf(pass);
- return result;
- }
- // Paper end
public boolean save(CompoundTag nbt) {
return this.isPassenger() ? false : this.saveAsPassenger(nbt);
}
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
index 1e81801e5701b08feedd840c1e1663ae26507c16..2b5040c15657f73dfad12a97ce61161098832807 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
@@ -511,8 +511,13 @@ public final class CraftMagicNumbers implements UnsafeValues {
Preconditions.checkNotNull(entity, "null cannot be serialized");
Preconditions.checkArgument(entity instanceof org.bukkit.craftbukkit.entity.CraftEntity, "only CraftEntities can be serialized");
+ net.minecraft.world.entity.Entity nmsEntity = ((org.bukkit.craftbukkit.entity.CraftEntity) entity).getHandle();
CompoundTag compound = new CompoundTag();
- ((org.bukkit.craftbukkit.entity.CraftEntity) entity).getHandle().serializeEntity(compound);
+ compound.putString("id", net.minecraft.world.entity.EntityType.getKey(nmsEntity.getType()).toString());
+ List<net.minecraft.world.entity.Entity> pass = new java.util.ArrayList<>(nmsEntity.getPassengers());
+ nmsEntity.passengers = com.google.common.collect.ImmutableList.of();
+ nmsEntity.saveWithoutId(compound);
+ nmsEntity.passengers = com.google.common.collect.ImmutableList.copyOf(pass);
return serializeNbtToBytes(compound);
}