Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport light level change from 1.18 #421

Merged
merged 4 commits into from
Feb 11, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -19,6 +19,7 @@ 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 @@ -63,6 +64,7 @@ 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, false, "This config reducec the required light level for mobs to spawn to light level 0, like in Minecraft 1.18+.");
Pilzinsel64 marked this conversation as resolved.
Show resolved Hide resolved
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -1955,6 +1955,19 @@ public void onWorldLoad(WorldEvent.Load e) {
e.world.getGameRules().addGameRule("disableElytraMovementCheck", "false");
}

@SubscribeEvent
public void onEntitySpawn(LivingSpawnEvent.CheckSpawn event) {
if (ConfigEntities.enableLightLevel0 && event.entityLiving instanceof IMob) {
int x = MathHelper.floor_double(event.entityLiving.posX);
int y = MathHelper.floor_double(event.entityLiving.boundingBox.minY);
int z = MathHelper.floor_double(event.entityLiving.posZ);

if (event.entityLiving.worldObj.getBlockLightValue(x, y, z) > 0) {
event.setResult(Result.DENY);
}
}
}

static MovingObjectPosition getMovingObjectPositionFromPlayer(World worldIn, EntityPlayer playerIn, boolean useLiquids) {
float f = 1.0F;
float f1 = playerIn.prevRotationPitch + (playerIn.rotationPitch - playerIn.prevRotationPitch) * f;
Expand Down