Skip to content

Commit a39fa74

Browse files
Gabe van der Weijdethraaawn
authored andcommitted
-- Added additional null-checks to avoid client-side NPE's in some edge cases involving (at least) Cyclic machines/blocks being placed right next to a Redstone Tunnel.
1 parent 8fe41ae commit a39fa74

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

src/main/java/org/dave/compactmachines3/tile/TileEntityRedstoneTunnel.java

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,28 @@ public class TileEntityRedstoneTunnel extends BaseTileEntityTunnel {
1717

1818
public int getRedstonePowerInput(EnumFacing facing) {
1919
int coords = StructureTools.getCoordsForPos(this.getPos());
20-
DimensionBlockPos dimpos = WorldSavedDataMachines.INSTANCE.machinePositions.get(coords);
21-
if(dimpos == null) {
20+
21+
WorldSavedDataMachines wsd = WorldSavedDataMachines.INSTANCE;
22+
if (wsd == null) {
23+
return 0;
24+
}
25+
26+
HashMap<Integer, DimensionBlockPos> machinePositions = wsd.machinePositions;
27+
if (machinePositions == null) {
28+
return 0;
29+
}
30+
31+
DimensionBlockPos dimpos = machinePositions.get(coords);
32+
if (dimpos == null) {
33+
return 0;
34+
}
35+
36+
HashMap<Integer, HashMap<EnumFacing, RedstoneTunnelData>> redstoneTunnels = wsd.redstoneTunnels;
37+
if (redstoneTunnels == null) {
2238
return 0;
2339
}
2440

25-
HashMap<EnumFacing, RedstoneTunnelData> tunnelMapping = WorldSavedDataMachines.INSTANCE.redstoneTunnels.get(coords);
41+
HashMap<EnumFacing, RedstoneTunnelData> tunnelMapping = redstoneTunnels.get(coords);
2642
if(tunnelMapping == null) {
2743
return 0;
2844
}

0 commit comments

Comments
 (0)