use of buildcraft.builders.snapshot.ITileForSnapshotBuilder in project BuildCraft by BuildCraft.
the class RenderSnapshotBuilder method render.
public static <T extends ITileForSnapshotBuilder> void render(SnapshotBuilder<T> snapshotBuilder, World world, BlockPos tilePos, double x, double y, double z, float partialTicks, BufferBuilder bb) {
for (SnapshotBuilder<T>.PlaceTask placeTask : snapshotBuilder.clientPlaceTasks) {
Vec3d prevPos = snapshotBuilder.prevClientPlaceTasks.stream().filter(renderTaskLocal -> renderTaskLocal.pos.equals(placeTask.pos)).map(snapshotBuilder::getPlaceTaskItemPos).findFirst().orElse(snapshotBuilder.getPlaceTaskItemPos(snapshotBuilder.new PlaceTask(tilePos, Collections.emptyList(), 0L)));
Vec3d pos = prevPos.add(snapshotBuilder.getPlaceTaskItemPos(placeTask).subtract(prevPos).scale(partialTicks));
for (ItemStack item : placeTask.items) {
ItemRenderUtil.renderItemStack(x - tilePos.getX() + pos.x, y - tilePos.getY() + pos.y, z - tilePos.getZ() + pos.z, item, world.getCombinedLight(new BlockPos(pos), 0), EnumFacing.SOUTH, bb);
}
ItemRenderUtil.endItemBatch();
}
Vec3d robotPos = snapshotBuilder.robotPos;
if (robotPos != null) {
if (snapshotBuilder.prevRobotPos != null) {
robotPos = snapshotBuilder.prevRobotPos.add(robotPos.subtract(snapshotBuilder.prevRobotPos).scale(partialTicks));
}
bb.setTranslation(x - tilePos.getX(), y - tilePos.getY(), z - tilePos.getZ());
int i = 0;
for (EnumFacing face : EnumFacing.VALUES) {
ModelUtil.createFace(face, new Point3f((float) robotPos.x, (float) robotPos.y, (float) robotPos.z), new Point3f(4 / 16F, 4 / 16F, 4 / 16F), new ModelUtil.UvFaceData(BCBuildersSprites.ROBOT.getInterpU((i * 8) / 64D), BCBuildersSprites.ROBOT.getInterpV(0 / 64D), BCBuildersSprites.ROBOT.getInterpU(((i + 1) * 8) / 64D), BCBuildersSprites.ROBOT.getInterpV(8 / 64D))).lighti(world.getCombinedLight(new BlockPos(robotPos), 0)).render(bb);
i++;
}
for (SnapshotBuilder.BreakTask breakTask : snapshotBuilder.clientBreakTasks) {
LaserRenderer_BC8.renderLaserDynamic(new LaserData_BC8(BuildCraftLaserManager.POWERS[(int) Math.round(MathUtil.clamp(breakTask.power * 1D / breakTask.getTarget(), 0D, 1D) * (BuildCraftLaserManager.POWERS.length - 1))], robotPos.subtract(new Vec3d(0, 0.27, 0)), new Vec3d(breakTask.pos).add(VecUtil.VEC_HALF), 1 / 16D), bb);
}
}
bb.setTranslation(0, 0, 0);
}
Aggregations