From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com> Date: Thu, 24 Apr 2025 16:36:16 -0400 Subject: [PATCH] Paw optimization Some random optimizations - Remove Paper's dead code - Only set shuffle random seed if is really used - Cache direction values to skip copy - Secret patches (WIP) diff --git a/net/minecraft/Util.java b/net/minecraft/Util.java index 25b6aaa71ff389094d0f44c341f0c6458fc644ff..d899cde3d9964709cb9697eccac986526304b758 100644 --- a/net/minecraft/Util.java +++ b/net/minecraft/Util.java @@ -95,7 +95,7 @@ public class Util { private static final TracingExecutor BACKGROUND_EXECUTOR = makeExecutor("Main", -1); // Paper - Perf: add priority private static final TracingExecutor IO_POOL = makeIoExecutor("IO-Worker-", false); public static final TracingExecutor DIMENSION_DATA_IO_POOL = makeExtraIoExecutor("Dimension-Data-IO-Worker-"); // Paper - Separate dimension data IO pool - private static final TracingExecutor DOWNLOAD_POOL = makeIoExecutor("Download-", true); + //private static final TracingExecutor DOWNLOAD_POOL = makeIoExecutor("Download-", true); // Leaf - paw optimization - Remove client-only code // Paper start - don't submit BLOCKING PROFILE LOOKUPS to the world gen thread // Leaf start - More virtual threads public static final ExecutorService PROFILE_EXECUTOR = createProfileExecutor(); /* new Executors.newFixedThreadPool(2, new java.util.concurrent.ThreadFactory() { @@ -269,7 +269,7 @@ public class Util { } public static TracingExecutor nonCriticalIoPool() { - return DOWNLOAD_POOL; + return null; // Leaf - paw optimization - Remove client-only code } public static void shutdownExecutors() { diff --git a/net/minecraft/network/Connection.java b/net/minecraft/network/Connection.java index 3dce0665e7438d2994a86450e31fb2a10431df9b..f9634a821fbfaf31a66e0e25973794149b1a5239 100644 --- a/net/minecraft/network/Connection.java +++ b/net/minecraft/network/Connection.java @@ -654,13 +654,7 @@ public class Connection extends SimpleChannelInboundHandler> { if (!(this.packetListener instanceof net.minecraft.server.network.ServerLoginPacketListenerImpl loginPacketListener) || loginPacketListener.state != net.minecraft.server.network.ServerLoginPacketListenerImpl.State.VERIFYING || Connection.joinAttemptsThisTick++ < MAX_PER_TICK) { - // Paper start - detailed watchdog information - net.minecraft.network.protocol.PacketUtils.packetProcessing.push(this.packetListener); - try { tickablePacketListener.tick(); - } finally { - net.minecraft.network.protocol.PacketUtils.packetProcessing.pop(); - } // Paper end - detailed watchdog information } // Paper end - Buffer joins to world } diff --git a/net/minecraft/network/protocol/PacketUtils.java b/net/minecraft/network/protocol/PacketUtils.java index 4535858701b2bb232b9d2feb2af6551526232ddc..e65c62dbe4c1560ae153e4c4344e9194c783a2f4 100644 --- a/net/minecraft/network/protocol/PacketUtils.java +++ b/net/minecraft/network/protocol/PacketUtils.java @@ -21,8 +21,6 @@ public class PacketUtils { public static void ensureRunningOnSameThread(Packet packet, T processor, BlockableEventLoop executor) throws RunningOnDifferentThreadException { if (!executor.isSameThread()) { executor.executeIfPossible(() -> { - packetProcessing.push(processor); // Paper - detailed watchdog information - try { // Paper - detailed watchdog information if (processor instanceof net.minecraft.server.network.ServerCommonPacketListenerImpl serverCommonPacketListener && serverCommonPacketListener.processedDisconnect) return; // Paper - Don't handle sync packets for kicked players if (processor.shouldHandleMessage(packet)) { try { @@ -37,12 +35,6 @@ public class PacketUtils { } else { LOGGER.debug("Ignoring packet due to disconnection: {}", packet); } - // Paper start - detailed watchdog information - } finally { - totalMainThreadPacketsProcessed.getAndIncrement(); - packetProcessing.pop(); - } - // Paper end - detailed watchdog information }); throw RunningOnDifferentThreadException.RUNNING_ON_DIFFERENT_THREAD; } @@ -69,22 +61,4 @@ public class PacketUtils { packetListener.fillCrashReport(crashReport); } - - // Paper start - detailed watchdog information - public static final java.util.concurrent.ConcurrentLinkedDeque packetProcessing = new java.util.concurrent.ConcurrentLinkedDeque<>(); - static final java.util.concurrent.atomic.AtomicLong totalMainThreadPacketsProcessed = new java.util.concurrent.atomic.AtomicLong(); - - public static long getTotalProcessedPackets() { - return totalMainThreadPacketsProcessed.get(); - } - - public static java.util.List getCurrentPacketProcessors() { - java.util.List listeners = new java.util.ArrayList<>(4); - for (PacketListener listener : packetProcessing) { - listeners.add(listener); - } - - return listeners; - } - // Paper end - detailed watchdog information } diff --git a/net/minecraft/server/level/ServerChunkCache.java b/net/minecraft/server/level/ServerChunkCache.java index 55f20122732e88037d24be311469b6cab72c37ad..2f927b422c2c4f2f65d822befe3cbfd9e3bb3708 100644 --- a/net/minecraft/server/level/ServerChunkCache.java +++ b/net/minecraft/server/level/ServerChunkCache.java @@ -506,9 +506,10 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon try { this.collectTickingChunks(list); // Paper start - chunk tick iteration optimisation - this.shuffleRandom.setSeed(this.level.random.nextLong()); - if (!this.level.paperConfig().entities.spawning.perPlayerMobSpawns) + if (!this.level.paperConfig().entities.spawning.perPlayerMobSpawns) { + this.shuffleRandom.setSeed(this.level.random.nextLong()); // Leaf - paw optimization - Only set seed if is really used Util.shuffle(list, this.shuffleRandom); // Paper - Optional per player mob spawns; do not need this when per-player is enabled + } // Paper end - chunk tick iteration optimisation this.tickChunks(l, list); // Gale - Purpur - remove vanilla profiler } finally { diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java index 7955a8fa9c4de139b24c9d53018b055ff4008e02..eb849c57992658005e0f514c6f7923f8ca43bebf 100644 --- a/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java @@ -1521,13 +1521,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe // Paper end - log detailed entity tick information public void tickNonPassenger(Entity entity) { - // Paper start - log detailed entity tick information ca.spottedleaf.moonrise.common.util.TickThread.ensureTickThread("Cannot tick an entity off-main"); - try { - if (currentlyTickingEntity.get() == null) { - currentlyTickingEntity.lazySet(entity); - } - // Paper end - log detailed entity tick information entity.setOldPosAndRot(); entity.tickCount++; entity.totalEntityAge++; // Paper - age-like counter for all entities @@ -1540,13 +1534,6 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe for (Entity entity1 : entity.getPassengers()) { this.tickPassenger(entity, entity1, isActive); // Paper - EAR 2 } - // Paper start - log detailed entity tick information - } finally { - if (currentlyTickingEntity.get() == entity) { - currentlyTickingEntity.lazySet(null); - } - } - // Paper end - log detailed entity tick information } 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 80baa2dff5c1034a72271fc727fdb2acc1b69488..9f581d5bdc3f658694bbd8c80abbce4e27e568d3 100644 --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java @@ -1147,31 +1147,6 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess return this.onGround; } - // Paper start - detailed watchdog information - public final Object posLock = new Object(); // Paper - log detailed entity tick information - - private Vec3 moveVector; - private double moveStartX; - private double moveStartY; - private double moveStartZ; - - public final Vec3 getMoveVector() { - return this.moveVector; - } - - public final double getMoveStartX() { - return this.moveStartX; - } - - public final double getMoveStartY() { - return this.moveStartY; - } - - public final double getMoveStartZ() { - return this.moveStartZ; - } - // Paper end - detailed watchdog information - public void move(MoverType type, Vec3 movement) { // Gale start - VMP - skip entity move if movement is zero if (!this.boundingBoxChanged && movement.equals(Vec3.ZERO)) { @@ -1179,16 +1154,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess } // Gale end - VMP - skip entity move if movement is zero final Vec3 originalMovement = movement; // Paper - Expose pre-collision velocity - // Paper start - detailed watchdog information ca.spottedleaf.moonrise.common.util.TickThread.ensureTickThread("Cannot move an entity off-main"); - synchronized (this.posLock) { - this.moveStartX = this.getX(); - this.moveStartY = this.getY(); - this.moveStartZ = this.getZ(); - this.moveVector = movement; - } - try { - // Paper end - detailed watchdog information if (this.noPhysics) { this.setPos(this.getX() + movement.x, this.getY() + movement.y, this.getZ() + movement.z); } else { @@ -1309,13 +1275,6 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess // Gale end - skip negligible planar movement multiplication } } - // Paper start - detailed watchdog information - } finally { - synchronized (this.posLock) { // Paper - this.moveVector = null; - } // Paper - } - // Paper end - detailed watchdog information } private void applyMovementEmissionAndPlaySound(Entity.MovementEmission movementEmission, Vec3 movement, BlockPos pos, BlockState state) { @@ -4881,9 +4840,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess } public void setDeltaMovement(Vec3 deltaMovement) { - synchronized (this.posLock) { // Paper - detailed watchdog information this.deltaMovement = deltaMovement; - } // Paper - detailed watchdog information } public void addDeltaMovement(Vec3 addend) { @@ -4989,9 +4946,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess } // Paper end - Fix MC-4 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); - } // Paper - detailed watchdog information int floor = Mth.floor(x); int floor1 = Mth.floor(y); int floor2 = Mth.floor(z); diff --git a/net/minecraft/world/level/block/BaseCoralPlantTypeBlock.java b/net/minecraft/world/level/block/BaseCoralPlantTypeBlock.java index e804ca8d6c9c9b8d9f982a970cc3edddf5c03aa1..0a4ca9f0dba64c5539b99af5d95292159f51b6ba 100644 --- a/net/minecraft/world/level/block/BaseCoralPlantTypeBlock.java +++ b/net/minecraft/world/level/block/BaseCoralPlantTypeBlock.java @@ -43,7 +43,7 @@ public abstract class BaseCoralPlantTypeBlock extends Block implements SimpleWat if (state.getValue(WATERLOGGED)) { return true; } else { - for (Direction direction : Direction.values()) { + for (Direction direction : Direction.VALUES) { // Leaf - paw optimization - cache direction values if (level.getFluidState(pos.relative(direction)).is(FluidTags.WATER)) { return true; } diff --git a/net/minecraft/world/level/block/BaseFireBlock.java b/net/minecraft/world/level/block/BaseFireBlock.java index 45df9f008b74dd0d6d790c91102e9afe1da45633..baee320ad6f1918cc9009db9f65c28e33a544e19 100644 --- a/net/minecraft/world/level/block/BaseFireBlock.java +++ b/net/minecraft/world/level/block/BaseFireBlock.java @@ -204,7 +204,7 @@ public abstract class BaseFireBlock extends Block { BlockPos.MutableBlockPos mutableBlockPos = pos.mutable(); boolean flag = false; - for (Direction direction1 : Direction.values()) { + for (Direction direction1 : Direction.VALUES) { // Leaf - paw optimization - cache direction values if (level.getBlockState(mutableBlockPos.set(pos).move(direction1)).is(Blocks.OBSIDIAN)) { flag = true; break; diff --git a/net/minecraft/world/level/block/FireBlock.java b/net/minecraft/world/level/block/FireBlock.java index 7340c664fdcf991a2549c8f07f6ab093bbe6e4e8..90f1a971888a76ab3f8522d86a9f9f240ef76a53 100644 --- a/net/minecraft/world/level/block/FireBlock.java +++ b/net/minecraft/world/level/block/FireBlock.java @@ -159,7 +159,7 @@ public class FireBlock extends BaseFireBlock { if (!this.canBurn(blockState) && !blockState.isFaceSturdy(level, blockPos, Direction.UP)) { BlockState blockState1 = this.defaultBlockState(); - for (Direction direction : Direction.values()) { + for (Direction direction : Direction.VALUES) { // Leaf - paw optimization - cache direction values BooleanProperty booleanProperty = PROPERTY_BY_DIRECTION.get(direction); if (booleanProperty != null) { blockState1 = blockState1.setValue(booleanProperty, Boolean.valueOf(this.canBurn(level.getBlockState(pos.relative(direction))))); @@ -331,7 +331,7 @@ public class FireBlock extends BaseFireBlock { } private boolean isValidFireLocation(BlockGetter level, BlockPos pos) { - for (Direction direction : Direction.values()) { + for (Direction direction : Direction.VALUES) { // Leaf - paw optimization - cache direction values if (this.canBurn(level.getBlockState(pos.relative(direction)))) { return true; } @@ -346,7 +346,7 @@ public class FireBlock extends BaseFireBlock { } else { int i = 0; - for (Direction direction : Direction.values()) { + for (Direction direction : Direction.VALUES) { // Leaf - paw optimization - cache direction values BlockState blockState = level.getBlockState(pos.relative(direction)); i = Math.max(this.getIgniteOdds(blockState), i); } diff --git a/net/minecraft/world/level/block/FrostedIceBlock.java b/net/minecraft/world/level/block/FrostedIceBlock.java index 8eb24bf0477c8d0cf4bfa7f122bbcd20aa2a5d5b..3035455cd9d8c238e33d493935a8498687d6a303 100644 --- a/net/minecraft/world/level/block/FrostedIceBlock.java +++ b/net/minecraft/world/level/block/FrostedIceBlock.java @@ -48,7 +48,7 @@ public class FrostedIceBlock extends IceBlock { && this.slightlyMelt(state, level, pos)) { BlockPos.MutableBlockPos mutableBlockPos = new BlockPos.MutableBlockPos(); - for (Direction direction : Direction.values()) { + for (Direction direction : Direction.VALUES) { // Leaf - paw optimization - cache direction values mutableBlockPos.setWithOffset(pos, direction); BlockState blockState = level.getBlockState(mutableBlockPos); if (blockState.is(this) && !this.slightlyMelt(blockState, level, mutableBlockPos)) { @@ -84,7 +84,7 @@ public class FrostedIceBlock extends IceBlock { int i = 0; BlockPos.MutableBlockPos mutableBlockPos = new BlockPos.MutableBlockPos(); - for (Direction direction : Direction.values()) { + for (Direction direction : Direction.VALUES) { // Leaf - paw optimization - cache direction values mutableBlockPos.setWithOffset(pos, direction); if (level.getBlockState(mutableBlockPos).is(this)) { if (++i >= neighborsRequired) { diff --git a/net/minecraft/world/level/block/LeavesBlock.java b/net/minecraft/world/level/block/LeavesBlock.java index a97b22e5acb791e959c528ccb330fa5ff92251e4..ca1a1661642a8ddd66d0e180be996a978a150730 100644 --- a/net/minecraft/world/level/block/LeavesBlock.java +++ b/net/minecraft/world/level/block/LeavesBlock.java @@ -117,7 +117,7 @@ public class LeavesBlock extends Block implements SimpleWaterloggedBlock { int i = 7; BlockPos.MutableBlockPos mutableBlockPos = new BlockPos.MutableBlockPos(); - for (Direction direction : Direction.values()) { + for (Direction direction : Direction.VALUES) { // Leaf - paw optimization - cache direction values mutableBlockPos.setWithOffset(pos, direction); i = Math.min(i, getDistanceAt(level.getBlockState(mutableBlockPos)) + 1); if (i == 1) { diff --git a/net/minecraft/world/level/block/piston/PistonBaseBlock.java b/net/minecraft/world/level/block/piston/PistonBaseBlock.java index 41802482875bd4d4b505eb758740140de0db415a..8301a6d0fa0eeefc527aa79933a83da29ebaf451 100644 --- a/net/minecraft/world/level/block/piston/PistonBaseBlock.java +++ b/net/minecraft/world/level/block/piston/PistonBaseBlock.java @@ -150,7 +150,7 @@ public class PistonBaseBlock extends DirectionalBlock { } private boolean getNeighborSignal(SignalGetter signalGetter, BlockPos pos, Direction direction) { - for (Direction direction1 : Direction.values()) { + for (Direction direction1 : Direction.VALUES) { // Leaf - paw optimization - cache direction values if (direction1 != direction && signalGetter.hasSignal(pos.relative(direction1), direction1)) { return true; } @@ -161,7 +161,7 @@ public class PistonBaseBlock extends DirectionalBlock { } else { BlockPos blockPos = pos.above(); - for (Direction direction2 : Direction.values()) { + for (Direction direction2 : Direction.VALUES) { // Leaf - paw optimization - cache direction values if (direction2 != Direction.DOWN && signalGetter.hasSignal(blockPos.relative(direction2), direction2)) { return true; } diff --git a/net/minecraft/world/level/block/state/pattern/BlockPattern.java b/net/minecraft/world/level/block/state/pattern/BlockPattern.java index f7bb979f08634a7e1b77c59040f59fb5e11aafa5..9b60bbebd32f045bd0f5b91cd30264396e673d30 100644 --- a/net/minecraft/world/level/block/state/pattern/BlockPattern.java +++ b/net/minecraft/world/level/block/state/pattern/BlockPattern.java @@ -79,8 +79,8 @@ public class BlockPattern { int max = Math.max(Math.max(this.width, this.height), this.depth); for (BlockPos blockPos : BlockPos.betweenClosed(pos, pos.offset(max - 1, max - 1, max - 1))) { - for (Direction direction : Direction.values()) { - for (Direction direction1 : Direction.values()) { + for (Direction direction : Direction.VALUES) { // Leaf - paw optimization - cache direction values + for (Direction direction1 : Direction.VALUES) { // Leaf - paw optimization - cache direction values if (direction1 != direction && direction1 != direction.getOpposite()) { BlockPattern.BlockPatternMatch blockPatternMatch = this.matches(blockPos, direction, direction1, loadingCache); if (blockPatternMatch != null) { diff --git a/net/minecraft/world/level/gameevent/vibrations/VibrationSystem.java b/net/minecraft/world/level/gameevent/vibrations/VibrationSystem.java index 60d34309f6a961448944faedafd242e7496d14d9..e6cceee73b41604d3e034ad2a7edf7e281cf017b 100644 --- a/net/minecraft/world/level/gameevent/vibrations/VibrationSystem.java +++ b/net/minecraft/world/level/gameevent/vibrations/VibrationSystem.java @@ -256,7 +256,7 @@ public interface VibrationSystem { Vec3 vec3 = new Vec3(Mth.floor(eventPos.x) + 0.5, Mth.floor(eventPos.y) + 0.5, Mth.floor(eventPos.z) + 0.5); Vec3 vec31 = new Vec3(Mth.floor(vibrationUserPos.x) + 0.5, Mth.floor(vibrationUserPos.y) + 0.5, Mth.floor(vibrationUserPos.z) + 0.5); - for (Direction direction : Direction.values()) { + for (Direction direction : Direction.VALUES) { // Leaf - paw optimization - cache direction values Vec3 vec32 = vec3.relative(direction, 1.0E-5F); if (level.isBlockInLine(new ClipBlockStateContext(vec32, vec31, state -> state.is(BlockTags.OCCLUDES_VIBRATION_SIGNALS))).getType() != HitResult.Type.BLOCK) { diff --git a/net/minecraft/world/level/levelgen/feature/BlueIceFeature.java b/net/minecraft/world/level/levelgen/feature/BlueIceFeature.java index 5bbc9cacd8675c96d99f8b46399742753888d2f7..0c818d43c3d58e1f61e30d63556ba82356d53290 100644 --- a/net/minecraft/world/level/levelgen/feature/BlueIceFeature.java +++ b/net/minecraft/world/level/levelgen/feature/BlueIceFeature.java @@ -26,7 +26,7 @@ public class BlueIceFeature extends Feature { } else { boolean flag = false; - for (Direction direction : Direction.values()) { + for (Direction direction : Direction.VALUES) { // Leaf - paw optimization - cache direction values if (direction != Direction.DOWN && worldGenLevel.getBlockState(blockPos.relative(direction)).is(Blocks.PACKED_ICE)) { flag = true; break; @@ -51,7 +51,7 @@ public class BlueIceFeature extends Feature { ); BlockState blockState = worldGenLevel.getBlockState(blockPos1); if (blockState.isAir() || blockState.is(Blocks.WATER) || blockState.is(Blocks.PACKED_ICE) || blockState.is(Blocks.ICE)) { - for (Direction direction1 : Direction.values()) { + for (Direction direction1 : Direction.VALUES) { // Leaf - paw optimization - cache direction values BlockState blockState1 = worldGenLevel.getBlockState(blockPos1.relative(direction1)); if (blockState1.is(Blocks.BLUE_ICE)) { worldGenLevel.setBlock(blockPos1, Blocks.BLUE_ICE.defaultBlockState(), 2); diff --git a/net/minecraft/world/level/levelgen/feature/Feature.java b/net/minecraft/world/level/levelgen/feature/Feature.java index 6d7c2c6f0469f934b9599b59f00580cd1919be58..c868fbf333d59bee5256c07f7878c2dc6462a637 100644 --- a/net/minecraft/world/level/levelgen/feature/Feature.java +++ b/net/minecraft/world/level/levelgen/feature/Feature.java @@ -205,7 +205,7 @@ public abstract class Feature { public static boolean checkNeighbors(Function adjacentStateAccessor, BlockPos pos, Predicate filter) { BlockPos.MutableBlockPos mutableBlockPos = new BlockPos.MutableBlockPos(); - for (Direction direction : Direction.values()) { + for (Direction direction : Direction.VALUES) { // Leaf - paw optimization - cache direction values mutableBlockPos.setWithOffset(pos, direction); if (filter.test(adjacentStateAccessor.apply(mutableBlockPos))) { return true; diff --git a/net/minecraft/world/level/levelgen/feature/GlowstoneFeature.java b/net/minecraft/world/level/levelgen/feature/GlowstoneFeature.java index 0062e6ba05ff73ed80c5bc5d3765c8872ef081e0..e002a1ad27bc18a7fc5ac9d1ecae523a9e66886f 100644 --- a/net/minecraft/world/level/levelgen/feature/GlowstoneFeature.java +++ b/net/minecraft/world/level/levelgen/feature/GlowstoneFeature.java @@ -35,7 +35,7 @@ public class GlowstoneFeature extends Feature { if (worldGenLevel.getBlockState(blockPos1).isAir()) { int i1 = 0; - for (Direction direction : Direction.values()) { + for (Direction direction : Direction.VALUES) { // Leaf - paw optimization - cache direction values if (worldGenLevel.getBlockState(blockPos1.relative(direction)).is(Blocks.GLOWSTONE)) { i1++; } diff --git a/net/minecraft/world/level/levelgen/feature/TreeFeature.java b/net/minecraft/world/level/levelgen/feature/TreeFeature.java index bd17dbe53c82001b60f4cfdd9d2dacb06a98f5ea..59957ddf6b7742c0a8eac53eddb1b9fa0c7a7bec 100644 --- a/net/minecraft/world/level/levelgen/feature/TreeFeature.java +++ b/net/minecraft/world/level/levelgen/feature/TreeFeature.java @@ -203,7 +203,7 @@ public class TreeFeature extends Feature { discreteVoxelShape.fill(blockPos1.getX() - box.minX(), blockPos1.getY() - box.minY(), blockPos1.getZ() - box.minZ()); - for (Direction direction : Direction.values()) { + for (Direction direction : Direction.VALUES) { // Leaf - paw optimization - cache direction values mutableBlockPos.setWithOffset(blockPos1, direction); if (box.isInside(mutableBlockPos)) { int i3 = mutableBlockPos.getX() - box.minX(); diff --git a/net/minecraft/world/level/levelgen/feature/VinesFeature.java b/net/minecraft/world/level/levelgen/feature/VinesFeature.java index 256e130ff43f826c3eac2a0faa526dc12e5fda0e..c744ea5d2df9692e7e8c53ea96fedc8a2b77c0c9 100644 --- a/net/minecraft/world/level/levelgen/feature/VinesFeature.java +++ b/net/minecraft/world/level/levelgen/feature/VinesFeature.java @@ -21,7 +21,7 @@ public class VinesFeature extends Feature { if (!worldGenLevel.isEmptyBlock(blockPos)) { return false; } else { - for (Direction direction : Direction.values()) { + for (Direction direction : Direction.VALUES) { // Leaf - paw optimization - cache direction values if (direction != Direction.DOWN && VineBlock.isAcceptableNeighbour(worldGenLevel, blockPos.relative(direction), direction)) { worldGenLevel.setBlock( blockPos, Blocks.VINE.defaultBlockState().setValue(VineBlock.getPropertyForFace(direction), Boolean.valueOf(true)), 2 diff --git a/net/minecraft/world/level/levelgen/feature/treedecorators/CreakingHeartDecorator.java b/net/minecraft/world/level/levelgen/feature/treedecorators/CreakingHeartDecorator.java index 75ae614790d46ba01003a13fb9d521299c675c56..ccb5a5d7536d4a3b57e08ff81a06784aed863dc7 100644 --- a/net/minecraft/world/level/levelgen/feature/treedecorators/CreakingHeartDecorator.java +++ b/net/minecraft/world/level/levelgen/feature/treedecorators/CreakingHeartDecorator.java @@ -37,7 +37,7 @@ public class CreakingHeartDecorator extends TreeDecorator { List list1 = new ArrayList<>(list); Util.shuffle(list1, randomSource); Optional optional = list1.stream().filter(pos -> { - for (Direction direction : Direction.values()) { + for (Direction direction : Direction.VALUES) { // Leaf - paw optimization - cache direction values if (!context.checkBlock(pos.relative(direction), blockState -> blockState.is(BlockTags.LOGS))) { return false; } diff --git a/net/minecraft/world/level/levelgen/structure/structures/BuriedTreasurePieces.java b/net/minecraft/world/level/levelgen/structure/structures/BuriedTreasurePieces.java index f515f7c881d597072db226f60cfae2d7ebe89ea4..ed4d719c7dfbce695a8fdc59ded6aae75c273714 100644 --- a/net/minecraft/world/level/levelgen/structure/structures/BuriedTreasurePieces.java +++ b/net/minecraft/world/level/levelgen/structure/structures/BuriedTreasurePieces.java @@ -54,7 +54,7 @@ public class BuriedTreasurePieces { || blockState1 == Blocks.DIORITE.defaultBlockState()) { BlockState blockState2 = !blockState.isAir() && !this.isLiquid(blockState) ? blockState : Blocks.SAND.defaultBlockState(); - for (Direction direction : Direction.values()) { + for (Direction direction : Direction.VALUES) { // Leaf - paw optimization - cache direction values BlockPos blockPos = mutableBlockPos.relative(direction); BlockState blockState3 = level.getBlockState(blockPos); if (blockState3.isAir() || this.isLiquid(blockState3)) { diff --git a/net/minecraft/world/level/levelgen/structure/structures/DesertPyramidStructure.java b/net/minecraft/world/level/levelgen/structure/structures/DesertPyramidStructure.java index 03ec2264b19e1794b609fe09d1ceaba4e0c4d669..3f38fe0140d13c7c356340ba06b55469ede0a1ad 100644 --- a/net/minecraft/world/level/levelgen/structure/structures/DesertPyramidStructure.java +++ b/net/minecraft/world/level/levelgen/structure/structures/DesertPyramidStructure.java @@ -48,7 +48,7 @@ public class DesertPyramidStructure extends SinglePieceStructure { } } - ObjectArrayList list = new ObjectArrayList<>(set.stream().toList()); + ObjectArrayList list = new ObjectArrayList<>(set); // Leaf - paw optimization - TODO: use array RandomSource randomSource = RandomSource.create(level.getSeed()).forkPositional().at(pieces.calculateBoundingBox().getCenter()); Util.shuffle(list, randomSource); int min = Math.min(set.size(), randomSource.nextInt(5, 8)); diff --git a/net/minecraft/world/level/levelgen/structure/structures/MineshaftPieces.java b/net/minecraft/world/level/levelgen/structure/structures/MineshaftPieces.java index 1acd506f7c0679fa9f69b6ab221002b28d00c3e5..20502112f4e338984efc264109d0c894b1d33d56 100644 --- a/net/minecraft/world/level/levelgen/structure/structures/MineshaftPieces.java +++ b/net/minecraft/world/level/levelgen/structure/structures/MineshaftPieces.java @@ -565,7 +565,7 @@ public class MineshaftPieces { BlockPos.MutableBlockPos worldPos = this.getWorldPos(x, y, z); int i = 0; - for (Direction direction : Direction.values()) { + for (Direction direction : Direction.VALUES) { // Leaf - paw optimization - cache direction values worldPos.move(direction); if (box.isInside(worldPos) && level.getBlockState(worldPos).isFaceSturdy(level, worldPos, direction.getOpposite())) { if (++i >= required) { diff --git a/net/minecraft/world/level/levelgen/structure/structures/OceanMonumentPieces.java b/net/minecraft/world/level/levelgen/structure/structures/OceanMonumentPieces.java index b70ef62b4e41ee4851b2cdf53e0be1083233d052..f1ac1e1283cb276e5b21330d700cafdb65e60be1 100644 --- a/net/minecraft/world/level/levelgen/structure/structures/OceanMonumentPieces.java +++ b/net/minecraft/world/level/levelgen/structure/structures/OceanMonumentPieces.java @@ -244,7 +244,7 @@ public class OceanMonumentPieces { for (int i2 = 0; i2 < 3; i2++) { int roomIndex = getRoomIndex(i, i2, i1); if (roomDefinitions[roomIndex] != null) { - for (Direction direction : Direction.values()) { + for (Direction direction : Direction.VALUES) { // Leaf - paw optimization - cache direction values int i3 = i + direction.getStepX(); int i4 = i2 + direction.getStepY(); int i5 = i1 + direction.getStepZ(); diff --git a/net/minecraft/world/level/material/LavaFluid.java b/net/minecraft/world/level/material/LavaFluid.java index d66321acb26682a02efa02cf1443b40d2a17f67b..86ed35984760a0a90e92a297d3080378e8b4bf6f 100644 --- a/net/minecraft/world/level/material/LavaFluid.java +++ b/net/minecraft/world/level/material/LavaFluid.java @@ -126,7 +126,7 @@ public abstract class LavaFluid extends FlowingFluid { } private boolean hasFlammableNeighbours(LevelReader level, BlockPos pos) { - for (Direction direction : Direction.values()) { + for (Direction direction : Direction.VALUES) { // Leaf - paw optimization - cache direction values if (this.isFlammable(level, pos.relative(direction))) { return true; } diff --git a/net/minecraft/world/level/pathfinder/AmphibiousNodeEvaluator.java b/net/minecraft/world/level/pathfinder/AmphibiousNodeEvaluator.java index 33047e446adf252a179cb0220c20a7d83f361482..9c58425f2afdbe5701910d8473fd5b344ffe31dd 100644 --- a/net/minecraft/world/level/pathfinder/AmphibiousNodeEvaluator.java +++ b/net/minecraft/world/level/pathfinder/AmphibiousNodeEvaluator.java @@ -97,7 +97,7 @@ public class AmphibiousNodeEvaluator extends WalkNodeEvaluator { if (pathTypeFromState == PathType.WATER) { BlockPos.MutableBlockPos mutableBlockPos = new BlockPos.MutableBlockPos(); - for (Direction direction : Direction.values()) { + for (Direction direction : Direction.VALUES) { // Leaf - paw optimization - cache direction values mutableBlockPos.set(x, y, z).move(direction); PathType pathTypeFromState1 = context.getPathTypeFromState(mutableBlockPos.getX(), mutableBlockPos.getY(), mutableBlockPos.getZ()); if (pathTypeFromState1 == PathType.BLOCKED) { diff --git a/net/minecraft/world/level/pathfinder/SwimNodeEvaluator.java b/net/minecraft/world/level/pathfinder/SwimNodeEvaluator.java index b25d3bf3d5c575cd5c9a97a6d5ee7191467fe839..c598d91cd9fb711bc9aaa068fbb806619c0d4fe2 100644 --- a/net/minecraft/world/level/pathfinder/SwimNodeEvaluator.java +++ b/net/minecraft/world/level/pathfinder/SwimNodeEvaluator.java @@ -51,7 +51,7 @@ public class SwimNodeEvaluator extends NodeEvaluator { int i = 0; Map map = Maps.newEnumMap(Direction.class); - for (Direction direction : Direction.values()) { + for (Direction direction : Direction.VALUES) { // Leaf - paw optimization - cache direction values Node node1 = this.findAcceptedNode(node.x + direction.getStepX(), node.y + direction.getStepY(), node.z + direction.getStepZ()); map.put(direction, node1); if (this.isNodeValid(node1)) {