File tree Expand file tree Collapse file tree 1 file changed +9
-5
lines changed
src/main/java/gregtech/api/metatileentity Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -75,16 +75,20 @@ public void onChunkUnload() {
7575
7676 private boolean invalidRef (EnumFacing facing ) {
7777 WeakReference <TileEntity > ref = getRef (facing );
78- if (ref == INVALID || crossesChunk (facing )) return true ;
78+ if (ref == INVALID || crossesUnloadedChunk (facing )) return true ;
7979 TileEntity te = ref .get ();
8080 return te != null && te .isInvalid ();
8181 }
8282
83- private boolean crossesChunk (EnumFacing facing ) {
84- BlockPos pos = getPos ();
83+ private boolean crossesUnloadedChunk (EnumFacing facing ) {
84+ int cx = getPos (). getX () >> 4 , cz = getPos (). getZ () >> 4 ;
8585 BlockPos offset = getPos ().offset (facing );
86- return pos .getX () >> 4 != offset .getX () >> 4 ||
87- pos .getZ () >> 4 != offset .getZ () >> 4 ;
86+ int ncx = offset .getX () >> 4 , ncz = offset .getZ () >> 4 ;
87+
88+ if (cx != ncx || cz != ncz ) {
89+ return getWorld ().getChunkProvider ().getLoadedChunk (ncx , ncz ) == null ;
90+ }
91+ return false ;
8892 }
8993
9094 @ NotNull
You can’t perform that action at this time.
0 commit comments