Merge master into algent/java and port client conversion fix

Keep the existing Java recipe fix for PR #61. Port PR #62 so client additions reuse multipart tiles without converting stale blocks, preserving server-side conversion. Add a regression for stale client torches and subsequent additions.

Validation: full build, formatting, checkstyleTest and Scala-free API examples passed; 588 unit tests and 300 Forge functional tests passed without skips. The new Forge regression failed before the fix by retaining an extra converted torch.
This commit is contained in:
Algent committed 2026-10-07 17:03:55 +02:00
commit ac2cd5017c
3 files changed
+40 -3

No files matched your search

+2 -1
View File
@@ -19,7 +19,8 @@ of the later upstream rename, not a divergence from the `1.7.12` reference.
| Area | Difference and consequence |
| --- | --- |
| Raw microblock recipe material lookup | Skips `MissingMicroMaterial`, whose recovery item is stone, so sawing stone selects the real stone material. Existing missing-material microblocks retain their recovery behavior. This fixes a pre-existing Scala bug. |
| Raw microblock recipe material lookup | Skips `MissingMicroMaterial`, whose recovery item is stone, so sawing stone selects the real stone material. Existing missing-material microblocks retain their recovery behavior. This fixes a pre-existing Scala bug, also fixed upstream in PR #61. |
| Client part additions | Reuses an existing multipart tile or creates one without converting the stale client block. Conversion and its outgoing packets remain server-side, avoiding duplicate parts and client disconnects. Matches upstream PR #62. |
| `BlockMicroMaterial.createAndRegister(Block, Seq, String)` | Registers every supplied metadata value instead of only zero, including dark-oak logs and leaves and their legacy-name remaps. This fixes a pre-existing Scala bug; material IDs are rebuilt through the existing registry mapping. |
| Chunk scheduled-tick restoration | Reactivates chunks with restored scheduled ticks so their callbacks resume at the saved deadlines. The Scala implementation restored entries without activating their chunk. NBT layout and duplicate-scheduling behavior are unchanged. |
| World scheduler clock loading | Retains successfully loaded `schedTime` instead of overwriting it with total world time. Missing or unreadable files still fall back to world time. This fixes a pre-existing Scala bug and preserves the clock used by saved absolute tick deadlines; the file format is unchanged. |
@@ -28,6 +28,7 @@ import codechicken.multipart.MultipartGenerator;
import codechicken.multipart.MultipartGenerator$;
import codechicken.multipart.TMultiPart;
import codechicken.multipart.TSlottedPart;
import codechicken.multipart.TileCache;
import codechicken.multipart.TileMultipart;
import codechicken.multipart.TileMultipartClient;
import codechicken.multipart.asm.MultipartMixinFactory;
@@ -175,6 +176,39 @@ public class MultipartGeneratorFunctionalTest {
}
}
@Test
void clientAdditionsReplaceStaleConvertibleBlocksWithoutConvertingThem() {
World world = MinecraftServer.getServer().worldServers[0];
BlockCoord pos = new BlockCoord(51, 200, 48);
world.getChunkFromBlockCoords(pos.x, pos.z);
world.setBlock(pos.x, pos.y - 1, pos.z, Blocks.stone, 0, 0);
world.setBlock(pos.x, pos.y, pos.z, Blocks.torch, 5, 0);
boolean wasRemote = world.isRemote;
TileCache.FlaggedTile cached = TileCache.map().get(pos);
try {
// The server-started test event is synchronous; restore the side before any server tick.
world.isRemote = true;
PlainPart first = new PlainPart();
TileMultipart tile = MultipartGenerator$.MODULE$.addPart(world, pos, first);
assertTrue(tile instanceof TileMultipartClient);
assertSame(MultipartProxy.block(), world.getBlock(pos.x, pos.y, pos.z));
assertSame(tile, world.getTileEntity(pos.x, pos.y, pos.z));
assertEquals(Collections.singletonList(first), tile.jPartList());
assertSame(tile, first.tile());
PlainPart second = new PlainPart();
assertSame(tile, MultipartGenerator$.MODULE$.addPart(world, pos, second));
assertEquals(Arrays.asList(first, second), tile.jPartList());
assertSame(tile, second.tile());
} finally {
world.isRemote = wasRemote;
world.setBlockToAir(pos.x, pos.y, pos.z);
world.setBlockToAir(pos.x, pos.y - 1, pos.z);
if (cached == null) TileCache.map().remove(pos);
else TileCache.map().put(pos, cached);
}
}
@Test
void frozenScalaConsumerLinksCompanionGenerationAndDefaultPassThroughRegistration() throws Exception {
byte[] bytes;
@@ -105,14 +105,16 @@ public final class MultipartGenerator$ implements ScratchBitSet {
/** Replaces the tile if the new part requires additional interfaces, then adds the part. */
public TileMultipart addPart(World world, BlockCoord pos, TMultiPart part) {
Tuple2<TileMultipart, Object> convertedTile = TileMultipart.getOrConvertTile2(world, pos);
Tuple2<TileMultipart, Object> convertedTile = world.isRemote
? new Tuple2<>(TileMultipart.getTile(world, pos), Boolean.FALSE)
: TileMultipart.getOrConvertTile2(world, pos);
TileMultipart tile = convertedTile._1();
boolean converted = (Boolean) convertedTile._2();
BitSet bitset = setTraits(part, world.isRemote);
TileMultipart next = tile;
if (next != null) {
if (converted) {
if (converted) { // Server-side conversion, then tell the clients.
next.partList().apply(0).invalidateConvertedTile();
world.setBlock(pos.x, pos.y, pos.z, MultipartProxy.block(), 0, 0);
silentAddTile(world, pos, next);