Skip to content
Open
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
7 changes: 7 additions & 0 deletions src/main/java/untamedwilds/entity/ComplexMob.java
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,13 @@ public boolean wantsToBreed() {

@SuppressWarnings("unchecked") // Don't use this outside ComplexMobs
public <T extends ComplexMob> void breed() {
// Just return early if we're not the main server thread
// AKA don't allow WorldGen ForkJoin-created entities to breed entities (since they were added off-thread)
// This might be due to wantsToBreed() returning true as long as naturalBreeding is not explicitly disabled
if (!(this.level instanceof ServerLevel serverLevel) || !serverLevel.getServer().isSameThread()) {
return;
}

int bound = 1 + (this.getOffspring() > 0 ? this.random.nextInt(this.getOffspring() + 1) : 0);
for (int i = 0; i < bound; i++) {
T child = (T) this.getBreedOffspring((ServerLevel) this.level, this);
Expand Down