Halloween options and optimizations

This commit is contained in:
DoctaEnkoda
2025-01-12 12:55:33 -08:00
committed by granny
parent 1fcef85969
commit e3828b3f5d
5 changed files with 56 additions and 83 deletions

View File

@@ -0,0 +1,23 @@
--- a/net/minecraft/world/entity/ambient/Bat.java
+++ b/net/minecraft/world/entity/ambient/Bat.java
@@ -231,7 +_,7 @@
} else {
int maxLocalRawBrightness = level.getMaxLocalRawBrightness(pos);
int i = 4;
- if (isHalloween()) {
+ if (Bat.isHalloweenSeason(level.getMinecraftWorld())) { // Purpur - Halloween options and optimizations
i = 7;
} else if (randomSource.nextBoolean()) {
return false;
@@ -243,6 +_,11 @@
}
}
+ // Pufferfish start - only check for spooky season once an hour
+ //private static boolean isSpookySeason = false;
+ //private static final int ONE_HOUR = 20 * 60 * 60;
+ //private static int lastSpookyCheck = -ONE_HOUR;
+ public static boolean isHalloweenSeason(Level level) { return level.purpurConfig.forceHalloweenSeason || isHalloween(); } // Purpur - Halloween options and optimizations
private static boolean isHalloween() {
LocalDate localDate = LocalDate.now();
int i = localDate.get(ChronoField.DAY_OF_MONTH);

View File

@@ -0,0 +1,14 @@
--- a/net/minecraft/world/entity/monster/AbstractSkeleton.java
+++ b/net/minecraft/world/entity/monster/AbstractSkeleton.java
@@ -158,10 +_,7 @@
this.reassessWeaponGoal();
this.setCanPickUpLoot(this.level().paperConfig().entities.behavior.mobsCanAlwaysPickUpLoot.skeletons || random.nextFloat() < 0.55F * difficulty.getSpecialMultiplier()); // Paper - Add world settings for mobs picking up loot
if (this.getItemBySlot(EquipmentSlot.HEAD).isEmpty()) {
- LocalDate localDate = LocalDate.now();
- int i = localDate.get(ChronoField.DAY_OF_MONTH);
- int i1 = localDate.get(ChronoField.MONTH_OF_YEAR);
- if (i1 == 10 && i == 31 && random.nextFloat() < 0.25F) {
+ if (net.minecraft.world.entity.ambient.Bat.isHalloweenSeason(level.getMinecraftWorld()) && this.random.nextFloat() < this.level().purpurConfig.chanceHeadHalloweenOnEntity) { // Purpur - Halloween options and optimizations
this.setItemSlot(EquipmentSlot.HEAD, new ItemStack(random.nextFloat() < 0.1F ? Blocks.JACK_O_LANTERN : Blocks.CARVED_PUMPKIN));
this.armorDropChances[EquipmentSlot.HEAD.getIndex()] = 0.0F;
}

View File

@@ -21,3 +21,15 @@
this.targetSelector.addGoal(3, new NearestAttackableTargetGoal<>(this, IronGolem.class, true));
this.targetSelector.addGoal(5, new NearestAttackableTargetGoal<>(this, Turtle.class, 10, true, false, Turtle.BABY_ON_LAND_SELECTOR));
}
@@ -550,10 +_,7 @@
}
if (this.getItemBySlot(EquipmentSlot.HEAD).isEmpty()) {
- LocalDate localDate = LocalDate.now();
- int i = localDate.get(ChronoField.DAY_OF_MONTH);
- int i1 = localDate.get(ChronoField.MONTH_OF_YEAR);
- if (i1 == 10 && i == 31 && random.nextFloat() < 0.25F) {
+ if (net.minecraft.world.entity.ambient.Bat.isHalloweenSeason(level.getMinecraftWorld()) && this.random.nextFloat() < this.level().purpurConfig.chanceHeadHalloweenOnEntity) { // Purpur - Halloween options and optimizations
this.setItemSlot(EquipmentSlot.HEAD, new ItemStack(random.nextFloat() < 0.1F ? Blocks.JACK_O_LANTERN : Blocks.CARVED_PUMPKIN));
this.armorDropChances[EquipmentSlot.HEAD.getIndex()] = 0.0F;
}

View File

@@ -1729,6 +1729,13 @@ public class PurpurWorldConfig {
guardianTakeDamageFromWater = getBoolean("mobs.guardian.takes-damage-from-water", guardianTakeDamageFromWater);
}
public boolean forceHalloweenSeason = false;
public float chanceHeadHalloweenOnEntity = 0.25F;
private void halloweenSetting() {
forceHalloweenSeason = getBoolean("gameplay-mechanics.halloween.force", forceHalloweenSeason);
chanceHeadHalloweenOnEntity = (float) getDouble("gameplay-mechanics.halloween.head-chance", chanceHeadHalloweenOnEntity);
}
public boolean hoglinRidable = false;
public boolean hoglinRidableInWater = true;
public boolean hoglinControllable = true;