Search in sources :

Example 1 with IMultiblockRecipe

use of blusunrize.immersiveengineering.api.crafting.IMultiblockRecipe 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 IMultiblockRecipe

use of blusunrize.immersiveengineering.api.crafting.IMultiblockRecipe 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 3 with IMultiblockRecipe

use of blusunrize.immersiveengineering.api.crafting.IMultiblockRecipe in project ImmersiveEngineering by BluSunrize.

the class TileEntityMetalPress method onEntityCollision.

@Override
public void onEntityCollision(World world, Entity entity) {
    if (pos == 3 && !world.isRemote && entity != null && !entity.isDead && entity instanceof EntityItem && !((EntityItem) entity).getItem().isEmpty()) {
        TileEntityMetalPress master = master();
        if (master == null)
            return;
        ItemStack stack = ((EntityItem) entity).getItem();
        if (stack.isEmpty())
            return;
        IMultiblockRecipe recipe = master.findRecipeForInsertion(stack);
        if (recipe == null)
            return;
        ItemStack displayStack = recipe.getDisplayStack(stack);
        float transformationPoint = 56.25f / 120f;
        MultiblockProcess process = new MultiblockProcessInWorld(recipe, transformationPoint, Utils.createNonNullItemStackListFromItemStack(displayStack));
        if (master.addProcessToQueue(process, true)) {
            master.addProcessToQueue(process, false);
            stack.shrink(displayStack.getCount());
            if (stack.getCount() <= 0)
                entity.setDead();
        }
    }
}
Also used : IMultiblockRecipe(blusunrize.immersiveengineering.api.crafting.IMultiblockRecipe) ItemStack(net.minecraft.item.ItemStack) EntityItem(net.minecraft.entity.item.EntityItem)

Example 4 with IMultiblockRecipe

use of blusunrize.immersiveengineering.api.crafting.IMultiblockRecipe in project ImmersiveEngineering by BluSunrize.

the class TileEntityMultiblockMetal method readCustomNBT.

// =================================
// DATA MANAGEMENT
// =================================
@Override
public void readCustomNBT(NBTTagCompound nbt, boolean descPacket) {
    super.readCustomNBT(nbt, descPacket);
    energyStorage.readFromNBT(nbt);
    redstoneControlInverted = nbt.getBoolean("redstoneControlInverted");
    NBTTagList processNBT = nbt.getTagList("processQueue", 10);
    processQueue.clear();
    for (int i = 0; i < processNBT.tagCount(); i++) {
        NBTTagCompound tag = processNBT.getCompoundTagAt(i);
        IMultiblockRecipe recipe = readRecipeFromNBT(tag);
        if (recipe != null) {
            int processTick = tag.getInteger("process_processTick");
            MultiblockProcess process = loadProcessFromNBT(tag);
            if (process != null) {
                process.processTick = processTick;
                processQueue.add(process);
            }
        }
    }
    if (nbt.hasKey("computerOn", Constants.NBT.TAG_BYTE) && Loader.isModLoaded("opencomputers")) {
        byte cOn = nbt.getByte("computerOn");
        switch(cOn) {
            case 0:
                computerOn = Optional.of(false);
                break;
            case 1:
                computerOn = Optional.of(true);
                break;
            case 2:
                computerOn = Optional.empty();
                break;
        }
    }
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) IMultiblockRecipe(blusunrize.immersiveengineering.api.crafting.IMultiblockRecipe)

Aggregations

IMultiblockRecipe (blusunrize.immersiveengineering.api.crafting.IMultiblockRecipe)4 ItemStack (net.minecraft.item.ItemStack)3 BlueprintCraftingRecipe (blusunrize.immersiveengineering.api.crafting.BlueprintCraftingRecipe)2 MultiblockProcess (blusunrize.immersiveengineering.common.blocks.metal.TileEntityMultiblockMetal.MultiblockProcess)2 MultiblockProcessInWorld (blusunrize.immersiveengineering.common.blocks.metal.TileEntityMultiblockMetal.MultiblockProcessInWorld)2 List (java.util.List)2 IBlockState (net.minecraft.block.state.IBlockState)2 IBakedModel (net.minecraft.client.renderer.block.model.IBakedModel)2 EnumFacing (net.minecraft.util.EnumFacing)2 BlockPos (net.minecraft.util.math.BlockPos)2 EntityItem (net.minecraft.entity.item.EntityItem)1 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)1 NBTTagList (net.minecraft.nbt.NBTTagList)1