Use Forge's loadChunk method instead of our forceLoadChunk method
Closes
Forge's method proerply handles any concurrent chunk loads happening
asynchronously
import net.minecraft.world.gen.ChunkProviderServer;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
@Shadow @Final public WorldServer world;
@Shadow @Final public Long2ObjectMap<Chunk> id2ChunkMap;
+ @Shadow public abstract Chunk loadChunk(int x, int z);
@Inject(method = "tick", at = @At("RETURN"))
public void onTickReturn(CallbackInfoReturnable<Boolean> cir) {
@@ -49,4 +51,18 @@ public void onTickReturn(CallbackInfoReturnable<Boolean> cir) {
net.minecraftforge.common.DimensionManager.unloadWorld(this.world.provider.getDimension());
}
}
+
+ /**
+ * @author Aaron1011 - January 28, 2017
+ * @reason In SpongeVanilla, it's safe to run this method instead of loadChunk,
+ * since the only modification made is the removal of a check we've already done.
+ *
+ * However, loadChunk is completely different in Forge. therefore, we need to delegate to
+ * the original method to ensure that async loadig gets handled properly (Forge's code properly
+ * handles a concurrent asychronous load of the same chunk).
+ *
+ */
+ private Chunk loadChunkForce(int x, int z) {
+ return this.loadChunk(x, z);
+ }
}
