Search in sources :

Example 1 with MultiblockProcess

use of blusunrize.immersiveengineering.common.blocks.metal.TileEntityMultiblockMetal.MultiblockProcess in project ImmersiveEngineering by BluSunrize.

the class TileRenderAutoWorkbench method renderTileEntityAt.

@Override
public void renderTileEntityAt(TileEntityAutoWorkbench te, double x, double y, double z, float partialTicks, int destroyStage) {
    if (!te.formed || te.isDummy() || !te.getWorld().isBlockLoaded(te.getPos(), false))
        return;
    //Grab model + correct eextended state
    final BlockRendererDispatcher blockRenderer = Minecraft.getMinecraft().getBlockRendererDispatcher();
    BlockPos blockPos = te.getPos();
    IBlockState state = getWorld().getBlockState(blockPos);
    if (state.getBlock() != IEContent.blockMetalMultiblock)
        return;
    state = state.getBlock().getActualState(state, getWorld(), blockPos);
    state = state.withProperty(IEProperties.DYNAMICRENDER, true);
    IBakedModel model = blockRenderer.getBlockModelShapes().getModelForState(state);
    //Initialize Tesselator and VertexBuffer
    Tessellator tessellator = Tessellator.getInstance();
    VertexBuffer worldRenderer = tessellator.getBuffer();
    //Outer GL Wrapping, initial translation
    GlStateManager.pushMatrix();
    GlStateManager.translate(x + .5, y + .5, z + .5);
    if (te.mirrored)
        GlStateManager.scale(te.facing.getFrontOffsetX() == 0 ? -1 : 1, 1, te.facing.getFrontOffsetZ() == 0 ? -1 : 1);
    //Item Displacement
    float[][] itemDisplays = new float[te.processQueue.size()][];
    //Animations
    float drill = 0;
    float lift = 0;
    float press = 0;
    float liftPress = 0;
    for (int i = 0; i < itemDisplays.length; i++) {
        MultiblockProcess<IMultiblockRecipe> process = te.processQueue.get(i);
        if (process == null || process.processTick <= 0 || process.processTick == process.maxTicks)
            continue;
        //+partialTicks
        float processTimer = ((float) process.processTick) / process.maxTicks * 180;
        if (processTimer <= 9)
            continue;
        float itemX = -1;
        float itemY = -.34375f;
        float itemZ = -.9375f;
        float itemAngle = 90f;
        if (//slide
        processTimer <= 24) {
            itemAngle = 67.5f;
            if (processTimer <= 19) {
                itemZ += .25 + (19 - processTimer) / 10f * .5f;
                itemY += .25 + (19 - processTimer) / 10f * .21875f;
            } else {
                itemZ += (24 - processTimer) / 5f * .25f;
                itemY += (24 - processTimer) / 5f * .25f;
            }
        } else if (processTimer <= 40) {
            itemX += (processTimer - 24) / 16f;
        } else if (processTimer <= 100) {
            itemX += 1;
            float drillStep = 0;
            if (processTimer <= 60) {
                lift = (processTimer - 40) / 20f * .3125f;
                drillStep = 4 + (60 - processTimer) * 4;
            } else if (processTimer <= 80) {
                lift = .3125f;
                drillStep = 4;
            } else {
                lift = (100 - processTimer) / 20f * .3125f;
                drillStep = 4 + (processTimer - 80) * 4;
            }
            if (drillStep > 0)
                drill = processTimer % drillStep / drillStep * 360;
            itemY += Math.max(0, lift - .0625);
        } else if (processTimer <= 116) {
            itemX += 1;
            itemZ += (processTimer - 100) / 16f;
        } else if (processTimer <= 132) {
            itemX += 1 + (processTimer - 116) / 16f;
            itemZ += 1;
        } else if (processTimer <= 172) {
            itemX += 2;
            itemZ += 1;
            if (processTimer <= 142)
                press = (processTimer - 132) / 10f;
            else if (processTimer <= 162)
                press = 1;
            else
                press = (172 - processTimer) / 10f;
            liftPress = press * .0625f;
            itemY += liftPress;
        } else if (processTimer <= 180) {
            itemX += 2 + (processTimer - 172) / 16f;
            itemZ += 1;
        }
        itemDisplays[i] = new float[] { processTimer, itemX, itemY, itemZ, itemAngle };
    }
    ClientUtils.bindAtlas();
    GlStateManager.pushMatrix();
    ItemStack blueprintStack = te.inventory[0];
    if (blueprintStack != null)
        renderModelPart(blockRenderer, tessellator, worldRenderer, te.getWorld(), state, model, blockPos, "blueprint");
    GlStateManager.translate(0, lift, 0);
    renderModelPart(blockRenderer, tessellator, worldRenderer, te.getWorld(), state, model, blockPos, "lift");
    GlStateManager.translate(0, -lift, 0);
    EnumFacing f = te.getFacing();
    float tx = f == EnumFacing.WEST ? -.9375f : f == EnumFacing.EAST ? .9375f : 0;
    float tz = f == EnumFacing.NORTH ? -.9375f : f == EnumFacing.SOUTH ? .9375f : 0;
    GlStateManager.translate(tx, 0, tz);
    GlStateManager.rotate(drill, 0, 1, 0);
    renderModelPart(blockRenderer, tessellator, worldRenderer, te.getWorld(), state, model, blockPos, "drill");
    GlStateManager.rotate(-drill, 0, 1, 0);
    GlStateManager.translate(-tx, 0, -tz);
    tx = f == EnumFacing.WEST ? -.59375f : f == EnumFacing.EAST ? .59375f : 0;
    tz = f == EnumFacing.NORTH ? -.59375f : f == EnumFacing.SOUTH ? .59375f : 0;
    GlStateManager.translate(tx, -.21875, tz);
    GlStateManager.rotate(press * 90, -f.getFrontOffsetZ(), 0, f.getFrontOffsetX());
    renderModelPart(blockRenderer, tessellator, worldRenderer, te.getWorld(), state, model, blockPos, "press");
    GlStateManager.rotate(-press * 90, -f.getFrontOffsetZ(), 0, f.getFrontOffsetX());
    GlStateManager.translate(-tx, .21875, -tz);
    GlStateManager.translate(0, liftPress, 0);
    renderModelPart(blockRenderer, tessellator, worldRenderer, te.getWorld(), state, model, blockPos, "pressLift");
    GlStateManager.translate(0, -liftPress, 0);
    RenderHelper.enableStandardItemLighting();
    GlStateManager.popMatrix();
    switch(f) {
        case NORTH:
            break;
        case SOUTH:
            GlStateManager.rotate(180, 0, 1, 0);
            break;
        case WEST:
            GlStateManager.rotate(90, 0, 1, 0);
            break;
        case EAST:
            GlStateManager.rotate(-90, 0, 1, 0);
            break;
    }
    //DRAW ITEMS HERE
    for (int i = 0; i < itemDisplays.length; i++) if (itemDisplays[i] != null) {
        MultiblockProcess<IMultiblockRecipe> process = te.processQueue.get(i);
        if (process == null || !(process instanceof MultiblockProcessInWorld))
            continue;
        float scale = .3125f;
        List<ItemStack> dList = ((MultiblockProcessInWorld) process).getDisplayItem();
        if (!dList.isEmpty())
            if (dList.size() < 2) {
                GlStateManager.translate(itemDisplays[i][1], itemDisplays[i][2], itemDisplays[i][3]);
                GlStateManager.rotate(itemDisplays[i][4], 1, 0, 0);
                GlStateManager.scale(scale, scale, .5f);
                ClientUtils.mc().getRenderItem().renderItem(dList.get(0), ItemCameraTransforms.TransformType.FIXED);
                GlStateManager.scale(1 / scale, 1 / scale, 2);
                GlStateManager.rotate(-itemDisplays[i][4], 1, 0, 0);
                GlStateManager.translate(-itemDisplays[i][1], -itemDisplays[i][2], -itemDisplays[i][3]);
            } else {
                int size = dList.size();
                int lines = (int) Math.ceil(size / 2f);
                float spacer = (lines - 1) * .234375f;
                for (int d = 0; d < size; d++) {
                    float oX = (size > 2 ? -.3125f : 0) + (lines - d / 2) * .0625f + d % 2 * .3125f;
                    float oZ = -spacer / 2f + d / 2 * .234375f;
                    float oY = 0;
                    float localItemX = itemDisplays[i][1] + oX;
                    float localItemY = itemDisplays[i][2] + oY;
                    float localItemZ = itemDisplays[i][3] + oZ;
                    float subProcess = itemDisplays[i][0] - d / 2 * 4;
                    float localAngle = itemDisplays[i][4];
                    if (//slide
                    subProcess <= 24) {
                        localAngle = 67.5f;
                        if (subProcess <= 19) {
                            localItemZ = -1 + .25f + (19 - subProcess) / 10f * .5f;
                            localItemY = -.34375f + .25f + (19 - subProcess) / 10f * .21875f;
                        } else {
                            localItemZ = -1 + (oZ - (24 - subProcess) / 5f * oZ);
                            localItemY = -.34375f + (24 - subProcess) / 5f * .25f;
                        }
                    }
                    GlStateManager.translate(localItemX, localItemY, localItemZ);
                    GlStateManager.rotate(localAngle, 1, 0, 0);
                    GlStateManager.scale(scale, scale, .5f);
                    ClientUtils.mc().getRenderItem().renderItem(dList.get(d), ItemCameraTransforms.TransformType.FIXED);
                    GlStateManager.scale(1 / scale, 1 / scale, 2);
                    GlStateManager.rotate(-localAngle, 1, 0, 0);
                    GlStateManager.translate(-localItemX, -localItemY, -localItemZ);
                }
            }
    }
    //Blueprint
    double playerDistanceSq = ClientUtils.mc().thePlayer.getDistanceSq(blockPos);
    if (blueprintStack != null && playerDistanceSq < 1000) {
        BlueprintCraftingRecipe[] recipes = BlueprintCraftingRecipe.findRecipes(ItemNBTHelper.getString(blueprintStack, "blueprint"));
        BlueprintCraftingRecipe recipe = (te.selectedRecipe < 0 || te.selectedRecipe >= recipes.length) ? null : recipes[te.selectedRecipe];
        BlueprintLines blueprint = recipe == null ? null : getBlueprintDrawable(recipe, te.getWorld());
        if (blueprint != null) {
            //Width depends on distance
            float lineWidth = playerDistanceSq < 6 ? 3 : playerDistanceSq < 25 ? 2 : playerDistanceSq < 40 ? 1 : .5f;
            GlStateManager.translate(-.195, .125, .97);
            GlStateManager.rotate(-45, 1, 0, 0);
            GlStateManager.disableCull();
            GlStateManager.disableTexture2D();
            GlStateManager.enableBlend();
            float scale = .0375f / (blueprint.textureScale / 16f);
            GlStateManager.scale(scale, -scale, scale);
            GlStateManager.color(1, 1, 1, 1);
            blueprint.draw(lineWidth);
            GlStateManager.scale(1 / scale, -1 / scale, 1 / scale);
            GlStateManager.enableAlpha();
            GlStateManager.enableTexture2D();
            GlStateManager.enableCull();
        }
    }
    GlStateManager.popMatrix();
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) MultiblockProcess(blusunrize.immersiveengineering.common.blocks.metal.TileEntityMultiblockMetal.MultiblockProcess) EnumFacing(net.minecraft.util.EnumFacing) MultiblockProcessInWorld(blusunrize.immersiveengineering.common.blocks.metal.TileEntityMultiblockMetal.MultiblockProcessInWorld) BlueprintCraftingRecipe(blusunrize.immersiveengineering.api.crafting.BlueprintCraftingRecipe) IMultiblockRecipe(blusunrize.immersiveengineering.api.crafting.IMultiblockRecipe) BlockPos(net.minecraft.util.math.BlockPos) List(java.util.List) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel) ItemStack(net.minecraft.item.ItemStack)

Example 2 with MultiblockProcess

use of blusunrize.immersiveengineering.common.blocks.metal.TileEntityMultiblockMetal.MultiblockProcess in project ImmersiveEngineering by BluSunrize.

the class TileRenderMetalPress method renderTileEntityAt.

@Override
public void renderTileEntityAt(TileEntityMetalPress te, double x, double y, double z, float partialTicks, int destroyStage) {
    if (!te.formed || te.isDummy() || !te.getWorld().isBlockLoaded(te.getPos(), false))
        return;
    final BlockRendererDispatcher blockRenderer = Minecraft.getMinecraft().getBlockRendererDispatcher();
    BlockPos blockPos = te.getPos();
    IBlockState state = getWorld().getBlockState(blockPos);
    if (state.getBlock() != IEContent.blockMetalMultiblock)
        return;
    state = state.getBlock().getActualState(state, getWorld(), blockPos);
    state = state.withProperty(IEProperties.DYNAMICRENDER, true);
    IBakedModel model = blockRenderer.getBlockModelShapes().getModelForState(state);
    Tessellator tessellator = Tessellator.getInstance();
    VertexBuffer worldRenderer = tessellator.getBuffer();
    ClientUtils.bindAtlas();
    GlStateManager.pushMatrix();
    GlStateManager.translate(x + .5, y + .5, z + .5);
    float piston = 0;
    float[] shift = new float[te.processQueue.size()];
    for (int i = 0; i < shift.length; i++) {
        MultiblockProcess process = te.processQueue.get(i);
        if (process == null)
            continue;
        float transportTime = 52.5f / (float) process.maxTicks;
        float pressTime = 3.75f / (float) process.maxTicks;
        float fProcess = (process.processTick + (te.shouldRenderAsActive() ? partialTicks : 0)) / (float) process.maxTicks;
        if (fProcess < transportTime)
            shift[i] = fProcess / transportTime * .5f;
        else if (fProcess < (1 - transportTime))
            shift[i] = .5f;
        else
            shift[i] = .5f + (fProcess - (1 - transportTime)) / transportTime * .5f;
        if (te.mold != null)
            if (fProcess >= transportTime && fProcess < (1 - transportTime)) {
                if (fProcess < (transportTime + pressTime))
                    piston = (fProcess - transportTime) / pressTime;
                else if (fProcess < (1 - transportTime - pressTime))
                    piston = 1;
                else
                    piston = 1 - (fProcess - (1 - transportTime - pressTime)) / pressTime;
            }
    }
    GlStateManager.translate(0, -piston * .6875f, 0);
    RenderHelper.disableStandardItemLighting();
    GlStateManager.blendFunc(770, 771);
    GlStateManager.enableBlend();
    GlStateManager.disableCull();
    if (Minecraft.isAmbientOcclusionEnabled())
        GlStateManager.shadeModel(7425);
    else
        GlStateManager.shadeModel(7424);
    worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
    worldRenderer.setTranslation(-.5 - blockPos.getX(), -.5 - blockPos.getY(), -.5 - blockPos.getZ());
    worldRenderer.color(255, 255, 255, 255);
    blockRenderer.getBlockModelRenderer().renderModel(te.getWorld(), model, state, blockPos, worldRenderer, true);
    worldRenderer.setTranslation(0.0D, 0.0D, 0.0D);
    tessellator.draw();
    RenderHelper.enableStandardItemLighting();
    GlStateManager.rotate(te.facing == EnumFacing.SOUTH ? 180 : te.facing == EnumFacing.WEST ? 90 : te.facing == EnumFacing.EAST ? -90 : 0, 0, 1, 0);
    if (te.mold != null) {
        GlStateManager.pushMatrix();
        GlStateManager.translate(0, .34, 0);
        GlStateManager.rotate(-90, 1, 0, 0);
        float scale = .75f;
        GlStateManager.scale(scale, scale, 1);
        ClientUtils.mc().getRenderItem().renderItem(te.mold, ItemCameraTransforms.TransformType.FIXED);
        GlStateManager.scale(1 / scale, 1 / scale, 1);
        GlStateManager.popMatrix();
    }
    GlStateManager.translate(0, piston * .6875f, 0);
    GlStateManager.translate(0, -.35, 1.25);
    for (int i = 0; i < shift.length; i++) {
        MultiblockProcess process = te.processQueue.get(i);
        if (process == null || !(process instanceof MultiblockProcessInWorld))
            continue;
        GlStateManager.pushMatrix();
        GlStateManager.translate(0, 0, -2.5 * shift[i]);
        List<ItemStack> displays = ((MultiblockProcessInWorld) process).getDisplayItem();
        if (!displays.isEmpty()) {
            GlStateManager.rotate(-90, 1, 0, 0);
            float scale = .625f;
            GlStateManager.scale(scale, scale, 1);
            ClientUtils.mc().getRenderItem().renderItem(displays.get(0), ItemCameraTransforms.TransformType.FIXED);
            GlStateManager.popMatrix();
        }
    }
    GlStateManager.popMatrix();
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) MultiblockProcess(blusunrize.immersiveengineering.common.blocks.metal.TileEntityMultiblockMetal.MultiblockProcess) MultiblockProcessInWorld(blusunrize.immersiveengineering.common.blocks.metal.TileEntityMultiblockMetal.MultiblockProcessInWorld) BlockPos(net.minecraft.util.math.BlockPos) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel) ItemStack(net.minecraft.item.ItemStack)

Example 3 with MultiblockProcess

use of blusunrize.immersiveengineering.common.blocks.metal.TileEntityMultiblockMetal.MultiblockProcess in project ImmersiveEngineering by BluSunrize.

the class TileRenderAutoWorkbench method render.

@Override
public void render(TileEntityAutoWorkbench te, double x, double y, double z, float partialTicks, int destroyStage, float alpha) {
    if (!te.formed || te.isDummy() || !te.getWorld().isBlockLoaded(te.getPos(), false))
        return;
    // Grab model + correct eextended state
    final BlockRendererDispatcher blockRenderer = Minecraft.getMinecraft().getBlockRendererDispatcher();
    BlockPos blockPos = te.getPos();
    IBlockState state = getWorld().getBlockState(blockPos);
    if (state.getBlock() != IEContent.blockMetalMultiblock)
        return;
    state = state.getBlock().getActualState(state, getWorld(), blockPos);
    state = state.withProperty(IEProperties.DYNAMICRENDER, true);
    IBakedModel model = blockRenderer.getBlockModelShapes().getModelForState(state);
    // Initialize Tesselator and BufferBuilder
    Tessellator tessellator = Tessellator.getInstance();
    BufferBuilder worldRenderer = tessellator.getBuffer();
    // Outer GL Wrapping, initial translation
    GlStateManager.pushMatrix();
    GlStateManager.translate(x + .5, y + .5, z + .5);
    if (te.mirrored)
        GlStateManager.scale(te.facing.getXOffset() == 0 ? -1 : 1, 1, te.facing.getZOffset() == 0 ? -1 : 1);
    // Item Displacement
    float[][] itemDisplays = new float[te.processQueue.size()][];
    // Animations
    float drill = 0;
    float lift = 0;
    float press = 0;
    float liftPress = 0;
    for (int i = 0; i < itemDisplays.length; i++) {
        MultiblockProcess<IMultiblockRecipe> process = te.processQueue.get(i);
        if (process == null || process.processTick <= 0 || process.processTick == process.maxTicks)
            continue;
        // +partialTicks
        float processTimer = ((float) process.processTick) / process.maxTicks * 180;
        if (processTimer <= 9)
            continue;
        float itemX = -1;
        float itemY = -.34375f;
        float itemZ = -.9375f;
        float itemAngle = 90f;
        if (// slide
        processTimer <= 24) {
            itemAngle = 67.5f;
            if (processTimer <= 19) {
                itemZ += .25 + (19 - processTimer) / 10f * .5f;
                itemY += .25 + (19 - processTimer) / 10f * .21875f;
            } else {
                itemZ += (24 - processTimer) / 5f * .25f;
                itemY += (24 - processTimer) / 5f * .25f;
            }
        } else if (processTimer <= 40) {
            itemX += (processTimer - 24) / 16f;
        } else if (processTimer <= 100) {
            itemX += 1;
            float drillStep = 0;
            if (processTimer <= 60) {
                lift = (processTimer - 40) / 20f * .3125f;
                drillStep = 4 + (60 - processTimer) * 4;
            } else if (processTimer <= 80) {
                lift = .3125f;
                drillStep = 4;
            } else {
                lift = (100 - processTimer) / 20f * .3125f;
                drillStep = 4 + (processTimer - 80) * 4;
            }
            if (drillStep > 0)
                drill = processTimer % drillStep / drillStep * 360;
            itemY += Math.max(0, lift - .0625);
        } else if (processTimer <= 116) {
            itemX += 1;
            itemZ += (processTimer - 100) / 16f;
        } else if (processTimer <= 132) {
            itemX += 1 + (processTimer - 116) / 16f;
            itemZ += 1;
        } else if (processTimer <= 172) {
            itemX += 2;
            itemZ += 1;
            if (processTimer <= 142)
                press = (processTimer - 132) / 10f;
            else if (processTimer <= 162)
                press = 1;
            else
                press = (172 - processTimer) / 10f;
            liftPress = press * .0625f;
            itemY += liftPress;
        } else if (processTimer <= 180) {
            itemX += 2 + (processTimer - 172) / 16f;
            itemZ += 1;
        }
        itemDisplays[i] = new float[] { processTimer, itemX, itemY, itemZ, itemAngle };
    }
    ClientUtils.bindAtlas();
    GlStateManager.pushMatrix();
    ItemStack blueprintStack = te.inventory.get(0);
    if (!blueprintStack.isEmpty())
        renderModelPart(blockRenderer, tessellator, worldRenderer, te.getWorld(), state, model, blockPos, "blueprint");
    GlStateManager.translate(0, lift, 0);
    renderModelPart(blockRenderer, tessellator, worldRenderer, te.getWorld(), state, model, blockPos, "lift");
    GlStateManager.translate(0, -lift, 0);
    EnumFacing f = te.getFacing();
    float tx = f == EnumFacing.WEST ? -.9375f : f == EnumFacing.EAST ? .9375f : 0;
    float tz = f == EnumFacing.NORTH ? -.9375f : f == EnumFacing.SOUTH ? .9375f : 0;
    GlStateManager.translate(tx, 0, tz);
    GlStateManager.rotate(drill, 0, 1, 0);
    renderModelPart(blockRenderer, tessellator, worldRenderer, te.getWorld(), state, model, blockPos, "drill");
    GlStateManager.rotate(-drill, 0, 1, 0);
    GlStateManager.translate(-tx, 0, -tz);
    tx = f == EnumFacing.WEST ? -.59375f : f == EnumFacing.EAST ? .59375f : 0;
    tz = f == EnumFacing.NORTH ? -.59375f : f == EnumFacing.SOUTH ? .59375f : 0;
    GlStateManager.translate(tx, -.21875, tz);
    GlStateManager.rotate(press * 90, -f.getZOffset(), 0, f.getXOffset());
    renderModelPart(blockRenderer, tessellator, worldRenderer, te.getWorld(), state, model, blockPos, "press");
    GlStateManager.rotate(-press * 90, -f.getZOffset(), 0, f.getXOffset());
    GlStateManager.translate(-tx, .21875, -tz);
    GlStateManager.translate(0, liftPress, 0);
    renderModelPart(blockRenderer, tessellator, worldRenderer, te.getWorld(), state, model, blockPos, "pressLift");
    GlStateManager.translate(0, -liftPress, 0);
    RenderHelper.enableStandardItemLighting();
    GlStateManager.popMatrix();
    switch(f) {
        case NORTH:
            break;
        case SOUTH:
            GlStateManager.rotate(180, 0, 1, 0);
            break;
        case WEST:
            GlStateManager.rotate(90, 0, 1, 0);
            break;
        case EAST:
            GlStateManager.rotate(-90, 0, 1, 0);
            break;
    }
    // DRAW ITEMS HERE
    for (int i = 0; i < itemDisplays.length; i++) if (itemDisplays[i] != null) {
        MultiblockProcess<IMultiblockRecipe> process = te.processQueue.get(i);
        if (process == null || !(process instanceof MultiblockProcessInWorld))
            continue;
        float scale = .3125f;
        List<ItemStack> dList = ((MultiblockProcessInWorld) process).getDisplayItem();
        if (!dList.isEmpty())
            if (dList.size() < 2) {
                GlStateManager.translate(itemDisplays[i][1], itemDisplays[i][2], itemDisplays[i][3]);
                GlStateManager.rotate(itemDisplays[i][4], 1, 0, 0);
                GlStateManager.scale(scale, scale, .5f);
                ClientUtils.mc().getRenderItem().renderItem(dList.get(0), ItemCameraTransforms.TransformType.FIXED);
                GlStateManager.scale(1 / scale, 1 / scale, 2);
                GlStateManager.rotate(-itemDisplays[i][4], 1, 0, 0);
                GlStateManager.translate(-itemDisplays[i][1], -itemDisplays[i][2], -itemDisplays[i][3]);
            } else {
                int size = dList.size();
                int lines = (int) Math.ceil(size / 2f);
                float spacer = (lines - 1) * .234375f;
                for (int d = 0; d < size; d++) {
                    float oX = (size > 2 ? -.3125f : 0) + (lines - d / 2) * .0625f + d % 2 * .3125f;
                    float oZ = -spacer / 2f + d / 2 * .234375f;
                    float oY = 0;
                    float localItemX = itemDisplays[i][1] + oX;
                    float localItemY = itemDisplays[i][2] + oY;
                    float localItemZ = itemDisplays[i][3] + oZ;
                    float subProcess = itemDisplays[i][0] - d / 2 * 4;
                    float localAngle = itemDisplays[i][4];
                    if (// slide
                    subProcess <= 24) {
                        localAngle = 67.5f;
                        if (subProcess <= 19) {
                            localItemZ = -1 + .25f + (19 - subProcess) / 10f * .5f;
                            localItemY = -.34375f + .25f + (19 - subProcess) / 10f * .21875f;
                        } else {
                            localItemZ = -1 + (oZ - (24 - subProcess) / 5f * oZ);
                            localItemY = -.34375f + (24 - subProcess) / 5f * .25f;
                        }
                    }
                    GlStateManager.translate(localItemX, localItemY, localItemZ);
                    GlStateManager.rotate(localAngle, 1, 0, 0);
                    GlStateManager.scale(scale, scale, .5f);
                    ClientUtils.mc().getRenderItem().renderItem(dList.get(d), ItemCameraTransforms.TransformType.FIXED);
                    GlStateManager.scale(1 / scale, 1 / scale, 2);
                    GlStateManager.rotate(-localAngle, 1, 0, 0);
                    GlStateManager.translate(-localItemX, -localItemY, -localItemZ);
                }
            }
    }
    // Blueprint
    double playerDistanceSq = ClientUtils.mc().player.getDistanceSq(blockPos);
    if (!Config.IEConfig.disableFancyBlueprints && !blueprintStack.isEmpty() && playerDistanceSq < 1000) {
        BlueprintCraftingRecipe[] recipes = BlueprintCraftingRecipe.findRecipes(ItemNBTHelper.getString(blueprintStack, "blueprint"));
        BlueprintCraftingRecipe recipe = (te.selectedRecipe < 0 || te.selectedRecipe >= recipes.length) ? null : recipes[te.selectedRecipe];
        BlueprintLines blueprint = recipe == null ? null : getBlueprintDrawable(recipe, te.getWorld());
        if (blueprint != null) {
            // Width depends on distance
            float lineWidth = playerDistanceSq < 6 ? 3 : playerDistanceSq < 25 ? 2 : playerDistanceSq < 40 ? 1 : .5f;
            GlStateManager.translate(-.195, .125, .97);
            GlStateManager.rotate(-45, 1, 0, 0);
            GlStateManager.disableCull();
            GlStateManager.disableTexture2D();
            GlStateManager.enableBlend();
            float scale = .0375f / (blueprint.textureScale / 16f);
            GlStateManager.scale(scale, -scale, scale);
            GlStateManager.color(1, 1, 1, 1);
            blueprint.draw(lineWidth);
            GlStateManager.scale(1 / scale, -1 / scale, 1 / scale);
            GlStateManager.enableAlpha();
            GlStateManager.enableTexture2D();
            GlStateManager.enableCull();
        }
    }
    GlStateManager.popMatrix();
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) MultiblockProcess(blusunrize.immersiveengineering.common.blocks.metal.TileEntityMultiblockMetal.MultiblockProcess) EnumFacing(net.minecraft.util.EnumFacing) MultiblockProcessInWorld(blusunrize.immersiveengineering.common.blocks.metal.TileEntityMultiblockMetal.MultiblockProcessInWorld) BlueprintCraftingRecipe(blusunrize.immersiveengineering.api.crafting.BlueprintCraftingRecipe) IMultiblockRecipe(blusunrize.immersiveengineering.api.crafting.IMultiblockRecipe) BlockPos(net.minecraft.util.math.BlockPos) List(java.util.List) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel) ItemStack(net.minecraft.item.ItemStack)

Example 4 with MultiblockProcess

use of blusunrize.immersiveengineering.common.blocks.metal.TileEntityMultiblockMetal.MultiblockProcess in project ImmersiveEngineering by BluSunrize.

the class TileRenderMetalPress method render.

@Override
public void render(TileEntityMetalPress te, double x, double y, double z, float partialTicks, int destroyStage, float alpha) {
    if (!te.formed || te.isDummy() || !te.getWorld().isBlockLoaded(te.getPos(), false))
        return;
    final BlockRendererDispatcher blockRenderer = Minecraft.getMinecraft().getBlockRendererDispatcher();
    BlockPos blockPos = te.getPos();
    IBlockState state = getWorld().getBlockState(blockPos);
    if (state.getBlock() != IEContent.blockMetalMultiblock)
        return;
    state = state.getBlock().getActualState(state, getWorld(), blockPos);
    state = state.withProperty(IEProperties.DYNAMICRENDER, true);
    IBakedModel model = blockRenderer.getBlockModelShapes().getModelForState(state);
    Tessellator tessellator = Tessellator.getInstance();
    BufferBuilder worldRenderer = tessellator.getBuffer();
    ClientUtils.bindAtlas();
    GlStateManager.pushMatrix();
    GlStateManager.translate(x + .5, y + .5, z + .5);
    float piston = 0;
    float[] shift = new float[te.processQueue.size()];
    for (int i = 0; i < shift.length; i++) {
        MultiblockProcess process = te.processQueue.get(i);
        if (process == null)
            continue;
        float transportTime = 52.5f / 120f;
        float pressTime = 3.75f / 120f;
        float fProcess = (process.processTick + (te.shouldRenderAsActive() ? partialTicks : 0)) / (float) process.maxTicks;
        if (fProcess < transportTime)
            shift[i] = fProcess / transportTime * .5f;
        else if (fProcess < (1 - transportTime))
            shift[i] = .5f;
        else
            shift[i] = .5f + (fProcess - (1 - transportTime)) / transportTime * .5f;
        if (!te.mold.isEmpty())
            if (fProcess >= transportTime && fProcess < (1 - transportTime)) {
                if (fProcess < (transportTime + pressTime))
                    piston = (fProcess - transportTime) / pressTime;
                else if (fProcess < (1 - transportTime - pressTime))
                    piston = 1;
                else
                    piston = 1 - (fProcess - (1 - transportTime - pressTime)) / pressTime;
            }
    }
    GlStateManager.translate(0, -piston * .6875f, 0);
    RenderHelper.disableStandardItemLighting();
    GlStateManager.blendFunc(770, 771);
    GlStateManager.enableBlend();
    GlStateManager.disableCull();
    if (Minecraft.isAmbientOcclusionEnabled())
        GlStateManager.shadeModel(7425);
    else
        GlStateManager.shadeModel(7424);
    worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
    worldRenderer.setTranslation(-.5 - blockPos.getX(), -.5 - blockPos.getY(), -.5 - blockPos.getZ());
    worldRenderer.color(255, 255, 255, 255);
    blockRenderer.getBlockModelRenderer().renderModel(te.getWorld(), model, state, blockPos, worldRenderer, true);
    worldRenderer.setTranslation(0.0D, 0.0D, 0.0D);
    tessellator.draw();
    RenderHelper.enableStandardItemLighting();
    GlStateManager.rotate(te.facing == EnumFacing.SOUTH ? 180 : te.facing == EnumFacing.WEST ? 90 : te.facing == EnumFacing.EAST ? -90 : 0, 0, 1, 0);
    if (!te.mold.isEmpty()) {
        GlStateManager.pushMatrix();
        GlStateManager.translate(0, .34, 0);
        GlStateManager.rotate(-90, 1, 0, 0);
        float scale = .75f;
        GlStateManager.scale(scale, scale, 1);
        ClientUtils.mc().getRenderItem().renderItem(te.mold, ItemCameraTransforms.TransformType.FIXED);
        GlStateManager.scale(1 / scale, 1 / scale, 1);
        GlStateManager.popMatrix();
    }
    GlStateManager.translate(0, piston * .6875f, 0);
    GlStateManager.translate(0, -.35, 1.25);
    for (int i = 0; i < shift.length; i++) {
        MultiblockProcess process = te.processQueue.get(i);
        if (process == null || !(process instanceof MultiblockProcessInWorld))
            continue;
        GlStateManager.pushMatrix();
        GlStateManager.translate(0, 0, -2.5 * shift[i]);
        if (piston > .92)
            GlStateManager.translate(0, .92 - piston, 0);
        List<ItemStack> displays = ((MultiblockProcessInWorld) process).getDisplayItem();
        if (!displays.isEmpty()) {
            GlStateManager.rotate(-90, 1, 0, 0);
            float scale = .625f;
            GlStateManager.scale(scale, scale, 1);
            ClientUtils.mc().getRenderItem().renderItem(displays.get(0), ItemCameraTransforms.TransformType.FIXED);
            GlStateManager.popMatrix();
        }
    }
    GlStateManager.popMatrix();
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) MultiblockProcess(blusunrize.immersiveengineering.common.blocks.metal.TileEntityMultiblockMetal.MultiblockProcess) MultiblockProcessInWorld(blusunrize.immersiveengineering.common.blocks.metal.TileEntityMultiblockMetal.MultiblockProcessInWorld) BlockPos(net.minecraft.util.math.BlockPos) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel) ItemStack(net.minecraft.item.ItemStack)

Example 5 with MultiblockProcess

use of blusunrize.immersiveengineering.common.blocks.metal.TileEntityMultiblockMetal.MultiblockProcess in project ImmersiveEngineering by BluSunrize.

the class GuiMixer method drawGuiContainerBackgroundLayer.

@Override
protected void drawGuiContainerBackgroundLayer(float f, int mx, int my) {
    GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
    ClientUtils.bindTexture("immersiveengineering:textures/gui/mixer.png");
    this.drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);
    for (MultiblockProcess process : tile.processQueue) if (process instanceof MultiblockProcessInMachine) {
        float mod = 1 - (process.processTick / (float) process.maxTicks);
        for (int slot : ((MultiblockProcessInMachine) process).getInputSlots()) {
            int h = (int) Math.max(1, mod * 16);
            this.drawTexturedModalRect(guiLeft + 24 + slot % 2 * 21, guiTop + 7 + slot / 2 * 18 + (16 - h), 176, 16 - h, 2, h);
        }
    }
    int stored = (int) (46 * (tile.getEnergyStored(null) / (float) tile.getMaxEnergyStored(null)));
    ClientUtils.drawGradientRect(guiLeft + 158, guiTop + 22 + (46 - stored), guiLeft + 165, guiTop + 68, 0xffb51500, 0xff600b00);
    float capacity = tile.tank.getCapacity();
    int fluidUpToNow = 0;
    int lastY = 0;
    for (int i = tile.tank.getFluidTypes() - 1; i >= 0; i--) {
        FluidStack fs = tile.tank.fluids.get(i);
        if (fs != null && fs.getFluid() != null) {
            fluidUpToNow += fs.amount;
            int newY = (int) (47 * (fluidUpToNow / capacity));
            ClientUtils.drawRepeatedFluidSprite(fs, guiLeft + 76, guiTop + 58 - newY, 58, newY - lastY);
            lastY = newY;
        }
    }
}
Also used : MultiblockProcess(blusunrize.immersiveengineering.common.blocks.metal.TileEntityMultiblockMetal.MultiblockProcess) FluidStack(net.minecraftforge.fluids.FluidStack) MultiblockProcessInMachine(blusunrize.immersiveengineering.common.blocks.metal.TileEntityMultiblockMetal.MultiblockProcessInMachine)

Aggregations

MultiblockProcess (blusunrize.immersiveengineering.common.blocks.metal.TileEntityMultiblockMetal.MultiblockProcess)6 MultiblockProcessInWorld (blusunrize.immersiveengineering.common.blocks.metal.TileEntityMultiblockMetal.MultiblockProcessInWorld)4 IBlockState (net.minecraft.block.state.IBlockState)4 IBakedModel (net.minecraft.client.renderer.block.model.IBakedModel)4 ItemStack (net.minecraft.item.ItemStack)4 BlockPos (net.minecraft.util.math.BlockPos)4 BlueprintCraftingRecipe (blusunrize.immersiveengineering.api.crafting.BlueprintCraftingRecipe)2 IMultiblockRecipe (blusunrize.immersiveengineering.api.crafting.IMultiblockRecipe)2 MultiblockProcessInMachine (blusunrize.immersiveengineering.common.blocks.metal.TileEntityMultiblockMetal.MultiblockProcessInMachine)2 List (java.util.List)2 EnumFacing (net.minecraft.util.EnumFacing)2 FluidStack (net.minecraftforge.fluids.FluidStack)1