Merge pull request #30 from xsmeths/development

fix for continuous egg entity spawn causing infinite chickens
This commit is contained in:
Christian Koop 2024-04-12 09:27:25 +02:00 committed by GitHub
commit 965d3deab2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 14 additions and 4 deletions

View File

@ -208,7 +208,7 @@ public class BlockListeners implements Listener {
try {
creatureSpawner.setSpawnedType(spawnerTier.getEntities().get(0));
} catch (Exception ex) {
creatureSpawner.setSpawnedType(ServerVersion.isServerVersionAtLeast(ServerVersion.V1_9) ? EntityType.EGG : EntityType.DROPPED_ITEM);
creatureSpawner.setSpawnedType(ServerVersion.isServerVersionBelow(ServerVersion.V1_9) ? EntityType.EGG : EntityType.DROPPED_ITEM);
}
spawner.updateDelay();

View File

@ -1,5 +1,6 @@
package com.craftaro.epicspawners.spawners.spawner;
import com.craftaro.core.compatibility.ServerVersion;
import com.craftaro.third_party.com.cryptomorin.xseries.XMaterial;
import com.craftaro.epicspawners.api.spawners.spawner.SpawnerData;
import com.craftaro.epicspawners.api.spawners.spawner.SpawnerTier;
@ -238,7 +239,11 @@ public class SpawnerDataImpl implements SpawnerData {
public void addDefaultTier() {
SpawnerTier tier = new SpawnerTierImpl(this);
tier.addCondition(new SpawnConditionNearbyPlayers(16, 1));
tier.addCondition(new SpawnConditionHeight(0, 265));
if (ServerVersion.isServerVersionBelow(ServerVersion.V1_17)) {
tier.addCondition(new SpawnConditionHeight(0, 265));
} else {
tier.addCondition(new SpawnConditionHeight(-64, 320));
}
tier.addCondition(new SpawnConditionBiome(Biome.values()));
tier.addCondition(new SpawnConditionLightDark(SpawnConditionLightDark.Type.BOTH));
tier.addCondition(new SpawnConditionStorm(false));

View File

@ -1,6 +1,7 @@
package com.craftaro.epicspawners.spawners.spawner;
import com.craftaro.core.compatibility.CompatibleBiome;
import com.craftaro.core.compatibility.ServerVersion;
import com.craftaro.core.configuration.Config;
import com.craftaro.third_party.com.cryptomorin.xseries.XMaterial;
import com.craftaro.core.third_party.de.tr7zw.nbtapi.NBTItem;
@ -262,7 +263,11 @@ public class SpawnerManagerImpl implements SpawnerManager {
} else {
tier.addCondition(new SpawnConditionBiome(Biome.values()));
// TODO: These values should probably be *world* dependent as even in older versions, the max build height could be higher (vanilla spawners probably work up there too?)
tier.addCondition(new SpawnConditionHeight(-64, 320));
if (ServerVersion.isServerVersionBelow(ServerVersion.V1_17)) {
tier.addCondition(new SpawnConditionHeight(0, 265));
} else {
tier.addCondition(new SpawnConditionHeight(-64, 320));
}
}
if (Monster.class.isAssignableFrom(type.getEntityClass())) {
tier.addCondition(new SpawnConditionLightDark(SpawnConditionLightDark.Type.DARK));

View File

@ -120,7 +120,7 @@ public class AppearanceTask extends BukkitRunnable {
EntityType next = spawnerTier.getEntities().get(0);
spawner.getCreatureSpawner().setSpawnedType(next);
} catch (Exception failure) {
spawner.getCreatureSpawner().setSpawnedType(ServerVersion.isServerVersionAtLeast(ServerVersion.V1_9) ? EntityType.EGG : EntityType.DROPPED_ITEM);
spawner.getCreatureSpawner().setSpawnedType(ServerVersion.isServerVersionBelow(ServerVersion.V1_9) ? EntityType.EGG : EntityType.DROPPED_ITEM);
if (itemStack.getType() == Material.AIR) {
return;
}