From f83dbd0bf8df6b957e97ac2e5605d442af5f67ec Mon Sep 17 00:00:00 2001 From: Pilzinsel64 Date: Thu, 8 Feb 2024 11:26:57 +0100 Subject: [PATCH 1/3] set light level to 0 for mobs --- .../configuration/configs/ConfigEntities.java | 2 ++ .../etfuturum/core/handlers/ServerEventHandler.java | 13 +++++++++++++ 2 files changed, 15 insertions(+) diff --git a/src/main/java/ganymedes01/etfuturum/configuration/configs/ConfigEntities.java b/src/main/java/ganymedes01/etfuturum/configuration/configs/ConfigEntities.java index 703fa5c24..a2d1b3f5a 100644 --- a/src/main/java/ganymedes01/etfuturum/configuration/configs/ConfigEntities.java +++ b/src/main/java/ganymedes01/etfuturum/configuration/configs/ConfigEntities.java @@ -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"; @@ -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+."); } } diff --git a/src/main/java/ganymedes01/etfuturum/core/handlers/ServerEventHandler.java b/src/main/java/ganymedes01/etfuturum/core/handlers/ServerEventHandler.java index bbff504b6..11025b924 100644 --- a/src/main/java/ganymedes01/etfuturum/core/handlers/ServerEventHandler.java +++ b/src/main/java/ganymedes01/etfuturum/core/handlers/ServerEventHandler.java @@ -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; From 87b40ae247d32bb10091dfac462773def9fed48b Mon Sep 17 00:00:00 2001 From: Pascal Date: Thu, 8 Feb 2024 12:26:52 +0100 Subject: [PATCH 2/3] Fix typo in config description Co-authored-by: makamys --- .../etfuturum/configuration/configs/ConfigEntities.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/ganymedes01/etfuturum/configuration/configs/ConfigEntities.java b/src/main/java/ganymedes01/etfuturum/configuration/configs/ConfigEntities.java index a2d1b3f5a..30aea262f 100644 --- a/src/main/java/ganymedes01/etfuturum/configuration/configs/ConfigEntities.java +++ b/src/main/java/ganymedes01/etfuturum/configuration/configs/ConfigEntities.java @@ -64,7 +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+."); + enableLightLevel0 = getBoolean("enableLightLevel0", catMisc, false, "This config reduces the required light level for mobs to spawn to light level 0, like in Minecraft 1.18+."); } } From 15ada4398cba3738fb84d5f4eaeb50c2891f7001 Mon Sep 17 00:00:00 2001 From: Pilzinsel64 Date: Thu, 8 Feb 2024 12:36:30 +0100 Subject: [PATCH 3/3] fix weird spaces --- .../etfuturum/core/handlers/ServerEventHandler.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/ganymedes01/etfuturum/core/handlers/ServerEventHandler.java b/src/main/java/ganymedes01/etfuturum/core/handlers/ServerEventHandler.java index 11025b924..697649de7 100644 --- a/src/main/java/ganymedes01/etfuturum/core/handlers/ServerEventHandler.java +++ b/src/main/java/ganymedes01/etfuturum/core/handlers/ServerEventHandler.java @@ -1959,12 +1959,12 @@ public void onWorldLoad(WorldEvent.Load e) { 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); - } + 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); + } } }