109 lines
6.8 KiB
Diff
109 lines
6.8 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: AlphaKR93 <dev@alpha93.kr>
|
|
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;
|
|
|
|
}
|
|
|