9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2025-12-23 17:09:29 +00:00
Files
Leaf/leaf-server/minecraft-patches/features/0298-Pluto-reduce-allocation.patch

50 lines
2.5 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Yive <6853318+Yive@users.noreply.github.com>
Date: Tue, 6 May 2025 10:12:32 -0700
Subject: [PATCH] Pluto: reduce allocation
Original license: GPL-3.0
Original project: https://github.com/Yive/Pluto
diff --git a/alternate/current/wire/WireHandler.java b/alternate/current/wire/WireHandler.java
index 259b301b2c8b64cb7974a235afb260e0e991af54..2c3dcd7e21f5e79ec12c9ffff3cd3c7f9da28b73 100644
--- a/alternate/current/wire/WireHandler.java
+++ b/alternate/current/wire/WireHandler.java
@@ -136,6 +136,8 @@ import net.minecraft.world.level.redstone.Redstone;
*/
public class WireHandler {
+ private static final UpdateOrder[] UPDATE_ORDERS = UpdateOrder.values(); // Pluto - reduce allocation
+
public static class Directions {
public static final Direction[] ALL = { Direction.WEST, Direction.NORTH, Direction.EAST, Direction.SOUTH, Direction.DOWN, Direction.UP };
@@ -489,7 +491,7 @@ public class WireHandler {
}
}
- updateOrder = UpdateOrder.values()[level.paperConfig().misc.alternateCurrentUpdateOrder.ordinal()];
+ updateOrder = UPDATE_ORDERS[level.paperConfig().misc.alternateCurrentUpdateOrder.ordinal()]; // Pluto - reduce allocation
}
/**
diff --git a/net/minecraft/world/entity/SpawnPlacementTypes.java b/net/minecraft/world/entity/SpawnPlacementTypes.java
index a18f4c2f6b8ab6fdcafc9345a1c3ba80d5114124..0a19c8bde1aba16ad9a63f18e071c9b0eabe313b 100644
--- a/net/minecraft/world/entity/SpawnPlacementTypes.java
+++ b/net/minecraft/world/entity/SpawnPlacementTypes.java
@@ -25,12 +25,12 @@ public interface SpawnPlacementTypes {
@Override
public boolean isSpawnPositionOk(LevelReader level, BlockPos pos, @Nullable EntityType<?> entityType) {
if (entityType != null && level.getWorldBorder().isWithinBounds(pos)) {
- BlockPos blockPos = pos.above();
+ // BlockPos blockPos = pos.above(); // Pluto - reduce allocation
BlockPos blockPos1 = pos.below();
BlockState blockState = level.getBlockState(blockPos1);
return blockState.isValidSpawn(level, blockPos1, entityType)
&& this.isValidEmptySpawnBlock(level, pos, entityType)
- && this.isValidEmptySpawnBlock(level, blockPos, entityType);
+ && this.isValidEmptySpawnBlock(level, pos.above(), entityType); // Pluto - reduce allocation
} else {
return false;
}