Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,6 @@ public <T extends Entity> void register(EntityType<T> entityType, SpawnPlacement
*/
@SuppressWarnings("unchecked")
public <T extends Entity> void register(EntityType<T> entityType, @Nullable SpawnPlacementType placementType, @Nullable Heightmap.Types heightmap, SpawnPlacements.SpawnPredicate<T> predicate, Operation operation) {
// Kilt: patch by @ItsBlackGear to fix Vanilla Backport (Fabric) + NML + Kilt, may be upstreamed.
if (this.map.containsKey(entityType) && operation != Operation.REPLACE) {
if (placementType != null || heightmap != null) {
((MergedSpawnPredicate<T>) this.map.get(entityType)).merge(operation, predicate, null, null);
return;
}
}

if (!map.containsKey(entityType)) {
if (placementType == null) {
throw new NullPointerException("Registering a new Spawn Predicate requires a nonnull placement type! Entity Type: " + BuiltInRegistries.ENTITY_TYPE.getKey(entityType));
Expand All @@ -87,9 +79,10 @@ public <T extends Entity> void register(EntityType<T> entityType, @Nullable Spaw
}
map.put(entityType, new MergedSpawnPredicate<>(predicate, placementType, heightmap));
} else {
if (operation != Operation.REPLACE && (heightmap != null || placementType != null)) {
throw new IllegalStateException("Nonnull heightmap types or spawn placement types may only be used with the REPLACE operation. Entity Type: " + BuiltInRegistries.ENTITY_TYPE.getKey(entityType));
}
// commented out as it's both punishing and redundant, merge already handles the operations without need of a throw
Comment thread
ItsBlackGear marked this conversation as resolved.
// if (operation != Operation.REPLACE && (heightmap != null || placementType != null)) {
// throw new IllegalStateException("Nonnull heightmap types or spawn placement types may only be used with the REPLACE operation. Entity Type: " + BuiltInRegistries.ENTITY_TYPE.getKey(entityType));
// }
Comment thread
ItsBlackGear marked this conversation as resolved.
((MergedSpawnPredicate<T>) map.get(entityType)).merge(operation, predicate, placementType, heightmap);
}
}
Expand Down