Load My Chunks

Load My Chunks

9.9k Downloads

[BUG] 2x Block Entity tick speed

Drathonix opened this issue ยท 3 comments

commented

There is currently an unknown mod conflict in the modpack used in #3 that causes block entities to tick twice each world tick.

The cause of the conflict is the "tickChunkWise" method in MixinLevel which makes an assumption that no other mods change block entity ticking in a significant way. Will update this issue once I find the other cause.

commented

Fixed in 1.0.5

commented

Update: Seems the tick acceleration only applies the first time a block entity is created. On subsequent chunk loads (including world restarts) the BE ticks normally.

commented

This is not a mod conflict, but rather a bad Mixin on my part.

The cause is the MixinLevelChunk.addToQueue method, which is Injected into the createTicker method. This mixin mis-assumes that LevelChunk.createTicker is called once for each block entity, but it is actually called multiple times, even DURING BlockEntity ticking. The vanilla implementation is definitely questionable, the multiple calls to this method are accounted for by using a "RebindableTickingBlockEntityWrapper" which is rebinded to each time the TickingBlockEntity object is recreated. This way, the vanilla implementation ensures that only one block entity ticker exists for each block entity and avoids having double ticks as I have unknowingly created.

The way vanilla does this is definitely odd and doesn't make much sense, the block entity ticker object is essentially just a Runnable, in all vanilla use cases this code is always the same, it doesn't do anything that justifies assuming the TickingBlockEntity object's ticker would EVER be any different, but none the less, this is the case.

The bug should only affect versions above 1.16.5 and will require patch for all other versions that introduced the rebindable wrapper system.

The good news is that this should have only minor side effects in most cases, but I will speed up release of 1.0.5 and remove the mekanism integration component of the release for the sake of removing this problem quickly.