aboutsummaryrefslogtreecommitdiffhomepage
path: root/Spigot-Server-Patches/0141-Don-t-load-Chunks-from-Hoppers-and-other-things.patch
blob: bec415521b81cd1a268f29d21e177a4142e068d4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
From 12c6e1557233d240f7f5ef44e6b5dcd93c19c097 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Thu, 3 Nov 2016 20:28:12 -0400
Subject: [PATCH] Don't load Chunks from Hoppers and other things

Hoppers call this to I guess "get the primary side" of a double sided chest.

If the double sided chest crosses chunk lines, it causes the chunk to load.
This will end up causing sync chunk loads, which will unload with Chunk GC,
only to be reloaded again the next tick.

This of course is undesirable, so just return the loaded side as "primary"
and treat it as a single chest if the other sides are unloaded

diff --git a/src/main/java/net/minecraft/server/BlockChest.java b/src/main/java/net/minecraft/server/BlockChest.java
index e94786138e..c61721bc3d 100644
--- a/src/main/java/net/minecraft/server/BlockChest.java
+++ b/src/main/java/net/minecraft/server/BlockChest.java
@@ -193,7 +193,12 @@ public class BlockChest extends BlockTileEntity implements IFluidSource, IFluidC
                 return (ITileInventory) object;
             } else {
                 BlockPosition blockposition1 = blockposition.shift(k(iblockdata));
-                IBlockData iblockdata1 = world.getType(blockposition1);
+                // Paper start - don't load chunks if the other side of the chest is in unloaded chunk
+                final IBlockData iblockdata1 = world.getTypeIfLoaded(blockposition1); // Paper
+                if (iblockdata1 ==  null) {
+                    return null;
+                }
+                // Paper end
 
                 if (iblockdata1.getBlock() == this) {
                     BlockPropertyChestType blockpropertychesttype1 = (BlockPropertyChestType) iblockdata1.get(BlockChest.b);
-- 
2.21.0