9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2025-12-19 15:09:25 +00:00

Merge branch 'ver/1.21.4' into dev/random-tick

This commit is contained in:
hayanesuru
2025-06-14 11:55:50 +09:00
19 changed files with 128 additions and 121 deletions

View File

@@ -3,7 +3,7 @@ From: hayanesuru <hayanesuru@outlook.jp>
Date: Wed, 4 Jun 2025 20:54:32 +0900
Subject: [PATCH] preload mob spawning position
No need
Removed since Leaf 1.21.4, No need
diff --git a/net/minecraft/world/level/NaturalSpawner.java b/net/minecraft/world/level/NaturalSpawner.java
index 458b17dca84c87591b030679c5aac6259c0f8308..c69922ac2b831d8af35c9e98a34825e6b8a268da 100644

View File

@@ -3,6 +3,9 @@ From: HaHaWTH <102713261+HaHaWTH@users.noreply.github.com>
Date: Tue, 9 Nov 2077 00:00:00 +0800
Subject: [PATCH] Lithium: equipment tracking
TODO: needs to fix issues related to Piglins lose the crossbow animation
original report is in discord.
Should have special treatment to ArmorStand, since Paper introduced the configurable
ArmorStand no-tick, and still gives it ability to update equipment changes.
Thus added a bypass condition in LivingEntity#collectEquipmentChanges, always send

View File

@@ -3,6 +3,7 @@ From: HaHaWTH <102713261+HaHaWTH@users.noreply.github.com>
Date: Tue, 9 Nov 2077 00:00:00 +0800
Subject: [PATCH] Use UUID for cure reputation
Related MC issue: https://bugs.mojang.com/browse/MC/issues/MC-247647
diff --git a/net/minecraft/world/entity/monster/ZombieVillager.java b/net/minecraft/world/entity/monster/ZombieVillager.java
index d4b6c93f9f0e109be300164c4fd9167aba2d951c..138e62965a4e532972e51c16b429e050bb147788 100644

View File

@@ -5,7 +5,7 @@ Subject: [PATCH] Cache potential behaviors in Brain
diff --git a/net/minecraft/world/entity/ai/Brain.java b/net/minecraft/world/entity/ai/Brain.java
index b143cd6d5636dc61458a864cd548c886d14cd30c..954aa416877fd8838fd88d84096918455baa5641 100644
index 636a945ce2a91b8bf73b790e0e9e412368b3fe71..27fc18000987d6f962df8a9e441eb2e3d28bf213 100644
--- a/net/minecraft/world/entity/ai/Brain.java
+++ b/net/minecraft/world/entity/ai/Brain.java
@@ -60,6 +60,7 @@ public class Brain<E extends LivingEntity> {

View File

@@ -5,7 +5,7 @@ Subject: [PATCH] Use ActivationList on runningBehaviors
diff --git a/net/minecraft/world/entity/ai/Brain.java b/net/minecraft/world/entity/ai/Brain.java
index 954aa416877fd8838fd88d84096918455baa5641..3749808c5392f351b2383dd8d8cf8d884519804e 100644
index 27fc18000987d6f962df8a9e441eb2e3d28bf213..205d7f583ad9415bd2411c3b13726c6e7d90ff83 100644
--- a/net/minecraft/world/entity/ai/Brain.java
+++ b/net/minecraft/world/entity/ai/Brain.java
@@ -61,6 +61,7 @@ public class Brain<E extends LivingEntity> {

View File

@@ -32,7 +32,8 @@ public class AsyncPlayerDataSaving {
new ThreadPoolExecutor.DiscardPolicy()
);
} else {
throw new IllegalStateException();
// Temp no-op
//throw new IllegalStateException();
}
}

View File

@@ -43,7 +43,8 @@ public class AsyncPathProcessor {
getRejectedPolicy()
);
} else {
throw new IllegalStateException();
// Temp no-op
//throw new IllegalStateException();
}
}

View File

@@ -46,7 +46,8 @@ public class MultithreadedTracker {
getRejectedPolicy()
);
} else {
throw new IllegalStateException();
// Temp no-op
//throw new IllegalStateException();
}
}

View File

@@ -71,7 +71,7 @@ public class LeafConfig {
Command.broadcastCommandMessage(sender, Component.text(success, NamedTextColor.GREEN));
} catch (Exception e) {
Command.broadcastCommandMessage(sender, Component.text("Failed to reload config. See error in console!", NamedTextColor.RED));
LOGGER.error(e);
LOGGER.error("Failed to reload config!", e);
}
}, Util.ioPool());
}
@@ -87,7 +87,7 @@ public class LeafConfig {
LOGGER.info("Successfully loaded config in {}ms.", (System.nanoTime() - begin) / 1_000_000);
} catch (Exception e) {
LeafConfig.LOGGER.error("Failed to load config modules!", e);
LOGGER.error("Failed to load config modules!", e);
}
}
@@ -95,7 +95,7 @@ public class LeafConfig {
private static void loadConfig(boolean init) throws Exception {
// Create config folder
createDirectory(LeafConfig.I_CONFIG_FOLDER);
createDirectory(I_CONFIG_FOLDER);
leafGlobalConfig = new LeafGlobalConfig(init);

View File

@@ -62,14 +62,14 @@ public class OptimizedPoweredRails {
}
}
private static boolean findPoweredRailSignalFaster(PoweredRailBlock self, Level world, BlockPos pos,
boolean bl, int distance, RailShape shape,
private static boolean findPoweredRailSignalFaster(PoweredRailBlock self, Level level, BlockPos pos,
boolean searchForward, int distance, RailShape shape,
Object2BooleanOpenHashMap<BlockPos> checkedPos) {
BlockState blockState = world.getBlockState(pos);
BlockState blockState = level.getBlockState(pos);
boolean speedCheck = checkedPos.containsKey(pos) && checkedPos.getBoolean(pos);
if (speedCheck) {
return world.hasNeighborSignal(pos) ||
findPoweredRailSignalFaster(self, world, pos, blockState, bl, distance + 1, checkedPos);
return level.hasNeighborSignal(pos) ||
findPoweredRailSignalFaster(self, level, pos, blockState, searchForward, distance + 1, checkedPos);
} else {
if (blockState.is(self)) {
RailShape railShape = blockState.getValue(SHAPE);
@@ -84,8 +84,8 @@ public class OptimizedPoweredRails {
)) {
return false;
} else if (blockState.getValue(POWERED)) {
return world.hasNeighborSignal(pos) ||
findPoweredRailSignalFaster(self, world, pos, blockState, bl, distance + 1, checkedPos);
return level.hasNeighborSignal(pos) ||
findPoweredRailSignalFaster(self, level, pos, blockState, searchForward, distance + 1, checkedPos);
} else {
return false;
}
@@ -95,200 +95,200 @@ public class OptimizedPoweredRails {
}
private static boolean findPoweredRailSignalFaster(PoweredRailBlock self, Level level,
BlockPos pos, BlockState state, boolean bl, int distance,
BlockPos pos, BlockState state, boolean searchForward, int distance,
Object2BooleanOpenHashMap<BlockPos> checkedPos) {
if (distance >= RAIL_POWER_LIMIT - 1) return false;
int i = pos.getX();
int j = pos.getY();
int k = pos.getZ();
boolean bl2 = true;
int x = pos.getX();
int y = pos.getY();
int z = pos.getZ();
boolean flag = true;
RailShape railShape = state.getValue(SHAPE);
switch (railShape.ordinal()) {
case 0 -> {
if (bl) ++k;
else --k;
if (searchForward) ++z;
else --z;
}
case 1 -> {
if (bl) --i;
else ++i;
if (searchForward) --x;
else ++x;
}
case 2 -> {
if (bl) {
--i;
if (searchForward) {
--x;
} else {
++i;
++j;
bl2 = false;
++x;
++y;
flag = false;
}
railShape = RailShape.EAST_WEST;
}
case 3 -> {
if (bl) {
--i;
++j;
bl2 = false;
if (searchForward) {
--x;
++y;
flag = false;
} else {
++i;
++x;
}
railShape = RailShape.EAST_WEST;
}
case 4 -> {
if (bl) {
++k;
if (searchForward) {
++z;
} else {
--k;
++j;
bl2 = false;
--z;
++y;
flag = false;
}
railShape = RailShape.NORTH_SOUTH;
}
case 5 -> {
if (bl) {
++k;
++j;
bl2 = false;
if (searchForward) {
++z;
++y;
flag = false;
} else {
--k;
--z;
}
railShape = RailShape.NORTH_SOUTH;
}
}
return findPoweredRailSignalFaster(
self, level, new BlockPos(i, j, k),
bl, distance, railShape, checkedPos
self, level, new BlockPos(x, y, z),
searchForward, distance, railShape, checkedPos
) ||
(bl2 && findPoweredRailSignalFaster(
self, level, new BlockPos(i, j - 1, k),
bl, distance, railShape, checkedPos
(flag && findPoweredRailSignalFaster(
self, level, new BlockPos(x, y - 1, z),
searchForward, distance, railShape, checkedPos
));
}
private static void powerLane(PoweredRailBlock self, Level world, BlockPos pos,
private static void powerLane(PoweredRailBlock self, Level level, BlockPos pos,
BlockState mainState, RailShape railShape) {
world.setBlock(pos, mainState.setValue(POWERED, true), UPDATE_FORCE_PLACE);
level.setBlock(pos, mainState.setValue(POWERED, true), UPDATE_FORCE_PLACE);
Object2BooleanOpenHashMap<BlockPos> checkedPos = CHECKED_POS_POOL;
checkedPos.clear();
checkedPos.put(pos, true);
int[] count = new int[2];
if (railShape == RailShape.NORTH_SOUTH) { // Order: +z, -z
for (int i = 0; i < NORTH_SOUTH_DIR.length; ++i) {
setRailPositionsPower(self, world, pos, checkedPos, count, i, NORTH_SOUTH_DIR[i]);
setRailPositionsPower(self, level, pos, checkedPos, count, i, NORTH_SOUTH_DIR[i]);
}
updateRails(self, false, world, pos, mainState, count);
updateRails(self, false, level, pos, mainState, count);
} else if (railShape == RailShape.EAST_WEST) { // Order: -x, +x
for (int i = 0; i < EAST_WEST_DIR.length; ++i) {
setRailPositionsPower(self, world, pos, checkedPos, count, i, EAST_WEST_DIR[i]);
setRailPositionsPower(self, level, pos, checkedPos, count, i, EAST_WEST_DIR[i]);
}
updateRails(self, true, world, pos, mainState, count);
updateRails(self, true, level, pos, mainState, count);
}
checkedPos.clear();
}
private static void dePowerLane(PoweredRailBlock self, Level world, BlockPos pos,
private static void dePowerLane(PoweredRailBlock self, Level level, BlockPos pos,
BlockState mainState, RailShape railShape) {
world.setBlock(pos, mainState.setValue(POWERED, false), UPDATE_FORCE_PLACE);
level.setBlock(pos, mainState.setValue(POWERED, false), UPDATE_FORCE_PLACE);
int[] count = new int[2];
if (railShape == RailShape.NORTH_SOUTH) { // Order: +z, -z
for (int i = 0; i < NORTH_SOUTH_DIR.length; ++i) {
setRailPositionsDePower(self, world, pos, count, i, NORTH_SOUTH_DIR[i]);
setRailPositionsDePower(self, level, pos, count, i, NORTH_SOUTH_DIR[i]);
}
updateRails(self, false, world, pos, mainState, count);
updateRails(self, false, level, pos, mainState, count);
} else if (railShape == RailShape.EAST_WEST) { // Order: -x, +x
for (int i = 0; i < EAST_WEST_DIR.length; ++i) {
setRailPositionsDePower(self, world, pos, count, i, EAST_WEST_DIR[i]);
setRailPositionsDePower(self, level, pos, count, i, EAST_WEST_DIR[i]);
}
updateRails(self, true, world, pos, mainState, count);
updateRails(self, true, level, pos, mainState, count);
}
}
private static void setRailPositionsPower(PoweredRailBlock self, Level world, BlockPos pos,
private static void setRailPositionsPower(PoweredRailBlock self, Level level, BlockPos pos,
Object2BooleanOpenHashMap<BlockPos> checkedPos, int[] count, int i, Direction dir) {
for (int z = 1; z < RAIL_POWER_LIMIT; z++) {
BlockPos newPos = pos.relative(dir, z);
BlockState state = world.getBlockState(newPos);
BlockState state = level.getBlockState(newPos);
if (checkedPos.containsKey(newPos)) {
if (!checkedPos.getBoolean(newPos))
break;
count[i]++;
} else if (!state.is(self) || state.getValue(POWERED) || !(world.hasNeighborSignal(newPos) ||
findPoweredRailSignalFaster(self, world, newPos, state, true, 0, checkedPos) ||
findPoweredRailSignalFaster(self, world, newPos, state, false, 0, checkedPos))) {
} else if (!state.is(self) || state.getValue(POWERED) || !(level.hasNeighborSignal(newPos) ||
findPoweredRailSignalFaster(self, level, newPos, state, true, 0, checkedPos) ||
findPoweredRailSignalFaster(self, level, newPos, state, false, 0, checkedPos))) {
checkedPos.put(newPos, false);
break;
} else {
checkedPos.put(newPos, true);
if (!state.getValue(POWERED)) {
world.setBlock(newPos, state.setValue(POWERED, true), UPDATE_FORCE_PLACE);
level.setBlock(newPos, state.setValue(POWERED, true), UPDATE_FORCE_PLACE);
}
count[i]++;
}
}
}
private static void setRailPositionsDePower(PoweredRailBlock self, Level world, BlockPos pos,
private static void setRailPositionsDePower(PoweredRailBlock self, Level level, BlockPos pos,
int[] count, int i, Direction dir) {
Object2BooleanOpenHashMap<BlockPos> checkedPos = CHECKED_POS_POOL;
checkedPos.clear();
for (int z = 1; z < RAIL_POWER_LIMIT; z++) {
BlockPos newPos = pos.relative(dir, z);
BlockState state = world.getBlockState(newPos);
if (!state.is(self) || !state.getValue(POWERED) || world.hasNeighborSignal(newPos) ||
findPoweredRailSignalFaster(self, world, newPos, state, true, 0, checkedPos) ||
findPoweredRailSignalFaster(self, world, newPos, state, false, 0, checkedPos))
BlockState state = level.getBlockState(newPos);
if (!state.is(self) || !state.getValue(POWERED) || level.hasNeighborSignal(newPos) ||
findPoweredRailSignalFaster(self, level, newPos, state, true, 0, checkedPos) ||
findPoweredRailSignalFaster(self, level, newPos, state, false, 0, checkedPos))
break;
if (state.getValue(POWERED)) {
world.setBlock(newPos, state.setValue(POWERED, false), UPDATE_FORCE_PLACE);
level.setBlock(newPos, state.setValue(POWERED, false), UPDATE_FORCE_PLACE);
}
count[i]++;
}
checkedPos.clear();
}
private static void shapeUpdateEnd(PoweredRailBlock self, Level world, BlockPos pos, BlockState mainState,
private static void shapeUpdateEnd(PoweredRailBlock self, Level level, BlockPos pos, BlockState mainState,
int endPos, Direction direction, int currentPos, BlockPos blockPos) {
if (currentPos == endPos) {
BlockPos newPos = pos.relative(direction, currentPos + 1);
giveShapeUpdate(world, mainState, newPos, pos, direction);
BlockState state = world.getBlockState(blockPos);
if (state.is(self) && state.getValue(SHAPE).isSlope()) giveShapeUpdate(world, mainState, newPos.above(), pos, direction);
giveShapeUpdate(level, mainState, newPos, pos, direction);
BlockState state = level.getBlockState(blockPos);
if (state.is(self) && state.getValue(SHAPE).isSlope()) giveShapeUpdate(level, mainState, newPos.above(), pos, direction);
}
}
private static void neighborUpdateEnd(PoweredRailBlock self, Level world, BlockPos pos, int endPos,
private static void neighborUpdateEnd(PoweredRailBlock self, Level level, BlockPos pos, int endPos,
Direction direction, Block block, int currentPos, BlockPos blockPos) {
if (currentPos == endPos) {
BlockPos newPos = pos.relative(direction, currentPos + 1);
world.neighborChanged(newPos, block, null);
BlockState state = world.getBlockState(blockPos);
if (state.is(self) && state.getValue(SHAPE).isSlope()) world.neighborChanged(newPos.above(), block, null);
level.neighborChanged(newPos, block, null);
BlockState state = level.getBlockState(blockPos);
if (state.is(self) && state.getValue(SHAPE).isSlope()) level.neighborChanged(newPos.above(), block, null);
}
}
private static void updateRailsSectionEastWestShape(PoweredRailBlock self, Level world, BlockPos pos,
private static void updateRailsSectionEastWestShape(PoweredRailBlock self, Level level, BlockPos pos,
int c, BlockState mainState, Direction dir,
int[] count, int countAmt) {
BlockPos pos1 = pos.relative(dir, c);
if (c == 0 && count[1] == 0) giveShapeUpdate(world, mainState, pos1.relative(dir.getOpposite()), pos, dir.getOpposite());
shapeUpdateEnd(self, world, pos, mainState, countAmt, dir, c, pos1);
giveShapeUpdate(world, mainState, pos1.below(), pos, Direction.DOWN);
giveShapeUpdate(world, mainState, pos1.above(), pos, Direction.UP);
giveShapeUpdate(world, mainState, pos1.north(), pos, Direction.NORTH);
giveShapeUpdate(world, mainState, pos1.south(), pos, Direction.SOUTH);
if (c == 0 && count[1] == 0) giveShapeUpdate(level, mainState, pos1.relative(dir.getOpposite()), pos, dir.getOpposite());
shapeUpdateEnd(self, level, pos, mainState, countAmt, dir, c, pos1);
giveShapeUpdate(level, mainState, pos1.below(), pos, Direction.DOWN);
giveShapeUpdate(level, mainState, pos1.above(), pos, Direction.UP);
giveShapeUpdate(level, mainState, pos1.north(), pos, Direction.NORTH);
giveShapeUpdate(level, mainState, pos1.south(), pos, Direction.SOUTH);
}
private static void updateRailsSectionNorthSouthShape(PoweredRailBlock self, Level world, BlockPos pos,
private static void updateRailsSectionNorthSouthShape(PoweredRailBlock self, Level level, BlockPos pos,
int c, BlockState mainState, Direction dir,
int[] count, int countAmt) {
BlockPos pos1 = pos.relative(dir, c);
giveShapeUpdate(world, mainState, pos1.west(), pos, Direction.WEST);
giveShapeUpdate(world, mainState, pos1.east(), pos, Direction.EAST);
giveShapeUpdate(world, mainState, pos1.below(), pos, Direction.DOWN);
giveShapeUpdate(world, mainState, pos1.above(), pos, Direction.UP);
shapeUpdateEnd(self, world, pos, mainState, countAmt, dir, c, pos1);
if (c == 0 && count[1] == 0) giveShapeUpdate(world, mainState, pos1.relative(dir.getOpposite()), pos, dir.getOpposite());
giveShapeUpdate(level, mainState, pos1.west(), pos, Direction.WEST);
giveShapeUpdate(level, mainState, pos1.east(), pos, Direction.EAST);
giveShapeUpdate(level, mainState, pos1.below(), pos, Direction.DOWN);
giveShapeUpdate(level, mainState, pos1.above(), pos, Direction.UP);
shapeUpdateEnd(self, level, pos, mainState, countAmt, dir, c, pos1);
if (c == 0 && count[1] == 0) giveShapeUpdate(level, mainState, pos1.relative(dir.getOpposite()), pos, dir.getOpposite());
}
private static void updateRails(PoweredRailBlock self, boolean eastWest, Level world,
private static void updateRails(PoweredRailBlock self, boolean eastWest, Level level,
BlockPos pos, BlockState mainState, int[] count) {
if (eastWest) {
for (int i = 0; i < EAST_WEST_DIR.length; ++i) {
@@ -298,21 +298,21 @@ public class OptimizedPoweredRails {
Block block = mainState.getBlock();
for (int c = countAmt; c >= i; c--) {
BlockPos p = pos.relative(dir, c);
if (c == 0 && count[1] == 0) world.neighborChanged(p.relative(dir.getOpposite()), block, null);
neighborUpdateEnd(self, world, pos, countAmt, dir, block, c, p);
world.neighborChanged(p.below(), block, null);
world.neighborChanged(p.above(), block, null);
world.neighborChanged(p.north(), block, null);
world.neighborChanged(p.south(), block, null);
if (c == 0 && count[1] == 0) level.neighborChanged(p.relative(dir.getOpposite()), block, null);
neighborUpdateEnd(self, level, pos, countAmt, dir, block, c, p);
level.neighborChanged(p.below(), block, null);
level.neighborChanged(p.above(), block, null);
level.neighborChanged(p.north(), block, null);
level.neighborChanged(p.south(), block, null);
BlockPos pos2 = pos.relative(dir, c).below();
world.neighborChanged(pos2.below(), block, null);
world.neighborChanged(pos2.north(), block, null);
world.neighborChanged(pos2.south(), block, null);
if (c == countAmt) world.neighborChanged(pos.relative(dir, c + 1).below(), block, null);
if (c == 0 && count[1] == 0) world.neighborChanged(p.relative(dir.getOpposite()).below(), block, null);
level.neighborChanged(pos2.below(), block, null);
level.neighborChanged(pos2.north(), block, null);
level.neighborChanged(pos2.south(), block, null);
if (c == countAmt) level.neighborChanged(pos.relative(dir, c + 1).below(), block, null);
if (c == 0 && count[1] == 0) level.neighborChanged(p.relative(dir.getOpposite()).below(), block, null);
}
for (int c = countAmt; c >= i; c--)
updateRailsSectionEastWestShape(self, world, pos, c, mainState, dir, count, countAmt);
updateRailsSectionEastWestShape(self, level, pos, c, mainState, dir, count, countAmt);
}
} else {
for (int i = 0; i < NORTH_SOUTH_DIR.length; ++i) {
@@ -322,21 +322,21 @@ public class OptimizedPoweredRails {
Block block = mainState.getBlock();
for (int c = countAmt; c >= i; c--) {
BlockPos p = pos.relative(dir, c);
world.neighborChanged(p.west(), block, null);
world.neighborChanged(p.east(), block, null);
world.neighborChanged(p.below(), block, null);
world.neighborChanged(p.above(), block, null);
neighborUpdateEnd(self, world, pos, countAmt, dir, block, c, p);
if (c == 0 && count[1] == 0) world.neighborChanged(p.relative(dir.getOpposite()), block, null);
level.neighborChanged(p.west(), block, null);
level.neighborChanged(p.east(), block, null);
level.neighborChanged(p.below(), block, null);
level.neighborChanged(p.above(), block, null);
neighborUpdateEnd(self, level, pos, countAmt, dir, block, c, p);
if (c == 0 && count[1] == 0) level.neighborChanged(p.relative(dir.getOpposite()), block, null);
BlockPos pos2 = pos.relative(dir, c).below();
world.neighborChanged(pos2.west(), block, null);
world.neighborChanged(pos2.east(), block, null);
world.neighborChanged(pos2.below(), block, null);
if (c == countAmt) world.neighborChanged(pos.relative(dir, c + 1).below(), block, null);
if (c == 0 && count[1] == 0) world.neighborChanged(p.relative(dir.getOpposite()).below(), block, null);
level.neighborChanged(pos2.west(), block, null);
level.neighborChanged(pos2.east(), block, null);
level.neighborChanged(pos2.below(), block, null);
if (c == countAmt) level.neighborChanged(pos.relative(dir, c + 1).below(), block, null);
if (c == 0 && count[1] == 0) level.neighborChanged(p.relative(dir.getOpposite()).below(), block, null);
}
for (int c = countAmt; c >= i; c--)
updateRailsSectionNorthSouthShape(self, world, pos, c, mainState, dir, count, countAmt);
updateRailsSectionNorthSouthShape(self, level, pos, c, mainState, dir, count, countAmt);
}
}
}