mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-16 04:33:56 -07:00
Ignore impossible spawn tick
This commit is contained in:
@@ -19,10 +19,11 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void clientTick(Level world, BlockPos pos) {
|
public void clientTick(Level world, BlockPos pos) {
|
||||||
@@ -82,13 +84,18 @@
|
@@ -82,13 +84,19 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public void serverTick(ServerLevel world, BlockPos pos) {
|
public void serverTick(ServerLevel world, BlockPos pos) {
|
||||||
|
+ if (spawnCount <= 0 || maxNearbyEntities <= 0) return; // Paper - Ignore impossible spawn tick
|
||||||
+ // Paper start - Configurable mob spawner tick rate
|
+ // Paper start - Configurable mob spawner tick rate
|
||||||
+ if (spawnDelay > 0 && --tickDelay > 0) return;
|
+ if (spawnDelay > 0 && --tickDelay > 0) return;
|
||||||
+ tickDelay = world.paperConfig().tickRates.mobSpawner;
|
+ tickDelay = world.paperConfig().tickRates.mobSpawner;
|
||||||
@@ -40,7 +41,7 @@
|
|||||||
} else {
|
} else {
|
||||||
boolean flag = false;
|
boolean flag = false;
|
||||||
RandomSource randomsource = world.getRandom();
|
RandomSource randomsource = world.getRandom();
|
||||||
@@ -125,6 +132,20 @@
|
@@ -125,6 +133,20 @@
|
||||||
} else if (!SpawnPlacements.checkSpawnRules((EntityType) optional.get(), world, EntitySpawnReason.SPAWNER, blockposition1, world.getRandom())) {
|
} else if (!SpawnPlacements.checkSpawnRules((EntityType) optional.get(), world, EntitySpawnReason.SPAWNER, blockposition1, world.getRandom())) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -61,7 +62,7 @@
|
|||||||
|
|
||||||
Entity entity = EntityType.loadEntityRecursive(nbttagcompound, world, EntitySpawnReason.SPAWNER, (entity1) -> {
|
Entity entity = EntityType.loadEntityRecursive(nbttagcompound, world, EntitySpawnReason.SPAWNER, (entity1) -> {
|
||||||
entity1.moveTo(d0, d1, d2, entity1.getYRot(), entity1.getXRot());
|
entity1.moveTo(d0, d1, d2, entity1.getYRot(), entity1.getXRot());
|
||||||
@@ -143,6 +164,7 @@
|
@@ -143,6 +165,7 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,7 +70,7 @@
|
|||||||
entity.moveTo(entity.getX(), entity.getY(), entity.getZ(), randomsource.nextFloat() * 360.0F, 0.0F);
|
entity.moveTo(entity.getX(), entity.getY(), entity.getZ(), randomsource.nextFloat() * 360.0F, 0.0F);
|
||||||
if (entity instanceof Mob) {
|
if (entity instanceof Mob) {
|
||||||
Mob entityinsentient = (Mob) entity;
|
Mob entityinsentient = (Mob) entity;
|
||||||
@@ -157,13 +179,27 @@
|
@@ -157,13 +180,27 @@
|
||||||
((Mob) entity).finalizeSpawn(world, world.getCurrentDifficultyAt(entity.blockPosition()), EntitySpawnReason.SPAWNER, (SpawnGroupData) null);
|
((Mob) entity).finalizeSpawn(world, world.getCurrentDifficultyAt(entity.blockPosition()), EntitySpawnReason.SPAWNER, (SpawnGroupData) null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,7 +100,7 @@
|
|||||||
this.delay(world, pos);
|
this.delay(world, pos);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -174,7 +210,7 @@
|
@@ -174,7 +211,7 @@
|
||||||
((Mob) entity).spawnAnim();
|
((Mob) entity).spawnAnim();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,7 +109,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -202,7 +238,13 @@
|
@@ -202,7 +239,13 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public void load(@Nullable Level world, BlockPos pos, CompoundTag nbt) {
|
public void load(@Nullable Level world, BlockPos pos, CompoundTag nbt) {
|
||||||
@@ -122,7 +123,7 @@
|
|||||||
boolean flag = nbt.contains("SpawnData", 10);
|
boolean flag = nbt.contains("SpawnData", 10);
|
||||||
|
|
||||||
if (flag) {
|
if (flag) {
|
||||||
@@ -225,9 +267,15 @@
|
@@ -225,9 +268,15 @@
|
||||||
this.spawnPotentials = SimpleWeightedRandomList.single(this.nextSpawnData != null ? this.nextSpawnData : new SpawnData());
|
this.spawnPotentials = SimpleWeightedRandomList.single(this.nextSpawnData != null ? this.nextSpawnData : new SpawnData());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -140,7 +141,7 @@
|
|||||||
this.spawnCount = nbt.getShort("SpawnCount");
|
this.spawnCount = nbt.getShort("SpawnCount");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -244,9 +292,20 @@
|
@@ -244,9 +293,20 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public CompoundTag save(CompoundTag nbt) {
|
public CompoundTag save(CompoundTag nbt) {
|
||||||
|
Reference in New Issue
Block a user