Hello, first of all, I'm new to forge so if I'm missing some basic things, feel free to point me into it.
I'm trying to migrate a minecraft mod from 1.18 to 1.19. Its pretty much done, but there is one bug that I can't resolve.
On the original mod (1.18) there is packet handler that takes care of the main business logic: it scans cube of a configured radius, finds chests and fills them from player's inventory. Here's github link to the method that does the job.
On contrary, my migrated (1.19) method does the same. The main issue is that on the Line 184 after we map BlockPos to BlockEntity and filter by NotNull, we get 0 blocks (at 1.18 it determines everything fine):
var blockEntities = BlockPos.betweenClosedStream(minX, minY, minZ, maxX, maxY, maxZ)
.map(world::getBlockEntity)
.toList();
DropOff.LOGGER.debug("Found {} block entities", blockEntities.size());
var nonNulls = blockEntities.stream()
.filter(Objects::nonNull).toList();
DropOff.LOGGER.debug("Found {} non-nulls", nonNulls.size());
This are the sources of Level#getBlockEntity(BlockPos):
@Nullable
public BlockEntity getBlockEntity(BlockPos p_46716_) {
if (this.isOutsideBuildHeight(p_46716_)) {
return null;
} else {
return !this.isClientSide && Thread.currentThread() != this.thread ? null : this.getChunkAt(p_46716_).getBlockEntity(p_46716_, LevelChunk.EntityCreationType.IMMEDIATE);
}
}
So I guess my issue lays in `Thread.currentThread() != this.thread`.
I reckon I did something wrong with the event listeners which led to this problem. Please help me troubleshoot the problem.
FYI: 1.19 repo, 1.18 repo