Search in sources :

Example 6 with LaserData_BC8

use of buildcraft.lib.client.render.laser.LaserData_BC8 in project BuildCraft by BuildCraft.

the class RenderMarkerVolume method renderLaser.

private static void renderLaser(Vec3d min, Vec3d max, Axis axis) {
    EnumFacing faceForMin = VecUtil.getFacing(axis, true);
    EnumFacing faceForMax = VecUtil.getFacing(axis, false);
    Vec3d one = offset(min, faceForMin);
    Vec3d two = offset(max, faceForMax);
    LaserData_BC8 data = new LaserData_BC8(LASER_TYPE, one, two, SCALE);
    LaserRenderer_BC8.renderLaserStatic(data);
}
Also used : EnumFacing(net.minecraft.util.EnumFacing) LaserData_BC8(buildcraft.lib.client.render.laser.LaserData_BC8) Vec3d(net.minecraft.util.math.Vec3d)

Example 7 with LaserData_BC8

use of buildcraft.lib.client.render.laser.LaserData_BC8 in project BuildCraft by BuildCraft.

the class RenderTube method renderTileEntityFast.

@Override
public void renderTileEntityFast(@Nonnull TileMiner tile, double x, double y, double z, float partialTicks, int destroyStage, float partial, @Nonnull BufferBuilder buffer) {
    if (tile.isComplete()) {
        return;
    }
    double tubeY = tile.getPos().getY() - tile.getLength(partialTicks);
    BlockPos from = tile.getPos();
    buffer.setTranslation(x - from.getX(), y - from.getY(), z - from.getZ());
    Vec3d start = new Vec3d(from.getX() + 0.5, from.getY(), from.getZ() + 0.5);
    Vec3d end = new Vec3d(from.getX() + 0.5, tubeY, from.getZ() + 0.5);
    LaserData_BC8 data = new LaserData_BC8(laserType, start, end, 1 / 16.0);
    LaserRenderer_BC8.renderLaserDynamic(data, buffer);
    buffer.setTranslation(0, 0, 0);
}
Also used : BlockPos(net.minecraft.util.math.BlockPos) LaserData_BC8(buildcraft.lib.client.render.laser.LaserData_BC8) Vec3d(net.minecraft.util.math.Vec3d)

Example 8 with LaserData_BC8

use of buildcraft.lib.client.render.laser.LaserData_BC8 in project BuildCraft by BuildCraft.

the class RenderQuarry method render.

@Override
public void render(TileQuarry tile, double x, double y, double z, float partialTicks, int destroyStage, float alpha) {
    Profiler profiler = Minecraft.getMinecraft().mcProfiler;
    profiler.startSection("bc");
    profiler.startSection("quarry");
    profiler.startSection("setup");
    SpriteUtil.bindBlockTextureMap();
    RenderHelper.disableStandardItemLighting();
    GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GlStateManager.enableBlend();
    GlStateManager.enableCull();
    if (Minecraft.isAmbientOcclusionEnabled()) {
        GlStateManager.shadeModel(GL11.GL_SMOOTH);
    } else {
        GlStateManager.shadeModel(GL11.GL_FLAT);
    }
    GlStateManager.pushMatrix();
    GlStateManager.translate(x - tile.getPos().getX(), y - tile.getPos().getY(), z - tile.getPos().getZ());
    final BlockPos min = tile.frameBox.min();
    final BlockPos max = tile.frameBox.max();
    profiler.endSection();
    if (tile.frameBox.isInitialized()) {
        double yOffset = 1 + 4 / 16D;
        profiler.startSection("laser");
        if (tile.currentTask != null && tile.currentTask instanceof TileQuarry.TaskBreakBlock) {
            TileQuarry.TaskBreakBlock taskBreakBlock = (TileQuarry.TaskBreakBlock) tile.currentTask;
            BlockPos pos = taskBreakBlock.breakPos;
            if (tile.drillPos == null) {
                if (taskBreakBlock.clientPower != 0) {
                    // Don't render a laser before we have any power
                    Vec3d from = VecUtil.convertCenter(tile.getPos());
                    Vec3d to = VecUtil.convertCenter(pos);
                    LaserData_BC8 laser = new LaserData_BC8(LASER, from, to, 1 / 16.0);
                    LaserRenderer_BC8.renderLaserStatic(laser);
                }
            } else {
                long power = (long) (taskBreakBlock.prevClientPower + (taskBreakBlock.clientPower - taskBreakBlock.prevClientPower) * (double) partialTicks);
                AxisAlignedBB aabb = tile.getWorld().getBlockState(pos).getBoundingBox(tile.getWorld(), pos);
                double value = (double) power / taskBreakBlock.getTarget();
                if (value < 0.9) {
                    value = 1 - value / 0.9;
                } else {
                    value = (value - 0.9) / 0.1;
                }
                double scaleMin = 1 - (1 - aabb.maxY) - (aabb.maxY - aabb.minY) / 2;
                double scaleMax = 1 + 4 / 16D;
                yOffset = scaleMin + value * (scaleMax - scaleMin);
            }
        }
        profiler.endStartSection("frame");
        if (tile.clientDrillPos != null && tile.prevClientDrillPos != null) {
            Vec3d interpolatedPos = tile.prevClientDrillPos.add(tile.clientDrillPos.subtract(tile.prevClientDrillPos).scale(partialTicks));
            LaserRenderer_BC8.renderLaserStatic(new // 
            LaserData_BC8(// 
            FRAME, // 
            new Vec3d(interpolatedPos.x + 0.5, max.getY() + 0.5, interpolatedPos.z), // 
            new Vec3d(interpolatedPos.x + 0.5, max.getY() + 0.5, max.getZ() + 12 / 16D), 1 / 16D, true, true, 0));
            LaserRenderer_BC8.renderLaserStatic(new // 
            LaserData_BC8(// 
            FRAME, // 
            new Vec3d(interpolatedPos.x + 0.5, max.getY() + 0.5, interpolatedPos.z), // 
            new Vec3d(interpolatedPos.x + 0.5, max.getY() + 0.5, min.getZ() + 4 / 16D), 1 / 16D, true, true, 0));
            LaserRenderer_BC8.renderLaserStatic(new // 
            LaserData_BC8(// 
            FRAME, // 
            new Vec3d(interpolatedPos.x, max.getY() + 0.5, interpolatedPos.z + 0.5), // 
            new Vec3d(max.getX() + 12 / 16D, max.getY() + 0.5, interpolatedPos.z + 0.5), 1 / 16D, true, true, 0));
            LaserRenderer_BC8.renderLaserStatic(new // 
            LaserData_BC8(// 
            FRAME, // 
            new Vec3d(interpolatedPos.x, max.getY() + 0.5, interpolatedPos.z + 0.5), // 
            new Vec3d(min.getX() + 4 / 16D, max.getY() + 0.5, interpolatedPos.z + 0.5), 1 / 16D, true, true, 0));
            LaserRenderer_BC8.renderLaserStatic(new // 
            LaserData_BC8(// 
            FRAME_BOTTOM, // 
            new Vec3d(interpolatedPos.x + 0.5, interpolatedPos.y + 1 + 4 / 16D, interpolatedPos.z + 0.5), // 
            new Vec3d(interpolatedPos.x + 0.5, max.getY() + 0.5, interpolatedPos.z + 0.5), 1 / 16D, true, true, 0));
            LaserRenderer_BC8.renderLaserStatic(new // 
            LaserData_BC8(// 
            DRILL, // 
            new Vec3d(interpolatedPos.x + 0.5, interpolatedPos.y + 1 + yOffset, interpolatedPos.z + 0.5), // 
            new Vec3d(interpolatedPos.x + 0.5, interpolatedPos.y + yOffset, interpolatedPos.z + 0.5), 1 / 16D, true, true, 0));
        } else {
            LaserBoxRenderer.renderLaserBoxStatic(tile.frameBox, BuildCraftLaserManager.STRIPES_WRITE, true);
        }
        profiler.endSection();
    }
    GlStateManager.popMatrix();
    profiler.startSection("items");
    if (tile.frameBox.isInitialized() && false) {
        TileQuarry.TaskAddFrame currentTask = (TileQuarry.TaskAddFrame) tile.currentTask;
        int index = tile.framePoses.indexOf(currentTask.framePos);
        if (index > 1) {
            double progress = (double) currentTask.power / currentTask.getTarget() * (index - 1) / tile.framePoses.size();
            double progress1 = // 
            (progress >= 0 && progress <= 0.25) ? // 
            progress * 4 : // 
            (progress >= 0.25 && progress <= 0.5) ? // 
            1 : // 
            (progress >= 0.5 && progress <= 0.75) ? // 
            1 - (progress - 0.5) * 4 : (progress >= 0.75 && progress <= 1) ? 0 : -1;
            double progress2 = (progress >= 0 && progress <= 0.25) ? 1 : (progress >= 0.25 && progress <= 0.5) ? 1 - (progress - 0.25) * 4 : (progress >= 0.5 && progress <= 0.75) ? 0 : (progress >= 0.75 && progress <= 1) ? (progress - 0.75) * 4 : -1;
            double xProgress = -1;
            double zProgress = -1;
            EnumFacing side = tile.getWorld().getBlockState(tile.getPos()).getValue(BuildCraftProperties.BLOCK_FACING).getOpposite();
            BlockPos firstPos = tile.getPos().offset(side);
            switch(side) {
                case SOUTH:
                    if (firstPos.getX() == min.getX()) {
                        xProgress = 1 - progress2;
                        zProgress = progress1;
                    } else {
                        xProgress = progress2;
                        zProgress = progress1;
                    }
                    break;
                case WEST:
                    if (firstPos.getZ() == min.getZ()) {
                        xProgress = 1 - progress1;
                        zProgress = 1 - progress2;
                    } else {
                        xProgress = 1 - progress1;
                        zProgress = progress2;
                    }
                    break;
                case NORTH:
                    if (firstPos.getX() == min.getX()) {
                        xProgress = 1 - progress2;
                        zProgress = 1 - progress1;
                    } else {
                        xProgress = progress2;
                        zProgress = 1 - progress1;
                    }
                    break;
                case EAST:
                    if (firstPos.getZ() == min.getZ()) {
                        xProgress = progress1;
                        zProgress = 1 - progress2;
                    } else {
                        xProgress = progress1;
                        zProgress = progress2;
                    }
                    break;
            }
            double xResult = min.getX() + (max.getX() - min.getX()) * xProgress;
            double zResult = min.getZ() + (max.getZ() - min.getZ()) * zProgress;
            ItemStack stack = new ItemStack(BCBuildersBlocks.frame);
            RenderHelper.disableStandardItemLighting();
            GlStateManager.setActiveTexture(OpenGlHelper.lightmapTexUnit);
            GlStateManager.disableTexture2D();
            GlStateManager.setActiveTexture(OpenGlHelper.defaultTexUnit);
            GlStateManager.pushMatrix();
            GlStateManager.translate(x - tile.getPos().getX(), y - tile.getPos().getY(), z - tile.getPos().getZ());
            GlStateManager.pushMatrix();
            GlStateManager.translate(xResult + 0.5, tile.getPos().getY(), zResult + 0.5);
            GlStateManager.scale(3, 3, 3);
            Minecraft.getMinecraft().getRenderItem().renderItem(stack, ItemCameraTransforms.TransformType.GROUND);
            GlStateManager.popMatrix();
            GlStateManager.popMatrix();
        }
    }
    RenderHelper.enableStandardItemLighting();
    profiler.endSection();
    profiler.endSection();
    profiler.endSection();
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) EnumFacing(net.minecraft.util.EnumFacing) LaserData_BC8(buildcraft.lib.client.render.laser.LaserData_BC8) Vec3d(net.minecraft.util.math.Vec3d) Profiler(net.minecraft.profiler.Profiler) BlockPos(net.minecraft.util.math.BlockPos) TileQuarry(buildcraft.builders.tile.TileQuarry) ItemStack(net.minecraft.item.ItemStack)

Example 9 with LaserData_BC8

use of buildcraft.lib.client.render.laser.LaserData_BC8 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);
}
Also used : ModelUtil(buildcraft.lib.client.model.ModelUtil) World(net.minecraft.world.World) BufferBuilder(net.minecraft.client.renderer.BufferBuilder) LaserData_BC8(buildcraft.lib.client.render.laser.LaserData_BC8) EnumFacing(net.minecraft.util.EnumFacing) BCBuildersSprites(buildcraft.builders.BCBuildersSprites) BlockPos(net.minecraft.util.math.BlockPos) LaserRenderer_BC8(buildcraft.lib.client.render.laser.LaserRenderer_BC8) BuildCraftLaserManager(buildcraft.core.client.BuildCraftLaserManager) Point3f(javax.vecmath.Point3f) ItemStack(net.minecraft.item.ItemStack) Vec3d(net.minecraft.util.math.Vec3d) Side(net.minecraftforge.fml.relauncher.Side) ITileForSnapshotBuilder(buildcraft.builders.snapshot.ITileForSnapshotBuilder) ItemRenderUtil(buildcraft.lib.client.render.ItemRenderUtil) MathUtil(buildcraft.lib.misc.MathUtil) VecUtil(buildcraft.lib.misc.VecUtil) SnapshotBuilder(buildcraft.builders.snapshot.SnapshotBuilder) SideOnly(net.minecraftforge.fml.relauncher.SideOnly) Collections(java.util.Collections) ITileForSnapshotBuilder(buildcraft.builders.snapshot.ITileForSnapshotBuilder) SnapshotBuilder(buildcraft.builders.snapshot.SnapshotBuilder) EnumFacing(net.minecraft.util.EnumFacing) LaserData_BC8(buildcraft.lib.client.render.laser.LaserData_BC8) Vec3d(net.minecraft.util.math.Vec3d) ModelUtil(buildcraft.lib.client.model.ModelUtil) Point3f(javax.vecmath.Point3f) BlockPos(net.minecraft.util.math.BlockPos) ItemStack(net.minecraft.item.ItemStack)

Aggregations

LaserData_BC8 (buildcraft.lib.client.render.laser.LaserData_BC8)9 Vec3d (net.minecraft.util.math.Vec3d)9 BlockPos (net.minecraft.util.math.BlockPos)6 EnumFacing (net.minecraft.util.EnumFacing)5 ItemStack (net.minecraft.item.ItemStack)2 Profiler (net.minecraft.profiler.Profiler)2 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)2 IBox (buildcraft.api.core.IBox)1 MapLocationType (buildcraft.api.items.IMapLocation.MapLocationType)1 BCBuildersSprites (buildcraft.builders.BCBuildersSprites)1 ITileForSnapshotBuilder (buildcraft.builders.snapshot.ITileForSnapshotBuilder)1 SnapshotBuilder (buildcraft.builders.snapshot.SnapshotBuilder)1 TileQuarry (buildcraft.builders.tile.TileQuarry)1 BuildCraftLaserManager (buildcraft.core.client.BuildCraftLaserManager)1 ModelUtil (buildcraft.lib.client.model.ModelUtil)1 ItemRenderUtil (buildcraft.lib.client.render.ItemRenderUtil)1 LaserType (buildcraft.lib.client.render.laser.LaserData_BC8.LaserType)1 LaserRenderer_BC8 (buildcraft.lib.client.render.laser.LaserRenderer_BC8)1 MathUtil (buildcraft.lib.misc.MathUtil)1 VecUtil (buildcraft.lib.misc.VecUtil)1