mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-26 10:29:13 +00:00
optimize chunk map (#438)
* rebase * optimize LivingEntity#travel * cleanup * Replace fluid height map * reuse array list in Entity#collide * cleanup * fix fire and liquid collision shape * fix checkInside * inline betweenClosed * cleanup * optimize getOnPos * optimize equals in getOnPos * update mainSupportingBlockPos on dirty * cleanup * rename * merge same patch * rebase and remove properly * [ci skip] cleanup * rebase and rebuild * fix async locator * remove async locator * cleanup * rebase --------- Co-authored-by: Taiyou06 <kaandindar21@gmail.com>
This commit is contained in:
@@ -1,242 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: HaHaWTH <102713261+HaHaWTH@users.noreply.github.com>
|
||||
Date: Wed, 23 Oct 2024 23:54:00 +0800
|
||||
Subject: [PATCH] Asynchronous locator
|
||||
|
||||
Original license: MIT
|
||||
Original project: https://github.com/thebrightspark/AsyncLocator
|
||||
|
||||
diff --git a/net/minecraft/server/commands/LocateCommand.java b/net/minecraft/server/commands/LocateCommand.java
|
||||
index a734b2597c3491db35d9660e169f8e8b6320900b..5274f09b0abf148aea1c0baa39edbfdac1acc4f5 100644
|
||||
--- a/net/minecraft/server/commands/LocateCommand.java
|
||||
+++ b/net/minecraft/server/commands/LocateCommand.java
|
||||
@@ -106,6 +106,34 @@ public class LocateCommand {
|
||||
BlockPos blockPos = BlockPos.containing(source.getPosition());
|
||||
ServerLevel level = source.getLevel();
|
||||
Stopwatch stopwatch = Stopwatch.createStarted(Util.TICKER);
|
||||
+ // Leaf start - Asynchronous locator
|
||||
+ if (org.dreeam.leaf.config.modules.async.AsyncLocator.enabled) {
|
||||
+ BlockPos originPos = BlockPos.containing(source.getPosition());
|
||||
+ org.dreeam.leaf.async.locate.AsyncLocator.locate(source.getLevel(), holderSet, originPos, 100, false)
|
||||
+ .thenOnServerThread(pair -> {
|
||||
+ stopwatch.stop();
|
||||
+ if (pair != null) {
|
||||
+ showLocateResult(
|
||||
+ source,
|
||||
+ structure,
|
||||
+ originPos,
|
||||
+ pair,
|
||||
+ "commands.locate.structure.success",
|
||||
+ false,
|
||||
+ stopwatch.elapsed()
|
||||
+ );
|
||||
+ } else {
|
||||
+ source.sendFailure(
|
||||
+ Component.literal(
|
||||
+ ERROR_STRUCTURE_NOT_FOUND.create(structure.asPrintable()).getMessage()
|
||||
+ )
|
||||
+ );
|
||||
+ }
|
||||
+ });
|
||||
+
|
||||
+ return 0;
|
||||
+ }
|
||||
+ // Leaf end - Asynchronous locator
|
||||
Pair<BlockPos, Holder<Structure>> pair = level.getChunkSource().getGenerator().findNearestMapStructure(level, holderSet, blockPos, 100, false);
|
||||
stopwatch.stop();
|
||||
if (pair == null) {
|
||||
diff --git a/net/minecraft/server/level/ServerChunkCache.java b/net/minecraft/server/level/ServerChunkCache.java
|
||||
index eaaa66c4d86d4ebda0acf8f1dbe8ecb55aa28285..8f41326fda8c5f9f6926038508be6c6529b051bc 100644
|
||||
--- a/net/minecraft/server/level/ServerChunkCache.java
|
||||
+++ b/net/minecraft/server/level/ServerChunkCache.java
|
||||
@@ -852,14 +852,25 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
|
||||
|
||||
@Override
|
||||
public boolean pollTask() {
|
||||
+ // Leaf start - Async Locator
|
||||
// Paper start - rewrite chunk system
|
||||
- final ServerChunkCache serverChunkCache = ServerChunkCache.this;
|
||||
- if (serverChunkCache.runDistanceManagerUpdates()) {
|
||||
- return true;
|
||||
+ java.util.function.Supplier<Boolean> supplier = () -> {
|
||||
+ final ServerChunkCache serverChunkCache = ServerChunkCache.this;
|
||||
+ if (serverChunkCache.runDistanceManagerUpdates()) {
|
||||
+ return true;
|
||||
+ } else {
|
||||
+ return super.pollTask() | ((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemServerLevel) serverChunkCache.level).moonrise$getChunkTaskScheduler().executeMainThreadTask();
|
||||
+ }
|
||||
+ };
|
||||
+ if (org.dreeam.leaf.config.modules.async.AsyncLocator.enabled && Thread.currentThread() instanceof org.dreeam.leaf.async.locate.AsyncLocator.AsyncLocatorThread) {
|
||||
+ return MinecraftServer.getServer().scheduleWithResult((java.util.concurrent.CompletableFuture<Boolean> future) -> {
|
||||
+ future.complete(supplier.get());
|
||||
+ }).join();
|
||||
} else {
|
||||
- return super.pollTask() | ((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemServerLevel)serverChunkCache.level).moonrise$getChunkTaskScheduler().executeMainThreadTask();
|
||||
+ return supplier.get();
|
||||
}
|
||||
// Paper end - rewrite chunk system
|
||||
+ // Leaf end - Async Locator
|
||||
}
|
||||
}
|
||||
}
|
||||
diff --git a/net/minecraft/world/entity/animal/Dolphin.java b/net/minecraft/world/entity/animal/Dolphin.java
|
||||
index 23696a5e2871ea07f34d4b4f6a20e2896ac3f5bd..c4fda92e078c9ba745b2548ecaaffffff97fb0fd 100644
|
||||
--- a/net/minecraft/world/entity/animal/Dolphin.java
|
||||
+++ b/net/minecraft/world/entity/animal/Dolphin.java
|
||||
@@ -487,6 +487,10 @@ public class Dolphin extends AgeableWaterCreature {
|
||||
static class DolphinSwimToTreasureGoal extends Goal {
|
||||
private final Dolphin dolphin;
|
||||
private boolean stuck;
|
||||
+ // Leaf start - Asynchronous locator
|
||||
+ @Nullable
|
||||
+ private org.dreeam.leaf.async.locate.AsyncLocator.LocateTask<?> asyncLocator$locateTask;
|
||||
+ // Leaf end - Asynchronous locator
|
||||
|
||||
DolphinSwimToTreasureGoal(Dolphin dolphin) {
|
||||
this.dolphin = dolphin;
|
||||
@@ -506,6 +510,11 @@ public class Dolphin extends AgeableWaterCreature {
|
||||
|
||||
@Override
|
||||
public boolean canContinueToUse() {
|
||||
+ // Leaf start - Asynchronous locator
|
||||
+ if (org.dreeam.leaf.config.modules.async.AsyncLocator.enabled && this.asyncLocator$locateTask != null) {
|
||||
+ return true;
|
||||
+ }
|
||||
+ // Leaf end - Asynchronous locator
|
||||
BlockPos blockPos = this.dolphin.treasurePos;
|
||||
return blockPos != null
|
||||
&& !BlockPos.containing(blockPos.getX(), this.dolphin.getY(), blockPos.getZ()).closerToCenterThan(this.dolphin.position(), 4.0)
|
||||
@@ -520,6 +529,22 @@ public class Dolphin extends AgeableWaterCreature {
|
||||
this.stuck = false;
|
||||
this.dolphin.getNavigation().stop();
|
||||
BlockPos blockPos = this.dolphin.blockPosition();
|
||||
+ // Leaf start - Asynchronous locator
|
||||
+ if (org.dreeam.leaf.config.modules.async.AsyncLocator.enabled) {
|
||||
+ asyncLocator$locateTask = org.dreeam.leaf.async.locate.AsyncLocator.locate(serverLevel, StructureTags.DOLPHIN_LOCATED, blockPos, 50, false)
|
||||
+ .thenOnServerThread(pos -> {
|
||||
+ asyncLocator$locateTask = null;
|
||||
+ if (pos != null) {
|
||||
+ this.dolphin.treasurePos = pos;
|
||||
+ serverLevel.broadcastEntityEvent(this.dolphin, (byte) 38);
|
||||
+ } else {
|
||||
+ this.stuck = true;
|
||||
+ }
|
||||
+ });
|
||||
+
|
||||
+ return;
|
||||
+ }
|
||||
+ // Leaf end - Asynchronous locator
|
||||
BlockPos blockPos1 = serverLevel.findNearestMapStructure(StructureTags.DOLPHIN_LOCATED, blockPos, 50, false);
|
||||
if (blockPos1 != null) {
|
||||
this.dolphin.treasurePos = blockPos1;
|
||||
@@ -532,6 +557,12 @@ public class Dolphin extends AgeableWaterCreature {
|
||||
|
||||
@Override
|
||||
public void stop() {
|
||||
+ // Leaf start - Asynchronous locator
|
||||
+ if (org.dreeam.leaf.config.modules.async.AsyncLocator.enabled && this.asyncLocator$locateTask != null) {
|
||||
+ this.asyncLocator$locateTask.cancel();
|
||||
+ this.asyncLocator$locateTask = null;
|
||||
+ }
|
||||
+ // Leaf end - Asynchronous locator
|
||||
BlockPos blockPos = this.dolphin.treasurePos;
|
||||
if (blockPos == null
|
||||
|| BlockPos.containing(blockPos.getX(), this.dolphin.getY(), blockPos.getZ()).closerToCenterThan(this.dolphin.position(), 4.0)
|
||||
@@ -542,6 +573,11 @@ public class Dolphin extends AgeableWaterCreature {
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
+ // Leaf start - Asynchronous locator
|
||||
+ if (org.dreeam.leaf.config.modules.async.AsyncLocator.enabled && this.asyncLocator$locateTask != null) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // Leaf end - Asynchronous locator
|
||||
if (this.dolphin.treasurePos != null) {
|
||||
Level level = this.dolphin.level();
|
||||
if (this.dolphin.closeToNextPos() || this.dolphin.getNavigation().isDone()) {
|
||||
diff --git a/net/minecraft/world/entity/projectile/EyeOfEnder.java b/net/minecraft/world/entity/projectile/EyeOfEnder.java
|
||||
index 2bb3c5018be0c669da4c28a34ce2f2e124547691..2c34e956e8a3263bb05ae2810a8578696f739263 100644
|
||||
--- a/net/minecraft/world/entity/projectile/EyeOfEnder.java
|
||||
+++ b/net/minecraft/world/entity/projectile/EyeOfEnder.java
|
||||
@@ -28,6 +28,7 @@ public class EyeOfEnder extends Entity implements ItemSupplier {
|
||||
public Vec3 target;
|
||||
public int life;
|
||||
public boolean surviveAfterDeath;
|
||||
+ public boolean asyncLocator$locateTaskOngoing = false; // Leaf - Asynchronous locator
|
||||
|
||||
public EyeOfEnder(EntityType<? extends EyeOfEnder> entityType, Level level) {
|
||||
super(entityType, level);
|
||||
@@ -95,6 +96,11 @@ public class EyeOfEnder extends Entity implements ItemSupplier {
|
||||
@Override
|
||||
public void tick() {
|
||||
super.tick();
|
||||
+ // Leaf start - Asynchronous locator
|
||||
+ if (org.dreeam.leaf.config.modules.async.AsyncLocator.enabled && this.asyncLocator$locateTaskOngoing) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // Leaf end - Asynchronous locator
|
||||
Vec3 vec3 = this.position().add(this.getDeltaMovement());
|
||||
if (!this.level().isClientSide() && this.target != null) {
|
||||
this.setDeltaMovement(updateDeltaMovement(this.getDeltaMovement(), vec3, this.target));
|
||||
diff --git a/net/minecraft/world/item/EnderEyeItem.java b/net/minecraft/world/item/EnderEyeItem.java
|
||||
index 51e0985bde9cf6ac2f4264d21edec3d1623a2d0d..ca2b493e4032208311c857db799632ac3d3ab077 100644
|
||||
--- a/net/minecraft/world/item/EnderEyeItem.java
|
||||
+++ b/net/minecraft/world/item/EnderEyeItem.java
|
||||
@@ -106,14 +106,46 @@ public class EnderEyeItem extends Item {
|
||||
} else {
|
||||
player.startUsingItem(hand);
|
||||
if (level instanceof ServerLevel serverLevel) {
|
||||
- BlockPos blockPos = serverLevel.findNearestMapStructure(StructureTags.EYE_OF_ENDER_LOCATED, player.blockPosition(), 100, false);
|
||||
+ // Leaf start - Asynchronous locator
|
||||
+ BlockPos blockPos;
|
||||
+ if (org.dreeam.leaf.config.modules.async.AsyncLocator.enabled) {
|
||||
+ blockPos = BlockPos.ZERO;
|
||||
+ } else {
|
||||
+ blockPos = serverLevel.findNearestMapStructure(StructureTags.EYE_OF_ENDER_LOCATED, player.blockPosition(), 100, false);
|
||||
+ }
|
||||
+ // Leaf end - Asynchronous locator
|
||||
if (blockPos == null) {
|
||||
return InteractionResult.CONSUME;
|
||||
}
|
||||
|
||||
EyeOfEnder eyeOfEnder = new EyeOfEnder(level, player.getX(), player.getY(0.5), player.getZ());
|
||||
+
|
||||
+ // Leaf start - Asynchronous locator
|
||||
+ final boolean isAsyncLocatorEnabled = org.dreeam.leaf.config.modules.async.AsyncLocator.enabled;
|
||||
+
|
||||
+ if (isAsyncLocatorEnabled) {
|
||||
+ eyeOfEnder.asyncLocator$locateTaskOngoing = true;
|
||||
+ org.dreeam.leaf.async.locate.AsyncLocator.locate(
|
||||
+ serverLevel,
|
||||
+ StructureTags.EYE_OF_ENDER_LOCATED,
|
||||
+ player.blockPosition(),
|
||||
+ 100,
|
||||
+ false
|
||||
+ ).thenOnServerThread(pos -> {
|
||||
+ eyeOfEnder.asyncLocator$locateTaskOngoing = false;
|
||||
+ if (pos != null) {
|
||||
+ eyeOfEnder.signalTo(Vec3.atLowerCornerOf(pos));
|
||||
+ CriteriaTriggers.USED_ENDER_EYE.trigger((ServerPlayer) player, pos);
|
||||
+ player.awardStat(Stats.ITEM_USED.get(this));
|
||||
+ } else {
|
||||
+ // Set the entity's life to long enough that it dies
|
||||
+ eyeOfEnder.life = Integer.MAX_VALUE - 100;
|
||||
+ }
|
||||
+ });
|
||||
+ }
|
||||
+ // Leaf end - Asynchronous locator
|
||||
eyeOfEnder.setItem(itemInHand);
|
||||
- eyeOfEnder.signalTo(Vec3.atLowerCornerOf(blockPos));
|
||||
+ if (!isAsyncLocatorEnabled) eyeOfEnder.signalTo(Vec3.atLowerCornerOf(blockPos)); // Leaf - Asynchronous locator
|
||||
level.gameEvent(GameEvent.PROJECTILE_SHOOT, eyeOfEnder.position(), GameEvent.Context.of(player));
|
||||
// CraftBukkit start
|
||||
if (!level.addFreshEntity(eyeOfEnder)) {
|
||||
@@ -127,7 +159,7 @@ public class EnderEyeItem extends Item {
|
||||
float f = Mth.lerp(level.random.nextFloat(), 0.33F, 0.5F);
|
||||
level.playSound(null, player.getX(), player.getY(), player.getZ(), SoundEvents.ENDER_EYE_LAUNCH, SoundSource.NEUTRAL, 1.0F, f);
|
||||
itemInHand.consume(1, player);
|
||||
- player.awardStat(Stats.ITEM_USED.get(this));
|
||||
+ if (!isAsyncLocatorEnabled) player.awardStat(Stats.ITEM_USED.get(this)); // Leaf - Asynchronous locator
|
||||
}
|
||||
|
||||
return InteractionResult.SUCCESS_SERVER;
|
||||
@@ -12,7 +12,7 @@ As part of: Lithium (https://github.com/CaffeineMC/lithium)
|
||||
Licensed under: LGPL-3.0 (https://www.gnu.org/licenses/lgpl-3.0.html)
|
||||
|
||||
diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java
|
||||
index de4d13e7c6f57d6cc3a78b1b9ca914157820186c..32f754a4c1d7a91bbbbf4995559ac2858ef10e1c 100644
|
||||
index 4f0b903945860e518ebf3c858722f28df9394b3d..0a253607733d7f31d0264931b20676c62a289e15 100644
|
||||
--- a/net/minecraft/world/entity/LivingEntity.java
|
||||
+++ b/net/minecraft/world/entity/LivingEntity.java
|
||||
@@ -2825,6 +2825,7 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin
|
||||
@@ -173,16 +173,3 @@ index 0376a10ee0544b13e8fd629a7b13f78811e57a30..aa6b900347635857b84460fa8435b81f
|
||||
// Paper end - Anti-Xray
|
||||
// Paper start - PlayerChunkLoadEvent
|
||||
if (io.papermc.paper.event.packet.PlayerChunkLoadEvent.getHandlerList().getRegisteredListeners().length > 0) {
|
||||
diff --git a/net/minecraft/world/level/chunk/LevelChunkSection.java b/net/minecraft/world/level/chunk/LevelChunkSection.java
|
||||
index df717c545472006b99532280c38c1fbef12bcf82..7689e005a7de17fa0411a346f595f40b06bb5ca4 100644
|
||||
--- a/net/minecraft/world/level/chunk/LevelChunkSection.java
|
||||
+++ b/net/minecraft/world/level/chunk/LevelChunkSection.java
|
||||
@@ -18,7 +18,7 @@ public class LevelChunkSection implements ca.spottedleaf.moonrise.patches.block_
|
||||
public static final int SECTION_HEIGHT = 16;
|
||||
public static final int SECTION_SIZE = 4096;
|
||||
public static final int BIOME_CONTAINER_BITS = 2;
|
||||
- short nonEmptyBlockCount; // Paper - package private
|
||||
+ volatile short nonEmptyBlockCount; // Paper - package private // Leaf - Async chunk sending - volatile
|
||||
private short tickingBlockCount;
|
||||
private short tickingFluidCount;
|
||||
public final PalettedContainer<BlockState> states;
|
||||
@@ -411,7 +411,7 @@ index 77f11179836636424927843f5f10c3fd23d2b2d4..9b8d119116b0c3a51d3fe2ff7efb33cc
|
||||
|
||||
// Gale start - Pufferfish - SIMD support
|
||||
diff --git a/net/minecraft/server/level/ServerChunkCache.java b/net/minecraft/server/level/ServerChunkCache.java
|
||||
index 8f41326fda8c5f9f6926038508be6c6529b051bc..f76da1dc0874493ce71fce19e02e68da5f3ff50d 100644
|
||||
index eaaa66c4d86d4ebda0acf8f1dbe8ecb55aa28285..3a6c894178829cec8daa08ea9f0294f7f39a8efe 100644
|
||||
--- a/net/minecraft/server/level/ServerChunkCache.java
|
||||
+++ b/net/minecraft/server/level/ServerChunkCache.java
|
||||
@@ -175,6 +175,7 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
|
||||
@@ -159,7 +159,7 @@ index 4ca68a903e67606fc4ef0bfa9862a73797121c8b..bed3a64388bb43e47c2ba4e67f7dde5b
|
||||
|
||||
public static final class SaveState {
|
||||
diff --git a/net/minecraft/world/level/chunk/LevelChunkSection.java b/net/minecraft/world/level/chunk/LevelChunkSection.java
|
||||
index 7689e005a7de17fa0411a346f595f40b06bb5ca4..5c5d51d5341dac68f89253c5181e1a099c305fac 100644
|
||||
index df717c545472006b99532280c38c1fbef12bcf82..abb7c8b4ffc73cedd5e03597fe82c71e51161a1b 100644
|
||||
--- a/net/minecraft/world/level/chunk/LevelChunkSection.java
|
||||
+++ b/net/minecraft/world/level/chunk/LevelChunkSection.java
|
||||
@@ -23,6 +23,7 @@ public class LevelChunkSection implements ca.spottedleaf.moonrise.patches.block_
|
||||
@@ -4,80 +4,6 @@ Date: Sat, 17 May 2025 08:25:33 +0800
|
||||
Subject: [PATCH] Optimize isEyeInFluid
|
||||
|
||||
|
||||
diff --git a/net/minecraft/core/Holder.java b/net/minecraft/core/Holder.java
|
||||
index 6c7edbbf3935c40ccb78bee680ea75431718b9bd..fd2f79d976c9587b00380f8b8f784b32ca294673 100644
|
||||
--- a/net/minecraft/core/Holder.java
|
||||
+++ b/net/minecraft/core/Holder.java
|
||||
@@ -29,6 +29,8 @@ public interface Holder<T> {
|
||||
|
||||
Stream<TagKey<T>> tags();
|
||||
|
||||
+ TagKey<T>[] tagArray(); // Leaf - Optimize isEyeInFluid
|
||||
+
|
||||
Either<ResourceKey<T>, T> unwrap();
|
||||
|
||||
Optional<ResourceKey<T>> unwrapKey();
|
||||
@@ -105,6 +107,13 @@ public interface Holder<T> {
|
||||
public Stream<TagKey<T>> tags() {
|
||||
return Stream.of();
|
||||
}
|
||||
+
|
||||
+ // Leaf start - Optimize isEyeInFluid
|
||||
+ @Override
|
||||
+ public TagKey<T>[] tagArray() {
|
||||
+ return me.titaniumtown.ArrayConstants.emptyTagKeyArray;
|
||||
+ }
|
||||
+ // Leaf end - Optimize isEyeInFluid
|
||||
}
|
||||
|
||||
public static enum Kind {
|
||||
@@ -116,6 +125,7 @@ public interface Holder<T> {
|
||||
private final HolderOwner<T> owner;
|
||||
@Nullable
|
||||
private Set<TagKey<T>> tags;
|
||||
+ @Nullable private TagKey<T>[] tagArray; // Leaf - Optimize isEyeInFluid
|
||||
private final Holder.Reference.Type type;
|
||||
@Nullable
|
||||
private ResourceKey<T> key;
|
||||
@@ -173,6 +183,16 @@ public interface Holder<T> {
|
||||
}
|
||||
}
|
||||
|
||||
+ // Leaf start - Optimize isEyeInFluid
|
||||
+ private TagKey<T>[] boundTagArray() {
|
||||
+ if (this.tags == null || this.tagArray == null) {
|
||||
+ throw new IllegalStateException("Tags not bound");
|
||||
+ } else {
|
||||
+ return this.tagArray;
|
||||
+ }
|
||||
+ }
|
||||
+ // Leaf end - Optimize isEyeInFluid
|
||||
+
|
||||
@Override
|
||||
public boolean is(TagKey<T> tagKey) {
|
||||
return this.boundTags().contains(tagKey);
|
||||
@@ -231,6 +251,7 @@ public interface Holder<T> {
|
||||
|
||||
void bindTags(Collection<TagKey<T>> tags) {
|
||||
this.tags = it.unimi.dsi.fastutil.objects.ReferenceSets.unmodifiable(new it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet<>(tags)); // Paper - use reference set because TagKey are interned
|
||||
+ this.tagArray = this.tags.toArray(new TagKey[0]); // Leaf - Optimize isEyeInFluid
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -238,6 +259,13 @@ public interface Holder<T> {
|
||||
return this.boundTags().stream();
|
||||
}
|
||||
|
||||
+ // Leaf start - Optimize isEyeInFluid
|
||||
+ @Override
|
||||
+ public TagKey<T>[] tagArray() {
|
||||
+ return this.boundTagArray();
|
||||
+ }
|
||||
+ // Leaf end - Optimize isEyeInFluid
|
||||
+
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Reference{" + this.key + "=" + this.value + "}";
|
||||
diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java
|
||||
index f2ec8dafb133999bed21eb48b118ab5d382bc962..a26943a7c70ac8b8eb3be5cd1f9838e4fcc6e04e 100644
|
||||
--- a/net/minecraft/server/level/ServerPlayer.java
|
||||
@@ -92,7 +18,7 @@ index f2ec8dafb133999bed21eb48b118ab5d382bc962..a26943a7c70ac8b8eb3be5cd1f9838e4
|
||||
if (rounded > 0) {
|
||||
this.awardStat(Stats.WALK_UNDER_WATER_ONE_CM, rounded);
|
||||
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
|
||||
index b694c7c1837fd4facb16d6bcf93245da9d18a56d..2f9304c4fc7ac9f42493bc19748ee6c0f57208ee 100644
|
||||
index b694c7c1837fd4facb16d6bcf93245da9d18a56d..48c2aeee828c1b79d8d6c5f5fd88fae1ef4befc8 100644
|
||||
--- a/net/minecraft/world/entity/Entity.java
|
||||
+++ b/net/minecraft/world/entity/Entity.java
|
||||
@@ -288,7 +288,14 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
@@ -122,19 +48,18 @@ index b694c7c1837fd4facb16d6bcf93245da9d18a56d..2f9304c4fc7ac9f42493bc19748ee6c0
|
||||
double eyeY = this.getEyeY();
|
||||
if (!(
|
||||
this.getVehicle() instanceof AbstractBoat abstractBoat
|
||||
@@ -2051,7 +2058,10 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
@@ -2051,7 +2058,9 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
FluidState fluidState = this.level().getFluidState(blockPos);
|
||||
double d = blockPos.getY() + fluidState.getHeight(this.level(), blockPos);
|
||||
if (d > eyeY) {
|
||||
- fluidState.getTags().forEach(this.fluidOnEyes::add);
|
||||
+ // Leaf start - Optimize isEyeInFluid
|
||||
+ TagKey<Fluid>[] tags = fluidState.getTagArray();
|
||||
+ this.isInWaterOrLava = tags.length == 0 ? 0 : tags[0] == FluidTags.WATER ? 1 : 2;
|
||||
+ this.isInWaterOrLava = fluidState.isEmpty() ? 0 : fluidState.is(FluidTags.WATER) ? 1 : 2;
|
||||
+ // Leaf end - Optimize isEyeInFluid
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2131,9 +2141,25 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
@@ -2131,9 +2140,25 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
}
|
||||
}
|
||||
|
||||
@@ -297,20 +222,3 @@ index d947801b616af5b5dcdcc8bb70b36f97d6a69fdd..678badf7622b81e94c973bed2082fbfa
|
||||
}
|
||||
|
||||
protected int getMaxPassengers() {
|
||||
diff --git a/net/minecraft/world/level/material/FluidState.java b/net/minecraft/world/level/material/FluidState.java
|
||||
index 0a5ae623a636923f3bbd3c01974497f39b7c4b62..cc6f2f756c407630aa4e99be329f643c9994af29 100644
|
||||
--- a/net/minecraft/world/level/material/FluidState.java
|
||||
+++ b/net/minecraft/world/level/material/FluidState.java
|
||||
@@ -167,6 +167,12 @@ public final class FluidState extends StateHolder<Fluid, FluidState> implements
|
||||
return this.owner.builtInRegistryHolder().tags();
|
||||
}
|
||||
|
||||
+ // Leaf start - Optimize isEyeInFluid
|
||||
+ public TagKey<Fluid>[] getTagArray() {
|
||||
+ return this.owner.builtInRegistryHolder().tagArray();
|
||||
+ }
|
||||
+ // Leaf end - Optimize isEyeInFluid
|
||||
+
|
||||
public void entityInside(Level level, BlockPos pos, Entity entity, InsideBlockEffectApplier effectApplier) {
|
||||
this.getType().entityInside(level, pos, entity, effectApplier);
|
||||
}
|
||||
@@ -26,7 +26,7 @@ index 5c369b3d94e369c3f240821ad90b9d96223f24ca..9803c395fce103cb7bc746f43a017ff9
|
||||
}
|
||||
// Paper end - Optional per player mob spawns
|
||||
diff --git a/net/minecraft/server/level/ServerChunkCache.java b/net/minecraft/server/level/ServerChunkCache.java
|
||||
index f76da1dc0874493ce71fce19e02e68da5f3ff50d..8b9d7129da577d7b613c0e21ee075e68edef7b12 100644
|
||||
index 3a6c894178829cec8daa08ea9f0294f7f39a8efe..8bf770fd490634787e794efec9f0d6a10d97e42f 100644
|
||||
--- a/net/minecraft/server/level/ServerChunkCache.java
|
||||
+++ b/net/minecraft/server/level/ServerChunkCache.java
|
||||
@@ -70,11 +70,11 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
|
||||
@@ -5,7 +5,7 @@ Subject: [PATCH] optimize random tick
|
||||
|
||||
|
||||
diff --git a/net/minecraft/server/level/ServerChunkCache.java b/net/minecraft/server/level/ServerChunkCache.java
|
||||
index 8b9d7129da577d7b613c0e21ee075e68edef7b12..8d074d2adf36827bc7c38a5f4efe4771453631b8 100644
|
||||
index 8bf770fd490634787e794efec9f0d6a10d97e42f..7e84b94a4602801e8cc713b28d0d93052589fd5e 100644
|
||||
--- a/net/minecraft/server/level/ServerChunkCache.java
|
||||
+++ b/net/minecraft/server/level/ServerChunkCache.java
|
||||
@@ -666,7 +666,13 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
|
||||
@@ -5,28 +5,20 @@ Subject: [PATCH] optimize waypoint
|
||||
|
||||
|
||||
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
|
||||
index 2f9304c4fc7ac9f42493bc19748ee6c0f57208ee..5d4350dbe1d4189e17de77586a342c4ed0087c13 100644
|
||||
index 48c2aeee828c1b79d8d6c5f5fd88fae1ef4befc8..b71acd053b38d9b59720e35e664f957df6626b27 100644
|
||||
--- a/net/minecraft/world/entity/Entity.java
|
||||
+++ b/net/minecraft/world/entity/Entity.java
|
||||
@@ -5112,6 +5112,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
return;
|
||||
}
|
||||
// Paper end - Block invalid positions and bounding box
|
||||
+ boolean blockUpdated; // Leaf - optimize waypoint
|
||||
if (this.position.x != x || this.position.y != y || this.position.z != z) {
|
||||
synchronized (this.posLock) { // Paper - detailed watchdog information
|
||||
this.position = new Vec3(x, y, z);
|
||||
@@ -5119,7 +5120,8 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
@@ -5118,7 +5118,8 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
int floor = Mth.floor(x);
|
||||
int floor1 = Mth.floor(y);
|
||||
int floor2 = Mth.floor(z);
|
||||
- if (floor != this.blockPosition.getX() || floor1 != this.blockPosition.getY() || floor2 != this.blockPosition.getZ()) {
|
||||
+ blockUpdated = floor != this.blockPosition.getX() || floor1 != this.blockPosition.getY() || floor2 != this.blockPosition.getZ(); // Leaf - optimize waypoint
|
||||
+ boolean blockUpdated = floor != this.blockPosition.getX() || floor1 != this.blockPosition.getY() || floor2 != this.blockPosition.getZ(); // Leaf - optimize waypoint
|
||||
+ if (blockUpdated) { // Leaf - optimize waypoint
|
||||
this.blockPosition = new BlockPos(floor, floor1, floor2);
|
||||
this.inBlockState = null;
|
||||
if (SectionPos.blockToSectionCoord(floor) != this.chunkPosition.x || SectionPos.blockToSectionCoord(floor2) != this.chunkPosition.z) {
|
||||
@@ -5128,7 +5130,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
@@ -5127,7 +5128,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
}
|
||||
|
||||
this.levelCallback.onMove();
|
||||
@@ -132,7 +132,7 @@ index a16bd45a3fd9a8937a7624c8f7838367e7e087bd..2712a9bf21731a1cf575dcb4ece19e6f
|
||||
|
||||
private void tickPassenger(Entity ridingEntity, Entity passengerEntity, final boolean isActive) { // Paper - EAR 2
|
||||
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
|
||||
index 5d4350dbe1d4189e17de77586a342c4ed0087c13..c1344b1313ff0999d6cb4ef7ca32ccc2715a7cde 100644
|
||||
index b71acd053b38d9b59720e35e664f957df6626b27..2d26a7a0b85c85830694e7947f2c4f29483bb99a 100644
|
||||
--- a/net/minecraft/world/entity/Entity.java
|
||||
+++ b/net/minecraft/world/entity/Entity.java
|
||||
@@ -1138,16 +1138,6 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
@@ -183,7 +183,7 @@ index 5d4350dbe1d4189e17de77586a342c4ed0087c13..c1344b1313ff0999d6cb4ef7ca32ccc2
|
||||
}
|
||||
|
||||
private void applyMovementEmissionAndPlaySound(Entity.MovementEmission movementEmission, Vec3 movement, BlockPos pos, BlockState state) {
|
||||
@@ -5013,9 +4987,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
@@ -5012,9 +4986,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
}
|
||||
|
||||
public void setDeltaMovement(Vec3 deltaMovement) {
|
||||
@@ -193,9 +193,9 @@ index 5d4350dbe1d4189e17de77586a342c4ed0087c13..c1344b1313ff0999d6cb4ef7ca32ccc2
|
||||
}
|
||||
|
||||
public void addDeltaMovement(Vec3 addend) {
|
||||
@@ -5114,9 +5086,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
@@ -5112,9 +5084,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
}
|
||||
// Paper end - Block invalid positions and bounding box
|
||||
boolean blockUpdated; // Leaf - optimize waypoint
|
||||
if (this.position.x != x || this.position.y != y || this.position.z != z) {
|
||||
- synchronized (this.posLock) { // Paper - detailed watchdog information
|
||||
this.position = new Vec3(x, y, z);
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user