Skip to content

Commit

Permalink
Some patch
Browse files Browse the repository at this point in the history
  • Loading branch information
s-yh-china committed Nov 17, 2024
1 parent 805026e commit 80d9144
Show file tree
Hide file tree
Showing 82 changed files with 536 additions and 651 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: violetc <[email protected]>
Date: Sun, 14 Aug 2022 17:16:19 +0800
Subject: [PATCH] Early return optimization for target finding

This patch is Powered by Pufferfish(https://github.com/pufferfish-gg/Pufferfish)

diff --git a/src/main/java/net/minecraft/world/entity/ai/targeting/TargetingConditions.java b/src/main/java/net/minecraft/world/entity/ai/targeting/TargetingConditions.java
index aecb0ad814586bfc5e56755ee14379a69388b38c..c618d7c87a0b2e2ee55cbe64cae80178fd8bd651 100644
--- a/src/main/java/net/minecraft/world/entity/ai/targeting/TargetingConditions.java
+++ b/src/main/java/net/minecraft/world/entity/ai/targeting/TargetingConditions.java
@@ -76,9 +76,17 @@ public class TargetingConditions {
}

if (this.range > 0.0) {
+ // Leaves start - check range before getting visibility
+ double f = baseEntity.distanceToSqr(targetEntity.getX(), targetEntity.getY(), targetEntity.getZ());
+ if (org.leavesmc.leaves.LeavesConfig.entityTargetFindingOptimization) {
+ double followRangeRaw = this.useFollowRange ? this.getFollowRange(baseEntity) : this.range;
+ if (f > followRangeRaw * followRangeRaw) { // the actual follow range will always be this value or smaller, so if the distance is larger then it never will return true after getting invis
+ return false;
+ }
+ }
+ // Leaves end - check range before getting visibility
double d = this.testInvisible ? targetEntity.getVisibilityPercent(baseEntity) : 1.0;
double e = Math.max((this.useFollowRange ? this.getFollowRange(baseEntity) : this.range) * d, 2.0); // Paper - Fix MC-145656
- double f = baseEntity.distanceToSqr(targetEntity.getX(), targetEntity.getY(), targetEntity.getZ());
if (f > e * e) {
return false;
}
32 changes: 32 additions & 0 deletions patches/server/0022-Config-to-disable-method-profiler.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: violetc <[email protected]>
Date: Mon, 15 Aug 2022 10:18:36 +0800
Subject: [PATCH] Config to disable method profiler

This patch is Powered by Pufferfish(https://github.com/pufferfish-gg/Pufferfish)

diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 59d4bc687af52ffb2b8529ce91a5703492fce96f..601d12cc2e0f2e180882f6b8c878e24a0856d082 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -1320,7 +1320,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
this.nextTickTimeNanos += i;

try {
- Profiler.Scope profiler_a = Profiler.use(this.createProfiler());
+ Profiler.Scope profiler_a = org.leavesmc.leaves.LeavesConfig.disableMethodProfiler ? null : Profiler.use(this.createProfiler()); // Leaves - disable profiler

try {
ProfilerFiller gameprofilerfiller = Profiler.get();
diff --git a/src/main/java/net/minecraft/util/profiling/Profiler.java b/src/main/java/net/minecraft/util/profiling/Profiler.java
index fe8a8ee1f88c58a9fe730c4c0cc5fc4e3651e9f8..1c2bead15410adec68f7a9fecb8bc94f8636aeb2 100644
--- a/src/main/java/net/minecraft/util/profiling/Profiler.java
+++ b/src/main/java/net/minecraft/util/profiling/Profiler.java
@@ -44,6 +44,7 @@ public final class Profiler {
}

public static ProfilerFiller get() {
+ if (org.leavesmc.leaves.LeavesConfig.disableMethodProfiler) return InactiveProfiler.INSTANCE; // Leaves - disable profiler
return ACTIVE_COUNT.get() == 0 ? getDefaultFiller() : Objects.requireNonNullElseGet(ACTIVE.get(), Profiler::getDefaultFiller);
}

39 changes: 0 additions & 39 deletions patches/server/0023-Config-to-disable-method-profiler.patch

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ Subject: [PATCH] Throttle goal selector during inactive ticking
This patch is Powered by Pufferfish(https://github.com/pufferfish-gg/Pufferfish)

diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java
index bd7c6ce15698aed70376c109ba36f52d6794a2f8..9f2ef5ea9f380e78d4a150df9f16ff6bfc398b75 100644
index dbd321f3dc3cc80737830db63aed47a6935e8e89..0fb446255cc4b513d6ae7358e77d01fc943cb625 100644
--- a/src/main/java/net/minecraft/world/entity/Mob.java
+++ b/src/main/java/net/minecraft/world/entity/Mob.java
@@ -232,11 +232,13 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab
@@ -235,11 +235,13 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab
return this.lookControl;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Subject: [PATCH] Reduce entity allocations
This patch is Powered by Pufferfish(https://github.com/pufferfish-gg/Pufferfish)

diff --git a/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMap.java b/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMap.java
index 69992ebc999ea3ff9e47e4e049bcc514c01150ca..2118ad41e94e8f5e5fac50286ceb24ab70db88f2 100644
index 94d04a20f97405e02d7cccaabadc7a7e86e336f7..1cf8abe04d4cf29b8de5d494f5564ed0ae57512c 100644
--- a/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMap.java
+++ b/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMap.java
@@ -23,9 +23,11 @@ public class AttributeMap {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ Subject: [PATCH] Remove lambda from ticking guard
This patch is Powered by Pufferfish(https://github.com/pufferfish-gg/Pufferfish)

diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index 49e7d9bc75e029a8800f7369681e43efd14cd322..5a97f8a853664a3ced63215a386286873a6c7a95 100644
index abaa89fdb80da461a9720a31d2bfae8ee9ad3a8f..b73881ad6656a990ad0313b4ab94ba7302fae6b2 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -725,7 +725,23 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf.
@@ -804,7 +804,23 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
}

gameprofilerfiller.push("tick");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ Subject: [PATCH] Remove iterators from inventory contains
This patch is Powered by Pufferfish(https://github.com/pufferfish-gg/Pufferfish)

diff --git a/src/main/java/net/minecraft/world/entity/player/Inventory.java b/src/main/java/net/minecraft/world/entity/player/Inventory.java
index 6e66141dca61f777b354854b5d0bac2570b8bf3b..eb11482f48c9f330b7fa62a278fd6f07d3a642e1 100644
index 0e214d502998e9eb959952b257844529992df0df..6d4d3eadb3408e5eb2f545551270071c9517eedb 100644
--- a/src/main/java/net/minecraft/world/entity/player/Inventory.java
+++ b/src/main/java/net/minecraft/world/entity/player/Inventory.java
@@ -643,17 +643,31 @@ public class Inventory implements Container, Nameable {
@@ -649,17 +649,31 @@ public class Inventory implements Container, Nameable {
}

public boolean contains(ItemStack stack) {
Expand Down Expand Up @@ -49,7 +49,7 @@ index 6e66141dca61f777b354854b5d0bac2570b8bf3b..eb11482f48c9f330b7fa62a278fd6f07
}
}
}
@@ -662,17 +676,30 @@ public class Inventory implements Container, Nameable {
@@ -668,17 +682,30 @@ public class Inventory implements Container, Nameable {
}

public boolean contains(TagKey<Item> tag) {
Expand Down Expand Up @@ -88,7 +88,7 @@ index 6e66141dca61f777b354854b5d0bac2570b8bf3b..eb11482f48c9f330b7fa62a278fd6f07
}
}
}
@@ -681,21 +708,34 @@ public class Inventory implements Container, Nameable {
@@ -687,21 +714,34 @@ public class Inventory implements Container, Nameable {
}

public boolean contains(Predicate<ItemStack> predicate) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ Subject: [PATCH] Cache climbing check for activation
This patch is Powered by Pufferfish(https://github.com/pufferfish-gg/Pufferfish)

diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
index 0556500fde799583a65a82d00a6b2c65a1757d5e..408700b2236b4e04baebe23b47e72722006e3e23 100644
index 9caeda8672567ecd9687f5b1b0e5eb3dbf0b7769..5ddea4ca32bc2741ab449dc00a3d9ce4f8c57c70 100644
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
@@ -2073,6 +2073,22 @@ public abstract class LivingEntity extends Entity implements Attackable {
@@ -2123,6 +2123,22 @@ public abstract class LivingEntity extends Entity implements Attackable {
return this.lastClimbablePos;
}

Expand All @@ -33,7 +33,7 @@ index 0556500fde799583a65a82d00a6b2c65a1757d5e..408700b2236b4e04baebe23b47e72722
if (this.isSpectator()) {
return false;
diff --git a/src/main/java/org/spigotmc/ActivationRange.java b/src/main/java/org/spigotmc/ActivationRange.java
index 621bda8248e35f5a5730f89a4bcfbe6615ed969c..47c30ebb3ea6fab0a0d51211905217a1d2a0c770 100644
index bd7c37123c70d2afdef252f39548725d4ef318ed..8f0815a38fbe2e6cc5d86172d5219f0a26334ea2 100644
--- a/src/main/java/org/spigotmc/ActivationRange.java
+++ b/src/main/java/org/spigotmc/ActivationRange.java
@@ -295,7 +295,7 @@ public class ActivationRange
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ Subject: [PATCH] Reduce chunk loading & lookups
This patch is Powered by Pufferfish(https://github.com/pufferfish-gg/Pufferfish)

diff --git a/src/main/java/net/minecraft/world/entity/monster/EnderMan.java b/src/main/java/net/minecraft/world/entity/monster/EnderMan.java
index 828c51477cd8f35d591367b30bf4feef6a250292..17a71bb3b65cc1030b70c931b1dc998d06713231 100644
index 48dcd2bc12ce1d08cc5195bff5460dc0dd9902d3..350ca2bf963b41227c69d0621330a0c1c024c09f 100644
--- a/src/main/java/net/minecraft/world/entity/monster/EnderMan.java
+++ b/src/main/java/net/minecraft/world/entity/monster/EnderMan.java
@@ -320,11 +320,28 @@ public class EnderMan extends Monster implements NeutralMob {
@@ -307,11 +307,28 @@ public class EnderMan extends Monster implements NeutralMob {
private boolean teleport(double x, double y, double z) {
BlockPos.MutableBlockPos blockposition_mutableblockposition = new BlockPos.MutableBlockPos(x, y, z);

- while (blockposition_mutableblockposition.getY() > this.level().getMinBuildHeight() && !this.level().getBlockState(blockposition_mutableblockposition).blocksMotion()) {
- while (blockposition_mutableblockposition.getY() > this.level().getMinY() && !this.level().getBlockState(blockposition_mutableblockposition).blocksMotion()) {
- blockposition_mutableblockposition.move(Direction.DOWN);
+ // Leaves start - single chunk lookup
+ BlockState iblockdata;
Expand All @@ -23,13 +23,13 @@ index 828c51477cd8f35d591367b30bf4feef6a250292..17a71bb3b65cc1030b70c931b1dc998d
+ return false;
+ }
+
+ while (blockposition_mutableblockposition.getY() > this.level().getMinBuildHeight() && !chunk.getBlockState(blockposition_mutableblockposition).blocksMotion()) {
+ while (blockposition_mutableblockposition.getY() > this.level().getMinY() && !chunk.getBlockState(blockposition_mutableblockposition).blocksMotion()) {
+ blockposition_mutableblockposition.move(Direction.DOWN);
+ }
+
+ iblockdata = chunk.getBlockState(blockposition_mutableblockposition);
+ } else {
+ while (blockposition_mutableblockposition.getY() > this.level().getMinBuildHeight() && !this.level().getBlockState(blockposition_mutableblockposition).blocksMotion()) {
+ while (blockposition_mutableblockposition.getY() > this.level().getMinY() && !this.level().getBlockState(blockposition_mutableblockposition).blocksMotion()) {
+ blockposition_mutableblockposition.move(Direction.DOWN);
+ }
+
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ Subject: [PATCH] InstantBlockUpdater Reintroduced
This patch is Powered by Carpet-TIS-Addition(https://github.com/plusls/Carpet-TIS-Addition)

diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index e935903d918f12e5e1617ebf2d74399b9cd4f79c..1f6e6bba0f6d16091f4c6a5fdb4bac4579ba525f 100644
index 022de445bbbb869c38be4972c98dcf1c665539ec..fe8c9aae9da0b3a6980d5d8e3d78e58003aff25a 100644
--- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -723,7 +723,13 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
@@ -878,7 +878,13 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
this.thread = Thread.currentThread();
this.biomeManager = new BiomeManager(this, i);
this.isDebug = flag1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Subject: [PATCH] Random flatten triangular distribution
This patch is Powered by Carpet-TIS-Addition(https://github.com/plusls/Carpet-TIS-Addition)

diff --git a/src/main/java/net/minecraft/util/RandomSource.java b/src/main/java/net/minecraft/util/RandomSource.java
index 9c6f5b55b1f1376fa75e216cd366ee47c79fafc4..50dc6530e6191f2a00025d4610e335041bc858a4 100644
index 252aef3ffe0fecd47ebea1ed7df48e14fa873eb9..3c71ef85b2444ea3858c12de48f4d7a2385e5b4f 100644
--- a/src/main/java/net/minecraft/util/RandomSource.java
+++ b/src/main/java/net/minecraft/util/RandomSource.java
@@ -53,7 +53,14 @@ public interface RandomSource {
Expand All @@ -24,4 +24,4 @@ index 9c6f5b55b1f1376fa75e216cd366ee47c79fafc4..50dc6530e6191f2a00025d4610e33504
+ // Leaves end - flattenTriangularDistribution
}

default void consumeCount(int count) {
default float triangle(float mode, float deviation) {
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ Subject: [PATCH] BBOR Protocol


diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
index 5221ab490fcbc11434c1209f654e5731fa15487e..7ba6579cfe925ef40940cce29ebc0abb6458f13d 100644
index 0e179ab666e936f59b9e2f42340871218b0439d3..8cc7815e0f996b7d5c4518a4a487b99480f48f97 100644
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
@@ -1596,6 +1596,7 @@ public abstract class PlayerList {
@@ -1566,6 +1566,7 @@ public abstract class PlayerList {
entityplayer.getRecipeBook().sendInitialRecipeBook(entityplayer);
}

Expand All @@ -17,10 +17,10 @@ index 5221ab490fcbc11434c1209f654e5731fa15487e..7ba6579cfe925ef40940cce29ebc0abb

public boolean isAllowCommandsForAllPlayers() {
diff --git a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
index c0ce5d4c3189337b06476c16558e12d3f8127797..382ca565fe1a680ab49b14ac90e4ec3bd903450d 100644
index 4640baec5bed6c2d53cc0f8ca1d273cc115abe9b..2fea5a46bba27578366c36f594472c3e38395bee 100644
--- a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
+++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
@@ -784,6 +784,11 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p
@@ -813,6 +813,11 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p

public void setLoaded(boolean loadedToWorld) {
this.loaded = loadedToWorld;
Expand Down
Loading

0 comments on commit 80d9144

Please sign in to comment.