Skip to content

Commit

Permalink
Revert light level 0 behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
Roadhog360 committed Feb 14, 2024
1 parent 7e8d829 commit e9b1ca1
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ public class ConfigEntities extends ConfigBase {
public static boolean enableNetherEndermen;
public static boolean enableShearableSnowGolems;
public static boolean enableBees;
public static boolean enableLightLevel0;

static final String catHostile = "hostile";
static final String catNeutral = "neutral";
Expand Down Expand Up @@ -64,7 +63,6 @@ protected void syncConfigOptions() {
enableVillagerTurnsIntoWitch = getBoolean("enableVillagerTurnsIntoWitch", catMisc, true, "Villagers turn into Witches when struck by lightning");
enableDragonRespawn = getBoolean("enableDragonRespawn", catMisc, true, "Crude implementation of respawning the dragon using four End crystals.");
enableNetherEndermen = getBoolean("enableNetherEndermen", catMisc, true, "Allow endermen to rarely spawn in the Nether");
enableLightLevel0 = getBoolean("enableLightLevel0", catMisc, true, "Reduces the required light level for hostile mobs to spawn to light level 0, like in Minecraft 1.18+.");
}

}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package ganymedes01.etfuturum.core.handlers;

import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.eventhandler.Event.Result;
import cpw.mods.fml.common.eventhandler.EventPriority;
Expand Down Expand Up @@ -76,7 +75,6 @@
import net.minecraft.world.World;
import net.minecraft.world.WorldProviderHell;
import net.minecraft.world.WorldServer;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.gen.ChunkProviderServer;
Expand Down Expand Up @@ -1360,13 +1358,6 @@ public void spawnEvent(LivingSpawnEvent.CheckSpawn event) {
int y = MathHelper.floor_double(event.y);
int z = MathHelper.floor_double(event.z);

if (ConfigEntities.enableLightLevel0 && (event.entityLiving instanceof IMob || getSpawnTypes(event.entityLiving).contains(EnumCreatureType.monster))) {
if (event.entityLiving.worldObj.getBlockLightValue(x, y, z) > 0) {
event.setResult(Result.DENY);
return;
}
}

if (event.world.provider instanceof WorldProviderHell) {
if (world.getBlock(x, y - 1, z) == ModBlocks.NETHER_WART.get() && world.getBlockMetadata(x, y - 1, z) == 0) {
if (!(event.entity instanceof EntityFlying)) {
Expand All @@ -1377,39 +1368,6 @@ public void spawnEvent(LivingSpawnEvent.CheckSpawn event) {
}
}

private static final Map<Class, List<EnumCreatureType>> typesMap = Maps.newHashMap();

@SuppressWarnings("unchecked")
/**
* Checks the spawn types the mob comes from. Used by the light level 0 monster spawning in case the monster isn't instance of IMob but is still being spawned as one.
* Derived from CoreTweaks
* @author makamys
*/
private static List<EnumCreatureType> getSpawnTypes(Entity entity) {
List<EnumCreatureType> list = typesMap.get(entity.getClass());
if (list == null) {
list = Lists.newArrayList();
for (BiomeGenBase biome : BiomeGenBase.getBiomeGenArray()) {
if (biome != null) {
for (EnumCreatureType type : EnumCreatureType.values()) {
if (list.contains(type)) continue;
List<BiomeGenBase.SpawnListEntry> spawnableList = biome.getSpawnableList(type);
if (spawnableList != null) {
for (BiomeGenBase.SpawnListEntry entry : spawnableList) {
if (entry.entityClass == entity.getClass()) {
list.add(type);
break;
}
}
}
}
}
}
typesMap.put(entity.getClass(), list);
}
return list;
}

@SubscribeEvent
public void spawnEvent(EntityJoinWorldEvent event) {
int x = MathHelper.floor_double(event.entity.posX);
Expand Down

0 comments on commit e9b1ca1

Please sign in to comment.