Skip to content

Commit fcb2956

Browse files
authored
Add debug logging for entities with invalid ids (#13229)
1 parent e74d702 commit fcb2956

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

build-data/paper.at

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -754,6 +754,7 @@ public net.minecraft.world.level.storage.DimensionDataStorage cache
754754
public net.minecraft.world.level.storage.LevelStorageSource baseDir
755755
public net.minecraft.world.level.storage.LevelStorageSource$LevelStorageAccess levelDirectory
756756
public net.minecraft.world.level.storage.PrimaryLevelData settings
757+
public net.minecraft.world.level.storage.TagValueInput input
757758
public net.minecraft.world.scores.Objective displayName
758759
public net.minecraft.world.scores.criteria.ObjectiveCriteria CRITERIA_CACHE
759760
public-f net.minecraft.server.MinecraftServer potionBrewing

paper-server/patches/sources/net/minecraft/world/entity/EntityType.java.patch

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
--- a/net/minecraft/world/entity/EntityType.java
22
+++ b/net/minecraft/world/entity/EntityType.java
3+
@@ -185,6 +_,7 @@
4+
import org.slf4j.Logger;
5+
6+
public class EntityType<T extends Entity> implements FeatureElement, EntityTypeTest<Entity, T> {
7+
+ private static final boolean DEBUG_ENTITIES_WITH_INVALID_IDS = Boolean.getBoolean("paper.debugEntitiesWithInvalidIds"); // Paper - Add logging for debugging entity tags with invalid ids
8+
private static final Logger LOGGER = LogUtils.getLogger();
9+
private final Holder.Reference<EntityType<?>> builtInRegistryHolder = BuiltInRegistries.ENTITY_TYPE.createIntrusiveHolder(this);
10+
public static final Codec<EntityType<?>> CODEC = BuiltInRegistries.ENTITY_TYPE.byNameCodec();
311
@@ -1265,6 +_,22 @@
412
boolean shouldOffsetY,
513
boolean shouldOffsetYMore
@@ -108,7 +116,7 @@
108116
entityData.loadInto(entity);
109117
}
110118
}
111-
@@ -1429,9 +_,20 @@
119+
@@ -1429,10 +_,28 @@
112120
}
113121

114122
public static Optional<Entity> create(ValueInput input, Level level, EntitySpawnReason spawnReason) {
@@ -121,15 +129,24 @@
121129
return Util.ifElse(
122130
by(input).map(entityType -> entityType.create(level, spawnReason)),
123131
- entity -> entity.load(input),
132+
- () -> LOGGER.warn("Skipping Entity with id {}", input.getStringOr("id", "[invalid]"))
124133
+ // Paper start - Don't fire sync event during generation
125134
+ entity -> {
126135
+ if (generation) entity.generation = true; // Paper - Don't fire sync event during generation
127136
+ entity.load(input);
128137
+ },
129138
+ // Paper end - Don't fire sync event during generation
130-
() -> LOGGER.warn("Skipping Entity with id {}", input.getStringOr("id", "[invalid]"))
139+
+ // Paper start - Add logging for debugging entity tags with invalid ids
140+
+ () -> {
141+
+ LOGGER.warn("Skipping Entity with id {}", input.getStringOr("id", "[invalid]"));
142+
+ if ((DEBUG_ENTITIES_WITH_INVALID_IDS || level.getCraftServer().getServer().isDebugging()) && input instanceof TagValueInput tagInput) {
143+
+ LOGGER.warn("Skipped entity tag: {}", tagInput.input);
144+
+ }
145+
+ }
146+
+ // Paper end - Add logging for debugging entity tags with invalid ids
131147
);
132148
}
149+
133150
@@ -1588,8 +_,23 @@
134151
return this.builtInRegistryHolder;
135152
}

0 commit comments

Comments
 (0)