diff --git a/src/main/java/carpet/script/value/EntityValue.java b/src/main/java/carpet/script/value/EntityValue.java index ea8a983c..fb737d0f 100644 --- a/src/main/java/carpet/script/value/EntityValue.java +++ b/src/main/java/carpet/script/value/EntityValue.java @@ -1758,16 +1758,13 @@ public class EntityValue extends Value { throw new NBTSerializableValue.IncompatibleTypeException(this); } - CompoundTag tag; + CompoundTag tag = new CompoundTag(); Entity entity = getEntity(); try (final ProblemReporter.ScopedCollector reporter = new ProblemReporter.ScopedCollector(entity.problemPath(), CarpetScriptServer.LOG)) { final TagValueOutput output = TagValueOutput.createWithContext(reporter, entity.registryAccess()); entity.save(output); - tag = output.buildResult(); + tag.put("Data", output.buildResult()); } - - tag.put("Data", tag); - Registry> reg = entity.level().registryAccess().lookupOrThrow(Registries.ENTITY_TYPE); tag.put("Name", StringTag.valueOf(reg.getKey(entity.getType()).toString())); return tag;