diff options
| author | Prometheus0000 <prometheus0000000@gmail.com> | 2021-02-11 14:29:19 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-02-11 14:29:19 -0500 |
| commit | 3a027e939e2c18e165b2f1405637c92f25736582 (patch) | |
| tree | 1d75209cd6c074313f0e3f15bc989f7b258a57bd /src/main/java/gregtech/api/threads | |
| parent | c6324633a4491296c0505e59aa7f8747af0c640a (diff) | |
| parent | e0c1f654b17d901d018603912bf32c32bd136bad (diff) | |
| download | GT5-Unofficial-3a027e939e2c18e165b2f1405637c92f25736582.tar.gz GT5-Unofficial-3a027e939e2c18e165b2f1405637c92f25736582.tar.bz2 GT5-Unofficial-3a027e939e2c18e165b2f1405637c92f25736582.zip | |
Merge pull request #23 from GTNewHorizons/experimental
update
Diffstat (limited to 'src/main/java/gregtech/api/threads')
| -rw-r--r-- | src/main/java/gregtech/api/threads/GT_Runnable_MachineBlockUpdate.java | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/main/java/gregtech/api/threads/GT_Runnable_MachineBlockUpdate.java b/src/main/java/gregtech/api/threads/GT_Runnable_MachineBlockUpdate.java index 8f7a84e2cb..3ce1daf9b2 100644 --- a/src/main/java/gregtech/api/threads/GT_Runnable_MachineBlockUpdate.java +++ b/src/main/java/gregtech/api/threads/GT_Runnable_MachineBlockUpdate.java @@ -3,6 +3,7 @@ package gregtech.api.threads; import gregtech.GT_Mod; import gregtech.api.GregTech_API; import gregtech.api.interfaces.tileentity.IMachineBlockUpdateable; +import gregtech.common.GT_Proxy; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ChunkCoordinates; import net.minecraft.world.World; @@ -101,8 +102,19 @@ public class GT_Runnable_MachineBlockUpdate implements Runnable { try { while (!tQueue.isEmpty()) { final ChunkCoordinates aCoords = tQueue.poll(); - TileEntity tTileEntity = world.getTileEntity(aCoords.posX, aCoords.posY, aCoords.posZ); - + final TileEntity tTileEntity; + final boolean isMachineBlock; + + // This might load a chunk... which might load a TileEntity... which might get added to `loadedTileEntityList`... which might be in the process + // of being iterated over during `UpdateEntities()`... which might cause a ConcurrentModificationException. So, lock that shit. + GT_Proxy.TICK_LOCK.lock(); + try { + tTileEntity = world.getTileEntity(aCoords.posX, aCoords.posY, aCoords.posZ); + isMachineBlock = GregTech_API.isMachineBlock(world.getBlock(aCoords.posX, aCoords.posY, aCoords.posZ), world.getBlockMetadata(aCoords.posX, aCoords.posY, aCoords.posZ)); + } finally { + GT_Proxy.TICK_LOCK.unlock(); + } + // See if the block itself needs an update if (tTileEntity instanceof IMachineBlockUpdateable) ((IMachineBlockUpdateable) tTileEntity).onMachineBlockUpdate(); @@ -113,7 +125,7 @@ public class GT_Runnable_MachineBlockUpdate implements Runnable { // 3) If the block at the coordinates is marked as a machine block if (visited.size() < 5 || (tTileEntity instanceof IMachineBlockUpdateable && ((IMachineBlockUpdateable) tTileEntity).isMachineBlockUpdateRecursive()) - || GregTech_API.isMachineBlock(world.getBlock(aCoords.posX, aCoords.posY, aCoords.posZ), world.getBlockMetadata(aCoords.posX, aCoords.posY, aCoords.posZ))) + || isMachineBlock) { ChunkCoordinates tCoords; |
