From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: DoctaEnkoda Date: Fri, 7 May 2021 03:35:42 +0200 Subject: [PATCH] Extend Halloween Optimization diff --git a/src/main/java/net/minecraft/world/entity/ambient/EntityBat.java b/src/main/java/net/minecraft/world/entity/ambient/EntityBat.java index bd02320d450a7fd7254f01b1c44ef421c1810ea7..33f380c543677b5a382d1e9163cd0bbd3585be4b 100644 --- a/src/main/java/net/minecraft/world/entity/ambient/EntityBat.java +++ b/src/main/java/net/minecraft/world/entity/ambient/EntityBat.java @@ -311,17 +311,31 @@ public class EntityBat extends EntityAmbient { private static boolean isSpookySeason = false; private static final int ONE_HOUR = 20 * 60 * 60; private static int lastSpookyCheck = -ONE_HOUR; - private static boolean eJ() { + // Purpur start + private static boolean isHalloween = false; + private static boolean eJ() { return isSpookySeason(); } + + public static boolean isSpookySeason() { + checkSeason(); + return isSpookySeason; + } + + public static boolean isHalloween() { + checkSeason(); + return isHalloween; + } + + public static void checkSeason() { if (MinecraftServer.currentTick - lastSpookyCheck > ONE_HOUR) { - LocalDate localdate = LocalDate.now(); - int i = localdate.get(ChronoField.DAY_OF_MONTH); - int j = localdate.get(ChronoField.MONTH_OF_YEAR); - isSpookySeason = j == 10 && i >= 20 || j == 11 && i <= 3; + LocalDate localdate = LocalDate.now(); + int day = localdate.get(ChronoField.DAY_OF_MONTH); + int month = localdate.get(ChronoField.MONTH_OF_YEAR); + isHalloween = month == 10 && day == 31; // Purpur + isSpookySeason = month == 10 && day >= 20 || month == 11 && day <= 3; lastSpookyCheck = MinecraftServer.currentTick; } - - return isSpookySeason; } + // Purpur end // Airplane end @Override diff --git a/src/main/java/net/minecraft/world/entity/monster/EntitySkeletonAbstract.java b/src/main/java/net/minecraft/world/entity/monster/EntitySkeletonAbstract.java index 81059fc3fc22f251b5b08f0cd6814a992cff6b1e..f4c5c7995247b182d01d9232c8060d9fdb97c0a1 100644 --- a/src/main/java/net/minecraft/world/entity/monster/EntitySkeletonAbstract.java +++ b/src/main/java/net/minecraft/world/entity/monster/EntitySkeletonAbstract.java @@ -160,11 +160,7 @@ public abstract class EntitySkeletonAbstract extends EntityMonster implements IR this.eL(); this.setCanPickupLoot(this.world.paperConfig.skeletonsAlwaysCanPickUpLoot || this.random.nextFloat() < 0.55F * difficultydamagescaler.d()); // Paper if (this.getEquipment(EnumItemSlot.HEAD).isEmpty()) { - LocalDate localdate = LocalDate.now(); - int i = localdate.get(ChronoField.DAY_OF_MONTH); - int j = localdate.get(ChronoField.MONTH_OF_YEAR); - - if (j == 10 && i == 31 && this.random.nextFloat() < 0.25F) { + if (net.minecraft.world.entity.ambient.EntityBat.isHalloween() && this.random.nextFloat() < 0.25F) { // Purpur this.setSlot(EnumItemSlot.HEAD, new ItemStack(this.random.nextFloat() < 0.1F ? Blocks.JACK_O_LANTERN : Blocks.CARVED_PUMPKIN)); this.dropChanceArmor[EnumItemSlot.HEAD.b()] = 0.0F; } diff --git a/src/main/java/net/minecraft/world/entity/monster/EntityZombie.java b/src/main/java/net/minecraft/world/entity/monster/EntityZombie.java index 7112db516e62ca75a445482005c524129b84f54c..ef8f6b442304285e2b398c9143e9e98e29330220 100644 --- a/src/main/java/net/minecraft/world/entity/monster/EntityZombie.java +++ b/src/main/java/net/minecraft/world/entity/monster/EntityZombie.java @@ -585,11 +585,7 @@ public class EntityZombie extends EntityMonster { } if (this.getEquipment(EnumItemSlot.HEAD).isEmpty()) { - LocalDate localdate = LocalDate.now(); - int i = localdate.get(ChronoField.DAY_OF_MONTH); - int j = localdate.get(ChronoField.MONTH_OF_YEAR); - - if (j == 10 && i == 31 && this.random.nextFloat() < 0.25F) { + if (net.minecraft.world.entity.ambient.EntityBat.isHalloween() && this.random.nextFloat() < 0.25F) { // Purpur this.setSlot(EnumItemSlot.HEAD, new ItemStack(this.random.nextFloat() < 0.1F ? Blocks.JACK_O_LANTERN : Blocks.CARVED_PUMPKIN)); this.dropChanceArmor[EnumItemSlot.HEAD.b()] = 0.0F; }