From 5efc27e3814f73f14bcef54af4da90e3829bdf0c Mon Sep 17 00:00:00 2001 From: AlphaKR93 Date: Wed, 27 Sep 2023 22:36:12 +0900 Subject: [PATCH] 56% Complete --- patches/api/0001-Pufferfish-API-Changes.patch | 2 +- patches/api/0002-Purpur-API-Changes.patch | 2 +- .../0001-Pufferfish-Server-Changes.patch | 2 +- .../server/0002-Purpur-Server-Changes.patch | 2 +- .../server/0006-Plazma-Configurations.patch | 11 +- ...0014-Configurable-nether-portal-size.patch | 4 +- .../0015-Reduce-create-random-instance.patch | 385 ++++++++++++++++++ .../0016-Apply-various-optimizations.patch | 32 ++ ...le-I-O-operation-on-load-player-file.patch | 29 ++ ...LootTable-for-non-player-interaction.patch | 30 ++ ...9-Don-t-load-chunks-to-spawn-phantom.patch | 36 ++ ...able-moved-to-quickly-check-for-spe.patch} | 35 +- .../0021-Use-faster-random.patch} | 66 +-- .../0022-Ignore-useless-entity-packets.patch | 52 +++ .../0020-Reduce-create-random-instance.patch | 176 -------- .../server/0021-Entity-Configuration.patch | 32 -- .../server/0022-Various-Optimizations.patch | 108 ----- ...5-Do-not-send-useless-entity-packets.patch | 52 --- 18 files changed, 631 insertions(+), 425 deletions(-) create mode 100644 patches/server/0015-Reduce-create-random-instance.patch create mode 100644 patches/server/0016-Apply-various-optimizations.patch create mode 100644 patches/server/0017-Avoid-double-I-O-operation-on-load-player-file.patch create mode 100644 patches/server/0018-Don-t-refresh-LootTable-for-non-player-interaction.patch create mode 100644 patches/server/0019-Don-t-load-chunks-to-spawn-phantom.patch rename patches/{unapplied/server/0023-Add-configuration-to-disable-moved-to-quickly-check-.patch => server/0020-Add-option-to-disable-moved-to-quickly-check-for-spe.patch} (51%) rename patches/{unapplied/server/0024-Apply-faster-random.patch => server/0021-Use-faster-random.patch} (86%) create mode 100644 patches/server/0022-Ignore-useless-entity-packets.patch delete mode 100644 patches/unapplied/server/0020-Reduce-create-random-instance.patch delete mode 100644 patches/unapplied/server/0021-Entity-Configuration.patch delete mode 100644 patches/unapplied/server/0022-Various-Optimizations.patch delete mode 100644 patches/unapplied/server/0025-Do-not-send-useless-entity-packets.patch diff --git a/patches/api/0001-Pufferfish-API-Changes.patch b/patches/api/0001-Pufferfish-API-Changes.patch index f7d6ad4a7..15cb12422 100644 --- a/patches/api/0001-Pufferfish-API-Changes.patch +++ b/patches/api/0001-Pufferfish-API-Changes.patch @@ -1,6 +1,6 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Kevin Raneri -Date: Wed, 27 Sep 2023 09:35:56 +0000 +Date: Wed, 27 Sep 2023 05:21:18 +0000 Subject: [PATCH] Pufferfish API Changes Original: Kevin Raneri diff --git a/patches/api/0002-Purpur-API-Changes.patch b/patches/api/0002-Purpur-API-Changes.patch index 37aa35984..82cd8684d 100644 --- a/patches/api/0002-Purpur-API-Changes.patch +++ b/patches/api/0002-Purpur-API-Changes.patch @@ -1,6 +1,6 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: William Blake Galbreath -Date: Wed, 27 Sep 2023 09:45:16 +0000 +Date: Wed, 27 Sep 2023 05:28:53 +0000 Subject: [PATCH] Purpur API Changes Original: PurpurMC diff --git a/patches/server/0001-Pufferfish-Server-Changes.patch b/patches/server/0001-Pufferfish-Server-Changes.patch index ce37c993a..18d3caf62 100644 --- a/patches/server/0001-Pufferfish-Server-Changes.patch +++ b/patches/server/0001-Pufferfish-Server-Changes.patch @@ -1,6 +1,6 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Kevin Raneri -Date: Wed, 27 Sep 2023 09:35:56 +0000 +Date: Wed, 27 Sep 2023 05:21:18 +0000 Subject: [PATCH] Pufferfish Server Changes Original: Kevin Raneri diff --git a/patches/server/0002-Purpur-Server-Changes.patch b/patches/server/0002-Purpur-Server-Changes.patch index 23b6f5957..2b99cc96a 100644 --- a/patches/server/0002-Purpur-Server-Changes.patch +++ b/patches/server/0002-Purpur-Server-Changes.patch @@ -1,6 +1,6 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: William Blake Galbreath -Date: Wed, 27 Sep 2023 09:45:16 +0000 +Date: Wed, 27 Sep 2023 05:28:53 +0000 Subject: [PATCH] Purpur Server Changes Original: PurpurMC diff --git a/patches/server/0006-Plazma-Configurations.patch b/patches/server/0006-Plazma-Configurations.patch index 8817b08d8..05e78bff3 100644 --- a/patches/server/0006-Plazma-Configurations.patch +++ b/patches/server/0006-Plazma-Configurations.patch @@ -617,10 +617,10 @@ index 0000000000000000000000000000000000000000..92524f24bdb56a861b06fffc900ff3c1 +} diff --git a/src/main/java/org/plazmamc/plazma/configurations/LevelConfigurations.java b/src/main/java/org/plazmamc/plazma/configurations/LevelConfigurations.java new file mode 100644 -index 0000000000000000000000000000000000000000..5e31a23ed4f31cc06562aa7814812242a04ee086 +index 0000000000000000000000000000000000000000..d990c031255daf0d43541efe175c5b52736a6990 --- /dev/null +++ b/src/main/java/org/plazmamc/plazma/configurations/LevelConfigurations.java -@@ -0,0 +1,40 @@ +@@ -0,0 +1,45 @@ +package org.plazmamc.plazma.configurations; + +import io.papermc.paper.configuration.Configuration; @@ -646,11 +646,16 @@ index 0000000000000000000000000000000000000000..5e31a23ed4f31cc06562aa7814812242 + @Setting(Configuration.VERSION_FIELD) + public int version = CURRENT_VERSION; + -+ public GlobalConfiguration.Misc misc; ++ public Misc misc; + public class Misc extends ConfigurationPart { + + } + ++ public Entity entity; ++ public class Entity extends ConfigurationPart { ++ ++ } ++ + public Structure structure; + public class Structure extends ConfigurationPart { + diff --git a/patches/server/0014-Configurable-nether-portal-size.patch b/patches/server/0014-Configurable-nether-portal-size.patch index 34dc49981..73e46ce22 100644 --- a/patches/server/0014-Configurable-nether-portal-size.patch +++ b/patches/server/0014-Configurable-nether-portal-size.patch @@ -37,10 +37,10 @@ index e7554ec800f321e4e34c926c53f2375a8c3aa979..c7f974e0b614afa1ced716ff7b6c67ee // CraftBukkit start - return boolean diff --git a/src/main/java/org/plazmamc/plazma/configurations/LevelConfigurations.java b/src/main/java/org/plazmamc/plazma/configurations/LevelConfigurations.java -index 5e31a23ed4f31cc06562aa7814812242a04ee086..0d4139ec1a34510bc8f96f2cbcb913626fd26b65 100644 +index d990c031255daf0d43541efe175c5b52736a6990..36c367c577e61422e51ab08c5aaa2a88c94e1636 100644 --- a/src/main/java/org/plazmamc/plazma/configurations/LevelConfigurations.java +++ b/src/main/java/org/plazmamc/plazma/configurations/LevelConfigurations.java -@@ -34,6 +34,27 @@ public class LevelConfigurations extends ConfigurationPart { +@@ -39,6 +39,27 @@ public class LevelConfigurations extends ConfigurationPart { public NetherPortal netherPortal; public class NetherPortal extends ConfigurationPart { diff --git a/patches/server/0015-Reduce-create-random-instance.patch b/patches/server/0015-Reduce-create-random-instance.patch new file mode 100644 index 000000000..f2196f4ad --- /dev/null +++ b/patches/server/0015-Reduce-create-random-instance.patch @@ -0,0 +1,385 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: AlphaKR93 +Date: Wed, 27 Sep 2023 21:18:22 +0900 +Subject: [PATCH] Reduce create random instance + + +diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java +index 44248dc470d0882b7287debd1993cedf0f238aca..ee571f465ca1e83e760a4d57b3d11accb53c6cfe 100644 +--- a/src/main/java/net/minecraft/server/MinecraftServer.java ++++ b/src/main/java/net/minecraft/server/MinecraftServer.java +@@ -228,7 +228,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop 2147483647L ? Integer.MAX_VALUE : (int) l; + int j1 = this.getCoprime(i1); +- int k1 = RandomSource.create().nextInt(i1); ++ int k1 = (worldserver.plazmaLevelConfiguration().misc.reduceCreateRandomInstance ? worldserver.getRandom() : RandomSource.create()).nextInt(i1); // Plazma - Reduce create random instance + + for (int l1 = 0; l1 < i1; ++l1) { + int i2 = (k1 + j1 * l1) % i1; +@@ -485,7 +485,7 @@ public class ServerPlayer extends Player { + long l = k * k; + int i1 = l > 2147483647L ? Integer.MAX_VALUE : (int) l; + int j1 = this.getCoprime(i1); +- int k1 = RandomSource.create().nextInt(i1); ++ int k1 = (world.plazmaLevelConfiguration().misc.reduceCreateRandomInstance ? world.getRandom() : RandomSource.create()).nextInt(i1); // Plazma - Reduce create random instance + + for (int l1 = 0; l1 < i1; ++l1) { + int i2 = (k1 + j1 * l1) % i1; +diff --git a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java +index d38685f82d2e6c4e71179bf3a85a8b183aa6c44b..1265e6a521222be0c957065f5b788d68cb3d863f 100644 +--- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java ++++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java +@@ -70,7 +70,7 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, + this.serverId = ""; + this.server = server; + this.connection = connection; +- this.challenge = Ints.toByteArray(RandomSource.create().nextInt()); ++ this.challenge = Ints.toByteArray((org.plazmamc.plazma.configurations.GlobalConfiguration.get().misc.reduceCreateRandomInstance ? server.getRandom() : RandomSource.create()).nextInt()); // Plazma - Reduce create random instance + } + + @Override +diff --git a/src/main/java/net/minecraft/server/rcon/thread/QueryThreadGs4.java b/src/main/java/net/minecraft/server/rcon/thread/QueryThreadGs4.java +index 1ef089dbf83de35d875c00efdf468c397be56978..7f4c0827d2269baa032dac4798fe6c2a740ba7fa 100644 +--- a/src/main/java/net/minecraft/server/rcon/thread/QueryThreadGs4.java ++++ b/src/main/java/net/minecraft/server/rcon/thread/QueryThreadGs4.java +@@ -349,7 +349,7 @@ public class QueryThreadGs4 extends GenericThread { + this.identBytes[2] = bs[5]; + this.identBytes[3] = bs[6]; + this.ident = new String(this.identBytes, StandardCharsets.UTF_8); +- this.challenge = RandomSource.create().nextInt(16777216); ++ this.challenge = (org.plazmamc.plazma.configurations.GlobalConfiguration.get().misc.reduceCreateRandomInstance ? net.minecraft.server.MinecraftServer.getServer().getRandom() : RandomSource.create()).nextInt(16777216); // Plazma - Reduce create random instance + this.challengeBytes = String.format(Locale.ROOT, "\t%s%d\u0000", this.ident, this.challenge).getBytes(StandardCharsets.UTF_8); + } + +diff --git a/src/main/java/net/minecraft/util/datafix/fixes/EntityZombieVillagerTypeFix.java b/src/main/java/net/minecraft/util/datafix/fixes/EntityZombieVillagerTypeFix.java +index 8311073e44ca8a2c8ac6f6864a875d6c90338664..8e488389b41c63809993262183204b77f73c0e55 100644 +--- a/src/main/java/net/minecraft/util/datafix/fixes/EntityZombieVillagerTypeFix.java ++++ b/src/main/java/net/minecraft/util/datafix/fixes/EntityZombieVillagerTypeFix.java +@@ -8,7 +8,7 @@ import net.minecraft.util.RandomSource; + + public class EntityZombieVillagerTypeFix extends NamedEntityFix { + private static final int PROFESSION_MAX = 6; +- private static final RandomSource RANDOM = RandomSource.create(); ++ private static final RandomSource RANDOM = org.plazmamc.plazma.PlazmaOptions.createNewRandom() ? RandomSource.create() : net.minecraft.server.MinecraftServer.getServer().getRandom(); // Plazma - Reduce create random source + + public EntityZombieVillagerTypeFix(Schema outputSchema, boolean changesType) { + super(outputSchema, changesType, "EntityZombieVillagerTypeFix", References.ENTITY, "Zombie"); +diff --git a/src/main/java/net/minecraft/world/entity/ai/behavior/ShufflingList.java b/src/main/java/net/minecraft/world/entity/ai/behavior/ShufflingList.java +index fe3ab3d388f0481fb0db06b7f730f868dbf8e8a5..265d8479b5c02994dba4288060b842789ebc7179 100644 +--- a/src/main/java/net/minecraft/world/entity/ai/behavior/ShufflingList.java ++++ b/src/main/java/net/minecraft/world/entity/ai/behavior/ShufflingList.java +@@ -15,7 +15,7 @@ import net.minecraft.util.RandomSource; + + public class ShufflingList implements Iterable { + public final List> entries; // Paper - public +- private final RandomSource random = RandomSource.create(); ++ private final RandomSource random = org.plazmamc.plazma.configurations.GlobalConfiguration.get().misc.reduceCreateRandomInstance ? net.minecraft.server.MinecraftServer.getServer().getRandom() : RandomSource.create(); // Plazma + private final boolean isUnsafe; // Paper + + public ShufflingList() { +diff --git a/src/main/java/net/minecraft/world/entity/ai/sensing/Sensor.java b/src/main/java/net/minecraft/world/entity/ai/sensing/Sensor.java +index 7094701d213c73ba47ace806962244c10fdf4dda..288ae299240c9626e576a7ae1c45c53d83f7f097 100644 +--- a/src/main/java/net/minecraft/world/entity/ai/sensing/Sensor.java ++++ b/src/main/java/net/minecraft/world/entity/ai/sensing/Sensor.java +@@ -8,7 +8,7 @@ import net.minecraft.world.entity.ai.memory.MemoryModuleType; + import net.minecraft.world.entity.ai.targeting.TargetingConditions; + + public abstract class Sensor { +- private static final RandomSource RANDOM = RandomSource.createThreadSafe(); ++ private static final RandomSource RANDOM = org.plazmamc.plazma.configurations.GlobalConfiguration.get().misc.reduceCreateRandomInstance && org.plazmamc.plazma.configurations.GlobalConfiguration.get().misc.suppressThreadSafeRandom ? net.minecraft.server.MinecraftServer.getServer().getRandom() : RandomSource.createThreadSafe(); // Plazma - Reduce create random instance + private static final int DEFAULT_SCAN_RATE = 20; + protected static final int TARGETING_RANGE = 16; + private static final TargetingConditions TARGET_CONDITIONS = TargetingConditions.forNonCombat().range(16.0D); +diff --git a/src/main/java/net/minecraft/world/entity/monster/warden/AngerManagement.java b/src/main/java/net/minecraft/world/entity/monster/warden/AngerManagement.java +index ece82743df21f0b776382821ad75dee96d0a0748..c25affe40eea32e1964aa4c62fdd27faa37baf28 100644 +--- a/src/main/java/net/minecraft/world/entity/monster/warden/AngerManagement.java ++++ b/src/main/java/net/minecraft/world/entity/monster/warden/AngerManagement.java +@@ -32,7 +32,7 @@ public class AngerManagement { + @VisibleForTesting + protected static final int MAX_ANGER = 150; + private static final int DEFAULT_ANGER_DECREASE = 1; +- private int conversionDelay = Mth.randomBetweenInclusive(RandomSource.create(), 0, 2); ++ private int conversionDelay = Mth.randomBetweenInclusive((org.plazmamc.plazma.configurations.GlobalConfiguration.get().misc.reduceCreateRandomInstance ? net.minecraft.server.MinecraftServer.getServer().getRandom() : RandomSource.create()), 0, 2); // Plazma - Reduce create random instance + int highestAnger; + private static final Codec> SUSPECT_ANGER_PAIR = RecordCodecBuilder.create((instance) -> { + return instance.group(UUIDUtil.CODEC.fieldOf("uuid").forGetter(Pair::getFirst), ExtraCodecs.NON_NEGATIVE_INT.fieldOf("anger").forGetter(Pair::getSecond)).apply(instance, Pair::of); +diff --git a/src/main/java/net/minecraft/world/entity/npc/WanderingTraderSpawner.java b/src/main/java/net/minecraft/world/entity/npc/WanderingTraderSpawner.java +index a5443f92786427c42092aec8350e7ab37704db7a..b1a44e460175b974e8830030ce61e523533bef8c 100644 +--- a/src/main/java/net/minecraft/world/entity/npc/WanderingTraderSpawner.java ++++ b/src/main/java/net/minecraft/world/entity/npc/WanderingTraderSpawner.java +@@ -32,7 +32,7 @@ public class WanderingTraderSpawner implements CustomSpawner { + private static final int SPAWN_CHANCE_INCREASE = 25; + private static final int SPAWN_ONE_IN_X_CHANCE = 10; + private static final int NUMBER_OF_SPAWN_ATTEMPTS = 10; +- private final RandomSource random = RandomSource.create(); ++ private final RandomSource random = org.plazmamc.plazma.configurations.GlobalConfiguration.get().misc.reduceCreateRandomInstance ? net.minecraft.server.MinecraftServer.getServer().getRandom() : RandomSource.create(); // Plazma - reduce create random instace + private final ServerLevelData serverLevelData; + private int tickDelay; + private int spawnDelay; +diff --git a/src/main/java/net/minecraft/world/entity/projectile/FishingHook.java b/src/main/java/net/minecraft/world/entity/projectile/FishingHook.java +index a9eaa079a43bc8a5e81deaf6df5ce2f9c53cb319..f1b0b8fd1042f2ce8a514000d95df5123223cc27 100644 +--- a/src/main/java/net/minecraft/world/entity/projectile/FishingHook.java ++++ b/src/main/java/net/minecraft/world/entity/projectile/FishingHook.java +@@ -86,7 +86,7 @@ public class FishingHook extends Projectile { + + private FishingHook(EntityType type, Level world, int luckOfTheSeaLevel, int lureLevel) { + super(type, world); +- this.syncronizedRandom = RandomSource.create(); ++ this.syncronizedRandom = world.plazmaLevelConfiguration().misc.reduceCreateRandomInstance ? world.getRandom() : RandomSource.create(); // Plazma - Reduce create random instance + this.openWater = true; + this.currentState = FishingHook.FishHookState.FLYING; + this.noCulling = true; +diff --git a/src/main/java/net/minecraft/world/entity/raid/Raid.java b/src/main/java/net/minecraft/world/entity/raid/Raid.java +index eaa2943b667967f93f28d9d794d702fdaeb670ec..75ba586277ece1aa56186679d3a8ebf0b3f7a0cb 100644 +--- a/src/main/java/net/minecraft/world/entity/raid/Raid.java ++++ b/src/main/java/net/minecraft/world/entity/raid/Raid.java +@@ -109,7 +109,7 @@ public class Raid { + + public Raid(int id, ServerLevel world, BlockPos pos) { + this.raidEvent = new ServerBossEvent(Raid.RAID_NAME_COMPONENT, BossEvent.BossBarColor.RED, BossEvent.BossBarOverlay.NOTCHED_10); +- this.random = RandomSource.create(); ++ this.random = world.plazmaLevelConfiguration().misc.reduceCreateRandomInstance ? world.getRandom() : RandomSource.create(); // Plazma - Reduce create random instace + this.waveSpawnPos = Optional.empty(); + this.id = id; + this.level = world; +@@ -123,7 +123,7 @@ public class Raid { + + public Raid(ServerLevel world, CompoundTag nbt) { + this.raidEvent = new ServerBossEvent(Raid.RAID_NAME_COMPONENT, BossEvent.BossBarColor.RED, BossEvent.BossBarOverlay.NOTCHED_10); +- this.random = RandomSource.create(); ++ this.random = world.plazmaLevelConfiguration().misc.reduceCreateRandomInstance ? world.getRandom() : RandomSource.create(); // Plazma - Reduce create random instace + this.waveSpawnPos = Optional.empty(); + this.level = world; + this.id = nbt.getInt("Id"); +diff --git a/src/main/java/net/minecraft/world/inventory/EnchantmentMenu.java b/src/main/java/net/minecraft/world/inventory/EnchantmentMenu.java +index d604b7ec46f08993647979ed220a84842e3fe325..f2a3049252a37ca6d6d5cb1cc51d512c7ebf5679 100644 +--- a/src/main/java/net/minecraft/world/inventory/EnchantmentMenu.java ++++ b/src/main/java/net/minecraft/world/inventory/EnchantmentMenu.java +@@ -97,7 +97,7 @@ public class EnchantmentMenu extends AbstractContainerMenu { + } + // Purpur end + }; +- this.random = RandomSource.create(); ++ this.random = playerInventory.player.level().plazmaLevelConfiguration().misc.reduceCreateRandomInstance ? playerInventory.player.level().random : RandomSource.create(); // Plazma - Reduce create random instace + this.enchantmentSeed = DataSlot.standalone(); + this.costs = new int[3]; + this.enchantClue = new int[]{-1, -1, -1}; +diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java +index ef9b1687dd2dfda5398523140aecc678b4690642..66a1db10249995144490dac292e09fd0aa30f168 100644 +--- a/src/main/java/net/minecraft/world/level/Explosion.java ++++ b/src/main/java/net/minecraft/world/level/Explosion.java +@@ -82,7 +82,7 @@ public class Explosion { + } + + public Explosion(Level world, @Nullable Entity entity, @Nullable DamageSource damageSource, @Nullable ExplosionDamageCalculator behavior, double x, double y, double z, float power, boolean createFire, Explosion.BlockInteraction destructionType) { +- this.random = RandomSource.create(); ++ this.random = world.plazmaLevelConfiguration().misc.reduceCreateRandomInstance ? world.getRandom() : RandomSource.create(); // Plazma - Reduce create random instace + this.toBlow = new ObjectArrayList(); + this.hitPlayers = Maps.newHashMap(); + this.level = world; +diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java +index 1a5880ae3c3b17d49f0b083dff66e5619c08ec20..e175cde654b36d8ffc98a36ef099d22e9f1d15e9 100644 +--- a/src/main/java/net/minecraft/world/level/Level.java ++++ b/src/main/java/net/minecraft/world/level/Level.java +@@ -124,16 +124,16 @@ public abstract class Level implements LevelAccessor, AutoCloseable { + public final Thread thread; + private final boolean isDebug; + private int skyDarken; +- protected int randValue = RandomSource.create().nextInt(); + protected final int addend = 1013904223; + protected float oRainLevel; + public float rainLevel; + protected float oThunderLevel; + public float thunderLevel; + public final RandomSource random = RandomSource.create(); ++ protected int randValue = org.plazmamc.plazma.configurations.GlobalConfiguration.get().misc.reduceCreateRandomInstance ? random.nextInt() : RandomSource.create().nextInt(); // Plazma - Reduce create random instace + /** @deprecated */ + @Deprecated +- private final RandomSource threadSafeRandom = RandomSource.createThreadSafe(); ++ private final RandomSource threadSafeRandom = org.plazmamc.plazma.configurations.GlobalConfiguration.get().misc.suppressThreadSafeRandom ? random : RandomSource.createThreadSafe(); // Plazma - Reduce create random instace + private final ResourceKey dimensionTypeId; + private final Holder dimensionTypeRegistration; + public final WritableLevelData levelData; +diff --git a/src/main/java/net/minecraft/world/level/block/entity/EnchantmentTableBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/EnchantmentTableBlockEntity.java +index b7370e64fd0d50e8725d7d5afc30af2e8bc8455d..b8d2c91a343478d89a5242254f3379dfa2556348 100644 +--- a/src/main/java/net/minecraft/world/level/block/entity/EnchantmentTableBlockEntity.java ++++ b/src/main/java/net/minecraft/world/level/block/entity/EnchantmentTableBlockEntity.java +@@ -22,7 +22,7 @@ public class EnchantmentTableBlockEntity extends BlockEntity implements Nameable + public float rot; + public float oRot; + public float tRot; +- private static final RandomSource RANDOM = RandomSource.create(); ++ private static final RandomSource RANDOM = org.plazmamc.plazma.configurations.GlobalConfiguration.get().misc.reduceCreateRandomInstance ? net.minecraft.server.MinecraftServer.getServer().getRandom() : RandomSource.create(); // Plazma - Reduce create random instace + private Component name; + private int lapis = 0; // Purpur + +diff --git a/src/main/java/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java +index 7291e4056b8e46ab59b71818388ac55fbb12993f..22faea52bc54cdcb52ff18a9d5a8c1bd1a64fa73 100644 +--- a/src/main/java/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java ++++ b/src/main/java/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java +@@ -368,7 +368,7 @@ public class TheEndGatewayBlockEntity extends TheEndPortalBlockEntity { + } + + private static void spawnGatewayPortal(ServerLevel world, BlockPos pos, EndGatewayConfiguration config) { +- Feature.END_GATEWAY.place(config, world, world.getChunkSource().getGenerator(), RandomSource.create(), pos); ++ Feature.END_GATEWAY.place(config, world, world.getChunkSource().getGenerator(), (world.plazmaLevelConfiguration().misc.reduceCreateRandomInstance ? world.getRandom() : RandomSource.create()), pos); // Plazma - Reduce create random instance + } + + @Override +diff --git a/src/main/java/net/minecraft/world/level/chunk/ChunkGeneratorStructureState.java b/src/main/java/net/minecraft/world/level/chunk/ChunkGeneratorStructureState.java +index f8cd23fb6ea7909b8f30bd21d3f2c7bcc483ef21..c85340232624529d4685bf34035bb62d294695c9 100644 +--- a/src/main/java/net/minecraft/world/level/chunk/ChunkGeneratorStructureState.java ++++ b/src/main/java/net/minecraft/world/level/chunk/ChunkGeneratorStructureState.java +@@ -221,7 +221,7 @@ public class ChunkGeneratorStructureState { + List> list = new ArrayList(j); + int k = placement.spread(); + HolderSet holderset = placement.preferredBiomes(); +- RandomSource randomsource = RandomSource.create(); ++ RandomSource randomsource = org.plazmamc.plazma.configurations.GlobalConfiguration.get().misc.reduceCreateRandomInstance ? net.minecraft.server.MinecraftServer.getServer().getRandom() : RandomSource.create(); // Plazma - Reduce create random instace + + // Paper start + if (this.conf.strongholdSeed != null && structureSetEntry.is(net.minecraft.world.level.levelgen.structure.BuiltinStructureSets.STRONGHOLDS)) { +diff --git a/src/main/java/net/minecraft/world/level/dimension/end/DragonRespawnAnimation.java b/src/main/java/net/minecraft/world/level/dimension/end/DragonRespawnAnimation.java +index 18fce94f0d4b9d28e3afec61c7578f672973a71f..2dfb801ec15a372bcb997942969fec64aea9e49e 100644 +--- a/src/main/java/net/minecraft/world/level/dimension/end/DragonRespawnAnimation.java ++++ b/src/main/java/net/minecraft/world/level/dimension/end/DragonRespawnAnimation.java +@@ -62,7 +62,7 @@ public enum DragonRespawnAnimation { + + world.explode((Entity)null, (double)((float)endSpike.getCenterX() + 0.5F), (double)endSpike.getHeight(), (double)((float)endSpike.getCenterZ() + 0.5F), 5.0F, Level.ExplosionInteraction.BLOCK); + SpikeConfiguration spikeConfiguration = new SpikeConfiguration(true, ImmutableList.of(endSpike), new BlockPos(0, 128, 0)); +- Feature.END_SPIKE.place(spikeConfiguration, world, world.getChunkSource().getGenerator(), RandomSource.create(), new BlockPos(endSpike.getCenterX(), 45, endSpike.getCenterZ())); ++ Feature.END_SPIKE.place(spikeConfiguration, world, world.getChunkSource().getGenerator(), (world.plazmaLevelConfiguration().misc.reduceCreateRandomInstance ? world.getRandom() : RandomSource.create()), new BlockPos(endSpike.getCenterX(), 45, endSpike.getCenterZ())); // Plazma - Reduce create random instance + } + } else if (bl) { + fight.setRespawnStage(SUMMONING_DRAGON); +diff --git a/src/main/java/net/minecraft/world/level/dimension/end/EndDragonFight.java b/src/main/java/net/minecraft/world/level/dimension/end/EndDragonFight.java +index c1ff2e15bc5da1a642872ac0fdcdc457e8abb063..67b4a65980059b0b2d4929c619c400c48e201e18 100644 +--- a/src/main/java/net/minecraft/world/level/dimension/end/EndDragonFight.java ++++ b/src/main/java/net/minecraft/world/level/dimension/end/EndDragonFight.java +@@ -472,7 +472,7 @@ public class EndDragonFight { + this.level.registryAccess().registry(Registries.CONFIGURED_FEATURE).flatMap((iregistry) -> { + return iregistry.getHolder(EndFeatures.END_GATEWAY_DELAYED); + }).ifPresent((holder_c) -> { +- ((ConfiguredFeature) holder_c.value()).place(this.level, this.level.getChunkSource().getGenerator(), RandomSource.create(), pos); ++ ((ConfiguredFeature) holder_c.value()).place(this.level, this.level.getChunkSource().getGenerator(), (this.level.plazmaLevelConfiguration().misc.reduceCreateRandomInstance ? this.level.getRandom() : RandomSource.create()), pos); // Plazma - Reduce create random instace + }); + } + +@@ -490,7 +490,7 @@ public class EndDragonFight { + this.portalLocation = this.portalLocation.atY(this.level.getMinBuildHeight() + 1); + } + // Paper end +- if (worldgenendtrophy.place(FeatureConfiguration.NONE, this.level, this.level.getChunkSource().getGenerator(), RandomSource.create(), this.portalLocation)) { ++ if (worldgenendtrophy.place(FeatureConfiguration.NONE, this.level, this.level.getChunkSource().getGenerator(), (this.level.plazmaLevelConfiguration().misc.reduceCreateRandomInstance ? this.level.getRandom() : RandomSource.create()), this.portalLocation)) { // Plazma - Reduce create random instace + int i = Mth.positiveCeilDiv(4, 16); + + this.level.getChunkSource().chunkMap.waitForLightBeforeSending(new ChunkPos(this.portalLocation), i); +diff --git a/src/main/java/net/minecraft/world/level/levelgen/WorldOptions.java b/src/main/java/net/minecraft/world/level/levelgen/WorldOptions.java +index d38cabc9eeb45dd863e5f87b7df3b6327ea6a4a2..d4bcdbc6ea420bdb05c0a8859d368213d87dba67 100644 +--- a/src/main/java/net/minecraft/world/level/levelgen/WorldOptions.java ++++ b/src/main/java/net/minecraft/world/level/levelgen/WorldOptions.java +@@ -77,6 +77,6 @@ public class WorldOptions { + } + + public static long randomSeed() { +- return RandomSource.create().nextLong(); ++ return (org.plazmamc.plazma.PlazmaOptions.createNewRandom() ? RandomSource.create() : net.minecraft.server.MinecraftServer.getServer().getRandom()).nextLong(); // Plazma - Reduce create random instance + } + } +diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java +index 68c5af9b67a2834ee6e2f80ceefa19c3a982b8ed..aabbf9ae1b772c9101e6f36236e5d34a5620a4d3 100644 +--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java ++++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java +@@ -2,6 +2,8 @@ package org.bukkit.craftbukkit.entity; + + import com.google.common.base.Preconditions; + import java.util.Random; ++ ++import net.minecraft.util.RandomSource; + import net.minecraft.world.entity.projectile.FireworkRocketEntity; + import net.minecraft.world.item.ItemStack; + import net.minecraft.world.item.Items; +@@ -14,11 +16,12 @@ import org.bukkit.inventory.meta.FireworkMeta; + + public class CraftFirework extends CraftProjectile implements Firework { + +- private final Random random = new Random(); ++ private final net.minecraft.util.RandomSource random; // Plazma - Reduce create random instance + //private CraftItemStack item; // Paper - Remove usage, not accurate representation of current item. + + public CraftFirework(CraftServer server, FireworkRocketEntity entity) { + super(server, entity); ++ this.random = this.getHandle().level().plazmaLevelConfiguration().misc.reduceCreateRandomInstance ? this.getHandle().level().getRandom() : RandomSource.create(); // Plazma - Reduce create random instance + + // Paper Start - Expose firework item directly + // ItemStack item = this.getHandle().getEntityData().get(FireworkRocketEntity.DATA_ID_FIREWORKS_ITEM); +diff --git a/src/main/java/org/plazmamc/plazma/PlazmaOptions.java b/src/main/java/org/plazmamc/plazma/PlazmaOptions.java +new file mode 100644 +index 0000000000000000000000000000000000000000..4421110e20a006c3773e922eb0facc88174ffb43 +--- /dev/null ++++ b/src/main/java/org/plazmamc/plazma/PlazmaOptions.java +@@ -0,0 +1,10 @@ ++package org.plazmamc.plazma; ++ ++public class PlazmaOptions { ++ ++ static final boolean DONT_CREATE_NEW_RANDOM_INSTANCE = Boolean.getBoolean("Plazma.doNotCreateRandomInstance"); ++ public static boolean createNewRandom() { ++ return !DONT_CREATE_NEW_RANDOM_INSTANCE; ++ } ++ ++} +diff --git a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java +index 351379de0811b3dc610e8bb0b526b3431e856b1c..f4634cc41e1aabc1e656f6720700c580645c8709 100644 +--- a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java ++++ b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java +@@ -24,6 +24,9 @@ public class GlobalConfiguration extends ConfigurationPart { + public Misc misc; + public class Misc extends ConfigurationPart { + ++ public boolean reduceCreateRandomInstance = DO_OPTIMIZE; ++ public boolean suppressThreadSafeRandom = DO_OPTIMIZE; ++ + } + + public Player player; +diff --git a/src/main/java/org/plazmamc/plazma/configurations/LevelConfigurations.java b/src/main/java/org/plazmamc/plazma/configurations/LevelConfigurations.java +index 36c367c577e61422e51ab08c5aaa2a88c94e1636..146af5bb54da67c134485dc67e8d9a569889434a 100644 +--- a/src/main/java/org/plazmamc/plazma/configurations/LevelConfigurations.java ++++ b/src/main/java/org/plazmamc/plazma/configurations/LevelConfigurations.java +@@ -26,6 +26,8 @@ public class LevelConfigurations extends ConfigurationPart { + public Misc misc; + public class Misc extends ConfigurationPart { + ++ public boolean reduceCreateRandomInstance = DO_OPTIMIZE; ++ + } + + public Entity entity; diff --git a/patches/server/0016-Apply-various-optimizations.patch b/patches/server/0016-Apply-various-optimizations.patch new file mode 100644 index 000000000..d8baa0557 --- /dev/null +++ b/patches/server/0016-Apply-various-optimizations.patch @@ -0,0 +1,32 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: AlphaKR93 +Date: Wed, 27 Sep 2023 22:11:15 +0900 +Subject: [PATCH] Apply various optimizations + +[REFERENCE PATCHES] +Akarin - Swaps the predicate order of collision + +diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java +index 1ca91631b03c9690b4f661ecfb4d500d23cb47ec..4461dc1b76cc2939130680f8039b69af902aa050 100644 +--- a/src/main/java/net/minecraft/world/entity/Entity.java ++++ b/src/main/java/net/minecraft/world/entity/Entity.java +@@ -2105,8 +2105,9 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { + public void playerTouch(Player player) {} + + public void push(Entity entity) { ++ if (entity.noPhysics || this.noPhysics) return; // Plazma + if (!this.isPassengerOfSameVehicle(entity)) { +- if (!entity.noPhysics && !this.noPhysics) { ++ //if (!entity.noPhysics && !this.noPhysics) { // Plazma - moved up + if (this.level.paperConfig().collisions.onlyPlayersCollide && !(entity instanceof ServerPlayer || this instanceof ServerPlayer)) return; // Paper + double d0 = entity.getX() - this.getX(); + double d1 = entity.getZ() - this.getZ(); +@@ -2135,7 +2136,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { + } + } + +- } ++ //} // Plazma + } + } + diff --git a/patches/server/0017-Avoid-double-I-O-operation-on-load-player-file.patch b/patches/server/0017-Avoid-double-I-O-operation-on-load-player-file.patch new file mode 100644 index 000000000..2f8f84749 --- /dev/null +++ b/patches/server/0017-Avoid-double-I-O-operation-on-load-player-file.patch @@ -0,0 +1,29 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: AlphaKR93 +Date: Wed, 27 Sep 2023 22:13:07 +0900 +Subject: [PATCH] Avoid double I/O operation on load player file + + +diff --git a/src/main/java/net/minecraft/world/level/storage/PlayerDataStorage.java b/src/main/java/net/minecraft/world/level/storage/PlayerDataStorage.java +index 36af81f0957d17e170d229059c66f4eb4539dfeb..b4b74bff0579b919266e91464b36c9381342b677 100644 +--- a/src/main/java/net/minecraft/world/level/storage/PlayerDataStorage.java ++++ b/src/main/java/net/minecraft/world/level/storage/PlayerDataStorage.java +@@ -56,7 +56,8 @@ public class PlayerDataStorage { + File file = new File(this.playerDir, player.getStringUUID() + ".dat"); + // Spigot Start + boolean usingWrongFile = false; +- if ( org.bukkit.Bukkit.getOnlineMode() && !file.exists() ) // Paper - Check online mode first ++ boolean isNormalFile = file.exists() && file.isFile(); // Plazma - Avoid double I/O operation ++ if ( org.bukkit.Bukkit.getOnlineMode() && isNormalFile ) // Paper - Check online mode first // Plazma - Avoid double I/O operation + { + file = new File( this.playerDir, java.util.UUID.nameUUIDFromBytes( ( "OfflinePlayer:" + player.getScoreboardName() ).getBytes( "UTF-8" ) ).toString() + ".dat"); + if ( file.exists() ) +@@ -67,7 +68,7 @@ public class PlayerDataStorage { + } + // Spigot End + +- if (file.exists() && file.isFile()) { ++ if (isNormalFile) { // Plazma - Avoid double I/O operation + nbttagcompound = NbtIo.readCompressed(file); + } + // Spigot Start diff --git a/patches/server/0018-Don-t-refresh-LootTable-for-non-player-interaction.patch b/patches/server/0018-Don-t-refresh-LootTable-for-non-player-interaction.patch new file mode 100644 index 000000000..2e5c0b10f --- /dev/null +++ b/patches/server/0018-Don-t-refresh-LootTable-for-non-player-interaction.patch @@ -0,0 +1,30 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: AlphaKR93 +Date: Wed, 27 Sep 2023 22:15:39 +0900 +Subject: [PATCH] Don't refresh LootTable for non player interaction + + +diff --git a/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java +index 081691f9710ff1115e4308f79ed49fbc38941193..79a27755534384ab94e79e422c0a5e9ccecacd8c 100644 +--- a/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java ++++ b/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java +@@ -70,6 +70,7 @@ public abstract class RandomizableContainerBlockEntity extends BaseContainerBloc + } + + public void unpackLootTable(@Nullable Player player) { ++ if (org.plazmamc.plazma.configurations.GlobalConfiguration.get().misc.dontRefreshLootTableForNonPlayerInteraction && player == null) return; // Plazma + if (this.lootableData.shouldReplenish(player) && this.level.getServer() != null) { // Paper + LootTable lootTable = this.level.getServer().getLootData().getLootTable(this.lootTable); + if (player instanceof ServerPlayer) { +diff --git a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java +index f4634cc41e1aabc1e656f6720700c580645c8709..b58d91e842c29a28e8c6cbb275f2906eb361626a 100644 +--- a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java ++++ b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java +@@ -26,6 +26,7 @@ public class GlobalConfiguration extends ConfigurationPart { + + public boolean reduceCreateRandomInstance = DO_OPTIMIZE; + public boolean suppressThreadSafeRandom = DO_OPTIMIZE; ++ public boolean dontRefreshLootTableForNonPlayerInteraction = DO_OPTIMIZE; + + } + diff --git a/patches/server/0019-Don-t-load-chunks-to-spawn-phantom.patch b/patches/server/0019-Don-t-load-chunks-to-spawn-phantom.patch new file mode 100644 index 000000000..13dbf61d4 --- /dev/null +++ b/patches/server/0019-Don-t-load-chunks-to-spawn-phantom.patch @@ -0,0 +1,36 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: AlphaKR93 +Date: Wed, 27 Sep 2023 22:17:11 +0900 +Subject: [PATCH] Don't load chunks to spawn phantom + + +diff --git a/src/main/java/net/minecraft/world/level/levelgen/PhantomSpawner.java b/src/main/java/net/minecraft/world/level/levelgen/PhantomSpawner.java +index f74c5eda91a3d521763ec7bc33f23e0c62458cc2..e7a9683fe6bd72e9e7644770953506195567e03b 100644 +--- a/src/main/java/net/minecraft/world/level/levelgen/PhantomSpawner.java ++++ b/src/main/java/net/minecraft/world/level/levelgen/PhantomSpawner.java +@@ -71,6 +71,7 @@ public class PhantomSpawner implements CustomSpawner { + + if (randomsource.nextInt(j) >= world.paperConfig().entities.behavior.playerInsomniaStartTicks) { // Paper + BlockPos blockposition1 = blockposition.above(20 + randomsource.nextInt(15)).east(-10 + randomsource.nextInt(21)).south(-10 + randomsource.nextInt(21)); ++ if (world.plazmaLevelConfiguration().entity.phantom.dontLoadChunksToSpawn && world.hasChunkAt(blockposition1)) continue; // Plazma + BlockState iblockdata = world.getBlockState(blockposition1); + FluidState fluid = world.getFluidState(blockposition1); + +diff --git a/src/main/java/org/plazmamc/plazma/configurations/LevelConfigurations.java b/src/main/java/org/plazmamc/plazma/configurations/LevelConfigurations.java +index 146af5bb54da67c134485dc67e8d9a569889434a..0a23900b18ec46ce2a7d47160dff013c7c8a8533 100644 +--- a/src/main/java/org/plazmamc/plazma/configurations/LevelConfigurations.java ++++ b/src/main/java/org/plazmamc/plazma/configurations/LevelConfigurations.java +@@ -33,6 +33,13 @@ public class LevelConfigurations extends ConfigurationPart { + public Entity entity; + public class Entity extends ConfigurationPart { + ++ public Phantom phantom; ++ public class Phantom extends ConfigurationPart { ++ ++ public boolean dontLoadChunksToSpawn = DO_OPTIMIZE; ++ ++ } ++ + } + + public Structure structure; diff --git a/patches/unapplied/server/0023-Add-configuration-to-disable-moved-to-quickly-check-.patch b/patches/server/0020-Add-option-to-disable-moved-to-quickly-check-for-spe.patch similarity index 51% rename from patches/unapplied/server/0023-Add-configuration-to-disable-moved-to-quickly-check-.patch rename to patches/server/0020-Add-option-to-disable-moved-to-quickly-check-for-spe.patch index 2696dc8ed..be03001c5 100644 --- a/patches/unapplied/server/0023-Add-configuration-to-disable-moved-to-quickly-check-.patch +++ b/patches/server/0020-Add-option-to-disable-moved-to-quickly-check-for-spe.patch @@ -1,32 +1,37 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: AlphaKR93 -Date: Sat, 25 Mar 2023 20:46:40 +0900 -Subject: [PATCH] Add configuration to disable moved to quickly check for - spectators +Date: Wed, 27 Sep 2023 22:21:47 +0900 +Subject: [PATCH] Add option to disable moved to quickly check for specific + players diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index 255b422078880b46dfa6f5140f6c92fef057d09e..6b6e7b8fbc0bb8a177affff0d7c7029d571faea2 100644 +index e001787e40cc0a843e65b36582e9d6593d0fff0e..1af44c18724b2d2dc1d910f5af49254eb845feaf 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -1566,7 +1566,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic +@@ -1435,6 +1435,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl if (!this.player.isChangingDimension() && (!this.player.level().getGameRules().getBoolean(GameRules.RULE_DISABLE_ELYTRA_MOVEMENT_CHECK) || !this.player.isFallFlying())) { float f2 = this.player.isFallFlying() ? 300.0F : 100.0F; -- if (d10 - d9 > Math.max(f2, Math.pow((double) (org.spigotmc.SpigotConfig.movedTooQuicklyMultiplier * (float) i * speed), 2)) && !this.isSingleplayerOwner()) { -+ if (!(this.player.level().plazmaLevelConfiguration().misc.checkSpectatorMovedToQuickly && this.player.isSpectator()) && d10 - d9 > Math.max(f2, Math.pow((double) (org.spigotmc.SpigotConfig.movedTooQuicklyMultiplier * (float) i * speed), 2)) && !this.isSingleplayerOwner()) { // Plazma ++ if (this.player.getBukkitEntity().hasPermission("plazma.bypass-moved-to-quickly-check") || !this.player.level().plazmaLevelConfiguration().entity.player.checkSpectatorMovecToQuickly && this.player.isSpectator()) return; // Plazma + if (d10 - d9 > Math.max(f2, Math.pow((double) (org.spigotmc.SpigotConfig.movedTooQuicklyMultiplier * (float) i * speed), 2)) && !this.isSingleplayerOwner()) { // CraftBukkit end // Paper start - Add fail move event - io.papermc.paper.event.player.PlayerFailMoveEvent event = fireFailMove(io.papermc.paper.event.player.PlayerFailMoveEvent.FailReason.MOVED_TOO_QUICKLY, diff --git a/src/main/java/org/plazmamc/plazma/configurations/LevelConfigurations.java b/src/main/java/org/plazmamc/plazma/configurations/LevelConfigurations.java -index 504913e8e05869f8f0b88f0faaf684d39eb14ea7..61c06213b4ceb8e38e9aa41c3517f152d0d669ad 100644 +index 0a23900b18ec46ce2a7d47160dff013c7c8a8533..414baade911fab3450430af9378feedc419868f3 100644 --- a/src/main/java/org/plazmamc/plazma/configurations/LevelConfigurations.java +++ b/src/main/java/org/plazmamc/plazma/configurations/LevelConfigurations.java -@@ -88,6 +88,7 @@ public class LevelConfigurations extends ConfigurationPart { - public class Misc extends ConfigurationPart { +@@ -33,6 +33,13 @@ public class LevelConfigurations extends ConfigurationPart { + public Entity entity; + public class Entity extends ConfigurationPart { - public boolean reduceCreateRandomInstance = DO_OPTIMIZE; -+ public boolean checkSpectatorMovedToQuickly = DO_OPTIMIZE; - - } ++ public Player player; ++ public class Player extends ConfigurationPart { ++ ++ public boolean checkSpectatorMovecToQuickly = !DO_OPTIMIZE; ++ ++ } ++ + public Phantom phantom; + public class Phantom extends ConfigurationPart { diff --git a/patches/unapplied/server/0024-Apply-faster-random.patch b/patches/server/0021-Use-faster-random.patch similarity index 86% rename from patches/unapplied/server/0024-Apply-faster-random.patch rename to patches/server/0021-Use-faster-random.patch index 69189d365..f6a80d2fd 100644 --- a/patches/unapplied/server/0024-Apply-faster-random.patch +++ b/patches/server/0021-Use-faster-random.patch @@ -1,11 +1,11 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: AlphaKR93 -Date: Sat, 25 Mar 2023 21:50:25 +0900 -Subject: [PATCH] Apply faster random +Date: Wed, 27 Sep 2023 22:30:49 +0900 +Subject: [PATCH] Use faster random diff --git a/src/main/java/com/destroystokyo/paper/loottable/PaperLootableInventoryData.java b/src/main/java/com/destroystokyo/paper/loottable/PaperLootableInventoryData.java -index 5408cbc21fc7577a6100b5a1ca0463e899d2df8b..4f264e098e7907c397f09ee23a579ed7da494edc 100644 +index 5408cbc21fc7577a6100b5a1ca0463e899d2df8b..f17b42176e9e5148b98baf4a6a7e7528242406d9 100644 --- a/src/main/java/com/destroystokyo/paper/loottable/PaperLootableInventoryData.java +++ b/src/main/java/com/destroystokyo/paper/loottable/PaperLootableInventoryData.java @@ -16,7 +16,7 @@ import java.util.UUID; @@ -13,51 +13,38 @@ index 5408cbc21fc7577a6100b5a1ca0463e899d2df8b..4f264e098e7907c397f09ee23a579ed7 public class PaperLootableInventoryData { - private static final Random RANDOM = new Random(); -+ private static final Random RANDOM = Boolean.getBoolean("Plazma.doNotUseFasterRandom") ? new Random() : new org.plazmamc.plazma.Random(); // Plazma ++ private static final Random RANDOM = org.plazmamc.plazma.PlazmaOptions.useJavaRandom() ? new Random() : new org.plazmamc.plazma.Random(); // Plazma - use faster random private long lastFill = -1; private long nextRefill = -1; diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 0acbaa18a61d1cfdb894c6c756d2b9bdc3599b82..93ff3ef401d4212cede5290990528988c7ca3a0c 100644 +index ee571f465ca1e83e760a4d57b3d11accb53c6cfe..1a92a7f6391df6395c11d11efdbf2f4eda5c6651 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java -@@ -691,7 +691,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop> 8); + if (i < buffer.length) { + buffer[i++] = (byte) (w >> 16); -+ if (i < buffer.length) { -+ buffer[i] = (byte) (w >> 24); -+ } ++ if (i < buffer.length) buffer[i] = (byte) (w >> 24); + } + } + } @@ -241,11 +242,10 @@ index 0000000000000000000000000000000000000000..e72e96be3938bdcc1ae1aa94f7465f64 + // The explicit int cast before the first multiplication gives better performance. + // See comments in NextDouble. + int range = upperBound - lowerBound; -+ if (range < 0) { ++ if (range < 0) + // If range is <0 then an overflow has occured and must resort to using long integer arithmetic instead (slower). + // We also must use all 32 bits of precision, instead of the normal 31, which again is slower. + return lowerBound + (int) ((REAL_UNIT_UINT * (double) (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)))) * (double) ((long) upperBound - (long) lowerBound)); -+ } + // 31 bits of precision will suffice if range<=int.MaxValue. This allows us to cast to an int and gain + // a little more performance. + return lowerBound + (int) ((REAL_UNIT_INT * (double) (int) (0x7FFFFFFF & (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8))))) * (double) range); diff --git a/patches/server/0022-Ignore-useless-entity-packets.patch b/patches/server/0022-Ignore-useless-entity-packets.patch new file mode 100644 index 000000000..c3e1d31d5 --- /dev/null +++ b/patches/server/0022-Ignore-useless-entity-packets.patch @@ -0,0 +1,52 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: AlphaKR93 +Date: Wed, 27 Sep 2023 22:35:19 +0900 +Subject: [PATCH] Ignore useless entity packets + + +diff --git a/src/main/java/net/minecraft/server/level/ServerEntity.java b/src/main/java/net/minecraft/server/level/ServerEntity.java +index c6d80accdac49564b5386717a92dbd5a10237f06..ddbff17499746cd370fdf18ff78606b0ac770df4 100644 +--- a/src/main/java/net/minecraft/server/level/ServerEntity.java ++++ b/src/main/java/net/minecraft/server/level/ServerEntity.java +@@ -200,6 +200,8 @@ public class ServerEntity { + flag4 = true; + flag5 = true; + } ++ ++ if (this.entity.level().plazmaLevelConfiguration().entity.ignoreUselessPackets && isUselessPacket(packet1)) packet1 = null; // Plazma + } + + if ((this.trackDelta || this.entity.hasImpulse || this.entity instanceof LivingEntity && ((LivingEntity) this.entity).isFallFlying()) && this.tickCount > 0) { +@@ -272,6 +274,19 @@ public class ServerEntity { + }); + } + ++ // Plazma start ++ private boolean isUselessPacket(@Nullable Packet packet) { ++ if (!(packet instanceof ClientboundMoveEntityPacket p)) return false; ++ if (p instanceof ClientboundMoveEntityPacket.Pos) ++ return p.getXa() == 0 && p.getYa() == 0 && p.getZa() == 0; ++ if (p instanceof ClientboundMoveEntityPacket.Rot) ++ return p.getxRot() == 0 && p.getyRot() == 0; ++ if (p instanceof ClientboundMoveEntityPacket.PosRot) ++ return p.getXa() == 0 && p.getYa() == 0 && p.getZa() == 0 && p.getxRot() == 0 && p.getyRot() == 0; ++ return false; ++ } ++ // Plazma end ++ + public void removePairing(ServerPlayer player) { + this.entity.stopSeenByPlayer(player); + player.connection.send(new ClientboundRemoveEntitiesPacket(new int[]{this.entity.getId()})); +diff --git a/src/main/java/org/plazmamc/plazma/configurations/LevelConfigurations.java b/src/main/java/org/plazmamc/plazma/configurations/LevelConfigurations.java +index 414baade911fab3450430af9378feedc419868f3..914cc4f9a5598d2d70c7338d7cfc9be0fe5f0e31 100644 +--- a/src/main/java/org/plazmamc/plazma/configurations/LevelConfigurations.java ++++ b/src/main/java/org/plazmamc/plazma/configurations/LevelConfigurations.java +@@ -33,6 +33,8 @@ public class LevelConfigurations extends ConfigurationPart { + public Entity entity; + public class Entity extends ConfigurationPart { + ++ public boolean ignoreUselessPackets = DO_OPTIMIZE; ++ + public Player player; + public class Player extends ConfigurationPart { + diff --git a/patches/unapplied/server/0020-Reduce-create-random-instance.patch b/patches/unapplied/server/0020-Reduce-create-random-instance.patch deleted file mode 100644 index 66d2a35bf..000000000 --- a/patches/unapplied/server/0020-Reduce-create-random-instance.patch +++ /dev/null @@ -1,176 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: AlphaKR93 -Date: Sat, 25 Mar 2023 20:02:59 +0900 -Subject: [PATCH] Reduce create random instance - - -diff --git a/src/main/java/net/minecraft/server/commands/SpreadPlayersCommand.java b/src/main/java/net/minecraft/server/commands/SpreadPlayersCommand.java -index f5bc3497831877e0c2b7dc1cbd8abe3a67d7695b..d157758282cc79d58134c056c52a43a24d443153 100644 ---- a/src/main/java/net/minecraft/server/commands/SpreadPlayersCommand.java -+++ b/src/main/java/net/minecraft/server/commands/SpreadPlayersCommand.java -@@ -65,7 +65,7 @@ public class SpreadPlayersCommand { - if (maxY < j) { - throw SpreadPlayersCommand.ERROR_INVALID_MAX_HEIGHT.create(maxY, j); - } else { -- RandomSource randomsource = RandomSource.create(); -+ RandomSource randomsource = worldserver.plazmaLevelConfiguration().misc.reduceCreateRandomInstance ? worldserver.getRandom() : RandomSource.create(); // Plazma - double d0 = (double) (center.x - maxRange); - double d1 = (double) (center.y - maxRange); - double d2 = (double) (center.x + maxRange); -diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java -index f39b3f1b5b37d1939766952a985684279cb2bf2d..69d22bc9f0087dc419b840c6626746e12f621012 100644 ---- a/src/main/java/net/minecraft/server/level/ServerPlayer.java -+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java -@@ -447,7 +447,7 @@ public class ServerPlayer extends Player { - long l = k * k; - int i1 = l > 2147483647L ? Integer.MAX_VALUE : (int) l; - int j1 = this.getCoprime(i1); -- int k1 = RandomSource.create().nextInt(i1); -+ int k1 = (worldserver.plazmaLevelConfiguration().misc.reduceCreateRandomInstance ? worldserver.getRandom() : RandomSource.create()).nextInt(i1); // Plazma - - for (int l1 = 0; l1 < i1; ++l1) { - int i2 = (k1 + j1 * l1) % i1; -@@ -484,7 +484,7 @@ public class ServerPlayer extends Player { - long l = k * k; - int i1 = l > 2147483647L ? Integer.MAX_VALUE : (int) l; - int j1 = this.getCoprime(i1); -- int k1 = RandomSource.create().nextInt(i1); -+ int k1 = (world.plazmaLevelConfiguration().misc.reduceCreateRandomInstance ? world.getRandom() : RandomSource.create()).nextInt(i1); // Plazma - - for (int l1 = 0; l1 < i1; ++l1) { - int i2 = (k1 + j1 * l1) % i1; -diff --git a/src/main/java/net/minecraft/server/rcon/thread/QueryThreadGs4.java b/src/main/java/net/minecraft/server/rcon/thread/QueryThreadGs4.java -index 1ef089dbf83de35d875c00efdf468c397be56978..dc111e0d1e7303c56cd12fa83be3ff85ab989e1b 100644 ---- a/src/main/java/net/minecraft/server/rcon/thread/QueryThreadGs4.java -+++ b/src/main/java/net/minecraft/server/rcon/thread/QueryThreadGs4.java -@@ -349,7 +349,7 @@ public class QueryThreadGs4 extends GenericThread { - this.identBytes[2] = bs[5]; - this.identBytes[3] = bs[6]; - this.ident = new String(this.identBytes, StandardCharsets.UTF_8); -- this.challenge = RandomSource.create().nextInt(16777216); -+ this.challenge = org.plazmamc.plazma.configurations.GlobalConfiguration.get().misc.reduceCreateRandomInstance ? java.util.concurrent.ThreadLocalRandom.current().nextInt(16777216) : RandomSource.create().nextInt(16777216); // Plazma - this.challengeBytes = String.format(Locale.ROOT, "\t%s%d\u0000", this.ident, this.challenge).getBytes(StandardCharsets.UTF_8); - } - -diff --git a/src/main/java/net/minecraft/world/entity/projectile/FishingHook.java b/src/main/java/net/minecraft/world/entity/projectile/FishingHook.java -index b8c238287e0639b578170c6fec0d4db5a1a59fe7..9e5eab45d589db16b4f1ec563e40dc3890581bf4 100644 ---- a/src/main/java/net/minecraft/world/entity/projectile/FishingHook.java -+++ b/src/main/java/net/minecraft/world/entity/projectile/FishingHook.java -@@ -86,7 +86,7 @@ public class FishingHook extends Projectile { - - private FishingHook(EntityType type, Level world, int luckOfTheSeaLevel, int lureLevel) { - super(type, world); -- this.syncronizedRandom = RandomSource.create(); -+ this.syncronizedRandom = world.plazmaLevelConfiguration().misc.reduceCreateRandomInstance ? world.getRandom() : RandomSource.create(); // Plazma - this.openWater = true; - this.currentState = FishingHook.FishHookState.FLYING; - this.noCulling = true; -diff --git a/src/main/java/net/minecraft/world/entity/raid/Raid.java b/src/main/java/net/minecraft/world/entity/raid/Raid.java -index f7399737548483905f3b5c08a03876b0da54b714..7ff8e19fcee67a33bbc8603f8c089a5b76ed23b6 100644 ---- a/src/main/java/net/minecraft/world/entity/raid/Raid.java -+++ b/src/main/java/net/minecraft/world/entity/raid/Raid.java -@@ -110,7 +110,7 @@ public class Raid { - - public Raid(int id, ServerLevel world, BlockPos pos) { - this.raidEvent = new ServerBossEvent(Raid.RAID_NAME_COMPONENT, BossEvent.BossBarColor.RED, BossEvent.BossBarOverlay.NOTCHED_10); -- this.random = RandomSource.create(); -+ this.random = world.plazmaLevelConfiguration().misc.reduceCreateRandomInstance ? world.getRandom() : RandomSource.create(); // Plazma - this.waveSpawnPos = Optional.empty(); - this.id = id; - this.level = world; -@@ -124,7 +124,7 @@ public class Raid { - - public Raid(ServerLevel world, CompoundTag nbt) { - this.raidEvent = new ServerBossEvent(Raid.RAID_NAME_COMPONENT, BossEvent.BossBarColor.RED, BossEvent.BossBarOverlay.NOTCHED_10); -- this.random = RandomSource.create(); -+ this.random = world.plazmaLevelConfiguration().misc.reduceCreateRandomInstance ? world.getRandom() : RandomSource.create(); // Plazma - this.waveSpawnPos = Optional.empty(); - this.level = world; - this.id = nbt.getInt("Id"); -diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java -index 4932374ab9a3d8582fb0ef024d817ad896dd23c4..fd9be520b838346555dee2dc13f54dcf0fe0e9d8 100644 ---- a/src/main/java/net/minecraft/world/level/Explosion.java -+++ b/src/main/java/net/minecraft/world/level/Explosion.java -@@ -81,7 +81,7 @@ public class Explosion { - } - - public Explosion(Level world, @Nullable Entity entity, @Nullable DamageSource damageSource, @Nullable ExplosionDamageCalculator behavior, double x, double y, double z, float power, boolean createFire, Explosion.BlockInteraction destructionType) { -- this.random = RandomSource.create(); -+ this.random = world.plazmaLevelConfiguration().misc.reduceCreateRandomInstance ? world.getRandom() : RandomSource.create(); // Plazma - this.toBlow = new ObjectArrayList(); - this.hitPlayers = Maps.newHashMap(); - this.level = world; -diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java -index 6d513c903e06fe79dffdffd02871d00cb958b715..589c58c6057ba5fa9d44796f807b8378ee50d2ee 100644 ---- a/src/main/java/net/minecraft/world/level/Level.java -+++ b/src/main/java/net/minecraft/world/level/Level.java -@@ -124,7 +124,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { - public final Thread thread; - private final boolean isDebug; - private int skyDarken; -- protected int randValue = RandomSource.create().nextInt(); -+ protected int randValue = org.plazmamc.plazma.configurations.GlobalConfiguration.get().misc.reduceCreateRandomInstance ? java.util.concurrent.ThreadLocalRandom.current().nextInt() : RandomSource.create().nextInt(); // Plazma - protected final int addend = 1013904223; - protected float oRainLevel; - public float rainLevel; -diff --git a/src/main/java/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java -index 7291e4056b8e46ab59b71818388ac55fbb12993f..5e5efeec92f70060b0d409252ceff65691155367 100644 ---- a/src/main/java/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java -+++ b/src/main/java/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java -@@ -368,7 +368,7 @@ public class TheEndGatewayBlockEntity extends TheEndPortalBlockEntity { - } - - private static void spawnGatewayPortal(ServerLevel world, BlockPos pos, EndGatewayConfiguration config) { -- Feature.END_GATEWAY.place(config, world, world.getChunkSource().getGenerator(), RandomSource.create(), pos); -+ Feature.END_GATEWAY.place(config, world, world.getChunkSource().getGenerator(), (world.plazmaLevelConfiguration().misc.reduceCreateRandomInstance ? world.getRandom() : RandomSource.create()), pos); // Plazma - } - - @Override -diff --git a/src/main/java/net/minecraft/world/level/dimension/end/EndDragonFight.java b/src/main/java/net/minecraft/world/level/dimension/end/EndDragonFight.java -index 5b333bef255d7ef61c99510837536920c6fb6e8c..6331c068aefcdf07d2c880eef8df07add277f856 100644 ---- a/src/main/java/net/minecraft/world/level/dimension/end/EndDragonFight.java -+++ b/src/main/java/net/minecraft/world/level/dimension/end/EndDragonFight.java -@@ -472,7 +472,7 @@ public class EndDragonFight { - this.level.registryAccess().registry(Registries.CONFIGURED_FEATURE).flatMap((iregistry) -> { - return iregistry.getHolder(EndFeatures.END_GATEWAY_DELAYED); - }).ifPresent((holder_c) -> { -- ((ConfiguredFeature) holder_c.value()).place(this.level, this.level.getChunkSource().getGenerator(), RandomSource.create(), pos); -+ ((ConfiguredFeature) holder_c.value()).place(this.level, this.level.getChunkSource().getGenerator(), (this.level.plazmaLevelConfiguration().misc.reduceCreateRandomInstance ? this.level.getRandom() : RandomSource.create()), pos); - }); - } - -@@ -490,7 +490,7 @@ public class EndDragonFight { - this.portalLocation = this.portalLocation.atY(this.level.getMinBuildHeight() + 1); - } - // Paper end -- worldgenendtrophy.place(FeatureConfiguration.NONE, this.level, this.level.getChunkSource().getGenerator(), RandomSource.create(), this.portalLocation); -+ worldgenendtrophy.place(FeatureConfiguration.NONE, this.level, this.level.getChunkSource().getGenerator(), (this.level.plazmaLevelConfiguration().misc.reduceCreateRandomInstance ? this.level.getRandom() : RandomSource.create()), this.portalLocation); - } - - @Nullable -diff --git a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java -index 61477d98f10ce7d0ec29d51de8c7a3b42026dd2d..3e0d0d21dc73b2a5d033d8bcd43b08866e0d6923 100644 ---- a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java -+++ b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java -@@ -40,7 +40,7 @@ public class GlobalConfiguration extends ConfigurationPart { - public Misc misc; - public class Misc extends ConfigurationPart { - -- -+ public boolean reduceCreateRandomInstance = DO_OPTIMIZE; - - } - } -diff --git a/src/main/java/org/plazmamc/plazma/configurations/LevelConfigurations.java b/src/main/java/org/plazmamc/plazma/configurations/LevelConfigurations.java -index 843cf772c18d2e9386bf5a7b1731a86c349d6b98..14987ceec693397602b5c8e1fe460a6fc212a0ee 100644 ---- a/src/main/java/org/plazmamc/plazma/configurations/LevelConfigurations.java -+++ b/src/main/java/org/plazmamc/plazma/configurations/LevelConfigurations.java -@@ -87,7 +87,7 @@ public class LevelConfigurations extends ConfigurationPart { - public Misc misc; - public class Misc extends ConfigurationPart { - -- -+ public boolean reduceCreateRandomInstance = DO_OPTIMIZE; - - } - } diff --git a/patches/unapplied/server/0021-Entity-Configuration.patch b/patches/unapplied/server/0021-Entity-Configuration.patch deleted file mode 100644 index 2a45e7c58..000000000 --- a/patches/unapplied/server/0021-Entity-Configuration.patch +++ /dev/null @@ -1,32 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: AlphaKR93 -Date: Sat, 25 Mar 2023 20:38:21 +0900 -Subject: [PATCH] Entity Configuration - - -diff --git a/src/main/java/org/plazmamc/plazma/configurations/LevelConfigurations.java b/src/main/java/org/plazmamc/plazma/configurations/LevelConfigurations.java -index 14987ceec693397602b5c8e1fe460a6fc212a0ee..5dcabaf3fa198a05afc25753f6d062fe7d86972e 100644 ---- a/src/main/java/org/plazmamc/plazma/configurations/LevelConfigurations.java -+++ b/src/main/java/org/plazmamc/plazma/configurations/LevelConfigurations.java -@@ -90,4 +90,21 @@ public class LevelConfigurations extends ConfigurationPart { - public boolean reduceCreateRandomInstance = DO_OPTIMIZE; - - } -+ -+ public Entity entity; -+ public class Entity extends ConfigurationPart { -+ -+ public Monster monster; -+ public class Monster extends ConfigurationPart { -+ -+ public Phantom phantom; -+ public class Phantom extends ConfigurationPart { -+ -+ -+ -+ } -+ -+ } -+ -+ } - } diff --git a/patches/unapplied/server/0022-Various-Optimizations.patch b/patches/unapplied/server/0022-Various-Optimizations.patch deleted file mode 100644 index 1dee101ca..000000000 --- a/patches/unapplied/server/0022-Various-Optimizations.patch +++ /dev/null @@ -1,108 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: AlphaKR93 -Date: Sat, 25 Mar 2023 20:42:23 +0900 -Subject: [PATCH] Various Optimizations - -[ORIGINAL PATCHES] -0007 - Avoid double I/O operation on load player file (Akarin) -0008 - Don't trigger Lootable Refresh for non player interaction - (Akarin) -0011 - Swaps the predicate order of collision (Akarin) - -diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index cf0d8da4c4b5f4aa4e4ef15897ca252a2b52ec8d..42c1b7c635cd22125dbb6b4d195976daac0c9ea1 100644 ---- a/src/main/java/net/minecraft/world/entity/Entity.java -+++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -2145,8 +2145,9 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { - public void playerTouch(Player player) {} - - public void push(Entity entity) { -+ if (entity.noPhysics || this.noPhysics) return; // Plazma - if (!this.isPassengerOfSameVehicle(entity)) { -- if (!entity.noPhysics && !this.noPhysics) { -+ //if (!entity.noPhysics && !this.noPhysics) { // Plazma - moved up - if (this.level.paperConfig().collisions.onlyPlayersCollide && !(entity instanceof ServerPlayer || this instanceof ServerPlayer)) return; // Paper - double d0 = entity.getX() - this.getX(); - double d1 = entity.getZ() - this.getZ(); -@@ -2174,8 +2175,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { - entity.push(d0, 0.0D, d1); - } - } -- -- } -+ //} // Plazma - } - } - -diff --git a/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java -index 765ee7f78532a363813286ef7db2a7e48605cb06..47830edd65b7f54a01559c80d28586b91cc07739 100644 ---- a/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java -+++ b/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java -@@ -70,6 +70,7 @@ public abstract class RandomizableContainerBlockEntity extends BaseContainerBloc - } - - public void unpackLootTable(@Nullable Player player) { -+ if (org.plazmamc.plazma.configurations.GlobalConfiguration.get().misc.doNotTriggerLootTableRefreshForNonPlayerInteraction && player == null) return; // Plazma - if (this.lootableData.shouldReplenish(player) && this.level.getServer() != null) { // Paper - LootTable lootTable = this.level.getServer().getLootData().getLootTable(this.lootTable); - if (player instanceof ServerPlayer) { -diff --git a/src/main/java/net/minecraft/world/level/levelgen/PhantomSpawner.java b/src/main/java/net/minecraft/world/level/levelgen/PhantomSpawner.java -index f74c5eda91a3d521763ec7bc33f23e0c62458cc2..9f1ee01eb9dcb599d1eb453653c7e7479fb24a4c 100644 ---- a/src/main/java/net/minecraft/world/level/levelgen/PhantomSpawner.java -+++ b/src/main/java/net/minecraft/world/level/levelgen/PhantomSpawner.java -@@ -71,6 +71,7 @@ public class PhantomSpawner implements CustomSpawner { - - if (randomsource.nextInt(j) >= world.paperConfig().entities.behavior.playerInsomniaStartTicks) { // Paper - BlockPos blockposition1 = blockposition.above(20 + randomsource.nextInt(15)).east(-10 + randomsource.nextInt(21)).south(-10 + randomsource.nextInt(21)); -+ if (world.plazmaLevelConfiguration().entity.monster.phantom.doNotLoadChunksToSpawn && world.hasChunkAt(blockposition1)) continue; // Plazma - BlockState iblockdata = world.getBlockState(blockposition1); - FluidState fluid = world.getFluidState(blockposition1); - -diff --git a/src/main/java/net/minecraft/world/level/storage/PlayerDataStorage.java b/src/main/java/net/minecraft/world/level/storage/PlayerDataStorage.java -index 36af81f0957d17e170d229059c66f4eb4539dfeb..039c952f0c157cba6e79fa9b976958bd1763a922 100644 ---- a/src/main/java/net/minecraft/world/level/storage/PlayerDataStorage.java -+++ b/src/main/java/net/minecraft/world/level/storage/PlayerDataStorage.java -@@ -56,7 +56,8 @@ public class PlayerDataStorage { - File file = new File(this.playerDir, player.getStringUUID() + ".dat"); - // Spigot Start - boolean usingWrongFile = false; -- if ( org.bukkit.Bukkit.getOnlineMode() && !file.exists() ) // Paper - Check online mode first -+ boolean normalFile = file.exists() && file.isFile(); // Plazma - Avoid double I/O operation -+ if ( org.bukkit.Bukkit.getOnlineMode() && !normalFile ) // Paper - Check online mode first // Plazma - Avoid double I/O operation - { - file = new File( this.playerDir, java.util.UUID.nameUUIDFromBytes( ( "OfflinePlayer:" + player.getScoreboardName() ).getBytes( "UTF-8" ) ).toString() + ".dat"); - if ( file.exists() ) -@@ -67,7 +68,7 @@ public class PlayerDataStorage { - } - // Spigot End - -- if (file.exists() && file.isFile()) { -+ if (normalFile) { // Plazma - Avoid double I/O operation - nbttagcompound = NbtIo.readCompressed(file); - } - // Spigot Start -diff --git a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java -index 3e0d0d21dc73b2a5d033d8bcd43b08866e0d6923..e91b404fca2823748c2ed343cbd83301e55b2f0a 100644 ---- a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java -+++ b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java -@@ -41,6 +41,7 @@ public class GlobalConfiguration extends ConfigurationPart { - public class Misc extends ConfigurationPart { - - public boolean reduceCreateRandomInstance = DO_OPTIMIZE; -+ public boolean doNotTriggerLootTableRefreshForNonPlayerInteraction = DO_OPTIMIZE; - - } - } -diff --git a/src/main/java/org/plazmamc/plazma/configurations/LevelConfigurations.java b/src/main/java/org/plazmamc/plazma/configurations/LevelConfigurations.java -index 5dcabaf3fa198a05afc25753f6d062fe7d86972e..504913e8e05869f8f0b88f0faaf684d39eb14ea7 100644 ---- a/src/main/java/org/plazmamc/plazma/configurations/LevelConfigurations.java -+++ b/src/main/java/org/plazmamc/plazma/configurations/LevelConfigurations.java -@@ -100,7 +100,7 @@ public class LevelConfigurations extends ConfigurationPart { - public Phantom phantom; - public class Phantom extends ConfigurationPart { - -- -+ public boolean doNotLoadChunksToSpawn = DO_OPTIMIZE; - - } - diff --git a/patches/unapplied/server/0025-Do-not-send-useless-entity-packets.patch b/patches/unapplied/server/0025-Do-not-send-useless-entity-packets.patch deleted file mode 100644 index 05a39a72b..000000000 --- a/patches/unapplied/server/0025-Do-not-send-useless-entity-packets.patch +++ /dev/null @@ -1,52 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: AlphaKR93 -Date: Sat, 25 Mar 2023 22:07:39 +0900 -Subject: [PATCH] Do not send useless entity packets - - -diff --git a/src/main/java/net/minecraft/server/level/ServerEntity.java b/src/main/java/net/minecraft/server/level/ServerEntity.java -index fb11b020d52988360562db23d8568e5ef37e21c8..80ab684a33876d62186dcf86f555e46db1594b09 100644 ---- a/src/main/java/net/minecraft/server/level/ServerEntity.java -+++ b/src/main/java/net/minecraft/server/level/ServerEntity.java -@@ -203,6 +203,7 @@ public class ServerEntity { - flag4 = true; - flag5 = true; - } -+ if (org.plazmamc.plazma.configurations.GlobalConfiguration.get().misc.doNotSendUselessEntityPackets && isUselessEntityPacket(packet1)) packet1 = null; // Plazma - } - - if ((this.trackDelta || this.entity.hasImpulse || this.entity instanceof LivingEntity && ((LivingEntity) this.entity).isFallFlying()) && this.tickCount > 0) { -@@ -275,6 +276,21 @@ public class ServerEntity { - }); - } - -+ // Plazma start -+ private boolean isUselessEntityPacket(@Nullable Packet packet) { -+ if (packet == null) return false; -+ if (packet instanceof ClientboundMoveEntityPacket p) { -+ if (p instanceof ClientboundMoveEntityPacket.Pos) -+ return p.getXa() == 0 && p.getYa() == 0 && p.getZa() == 0; -+ else if (p instanceof ClientboundMoveEntityPacket.Rot) -+ return p.getxRot() == 0 && p.getyRot() == 0; -+ else if (p instanceof ClientboundMoveEntityPacket.PosRot) -+ return p.getXa() == 0 && p.getYa() == 0 && p.getZa() == 0 && p.getxRot() == 0 && p.getyRot() == 0; -+ } -+ return false; -+ } -+ // Plazma end -+ - public void removePairing(ServerPlayer player) { - this.entity.stopSeenByPlayer(player); - player.connection.send(new ClientboundRemoveEntitiesPacket(new int[]{this.entity.getId()})); -diff --git a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java -index e91b404fca2823748c2ed343cbd83301e55b2f0a..d21be63b98f026fa3ac7dcdc73f9f488a7000643 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; - - } - }