Search in sources :

Example 1 with LaserData_BC8

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

the class PathConnection method renderLaser.

@SideOnly(Side.CLIENT)
private static void renderLaser(Vec3d from, Vec3d to) {
    Vec3d one = offset(from, to);
    Vec3d two = offset(to, from);
    LaserData_BC8 data = new LaserData_BC8(BuildCraftLaserManager.MARKER_PATH_CONNECTED, one, two, RENDER_SCALE);
    LaserRenderer_BC8.renderLaserStatic(data);
}
Also used : LaserData_BC8(buildcraft.lib.client.render.laser.LaserData_BC8) Vec3d(net.minecraft.util.math.Vec3d) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 2 with LaserData_BC8

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

the class RenderBuilder method renderTileEntityFast.

@Override
public void renderTileEntityFast(@Nonnull TileBuilder tile, double x, double y, double z, float partialTicks, int destroyStage, float partial, @Nonnull BufferBuilder buffer) {
    Minecraft.getMinecraft().mcProfiler.startSection("bc");
    Minecraft.getMinecraft().mcProfiler.startSection("builder");
    buffer.setTranslation(x - tile.getPos().getX(), y - tile.getPos().getY(), z - tile.getPos().getZ());
    Minecraft.getMinecraft().mcProfiler.startSection("box");
    Box box = tile.getBox();
    LaserBoxRenderer.renderLaserBoxDynamic(box, BuildCraftLaserManager.STRIPES_WRITE, buffer, true);
    Minecraft.getMinecraft().mcProfiler.endStartSection("path");
    List<BlockPos> path = tile.path;
    if (path != null) {
        BlockPos last = null;
        for (BlockPos p : path) {
            if (last != null) {
                Vec3d from = new Vec3d(last).add(VecUtil.VEC_HALF);
                Vec3d to = new Vec3d(p).add(VecUtil.VEC_HALF);
                Vec3d one = offset(from, to);
                Vec3d two = offset(to, from);
                LaserData_BC8 data = new LaserData_BC8(BuildCraftLaserManager.STRIPES_WRITE_DIRECTION, one, two, 1 / 16.1);
                LaserRenderer_BC8.renderLaserDynamic(data, buffer);
            }
            last = p;
        }
    }
    Minecraft.getMinecraft().mcProfiler.endSection();
    buffer.setTranslation(0, 0, 0);
    if (tile.getBuilder() != null) {
        RenderSnapshotBuilder.render(tile.getBuilder(), tile.getWorld(), tile.getPos(), x, y, z, partialTicks, buffer);
    }
    Minecraft.getMinecraft().mcProfiler.endSection();
    Minecraft.getMinecraft().mcProfiler.endSection();
}
Also used : Box(buildcraft.lib.misc.data.Box) BlockPos(net.minecraft.util.math.BlockPos) LaserData_BC8(buildcraft.lib.client.render.laser.LaserData_BC8) Vec3d(net.minecraft.util.math.Vec3d)

Example 3 with LaserData_BC8

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

the class RenderTickListener method renderMapLocation.

private static void renderMapLocation(@Nonnull ItemStack stack) {
    MapLocationType type = MapLocationType.getFromStack(stack);
    if (type == MapLocationType.SPOT) {
        EnumFacing face = ItemMapLocation.getPointFace(stack);
        IBox box = ItemMapLocation.getPointBox(stack);
        if (box != null) {
            Vec3d[][] vectors = MAP_LOCATION_POINT[face.ordinal()];
            GL11.glTranslated(box.min().getX(), box.min().getY(), box.min().getZ());
            for (Vec3d[] vec : vectors) {
                LaserData_BC8 laser = new LaserData_BC8(BuildCraftLaserManager.STRIPES_WRITE, vec[0], vec[1], 1 / 16.0);
                LaserRenderer_BC8.renderLaserStatic(laser);
            }
        }
    } else if (type == MapLocationType.AREA) {
        IBox box = ItemMapLocation.getAreaBox(stack);
        LAST_RENDERED_MAP_LOC.reset();
        LAST_RENDERED_MAP_LOC.initialize(box);
        LaserBoxRenderer.renderLaserBoxStatic(LAST_RENDERED_MAP_LOC, BuildCraftLaserManager.STRIPES_WRITE, true);
    } else if (type == MapLocationType.PATH) {
        List<BlockPos> path = BCCoreItems.mapLocation.getPath(stack);
        if (path != null && path.size() > 1) {
            BlockPos last = null;
            for (BlockPos p : path) {
                if (last == null) {
                    last = p;
                }
            }
        }
    // TODO!
    } else if (type == MapLocationType.ZONE) {
    // TODO!
    }
}
Also used : IBox(buildcraft.api.core.IBox) MapLocationType(buildcraft.api.items.IMapLocation.MapLocationType) EnumFacing(net.minecraft.util.EnumFacing) BlockPos(net.minecraft.util.math.BlockPos) LaserData_BC8(buildcraft.lib.client.render.laser.LaserData_BC8) Vec3d(net.minecraft.util.math.Vec3d)

Example 4 with LaserData_BC8

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

the class RenderTickListener method renderMarkerCache.

private static void renderMarkerCache(EntityPlayer player, MarkerSubCache<?> cache) {
    Profiler profiler = Minecraft.getMinecraft().mcProfiler;
    profiler.startSection("compute");
    Set<LaserData_BC8> toRender = new HashSet<>();
    for (final BlockPos a : cache.getAllMarkers()) {
        for (final BlockPos b : cache.getValidConnections(a)) {
            if (a.toLong() > b.toLong()) {
                // Only render each pair once
                continue;
            }
            Vec3d start = VecUtil.convertCenter(a);
            Vec3d end = VecUtil.convertCenter(b);
            Vec3d startToEnd = end.subtract(start).normalize();
            Vec3d endToStart = start.subtract(end).normalize();
            start = start.add(VecUtil.scale(startToEnd, 0.125));
            end = end.add(VecUtil.scale(endToStart, 0.125));
            LaserType laserType = cache.getPossibleLaserType();
            if (laserType == null || isLookingAt(a, b, player)) {
                laserType = BuildCraftLaserManager.MARKER_DEFAULT_POSSIBLE;
            }
            LaserData_BC8 data = new LaserData_BC8(laserType, start, end, 1 / 16.0);
            toRender.add(data);
        }
    }
    profiler.endStartSection("render");
    for (LaserData_BC8 laser : toRender) {
        LaserRenderer_BC8.renderLaserStatic(laser);
    }
    profiler.endSection();
}
Also used : LaserType(buildcraft.lib.client.render.laser.LaserData_BC8.LaserType) Profiler(net.minecraft.profiler.Profiler) BlockPos(net.minecraft.util.math.BlockPos) LaserData_BC8(buildcraft.lib.client.render.laser.LaserData_BC8) Vec3d(net.minecraft.util.math.Vec3d) HashSet(java.util.HashSet)

Example 5 with LaserData_BC8

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

the class RenderLaser method renderTileEntityFast.

@Override
public void renderTileEntityFast(@Nonnull TileLaser tile, double x, double y, double z, float partialTicks, int destroyStage, float partial, @Nonnull BufferBuilder buffer) {
    if (BCSiliconConfig.renderLaserBeams || isPlayerWearingGoggles()) {
        Minecraft.getMinecraft().mcProfiler.startSection("bc");
        Minecraft.getMinecraft().mcProfiler.startSection("laser");
        buffer.setTranslation(x - tile.getPos().getX(), y - tile.getPos().getY(), z - tile.getPos().getZ());
        if (tile.laserPos != null) {
            long avg = tile.getAverageClient();
            if (avg > 200_000) {
                avg += 200_000;
                EnumFacing side = tile.getWorld().getBlockState(tile.getPos()).getValue(BuildCraftProperties.BLOCK_FACING_6);
                Vec3d offset = new Vec3d(0.5, 0.5, 0.5).add(new Vec3d(side.getDirectionVec()).scale(4 / 16D));
                int index = (int) (avg * MAX_POWER / tile.getMaxPowerPerTick());
                if (index > MAX_POWER) {
                    index = MAX_POWER;
                }
                LaserData_BC8 laser = new LaserData_BC8(BuildCraftLaserManager.POWERS[index], new Vec3d(tile.getPos()).add(offset), tile.laserPos, 1 / 16D);
                LaserRenderer_BC8.renderLaserDynamic(laser, buffer);
            }
        }
        buffer.setTranslation(0, 0, 0);
        Minecraft.getMinecraft().mcProfiler.endSection();
        Minecraft.getMinecraft().mcProfiler.endSection();
    }
}
Also used : EnumFacing(net.minecraft.util.EnumFacing) LaserData_BC8(buildcraft.lib.client.render.laser.LaserData_BC8) Vec3d(net.minecraft.util.math.Vec3d)

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