Compare commits

...
1 Commits
Author SHA1 Message Date
Martin RobertzandPilzinsel64 985b0f18a5 Prevent ghostloading (#116)
* prevent ghostloading by MEConduit

* prevent more ghostloading by MEConduit

* spottlessApply

* prevent ghostloading by ConduitUtil

---------

Co-authored-by: Pilzinsel64 <[email protected]>
2023-03-29 22:15:12 +02:00
2 changed files with 22 additions and 4 deletions

No files matched your search

@@ -248,7 +248,7 @@ public class ConduitUtil {
public static <T extends IConduit> Collection<T> getConnectedConduits(World world, int x, int y, int z,
Class<T> type) {
TileEntity te = world.getTileEntity(x, y, z);
TileEntity te = world.blockExists(x, y, z) ? world.getTileEntity(x, y, z) : null;
if (!(te instanceof IConduitBundle)) {
return Collections.emptyList();
}
@@ -155,7 +155,16 @@ public class MEConduit extends AbstractConduit implements IMEConduit {
public boolean canConnectToExternal(ForgeDirection dir, boolean ignoreDisabled) {
World world = getBundle().getWorld();
BlockCoord pos = getLocation();
TileEntity te = world.getTileEntity(pos.x + dir.offsetX, pos.y + dir.offsetY, pos.z + dir.offsetZ);
final int exactPosX = pos.x + dir.offsetX;
final int exactPosY = pos.y + dir.offsetY;
final int exactPosZ = pos.z + dir.offsetZ;
if (!world.blockExists(exactPosX, exactPosY, exactPosZ)) {
return false;
}
TileEntity te = world.getTileEntity(exactPosX, exactPosY, exactPosZ);
if (te instanceof TileConduitBundle) {
return false;
@@ -305,7 +314,11 @@ public class MEConduit extends AbstractConduit implements IMEConduit {
private void onNodeChanged(BlockCoord location) {
World world = getBundle().getWorld();
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
TileEntity te = location.getLocation(dir).getTileEntity(world);
BlockCoord dirLocation = location.getLocation(dir);
TileEntity te = null;
if (world.blockExists(dirLocation.x, dirLocation.y, dirLocation.z)) {
te = location.getLocation(dir).getTileEntity(world);
}
if (te != null && te instanceof IGridHost && !(te instanceof IConduitBundle)) {
IGridNode node = ((IGridHost) te).getGridNode(ForgeDirection.UNKNOWN);
if (node == null) {
@@ -321,7 +334,12 @@ public class MEConduit extends AbstractConduit implements IMEConduit {
@Override
public void onAddedToBundle() {
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
TileEntity te = getLocation().getLocation(dir).getTileEntity(getBundle().getWorld());
World world = getBundle().getWorld();
BlockCoord dirLocation = getLocation().getLocation(dir);
TileEntity te = null;
if (world.blockExists(dirLocation.x, dirLocation.y, dirLocation.z)) {
te = dirLocation.getTileEntity(world);
}
if (te instanceof TileConduitBundle) {
IMEConduit cond = ((TileConduitBundle) te).getConduit(IMEConduit.class);
if (cond != null) {