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

Purpur Changes:
PurpurMC/Purpur@9690640 Updated Upstream (Paper)
PurpurMC/Purpur@20c48cd override the correct BlockPlayerDestroy method
PurpurMC/Purpur@ddc4fa9 Add configurable "sleep.not_possible" actionbar message (#1414)
PurpurMC/Purpur@8d384b0 Add option to always show item in player death messages (#1418)
PurpurMC/Purpur@cf23229 Updated Upstream (Paper)
PurpurMC/Purpur@ad645dc option to place end crystal on any block
2023-08-23 19:37:50 +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 cf0d8da4c4b5f4aa4e4ef15897ca252a2b52ec8d..95b6639d0075c2b86f83718b3093f972d2e89b83 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -2336,15 +2336,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 ffca5970a6259b024c9aa935e22cf72ed8cd8e9f..7c31515d1c0f199e8139d4c20651685b77edfcef 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
@@ -496,8 +496,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);
}