108 lines
6.7 KiB
Diff
108 lines
6.7 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 3c10c719f6172161a2dcc6592a0a1492e9b3d7c1..d64f188257c135e2a4af07e28ff8f912c80eac03 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
|
@@ -1991,8 +1991,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
|
|
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();
|
|
@@ -2021,7 +2022,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
|
}
|
|
}
|
|
|
|
- }
|
|
+ //} // 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 6d62cc8fb347ccafd51df05896e616995990f005..c26e4795afd0bd450d304f4528d0b8e4cfa761ce 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().getLootTables().get(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 f55c50f6637a4f930b15565d6ac82bb4f27b9059..9c4e65a67bda331625a0891be10495eaae5f3f5e 100644
|
|
--- a/src/main/java/net/minecraft/world/level/levelgen/PhantomSpawner.java
|
|
+++ b/src/main/java/net/minecraft/world/level/levelgen/PhantomSpawner.java
|
|
@@ -73,6 +73,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 66436d4eb66b5a71f18b7db359ab1d63bbac74c0..87a85fb1cd9a19541df04a5d1c457d86cf7f68eb 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 f560db0cd544c96264ebad8af3ed3dd8379bab1b..80ee8293d73ecdb1a942ca88f1aa00813d600849 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;
|
|
|
|
}
|
|
|