use of logisticspipes.asm.te.LPTileEntityObject in project LogisticsPipes by RS485.
the class TEControl method validate.
public static void validate(final TileEntity tile) {
final World world = tile.getWorldObj();
if (world == null) {
return;
}
if (!MainProxy.isServer(world)) {
return;
}
if (tile.getClass().getName().startsWith("net.minecraft.tileentity")) {
return;
}
final DoubleCoordinates pos = new DoubleCoordinates(tile);
if (pos.getXInt() == 0 && pos.getYInt() <= 0 && pos.getZInt() == 0) {
return;
}
if (SimpleServiceLocator.pipeInformationManager.isPipe(tile, false, ConnectionPipeType.UNDEFINED) || SimpleServiceLocator.specialtileconnection.isType(tile)) {
((ILPTEInformation) tile).setObject(new LPTileEntityObject());
((ILPTEInformation) tile).getObject().initialised = LPTickHandler.getWorldInfo(world).getWorldTick();
if (((ILPTEInformation) tile).getObject().initialised < 5) {
return;
}
QueuedTasks.queueTask(() -> {
if (!SimpleServiceLocator.pipeInformationManager.isPipe(tile, true, ConnectionPipeType.UNDEFINED)) {
return null;
}
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
DoubleCoordinates newPos = CoordinateUtils.sum(pos, dir);
if (!newPos.blockExists(world)) {
continue;
}
TileEntity nextTile = newPos.getTileEntity(world);
if (nextTile != null && ((ILPTEInformation) nextTile).getObject() != null) {
if (SimpleServiceLocator.pipeInformationManager.isItemPipe(nextTile)) {
SimpleServiceLocator.pipeInformationManager.getInformationProviderFor(nextTile).refreshTileCacheOnSide(dir.getOpposite());
}
if (SimpleServiceLocator.pipeInformationManager.isItemPipe(tile)) {
SimpleServiceLocator.pipeInformationManager.getInformationProviderFor(tile).refreshTileCacheOnSide(dir);
SimpleServiceLocator.pipeInformationManager.getInformationProviderFor(tile).refreshTileCacheOnSide(dir.getOpposite());
}
for (ITileEntityChangeListener listener : new ArrayList<>(((ILPTEInformation) nextTile).getObject().changeListeners)) {
listener.pipeAdded(pos, dir.getOpposite());
}
}
}
return null;
});
}
}
Aggregations