fix Phantom#setAnchorLocation(null)

This commit is contained in:
Lulu13022002
2025-06-08 20:34:06 +02:00
parent c5fc0dc84b
commit d4a7bbde1d
4 changed files with 8 additions and 3 deletions

View File

@@ -942,7 +942,7 @@
EntityType<?> type = this.getType();
ResourceLocation key = EntityType.getKey(type);
- return type.canSerialize() && key != null ? key.toString() : null;
+ return (type.canSerialize() || includeNonSaveable) && key != null ? key.toString() : null; // Paper - Raw entity serialization API
+ return (type.canSerialize() || includeNonSaveable) ? key.toString() : null; // Paper - Raw entity serialization API
}
protected abstract void readAdditionalSaveData(ValueInput input);

View File

@@ -1056,7 +1056,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
this.getHandle().registryAccess()
);
tagValueOutput.putString(Entity.TAG_ID, this.getHandle().getEncodeId()); // todo NPE?
tagValueOutput.putString(Entity.TAG_ID, this.getHandle().getEncodeId(true));
this.getHandle().saveWithoutId(tagValueOutput);
return tagValueOutput.buildResult();

View File

@@ -789,6 +789,9 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
@Override
public void setShoulderEntityLeft(org.bukkit.entity.Entity entity) {
if (entity != null) {
Preconditions.checkArgument(((CraftEntity) entity).getHandle().getType().canSerialize(), "Cannot set entity of type %s as a shoulder entity", entity.getType().getKey());
}
this.getHandle().setShoulderEntityLeft(entity == null ? new CompoundTag() : ((CraftEntity) entity).save());
if (entity != null) {
entity.remove();
@@ -812,6 +815,9 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
@Override
public void setShoulderEntityRight(org.bukkit.entity.Entity entity) {
if (entity != null) {
Preconditions.checkArgument(((CraftEntity) entity).getHandle().getType().canSerialize(), "Cannot set entity of type %s as a shoulder entity", entity.getType().getKey());
}
this.getHandle().setShoulderEntityRight(entity == null ? new CompoundTag() : ((CraftEntity) entity).save());
if (entity != null) {
entity.remove();

View File

@@ -50,7 +50,6 @@ public class CraftPhantom extends CraftMob implements Phantom, CraftEnemy {
@Override
public void setAnchorLocation(Location location) {
com.google.common.base.Preconditions.checkArgument(location != null, "location cannot be null");
this.getHandle().anchorPoint = location == null ? null : CraftLocation.toBlockPosition(location);
}
}