Search in sources :

Example 1 with ITileForSnapshotBuilder

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);
}
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

BCBuildersSprites (buildcraft.builders.BCBuildersSprites)1 ITileForSnapshotBuilder (buildcraft.builders.snapshot.ITileForSnapshotBuilder)1 SnapshotBuilder (buildcraft.builders.snapshot.SnapshotBuilder)1 BuildCraftLaserManager (buildcraft.core.client.BuildCraftLaserManager)1 ModelUtil (buildcraft.lib.client.model.ModelUtil)1 ItemRenderUtil (buildcraft.lib.client.render.ItemRenderUtil)1 LaserData_BC8 (buildcraft.lib.client.render.laser.LaserData_BC8)1 LaserRenderer_BC8 (buildcraft.lib.client.render.laser.LaserRenderer_BC8)1 MathUtil (buildcraft.lib.misc.MathUtil)1 VecUtil (buildcraft.lib.misc.VecUtil)1 Collections (java.util.Collections)1 Point3f (javax.vecmath.Point3f)1 BufferBuilder (net.minecraft.client.renderer.BufferBuilder)1 ItemStack (net.minecraft.item.ItemStack)1 EnumFacing (net.minecraft.util.EnumFacing)1 BlockPos (net.minecraft.util.math.BlockPos)1 Vec3d (net.minecraft.util.math.Vec3d)1 World (net.minecraft.world.World)1 Side (net.minecraftforge.fml.relauncher.Side)1 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)1