use of network.rs485.logisticspipes.world.DoubleCoordinates in project LogisticsPipes by RS485.
the class SideConfigDisplay method renderSelection.
private void renderSelection() {
if (selection == null) {
return;
}
GL11.glPushMatrix();
GL11.glShadeModel(GL11.GL_FLAT);
GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F);
GL11.glMatrixMode(GL11.GL_MODELVIEW);
GL11.glPopMatrix();
GL11.glDisable(GL11.GL_ALPHA_TEST);
if (selection.hit.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {
GL11.glEnable(GL11.GL_BLEND);
OpenGlHelper.glBlendFunc(770, 771, 1, 0);
GL11.glColor4f(0.0F, 0.0F, 0.0F, 0.4F);
GL11.glLineWidth(2.0F);
GL11.glDisable(GL11.GL_TEXTURE_2D);
GL11.glDepthMask(false);
float f1 = 0.002F;
Block block = mc.theWorld.getBlock(selection.hit.blockX, selection.hit.blockY, selection.hit.blockZ);
if (block.getMaterial() != Material.air) {
if (block instanceof LogisticsBlockGenericPipe) {
LogisticsBlockGenericPipe.bypassPlayerTrace = cachedLPBlockTrace;
}
block.setBlockBoundsBasedOnState(mc.theWorld, selection.hit.blockX, selection.hit.blockY, selection.hit.blockZ);
double d0 = origin.x - eye.x;
double d1 = origin.y - eye.y;
double d2 = origin.z - eye.z;
RenderGlobal.drawOutlinedBoundingBox(block.getSelectedBoundingBoxFromPool(mc.theWorld, selection.hit.blockX, selection.hit.blockY, selection.hit.blockZ).expand((double) f1, (double) f1, (double) f1).getOffsetBoundingBox(-d0, -d1, -d2), -1);
if (block instanceof LogisticsBlockGenericPipe) {
LogisticsBlockGenericPipe.bypassPlayerTrace = null;
}
}
GL11.glDepthMask(true);
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glDisable(GL11.GL_BLEND);
}
GL11.glEnable(GL11.GL_ALPHA_TEST);
BoundingBox bb = new BoundingBox(new DoubleCoordinates(selection.config));
IIcon icon = Textures.LOGISTICS_SIDE_SELECTION;
List<Vertex> corners = bb.getCornersWithUvForFace(selection.face, icon.getMinU(), icon.getMaxU(), icon.getMinV(), icon.getMaxV());
GL11.glDisable(GL11.GL_DEPTH_TEST);
GL11.glDisable(GL11.GL_LIGHTING);
RenderUtil.bindBlockTexture();
GL11.glColor3f(1, 1, 1);
Tessellator.instance.startDrawingQuads();
Tessellator.instance.setColorOpaque_F(1, 1, 1);
Vector3d trans = new Vector3d((-origin.x) + eye.x, (-origin.y) + eye.y, (-origin.z) + eye.z);
Tessellator.instance.setTranslation(trans.x, trans.y, trans.z);
RenderUtil.addVerticesToTesselator(corners);
Tessellator.instance.draw();
Tessellator.instance.setTranslation(0, 0, 0);
}
use of network.rs485.logisticspipes.world.DoubleCoordinates in project LogisticsPipes by RS485.
the class PipeTransportLogistics method resolveUnroutedDestination.
public ForgeDirection resolveUnroutedDestination(LPTravelingItemServer data) {
List<ForgeDirection> dirs = new ArrayList<>(Arrays.asList(ForgeDirection.VALID_DIRECTIONS));
dirs.remove(data.input.getOpposite());
Iterator<ForgeDirection> iter = dirs.iterator();
while (iter.hasNext()) {
ForgeDirection dir = iter.next();
DoubleCoordinates pos = CoordinateUtils.add(getPipe().getLPPosition(), dir);
TileEntity tile = pos.getTileEntity(getWorld());
if (!SimpleServiceLocator.pipeInformationManager.isItemPipe(tile)) {
iter.remove();
} else if (!canPipeConnect(tile, dir)) {
iter.remove();
} else if (tile instanceof LogisticsTileGenericPipe && !((LogisticsTileGenericPipe) tile).canConnect(container, dir.getOpposite(), false)) {
iter.remove();
}
}
if (dirs.isEmpty()) {
return ForgeDirection.UNKNOWN;
}
int num = new Random().nextInt(dirs.size());
return dirs.get(num);
}
use of network.rs485.logisticspipes.world.DoubleCoordinates in project LogisticsPipes by RS485.
the class TEControl method handleBlockUpdate.
public static void handleBlockUpdate(final World world, final LPWorldInfo info, int x, int y, int z) {
if (info.getWorldTick() < 5) {
return;
}
final DoubleCoordinates pos = new DoubleCoordinates(x, y, z);
if (info.getUpdateQueued().contains(pos)) {
return;
}
if (!pos.blockExists(world)) {
return;
}
final TileEntity tile = pos.getTileEntity(world);
if (SimpleServiceLocator.enderIOProxy.isBundledPipe(tile)) {
QueuedTasks.queueTask(() -> {
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
DoubleCoordinates newPos = CoordinateUtils.sum(pos, dir);
if (!newPos.blockExists(world)) {
continue;
}
TileEntity nextTile = newPos.getTileEntity(world);
if (nextTile instanceof LogisticsTileGenericPipe) {
((LogisticsTileGenericPipe) nextTile).scheduleNeighborChange();
}
}
return null;
});
}
if (tile == null || ((ILPTEInformation) tile).getObject() == null) {
return;
}
if (SimpleServiceLocator.pipeInformationManager.isItemPipe(tile) || SimpleServiceLocator.specialtileconnection.isType(tile)) {
info.getUpdateQueued().add(pos);
QueuedTasks.queueTask(() -> {
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) {
for (ITileEntityChangeListener listener : new ArrayList<>(((ILPTEInformation) nextTile).getObject().changeListeners)) {
listener.pipeModified(pos);
}
}
}
for (ITileEntityChangeListener listener : new ArrayList<>(((ILPTEInformation) tile).getObject().changeListeners)) {
listener.pipeModified(pos);
}
info.getUpdateQueued().remove(pos);
return null;
});
}
}
use of network.rs485.logisticspipes.world.DoubleCoordinates 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;
});
}
}
use of network.rs485.logisticspipes.world.DoubleCoordinates in project LogisticsPipes by RS485.
the class TEControl method invalidate.
public static void invalidate(final TileEntity tile) {
final World world = tile.getWorldObj();
if (world == null) {
return;
}
if (!MainProxy.isServer(world)) {
return;
}
if (tile instanceof LogisticsTileGenericPipe && ((LogisticsTileGenericPipe) tile).isRoutingPipe()) {
return;
}
if (((ILPTEInformation) tile).getObject() != null) {
QueuedTasks.queueTask(() -> {
DoubleCoordinates pos = new DoubleCoordinates(tile);
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());
}
}
}
for (ITileEntityChangeListener listener : new ArrayList<>(((ILPTEInformation) tile).getObject().changeListeners)) {
listener.pipeRemoved(pos);
}
return null;
});
}
}
Aggregations