use of network.rs485.logisticspipes.world.DoubleCoordinates in project LogisticsPipes by RS485.
the class LogisticsRenderPipe method renderSolids.
private void renderSolids(CoreUnroutedPipe pipe, double x, double y, double z, float partialTickTime) {
GL11.glPushMatrix();
float light = pipe.container.getWorldObj().getLightBrightness(pipe.container.xCoord, pipe.container.yCoord, pipe.container.zCoord);
int count = 0;
for (LPTravelingItem item : pipe.transport.items) {
CoreUnroutedPipe lPipe = pipe;
double lX = x;
double lY = y;
double lZ = z;
float lItemYaw = item.getYaw();
if (count >= LogisticsRenderPipe.MAX_ITEMS_TO_RENDER) {
break;
}
if (item.getItemIdentifierStack() == null) {
continue;
}
if (item.getContainer().xCoord != lPipe.container.xCoord || item.getContainer().yCoord != lPipe.container.yCoord || item.getContainer().zCoord != lPipe.container.zCoord) {
continue;
}
if (item.getPosition() > lPipe.transport.getPipeLength() || item.getPosition() < 0) {
continue;
}
float fPos = item.getPosition() + item.getSpeed() * partialTickTime;
if (fPos > lPipe.transport.getPipeLength() && item.output != ForgeDirection.UNKNOWN) {
CoreUnroutedPipe nPipe = lPipe.transport.getNextPipe(item.output);
if (nPipe != null) {
fPos -= lPipe.transport.getPipeLength();
lX -= lPipe.getX() - nPipe.getX();
lY -= lPipe.getY() - nPipe.getY();
lZ -= lPipe.getZ() - nPipe.getZ();
lItemYaw += lPipe.transport.getYawDiff(item);
lPipe = nPipe;
item = item.renderCopy();
item.input = item.output;
item.output = ForgeDirection.UNKNOWN;
} else {
continue;
}
}
DoubleCoordinates pos = lPipe.getItemRenderPos(fPos, item);
if (pos == null) {
continue;
}
double boxScale = lPipe.getBoxRenderScale(fPos, item);
double itemYaw = (lPipe.getItemRenderYaw(fPos, item) - lPipe.getItemRenderYaw(0, item) + lItemYaw) % 360;
double itemPitch = lPipe.getItemRenderPitch(fPos, item);
double itemYawForPitch = lPipe.getItemRenderYaw(fPos, item);
ItemStack itemstack = item.getItemIdentifierStack().makeNormalStack();
doRenderItem(itemstack, pipe.container.getWorldObj(), lX + pos.getXCoord(), lY + pos.getYCoord(), lZ + pos.getZCoord(), light, 0.75F, boxScale, itemYaw, itemPitch, itemYawForPitch, partialTickTime);
count++;
}
count = 0;
double dist = 0.135;
DoubleCoordinates pos = new DoubleCoordinates(0.5, 0.5, 0.5);
CoordinateUtils.add(pos, ForgeDirection.SOUTH, dist);
CoordinateUtils.add(pos, ForgeDirection.EAST, dist);
CoordinateUtils.add(pos, ForgeDirection.UP, dist);
for (Pair<ItemIdentifierStack, Pair<Integer, Integer>> item : pipe.transport._itemBuffer) {
if (item == null || item.getValue1() == null) {
continue;
}
ItemStack itemstack = item.getValue1().makeNormalStack();
doRenderItem(itemstack, pipe.container.getWorldObj(), x + pos.getXCoord(), y + pos.getYCoord(), z + pos.getZCoord(), light, 0.25F, 0, 0, 0, 0, partialTickTime);
count++;
if (count >= 27) {
break;
} else if (count % 9 == 0) {
CoordinateUtils.add(pos, ForgeDirection.SOUTH, dist * 2.0);
CoordinateUtils.add(pos, ForgeDirection.EAST, dist * 2.0);
CoordinateUtils.add(pos, ForgeDirection.DOWN, dist);
} else if (count % 3 == 0) {
CoordinateUtils.add(pos, ForgeDirection.SOUTH, dist * 2.0);
CoordinateUtils.add(pos, ForgeDirection.WEST, dist);
} else {
CoordinateUtils.add(pos, ForgeDirection.NORTH, dist);
}
}
GL11.glPopMatrix();
}
use of network.rs485.logisticspipes.world.DoubleCoordinates in project LogisticsPipes by RS485.
the class TDDuctInformationProvider method getDistanceTo.
@Override
public double getDistanceTo(int destinationint, ForgeDirection ignore, ItemIdentifier ident, boolean isActive, double traveled, double max, List<DoubleCoordinates> visited) {
if (traveled >= max) {
return Integer.MAX_VALUE;
}
IRouter destination = SimpleServiceLocator.routerManager.getRouter(destinationint);
if (destination == null) {
return Integer.MAX_VALUE;
}
Iterable<Route> paramIterable = duct.getCache(true).outputRoutes;
double closesedConnection = Integer.MAX_VALUE;
for (Route localRoute1 : paramIterable) {
if (localRoute1.endPoint instanceof LPItemDuct) {
LPItemDuct lpDuct = (LPItemDuct) localRoute1.endPoint;
if (traveled + localRoute1.pathWeight > max) {
continue;
}
DoubleCoordinates pos = new DoubleCoordinates((TileEntity) lpDuct.pipe);
if (visited.contains(pos)) {
continue;
}
visited.add(pos);
double distance = lpDuct.pipe.getDistanceTo(destinationint, ForgeDirection.getOrientation(localRoute1.pathDirections.get(localRoute1.pathDirections.size() - 1)).getOpposite(), ident, isActive, traveled + localRoute1.pathWeight, Math.min(max, closesedConnection), visited);
visited.remove(pos);
if (distance != Integer.MAX_VALUE && distance + localRoute1.pathWeight < closesedConnection) {
closesedConnection = distance + localRoute1.pathWeight;
}
}
}
return closesedConnection;
}
use of network.rs485.logisticspipes.world.DoubleCoordinates in project LogisticsPipes by RS485.
the class RenderTickHandler method renderWorldLast.
//private static final ResourceLocation TEXTURE = new ResourceLocation("logisticspipes", "textures/blocks/pipes/White.png");
@SubscribeEvent
public void renderWorldLast(RenderWorldLastEvent worldEvent) {
if (LogisticsRenderPipe.config.isUseNewRenderer()) {
if (displayPipeGhost()) {
Minecraft mc = Minecraft.getMinecraft();
EntityPlayer player = mc.thePlayer;
MovingObjectPosition box = mc.objectMouseOver;
if (box != null && box.typeOfHit == MovingObjectType.BLOCK) {
ItemStack stack = FMLClientHandler.instance().getClient().thePlayer.inventory.mainInventory[FMLClientHandler.instance().getClient().thePlayer.inventory.currentItem];
CoreUnroutedPipe pipe = ((ItemLogisticsPipe) stack.getItem()).getDummyPipe();
int i = box.blockX;
int j = box.blockY;
int k = box.blockZ;
World world = player.getEntityWorld();
int side = box.sideHit;
Block worldBlock = world.getBlock(i, j, k);
if (worldBlock == Blocks.snow) {
side = 1;
} else if (worldBlock != Blocks.vine && worldBlock != Blocks.tallgrass && worldBlock != Blocks.deadbush && (worldBlock == null || !worldBlock.isReplaceable(world, i, j, k))) {
if (side == 0) {
j--;
}
if (side == 1) {
j++;
}
if (side == 2) {
k--;
}
if (side == 3) {
k++;
}
if (side == 4) {
i--;
}
if (side == 5) {
i++;
}
}
double xCoord = i;
double yCoord = j;
double zCoord = k;
boolean isFreeSpace = true;
ITubeOrientation orientation = null;
if (pipe instanceof CoreMultiBlockPipe) {
CoreMultiBlockPipe multipipe = (CoreMultiBlockPipe) pipe;
DoubleCoordinates placeAt = new DoubleCoordinates(xCoord, yCoord, zCoord);
LPPositionSet<DoubleCoordinatesType<CoreMultiBlockPipe.SubBlockTypeForShare>> globalPos = new LPPositionSet<>(DoubleCoordinatesType.class);
globalPos.add(new DoubleCoordinatesType<>(placeAt, CoreMultiBlockPipe.SubBlockTypeForShare.NON_SHARE));
LPPositionSet<DoubleCoordinatesType<CoreMultiBlockPipe.SubBlockTypeForShare>> positions = multipipe.getSubBlocks();
orientation = multipipe.getTubeOrientation(player, (int) xCoord, (int) zCoord);
if (orientation != null) {
orientation.rotatePositions(positions);
positions.stream().map(pos -> pos.add(placeAt)).forEach(globalPos::add);
globalPos.addToAll(orientation.getOffset());
for (DoubleCoordinatesType<CoreMultiBlockPipe.SubBlockTypeForShare> pos : globalPos) {
if (!player.getEntityWorld().canPlaceEntityOnSide(LogisticsPipes.LogisticsPipeBlock, pos.getXInt(), pos.getYInt(), pos.getZInt(), false, side, player, stack)) {
TileEntity tile = player.getEntityWorld().getTileEntity(pos.getXInt(), pos.getYInt(), pos.getZInt());
boolean canPlace = false;
if (tile instanceof LogisticsTileGenericSubMultiBlock) {
if (CoreMultiBlockPipe.canShare(((LogisticsTileGenericSubMultiBlock) tile).getSubTypes(), pos.getType())) {
canPlace = true;
}
}
if (!canPlace) {
isFreeSpace = false;
break;
}
}
}
} else {
return;
}
} else {
if (!player.getEntityWorld().canPlaceEntityOnSide(LogisticsPipes.LogisticsPipeBlock, i, j, k, false, side, player, stack)) {
isFreeSpace = false;
}
}
if (isFreeSpace) {
GL11.glPushMatrix();
double x;
double y;
double z;
if (orientation != null) {
x = xCoord + orientation.getOffset().getXInt() - player.prevPosX - ((player.posX - player.prevPosX) * worldEvent.partialTicks);
y = yCoord + orientation.getOffset().getYInt() - player.prevPosY - ((player.posY - player.prevPosY) * worldEvent.partialTicks);
z = zCoord + orientation.getOffset().getZInt() - player.prevPosZ - ((player.posZ - player.prevPosZ) * worldEvent.partialTicks);
} else {
x = xCoord - player.prevPosX - ((player.posX - player.prevPosX) * worldEvent.partialTicks);
y = yCoord - player.prevPosY - ((player.posY - player.prevPosY) * worldEvent.partialTicks);
z = zCoord - player.prevPosZ - ((player.posZ - player.prevPosZ) * worldEvent.partialTicks);
}
GL11.glTranslated(x + 0.001, y + 0.001, z + 0.001);
GL11.glEnable(GL11.GL_BLEND);
//GL11.glDepthMask(false);
GL11.glDisable(GL11.GL_TEXTURE_2D);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
mc.renderEngine.bindTexture(new ResourceLocation("logisticspipes", "textures/blocks/pipes/White.png"));
Tessellator tess = Tessellator.instance;
CCRenderState.reset();
CCRenderState.useNormals = true;
CCRenderState.alphaOverride = 0xff;
GL11.glEnable(GL11.GL_TEXTURE_2D);
CCRenderState.alphaOverride = 0x50;
CCRenderState.useNormals = true;
CCRenderState.hasBrightness = false;
CCRenderState.startDrawing();
pipe.getHighlightRenderer().renderHighlight(orientation);
tess.draw();
CCRenderState.alphaOverride = 0xff;
GL11.glDisable(GL11.GL_BLEND);
GL11.glDepthMask(true);
GL11.glPopMatrix();
}
}
}
}
}
use of network.rs485.logisticspipes.world.DoubleCoordinates in project LogisticsPipes by RS485.
the class SideConfigDisplay method doTileEntityRenderPass.
private void doTileEntityRenderPass(List<DoubleCoordinates> blocks, int pass) {
RenderPassHelper.setEntityRenderPass(pass);
for (DoubleCoordinates bc : blocks) {
TileEntity tile = world.getTileEntity(bc.getXInt(), bc.getYInt(), bc.getZInt());
if (tile != null) {
Vector3d at = new Vector3d(eye.x, eye.y, eye.z);
at.x += bc.getXDouble() - origin.x;
at.y += bc.getYDouble() - origin.y;
at.z += bc.getZDouble() - origin.z;
GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
TileEntityRendererDispatcher.instance.renderTileEntityAt(tile, at.x, at.y, at.z, 0);
GL11.glPopAttrib();
}
}
RenderPassHelper.clearEntityRenderPass();
}
use of network.rs485.logisticspipes.world.DoubleCoordinates in project LogisticsPipes by RS485.
the class SideConfigDisplay method updateSelection.
private void updateSelection(Vector3d start, Vector3d end) {
start.add(origin);
end.add(origin);
List<MovingObjectPosition> hits = new ArrayList<>();
LogisticsBlockGenericPipe.ignoreSideRayTrace = true;
for (DoubleCoordinates bc : configurables) {
Block block = world.getBlock(bc.getXInt(), bc.getYInt(), bc.getZInt());
if (block != null) {
if (block instanceof LogisticsBlockGenericPipe) {
cachedLPBlockTrace = LogisticsPipes.LogisticsPipeBlock.doRayTrace(world, bc.getXInt(), bc.getYInt(), bc.getZInt(), Vec3.createVectorHelper(start.x, start.y, start.z), Vec3.createVectorHelper(end.x, end.y, end.z));
} else {
cachedLPBlockTrace = null;
}
MovingObjectPosition hit = block.collisionRayTrace(world, bc.getXInt(), bc.getYInt(), bc.getZInt(), Vec3.createVectorHelper(start.x, start.y, start.z), Vec3.createVectorHelper(end.x, end.y, end.z));
if (hit != null) {
hits.add(hit);
}
}
}
LogisticsBlockGenericPipe.ignoreSideRayTrace = false;
selection = null;
MovingObjectPosition hit = getClosestHit(Vec3.createVectorHelper(start.x, start.y, start.z), hits);
if (hit != null) {
TileEntity te = world.getTileEntity(hit.blockX, hit.blockY, hit.blockZ);
if (te != null) {
ForgeDirection face = ForgeDirection.getOrientation(hit.sideHit);
selection = new SelectedFace(te, face, hit);
}
}
}
Aggregations