Skip to content

Commit

Permalink
Improve fix of dupe with storage bus and chunk unloading
Browse files Browse the repository at this point in the history
  • Loading branch information
gamerforEA committed Sep 15, 2017
1 parent 781d52e commit 952076c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
16 changes: 16 additions & 0 deletions src/main/java/appeng/hooks/TickHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import appeng.tile.AEBaseTile;
import appeng.util.IWorldCallable;
import appeng.util.Platform;
import com.gamerforea.ae.BusUtils;
import com.google.common.base.Stopwatch;
import com.google.common.collect.LinkedListMultimap;
import com.google.common.collect.Multimap;
Expand Down Expand Up @@ -209,6 +210,21 @@ else if (busChunkX - chunkX + busChunkZ - chunkZ == 1)
int targetChunkZ = targetZ >> 4;
if (targetChunkX == chunkX && targetChunkZ == chunkZ)
storageGrid.unregisterCellProvider(bus);
else
{
TileEntity target = tile.getWorldObj().getTileEntity(targetX, tile.yCoord + side.offsetY, targetZ);
if (target != null)
{
TileEntity secondTarget = BusUtils.getSecondChest(target);
if (secondTarget != null)
{
int secondTargetChunkX = secondTarget.xCoord >> 4;
int secondTargetChunkZ = secondTarget.zCoord >> 4;
if (secondTargetChunkX == chunkX && secondTargetChunkZ == chunkZ)
storageGrid.unregisterCellProvider(bus);
}
}
}
}
}
}
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/com/gamerforea/ae/BusUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,11 @@ public static final boolean isValidTile(TileEntity t1)
}

// Copy from Platform.GetChestInv(TileEntity):IInventory
private static TileEntity getSecondChest(final TileEntityChest te)
public static final TileEntity getSecondChest(final TileEntity te)
{
if (!(te instanceof TileEntityChest))
return null;

TileEntityChest teA = (TileEntityChest) te;
TileEntity teB = null;
final Block myBlockID = teA.getWorldObj().getBlock(teA.xCoord, teA.yCoord, teA.zCoord);
Expand Down

0 comments on commit 952076c

Please sign in to comment.