diff --git a/patches/server/0030-Reduce-Sensor-Work.patch b/patches/server/0030-Reduce-Sensor-Work.patch new file mode 100644 index 0000000..2041e86 --- /dev/null +++ b/patches/server/0030-Reduce-Sensor-Work.patch @@ -0,0 +1,38 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: IPECTER +Date: Wed, 3 May 2023 16:51:49 +0900 +Subject: [PATCH] Reduce Sensor Work + +Original: Bloom-host/Petal +Copyright (C) 2023 peaches94 + +diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java +index b67660cda74a4754d1701e746aca99bde868c150..8dcc8ea2450ee14880e2ffff0f013ccee9b33e2f 100644 +--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java ++++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java +@@ -1020,20 +1020,20 @@ public abstract class LivingEntity extends Entity implements Attackable { + } + + if (entity != null) { +- ItemStack itemstack = this.getItemBySlot(EquipmentSlot.HEAD); ++ // ItemStack itemstack = this.getItemBySlot(EquipmentSlot.HEAD); // Plazma - check head itemstack only when needed + EntityType entitytypes = entity.getType(); + + // Purpur start +- if (entitytypes == EntityType.SKELETON && itemstack.is(Items.SKELETON_SKULL)) { ++ if (entitytypes == EntityType.SKELETON && this.getItemBySlot(EquipmentSlot.HEAD).is(Items.SKELETON_SKULL)) { // Plazma + d0 *= entity.level.purpurConfig.skeletonHeadVisibilityPercent; + } +- else if (entitytypes == EntityType.ZOMBIE && itemstack.is(Items.ZOMBIE_HEAD)) { ++ else if (entitytypes == EntityType.ZOMBIE && this.getItemBySlot(EquipmentSlot.HEAD).is(Items.ZOMBIE_HEAD)) { // Plazma + d0 *= entity.level.purpurConfig.zombieHeadVisibilityPercent; + } +- else if (entitytypes == EntityType.CREEPER && itemstack.is(Items.CREEPER_HEAD)) { ++ else if (entitytypes == EntityType.CREEPER && this.getItemBySlot(EquipmentSlot.HEAD).is(Items.CREEPER_HEAD)) { // Plazma + d0 *= entity.level.purpurConfig.creeperHeadVisibilityPercent; + } +- else if ((entitytypes == EntityType.PIGLIN || entitytypes == EntityType.PIGLIN_BRUTE) && itemstack.is(Items.PIGLIN_HEAD)) { ++ else if ((entitytypes == EntityType.PIGLIN || entitytypes == EntityType.PIGLIN_BRUTE) && this.getItemBySlot(EquipmentSlot.HEAD).is(Items.PIGLIN_HEAD)) { // Plazma + d0 *= entity.level.purpurConfig.piglinHeadVisibilityPercent; + } + // Purpur end diff --git a/patches/server/0031-Configurable-Sensor-Tick.patch b/patches/server/0031-Configurable-Sensor-Tick.patch new file mode 100644 index 0000000..d905013 --- /dev/null +++ b/patches/server/0031-Configurable-Sensor-Tick.patch @@ -0,0 +1,42 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: IPECTER +Date: Wed, 3 May 2023 16:51:49 +0900 +Subject: [PATCH] Configurable Sensor Tick + +Original: Bloom-host/Petal +Copyright (C) 2023 peaches94 + +diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java +index 8e2274f7dce34e0997356205cf96e46f8d41cca1..3a365d7efd439cb8ddb99381bd714fb48896f4d2 100644 +--- a/src/main/java/net/minecraft/world/entity/Mob.java ++++ b/src/main/java/net/minecraft/world/entity/Mob.java +@@ -932,10 +932,10 @@ public abstract class Mob extends LivingEntity implements Targeting { + } + // Paper end + //this.level.getProfiler().push("sensing"); // Purpur +- this.sensing.tick(); ++ // Plazma - Configurable Sensor Tick + //this.level.getProfiler().pop(); // Purpur + int i = this.level.getServer().getTickCount() + this.getId(); +- ++ if (i % this.level.plazmaLevelConfiguration().entity.sensor.tick == 0) this.sensing.tick(); // Plazma - Configurable Sensor Tick + if (i % 2 != 0 && this.tickCount > 1) { + //this.level.getProfiler().push("targetSelector"); // Purpur + if (this.targetSelector.inactiveTick(this.activatedPriority, false)) // Pufferfish - use this to alternate ticking +diff --git a/src/main/java/org/plazmamc/plazma/configurations/LevelConfigurations.java b/src/main/java/org/plazmamc/plazma/configurations/LevelConfigurations.java +index e6c22ab535ab8fecaadbf06d4982440fd5863f17..185e2627596314d979188468f838d008442f2d2e 100644 +--- a/src/main/java/org/plazmamc/plazma/configurations/LevelConfigurations.java ++++ b/src/main/java/org/plazmamc/plazma/configurations/LevelConfigurations.java +@@ -107,5 +107,12 @@ public class LevelConfigurations extends ConfigurationPart { + + } + ++ public Sensor sensor; ++ public class Sensor extends ConfigurationPart { ++ ++ public int tick = DO_OPTIMIZE ? 10 : 1; ++ ++ } ++ + } + } diff --git a/patches/server/0032-Optimize-VarInts.patch b/patches/server/0032-Optimize-VarInts.patch new file mode 100644 index 0000000..3997c2e --- /dev/null +++ b/patches/server/0032-Optimize-VarInts.patch @@ -0,0 +1,70 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: IPECTER +Date: Thu, 4 May 2023 16:54:53 +0900 +Subject: [PATCH] Optimize VarInts + +https://github.com/PaperMC/Paper/pull/8418 + +diff --git a/src/main/java/net/minecraft/network/FriendlyByteBuf.java b/src/main/java/net/minecraft/network/FriendlyByteBuf.java +index c0bd2997fe3ebbfe926de832a36d209cc875f3e2..6108f3aa438b96e817c3a2e582c2c817f096e2eb 100644 +--- a/src/main/java/net/minecraft/network/FriendlyByteBuf.java ++++ b/src/main/java/net/minecraft/network/FriendlyByteBuf.java +@@ -104,7 +104,20 @@ public class FriendlyByteBuf extends ByteBuf { + this.source = parent; + } + ++ // Plazma start - Optimize VarInts ++ private static final int[] VARINT_EXACT_BYTE_LENGTHS = new int[33]; ++ static { ++ for (int i = 0; i <= 32; ++i) { ++ VARINT_EXACT_BYTE_LENGTHS[i] = (int) Math.ceil((31d - (i - 1)) / 7d); ++ } ++ VARINT_EXACT_BYTE_LENGTHS[32] = 1; // Special case for the number 0. ++ } ++ // Plazma end + public static int getVarIntSize(int value) { ++ // Plazma start - Optimize VarInts ++ if (org.plazmamc.plazma.configurations.GlobalConfiguration.get().misc.optimizeVarInts) ++ return VARINT_EXACT_BYTE_LENGTHS[Integer.numberOfLeadingZeros(value)]; ++ // Plazma end + for (int j = 1; j < 5; ++j) { + if ((value & -1 << j * 7) == 0) { + return j; +@@ -620,6 +633,25 @@ public class FriendlyByteBuf extends ByteBuf { + } + + public FriendlyByteBuf writeVarInt(int value) { ++ // Plazma start - Optimize VarInts ++ if (org.plazmamc.plazma.configurations.GlobalConfiguration.get().misc.optimizeVarInts) { ++ // Peel the one and two byte count cases explicitly as they are the most common VarInt sizes ++ // that the proxy will write, to improve inlining. ++ if ((value & (0xFFFFFFFF << 7)) == 0) { ++ writeByte(value); ++ } else if ((value & (0xFFFFFFFF << 14)) == 0) { ++ int w = (value & 0x7F | 0x80) << 8 | (value >>> 7); ++ writeShort(w); ++ } else { ++ while ((value & -128) != 0) { ++ this.writeByte(value & 127 | 128); ++ value >>>= 7; ++ } ++ this.writeByte(value); ++ } ++ return this; ++ } ++ // Plazma end + while ((value & -128) != 0) { + this.writeByte(value & 127 | 128); + value >>>= 7; +diff --git a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java +index 39eca4acefa8f9cf143398cfc6cf157e8489947e..754ed13a04631c69e3fb2421a12b17d0a6f732c6 100644 +--- a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java ++++ b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java +@@ -42,6 +42,7 @@ public class GlobalConfiguration extends ConfigurationPart { + public boolean reduceCreateRandomInstance = DO_OPTIMIZE; + public boolean doNotTriggerLootTableRefreshForNonPlayerInteraction = DO_OPTIMIZE; + public boolean doNotSendUselessEntityPackets = DO_OPTIMIZE; ++ public boolean optimizeVarInts = DO_OPTIMIZE; + + } + diff --git a/patches/server/0033-Variable-Entity-WakeUp-Duration.patch b/patches/server/0033-Variable-Entity-WakeUp-Duration.patch new file mode 100644 index 0000000..f09cdd6 --- /dev/null +++ b/patches/server/0033-Variable-Entity-WakeUp-Duration.patch @@ -0,0 +1,78 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: IPECTER +Date: Sat, 6 May 2023 21:09:45 +0900 +Subject: [PATCH] Variable-Entity-WakeUp-Duration + +Original: GaleMC/Gale +Copyright (C) 2023 Martijn Muijsers + +diff --git a/src/main/java/org/plazmamc/plazma/configurations/LevelConfigurations.java b/src/main/java/org/plazmamc/plazma/configurations/LevelConfigurations.java +index 185e2627596314d979188468f838d008442f2d2e..238e10a35a9e4b300b11c838cda39b8799f16fe2 100644 +--- a/src/main/java/org/plazmamc/plazma/configurations/LevelConfigurations.java ++++ b/src/main/java/org/plazmamc/plazma/configurations/LevelConfigurations.java +@@ -114,5 +114,20 @@ public class LevelConfigurations extends ConfigurationPart { + + } + ++ public WakeUp wakeUp; ++ public class WakeUp extends ConfigurationPart { ++ ++ public DurationVariance durationVariance; ++ public class DurationVariance extends ConfigurationPart { ++ ++ public double animal = DO_OPTIMIZE ? 0.2 : 0.0; ++ public double monster = DO_OPTIMIZE ? 0.2 : 0.0; ++ public double flyingMonster = DO_OPTIMIZE ? 0.2 : 0.0; ++ public double villager = DO_OPTIMIZE ? 0.2 : 0.0; ++ ++ } ++ ++ } ++ + } + } +diff --git a/src/main/java/org/spigotmc/ActivationRange.java b/src/main/java/org/spigotmc/ActivationRange.java +index ee64ddb0da23ea1e54d0295324aca5b46a438111..d5230a360cd8c296303b494d716d33ad1fca6a96 100644 +--- a/src/main/java/org/spigotmc/ActivationRange.java ++++ b/src/main/java/org/spigotmc/ActivationRange.java +@@ -75,28 +75,36 @@ public class ActivationRange + if (entity.activationType == ActivationType.VILLAGER) { + if (inactiveFor > config.wakeUpInactiveVillagersEvery && world.wakeupInactiveRemainingVillagers > 0) { + world.wakeupInactiveRemainingVillagers--; +- return config.wakeUpInactiveVillagersFor; ++ return getWakeUpDurationWithVariance(config.wakeUpInactiveVillagersFor, entity.level.plazmaLevelConfiguration().entity.wakeUp.durationVariance.villager); // Plazma - Variable Entity WakeUp Duration + } + } else if (entity.activationType == ActivationType.ANIMAL) { + if (inactiveFor > config.wakeUpInactiveAnimalsEvery && world.wakeupInactiveRemainingAnimals > 0) { + world.wakeupInactiveRemainingAnimals--; +- return config.wakeUpInactiveAnimalsFor; ++ return getWakeUpDurationWithVariance(config.wakeUpInactiveAnimalsFor, entity.level.plazmaLevelConfiguration().entity.wakeUp.durationVariance.animal); // Plazma - Variable Entity WakeUp Duration + } + } else if (entity.activationType == ActivationType.FLYING_MONSTER) { + if (inactiveFor > config.wakeUpInactiveFlyingEvery && world.wakeupInactiveRemainingFlying > 0) { + world.wakeupInactiveRemainingFlying--; +- return config.wakeUpInactiveFlyingFor; ++ return getWakeUpDurationWithVariance(config.wakeUpInactiveFlyingFor, entity.level.plazmaLevelConfiguration().entity.wakeUp.durationVariance.flyingMonster); // Plazma - Variable Entity WakeUp Duration + } + } else if (entity.activationType == ActivationType.MONSTER || entity.activationType == ActivationType.RAIDER) { + if (inactiveFor > config.wakeUpInactiveMonstersEvery && world.wakeupInactiveRemainingMonsters > 0) { + world.wakeupInactiveRemainingMonsters--; +- return config.wakeUpInactiveMonstersFor; ++ return getWakeUpDurationWithVariance(config.wakeUpInactiveMonstersFor, entity.level.plazmaLevelConfiguration().entity.wakeUp.durationVariance.monster); // Plazma - Variable Entity WakeUp Duration + } + } + return -1; + } + // Paper end + ++ // Plazma start - Variable Entity WakeUp Duration ++ private static final java.util.Random wakeUpDurationRandom = new java.util.Random(); ++ private static int getWakeUpDurationWithVariance(int wakeUpDuration, double deviation) { ++ if (deviation <= 0) return wakeUpDuration; ++ return (int) Math.min(Integer.MAX_VALUE, Math.max(1, Math.round(wakeUpDuration * wakeUpDurationRandom.nextGaussian(1, deviation)))); ++ } ++ // Plazma end ++ + static AABB maxBB = new AABB( 0, 0, 0, 0, 0, 0 ); + + /**