Search in sources :

Example 11 with NonNullList

use of net.minecraft.util.NonNullList in project Random-Things by lumien231.

the class ModRecipes method register.

public static void register() {
    for (int i = 0; i < oreDictDyes.length; i++) {
        oreDictDyes[i] = "dye" + dyes[i];
    }
    ArrayUtils.reverse(oreDictDyes);
    RecipeSorter.register("randomthings:customWorkbenchRecipe", RecipeWorkbench.class, Category.SHAPED, "");
    final ItemStack rottenFlesh = new ItemStack(Items.ROTTEN_FLESH);
    final ItemStack boneMeal = new ItemStack(Items.DYE, 1, 15);
    final ItemStack lapis = new ItemStack(Items.DYE, 1, 4);
    final ItemStack cobblestone = new ItemStack(Blocks.COBBLESTONE);
    final ItemStack ghastTear = new ItemStack(Items.GHAST_TEAR);
    final ItemStack vine = new ItemStack(Blocks.VINE);
    final ItemStack waterBottle = PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM), PotionTypes.WATER);
    final ItemStack mossyCobblestone = new ItemStack(Blocks.MOSSY_COBBLESTONE);
    final ItemStack netherBrick = new ItemStack(Blocks.NETHER_BRICK);
    final ItemStack coal = new ItemStack(Items.COAL);
    final ItemStack blazePowder = new ItemStack(Items.BLAZE_POWDER);
    final ItemStack flint = new ItemStack(Items.FLINT);
    final ItemStack spiderEye = new ItemStack(Items.SPIDER_EYE);
    final ItemStack redMushroom = new ItemStack(Blocks.RED_MUSHROOM);
    final ItemStack glowStone = new ItemStack(Items.GLOWSTONE_DUST);
    final ItemStack glisteringMelon = new ItemStack(Items.SPECKLED_MELON);
    final ItemStack witherSkull = new ItemStack(Items.SKULL, 1, 1);
    ForgeRegistries.RECIPES.register(new RecipeWorkbench());
    // Imbuing Station
    ImbuingRecipeHandler.addRecipe(waterBottle, vine, boneMeal, cobblestone, mossyCobblestone);
    ImbuingRecipeHandler.addRecipe(coal, flint, blazePowder, waterBottle, new ItemStack(ModItems.imbue, 1, 0));
    ImbuingRecipeHandler.addRecipe(spiderEye, rottenFlesh, redMushroom, waterBottle, new ItemStack(ModItems.imbue, 1, 1));
    ImbuingRecipeHandler.addRecipe(new ItemStack(ModItems.beans, 1, 1), lapis, glowStone, waterBottle, new ItemStack(ModItems.imbue, 1, 2));
    ImbuingRecipeHandler.addRecipe(witherSkull, netherBrick, ghastTear, waterBottle, new ItemStack(ModItems.imbue, 1, 3));
    // Anvil
    if (Loader.isModLoaded("baubles")) {
        AnvilRecipeHandler.addAnvilRecipe(new ItemStack(ModItems.obsidianSkull), new ItemStack(Items.FIRE_CHARGE), new ItemStack(ModItems.obsidianSkullRing), 3);
    }
    AnvilRecipeHandler.addAnvilRecipe(new ItemStack(ModItems.waterWalkingBoots), new ItemStack(ModItems.obsidianSkull), new ItemStack(ModItems.obsidianWaterWalkingBoots), 10);
    AnvilRecipeHandler.addAnvilRecipe(new ItemStack(ModItems.waterWalkingBoots), new ItemStack(ModItems.obsidianSkullRing), new ItemStack(ModItems.obsidianWaterWalkingBoots), 10);
    AnvilRecipeHandler.addAnvilRecipe(new ItemStack(ModItems.obsidianWaterWalkingBoots), new ItemStack(ModItems.lavaCharm), new ItemStack(ModItems.lavaWader), 15);
    // Spectre Anchor
    IRecipe anchorRecipe = new SimpleRecipe(new ResourceLocation("randomthings", "spectreAnchorCombine")) {

        @Override
        public boolean matches(InventoryCrafting inv, World worldIn) {
            ItemStack anchor = null;
            ItemStack target = null;
            for (int i = 0; i < inv.getSizeInventory(); i++) {
                ItemStack is = inv.getStackInSlot(i);
                if (!is.isEmpty()) {
                    if (is.getItem() == ModItems.spectreAnchor) {
                        if (anchor == null) {
                            anchor = is;
                        } else {
                            return false;
                        }
                    } else {
                        if (target == null) {
                            if (is.getMaxStackSize() != 1) {
                                return false;
                            } else {
                                target = is;
                            }
                        } else {
                            return false;
                        }
                    }
                }
            }
            return anchor != null && target != null && (!target.hasTagCompound() || !target.getTagCompound().hasKey("spectreAnchor"));
        }

        @Override
        public NonNullList<ItemStack> getRemainingItems(InventoryCrafting inv) {
            return NonNullList.withSize(inv.getSizeInventory(), ItemStack.EMPTY);
        }

        @Override
        public ItemStack getRecipeOutput() {
            return new ItemStack(ModItems.spectreAnchor);
        }

        @Override
        public ItemStack getCraftingResult(InventoryCrafting inv) {
            ItemStack anchor = null;
            ItemStack target = null;
            for (int i = 0; i < inv.getSizeInventory(); i++) {
                ItemStack is = inv.getStackInSlot(i);
                if (!is.isEmpty()) {
                    if (is.getItem() == ModItems.spectreAnchor) {
                        anchor = is;
                    } else {
                        target = is;
                    }
                }
            }
            ItemStack result = target.copy();
            result.setTagInfo("spectreAnchor", new NBTTagByte((byte) 0));
            return result;
        }

        @Override
        public boolean canFit(int width, int height) {
            return true;
        }
    };
    RecipeSorter.register("spectreAnchorCombine", anchorRecipe.getClass(), Category.SHAPELESS, "");
    ForgeRegistries.RECIPES.register(anchorRecipe);
    // Golden Compass
    IRecipe goldenCompassRecipe = new SimpleRecipe(new ResourceLocation("randomthings", "goldenCompassSetPosition")) {

        @Override
        public boolean matches(InventoryCrafting inv, World worldIn) {
            ItemStack compass = null;
            ItemStack target = null;
            for (int i = 0; i < inv.getSizeInventory(); i++) {
                ItemStack is = inv.getStackInSlot(i);
                if (!is.isEmpty()) {
                    if (is.getItem() == ModItems.goldenCompass) {
                        if (compass == null) {
                            compass = is;
                        } else {
                            return false;
                        }
                    } else {
                        if (target == null) {
                            if (is.getItem() == ModItems.positionFilter) {
                                target = is;
                            } else {
                                return false;
                            }
                        } else {
                            return false;
                        }
                    }
                }
            }
            return compass != null && target != null && (!target.hasTagCompound() || !target.getTagCompound().hasKey("spectreAnchor"));
        }

        @Override
        public NonNullList<ItemStack> getRemainingItems(InventoryCrafting inv) {
            NonNullList aitemstack = NonNullList.withSize(inv.getSizeInventory(), ItemStack.EMPTY);
            for (int i = 0; i < inv.getSizeInventory(); i++) {
                ItemStack is = inv.getStackInSlot(i);
                if (!is.isEmpty()) {
                    if (is.getItem() == ModItems.positionFilter) {
                        aitemstack.set(i, is.copy());
                    }
                }
            }
            return aitemstack;
        }

        @Override
        public ItemStack getRecipeOutput() {
            return new ItemStack(ModItems.goldenCompass);
        }

        @Override
        public ItemStack getCraftingResult(InventoryCrafting inv) {
            ItemStack compass = null;
            ItemStack target = null;
            for (int i = 0; i < inv.getSizeInventory(); i++) {
                ItemStack is = inv.getStackInSlot(i);
                if (!is.isEmpty()) {
                    if (is.getItem() == ModItems.goldenCompass) {
                        compass = is;
                    } else {
                        target = is;
                    }
                }
            }
            ItemStack result = compass.copy();
            BlockPos pos = ItemPositionFilter.getPosition(target);
            if (pos != null) {
                if (result.getTagCompound() == null) {
                    result.setTagCompound(new NBTTagCompound());
                }
                NBTTagCompound compound = result.getTagCompound();
                compound.setInteger("targetX", pos.getX());
                compound.setInteger("targetZ", pos.getZ());
            }
            return result;
        }

        @Override
        public boolean canFit(int width, int height) {
            return true;
        }
    };
    RecipeSorter.register("goldenCompass", goldenCompassRecipe.getClass(), Category.SHAPELESS, "");
    ForgeRegistries.RECIPES.register(goldenCompassRecipe);
    // Luminous Powder
    IRecipe luminousPowderRecipe = new SimpleRecipe(new ResourceLocation("randomthings", "luminousPowder")) {

        @Override
        public boolean matches(InventoryCrafting inv, World worldIn) {
            ItemStack powder = null;
            ItemStack target = null;
            for (int i = 0; i < inv.getSizeInventory(); i++) {
                ItemStack is = inv.getStackInSlot(i);
                if (!is.isEmpty()) {
                    if (is.getItem() == ModItems.ingredients && is.getItemDamage() == ItemIngredient.INGREDIENT.LUMINOUS_POWDER.id) {
                        if (powder == null) {
                            powder = is;
                        } else {
                            return false;
                        }
                    } else {
                        if (target == null) {
                            if (!is.isItemEnchanted()) {
                                return false;
                            } else {
                                target = is;
                            }
                        } else {
                            return false;
                        }
                    }
                }
            }
            return powder != null && target != null && (!target.hasTagCompound() || !target.getTagCompound().hasKey("luminousEnchantment"));
        }

        @Override
        public NonNullList<ItemStack> getRemainingItems(InventoryCrafting inv) {
            return NonNullList.withSize(inv.getSizeInventory(), ItemStack.EMPTY);
        }

        @Override
        public ItemStack getRecipeOutput() {
            return new ItemStack(ModItems.spectreAnchor);
        }

        @Override
        public ItemStack getCraftingResult(InventoryCrafting inv) {
            ItemStack powder = null;
            ItemStack target = null;
            for (int i = 0; i < inv.getSizeInventory(); i++) {
                ItemStack is = inv.getStackInSlot(i);
                if (!is.isEmpty()) {
                    if (is.getItem() == ModItems.ingredients) {
                        powder = is;
                    } else {
                        target = is;
                    }
                }
            }
            ItemStack result = target.copy();
            result.setTagInfo("luminousEnchantment", new NBTTagByte((byte) 0));
            return result;
        }

        @Override
        public boolean canFit(int width, int height) {
            return true;
        }
    };
    RecipeSorter.register("luminousPowder", luminousPowderRecipe.getClass(), Category.SHAPELESS, "");
    ForgeRegistries.RECIPES.register(luminousPowderRecipe);
    // Emerald Compass
    IRecipe emeraldCompassRecipe = new SimpleRecipe(new ResourceLocation("randomthings", "emeraldcompass_settarget")) {

        @Override
        public boolean matches(InventoryCrafting inv, World worldIn) {
            ItemStack compass = null;
            ItemStack target = null;
            for (int i = 0; i < inv.getSizeInventory(); i++) {
                ItemStack is = inv.getStackInSlot(i);
                if (!is.isEmpty()) {
                    if (is.getItem() == ModItems.emeraldCompass) {
                        if (compass == null) {
                            compass = is;
                        } else {
                            return false;
                        }
                    } else {
                        if (target == null) {
                            if (is.getItem() == ModItems.idCard) {
                                target = is;
                            } else {
                                return false;
                            }
                        } else {
                            return false;
                        }
                    }
                }
            }
            return compass != null && target != null && (!target.hasTagCompound() || !target.getTagCompound().hasKey("spectreAnchor"));
        }

        @Override
        public NonNullList<ItemStack> getRemainingItems(InventoryCrafting inv) {
            NonNullList aitemstack = NonNullList.withSize(inv.getSizeInventory(), ItemStack.EMPTY);
            for (int i = 0; i < inv.getSizeInventory(); i++) {
                ItemStack is = inv.getStackInSlot(i);
                if (!is.isEmpty()) {
                    if (is.getItem() == ModItems.idCard) {
                        aitemstack.set(i, is.copy());
                    }
                }
            }
            return aitemstack;
        }

        @Override
        public ItemStack getRecipeOutput() {
            return new ItemStack(ModItems.emeraldCompass);
        }

        @Override
        public ItemStack getCraftingResult(InventoryCrafting inv) {
            ItemStack compass = null;
            ItemStack target = null;
            for (int i = 0; i < inv.getSizeInventory(); i++) {
                ItemStack is = inv.getStackInSlot(i);
                if (!is.isEmpty()) {
                    if (is.getItem() == ModItems.emeraldCompass) {
                        compass = is;
                    } else {
                        target = is;
                    }
                }
            }
            ItemStack result = compass.copy();
            UUID uuid = ItemIDCard.getUUID(target);
            if (uuid != null) {
                if (result.getTagCompound() == null) {
                    result.setTagCompound(new NBTTagCompound());
                }
                NBTTagCompound compound = result.getTagCompound();
                compound.setString("uuid", uuid.toString());
            }
            return result;
        }

        @Override
        public boolean canFit(int width, int height) {
            return true;
        }
    };
    // Emerald Compass
    IRecipe portKeyCamoRecipe = new SimpleRecipe(new ResourceLocation("randomthings", "portkey_camo")) {

        @Override
        public boolean matches(InventoryCrafting inv, World worldIn) {
            ItemStack portkey = null;
            ItemStack camo = null;
            for (int i = 0; i < inv.getSizeInventory(); i++) {
                ItemStack is = inv.getStackInSlot(i);
                if (!is.isEmpty()) {
                    if (is.getItem() == ModItems.portKey) {
                        if (portkey == null) {
                            portkey = is;
                        } else {
                            return false;
                        }
                    } else if (is.getItem() != ModItems.portKey) {
                        if (camo == null) {
                            camo = is;
                        } else {
                            return false;
                        }
                    }
                }
            }
            return portkey != null && camo != null;
        }

        @Override
        public NonNullList<ItemStack> getRemainingItems(InventoryCrafting inv) {
            NonNullList aitemstack = NonNullList.withSize(inv.getSizeInventory(), ItemStack.EMPTY);
            for (int i = 0; i < inv.getSizeInventory(); i++) {
                ItemStack is = inv.getStackInSlot(i);
                if (!is.isEmpty()) {
                    if (is.getItem() != ModItems.portKey) {
                        aitemstack.set(i, is.copy());
                    }
                }
            }
            return aitemstack;
        }

        @Override
        public ItemStack getRecipeOutput() {
            return new ItemStack(ModItems.portKey);
        }

        @Override
        public ItemStack getCraftingResult(InventoryCrafting inv) {
            ItemStack portKey = null;
            ItemStack camo = null;
            for (int i = 0; i < inv.getSizeInventory(); i++) {
                ItemStack is = inv.getStackInSlot(i);
                if (!is.isEmpty()) {
                    if (is.getItem() == ModItems.portKey) {
                        portKey = is;
                    } else {
                        camo = is;
                    }
                }
            }
            ItemStack result = portKey.copy();
            UUID uuid = ItemIDCard.getUUID(camo);
            NBTTagCompound camoTag = result.getOrCreateSubCompound("camo");
            NBTTagCompound stackTag = new NBTTagCompound();
            camo.writeToNBT(stackTag);
            camoTag.setTag("stack", stackTag);
            return result;
        }

        @Override
        public boolean canFit(int width, int height) {
            return true;
        }
    };
    RecipeSorter.register("portKeyCamoRecipe", portKeyCamoRecipe.getClass(), Category.SHAPELESS, "");
    ForgeRegistries.RECIPES.register(portKeyCamoRecipe);
}
Also used : IRecipe(net.minecraft.item.crafting.IRecipe) NBTTagByte(net.minecraft.nbt.NBTTagByte) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) InventoryCrafting(net.minecraft.inventory.InventoryCrafting) World(net.minecraft.world.World) NonNullList(net.minecraft.util.NonNullList) ResourceLocation(net.minecraft.util.ResourceLocation) BlockPos(net.minecraft.util.math.BlockPos) ItemStack(net.minecraft.item.ItemStack) UUID(java.util.UUID)

Example 12 with NonNullList

use of net.minecraft.util.NonNullList in project BuildCraft by BuildCraft.

the class IntegrationRecipeBasic method matches.

protected boolean matches(@Nonnull ItemStack target, NonNullList<ItemStack> toIntegrate) {
    if (!StackUtil.contains(this.target, target)) {
        return false;
    }
    NonNullList<ItemStack> toIntegrateCopy = toIntegrate.stream().filter(stack -> !stack.isEmpty()).collect(StackUtil.nonNullListCollector());
    boolean stackMatches = this.toIntegrate.stream().allMatch((definition) -> {
        boolean matches = false;
        Iterator<ItemStack> iterator = toIntegrateCopy.iterator();
        while (iterator.hasNext()) {
            ItemStack stack = iterator.next();
            if (StackUtil.contains(definition, stack)) {
                matches = true;
                iterator.remove();
                break;
            }
        }
        return matches;
    });
    return stackMatches && toIntegrateCopy.isEmpty();
}
Also used : ItemStack(net.minecraft.item.ItemStack) List(java.util.List) Iterator(java.util.Iterator) ImmutableList(com.google.common.collect.ImmutableList) ResourceLocation(net.minecraft.util.ResourceLocation) BuildCraftAPI(buildcraft.api.core.BuildCraftAPI) StackUtil(buildcraft.lib.misc.StackUtil) NonNullList(net.minecraft.util.NonNullList) IngredientStack(buildcraft.api.recipes.IngredientStack) IntegrationRecipe(buildcraft.api.recipes.IntegrationRecipe) Nonnull(javax.annotation.Nonnull) ItemStack(net.minecraft.item.ItemStack)

Example 13 with NonNullList

use of net.minecraft.util.NonNullList in project BuildCraft by BuildCraft.

the class GuiList method getExamplesList.

private NonNullList<ItemStack> getExamplesList(int lineId, ListMatchHandler.Type type) {
    Map<ListMatchHandler.Type, NonNullList<ItemStack>> exampleList = exampleCache.computeIfAbsent(lineId, k -> new EnumMap<>(ListMatchHandler.Type.class));
    if (!exampleList.containsKey(type)) {
        NonNullList<ItemStack> examples = container.lines[lineId].getExamples();
        ItemStack input = container.lines[lineId].stacks.get(0);
        if (!input.isEmpty()) {
            NonNullList<ItemStack> repetitions = NonNullList.create();
            for (ItemStack is : examples) {
                if (StackUtil.isMatchingItem(input, is, true, false)) {
                    repetitions.add(is);
                }
            }
            examples.removeAll(repetitions);
        }
        exampleList.put(type, examples);
    }
    return exampleList.get(type);
}
Also used : NonNullList(net.minecraft.util.NonNullList) ItemStack(net.minecraft.item.ItemStack)

Example 14 with NonNullList

use of net.minecraft.util.NonNullList in project ImmersiveEngineering by BluSunrize.

the class IEContent method init.

public static void init() {
    /*ARC FURNACE RECYCLING*/
    if (IEConfig.Machines.arcfurnace_recycle) {
        arcRecycleThread = new ArcRecyclingThreadHandler();
        arcRecycleThread.start();
    }
    /*MINING LEVELS*/
    blockOre.setHarvestLevel("pickaxe", 1, blockOre.getStateFromMeta(BlockTypes_Ore.COPPER.getMeta()));
    blockOre.setHarvestLevel("pickaxe", 1, blockOre.getStateFromMeta(BlockTypes_Ore.ALUMINUM.getMeta()));
    blockOre.setHarvestLevel("pickaxe", 2, blockOre.getStateFromMeta(BlockTypes_Ore.LEAD.getMeta()));
    blockOre.setHarvestLevel("pickaxe", 2, blockOre.getStateFromMeta(BlockTypes_Ore.SILVER.getMeta()));
    blockOre.setHarvestLevel("pickaxe", 2, blockOre.getStateFromMeta(BlockTypes_Ore.NICKEL.getMeta()));
    blockOre.setHarvestLevel("pickaxe", 2, blockOre.getStateFromMeta(BlockTypes_Ore.URANIUM.getMeta()));
    blockStorage.setHarvestLevel("pickaxe", 1, blockStorage.getStateFromMeta(BlockTypes_MetalsIE.COPPER.getMeta()));
    blockStorage.setHarvestLevel("pickaxe", 1, blockStorage.getStateFromMeta(BlockTypes_MetalsIE.ALUMINUM.getMeta()));
    blockStorage.setHarvestLevel("pickaxe", 2, blockStorage.getStateFromMeta(BlockTypes_MetalsIE.LEAD.getMeta()));
    blockStorage.setHarvestLevel("pickaxe", 2, blockStorage.getStateFromMeta(BlockTypes_MetalsIE.SILVER.getMeta()));
    blockStorage.setHarvestLevel("pickaxe", 2, blockStorage.getStateFromMeta(BlockTypes_MetalsIE.NICKEL.getMeta()));
    blockStorage.setHarvestLevel("pickaxe", 2, blockStorage.getStateFromMeta(BlockTypes_MetalsIE.URANIUM.getMeta()));
    blockStorage.setHarvestLevel("pickaxe", 2, blockStorage.getStateFromMeta(BlockTypes_MetalsIE.CONSTANTAN.getMeta()));
    blockStorage.setHarvestLevel("pickaxe", 2, blockStorage.getStateFromMeta(BlockTypes_MetalsIE.ELECTRUM.getMeta()));
    blockStorage.setHarvestLevel("pickaxe", 2, blockStorage.getStateFromMeta(BlockTypes_MetalsIE.STEEL.getMeta()));
    /*WORLDGEN*/
    addConfiguredWorldgen(blockOre.getStateFromMeta(0), "copper", IEConfig.Ores.ore_copper);
    addConfiguredWorldgen(blockOre.getStateFromMeta(1), "bauxite", IEConfig.Ores.ore_bauxite);
    addConfiguredWorldgen(blockOre.getStateFromMeta(2), "lead", IEConfig.Ores.ore_lead);
    addConfiguredWorldgen(blockOre.getStateFromMeta(3), "silver", IEConfig.Ores.ore_silver);
    addConfiguredWorldgen(blockOre.getStateFromMeta(4), "nickel", IEConfig.Ores.ore_nickel);
    addConfiguredWorldgen(blockOre.getStateFromMeta(5), "uranium", IEConfig.Ores.ore_uranium);
    /*TILEENTITIES*/
    registerTile(TileEntityIESlab.class);
    registerTile(TileEntityBalloon.class);
    registerTile(TileEntityStripCurtain.class);
    registerTile(TileEntityShaderBanner.class);
    registerTile(TileEntityCokeOven.class);
    registerTile(TileEntityBlastFurnace.class);
    registerTile(TileEntityBlastFurnaceAdvanced.class);
    registerTile(TileEntityCoresample.class);
    registerTile(TileEntityAlloySmelter.class);
    registerTile(TileEntityWoodenCrate.class);
    registerTile(TileEntityWoodenBarrel.class);
    registerTile(TileEntityModWorkbench.class);
    registerTile(TileEntitySorter.class);
    registerTile(TileEntityTurntable.class);
    registerTile(TileEntityFluidSorter.class);
    registerTile(TileEntityWatermill.class);
    registerTile(TileEntityWindmill.class);
    registerTile(TileEntityWoodenPost.class);
    registerTile(TileEntityWallmount.class);
    registerTile(TileEntityLadder.class);
    registerTile(TileEntityLantern.class);
    registerTile(TileEntityRazorWire.class);
    registerTile(TileEntityToolbox.class);
    registerTile(TileEntityStructuralArm.class);
    registerTile(TileEntityConnectorLV.class);
    registerTile(TileEntityRelayLV.class);
    registerTile(TileEntityConnectorMV.class);
    registerTile(TileEntityRelayMV.class);
    registerTile(TileEntityConnectorHV.class);
    registerTile(TileEntityRelayHV.class);
    registerTile(TileEntityConnectorStructural.class);
    registerTile(TileEntityTransformer.class);
    registerTile(TileEntityTransformerHV.class);
    registerTile(TileEntityBreakerSwitch.class);
    registerTile(TileEntityRedstoneBreaker.class);
    registerTile(TileEntityEnergyMeter.class);
    registerTile(TileEntityConnectorRedstone.class);
    registerTile(TileEntityConnectorProbe.class);
    registerTile(TileEntityFeedthrough.class);
    registerTile(TileEntityCapacitorLV.class);
    registerTile(TileEntityCapacitorMV.class);
    registerTile(TileEntityCapacitorHV.class);
    registerTile(TileEntityCapacitorCreative.class);
    registerTile(TileEntityMetalBarrel.class);
    registerTile(TileEntityFluidPump.class);
    registerTile(TileEntityFluidPlacer.class);
    registerTile(TileEntityBlastFurnacePreheater.class);
    registerTile(TileEntityFurnaceHeater.class);
    registerTile(TileEntityDynamo.class);
    registerTile(TileEntityThermoelectricGen.class);
    registerTile(TileEntityElectricLantern.class);
    registerTile(TileEntityChargingStation.class);
    registerTile(TileEntityFluidPipe.class);
    registerTile(TileEntitySampleDrill.class);
    registerTile(TileEntityTeslaCoil.class);
    registerTile(TileEntityFloodlight.class);
    registerTile(TileEntityTurret.class);
    registerTile(TileEntityTurretChem.class);
    registerTile(TileEntityTurretGun.class);
    registerTile(TileEntityBelljar.class);
    registerTile(TileEntityConveyorBelt.class);
    registerTile(TileEntityConveyorVertical.class);
    registerTile(TileEntityMetalPress.class);
    registerTile(TileEntityCrusher.class);
    registerTile(TileEntitySheetmetalTank.class);
    registerTile(TileEntitySilo.class);
    registerTile(TileEntityAssembler.class);
    registerTile(TileEntityAutoWorkbench.class);
    registerTile(TileEntityBottlingMachine.class);
    registerTile(TileEntitySqueezer.class);
    registerTile(TileEntityFermenter.class);
    registerTile(TileEntityRefinery.class);
    registerTile(TileEntityDieselGenerator.class);
    registerTile(TileEntityBucketWheel.class);
    registerTile(TileEntityExcavator.class);
    registerTile(TileEntityArcFurnace.class);
    registerTile(TileEntityLightningrod.class);
    registerTile(TileEntityMixer.class);
    // registerTile(TileEntitySkycrateDispenser.class);
    registerTile(TileEntityFakeLight.class);
    /*ENTITIES*/
    int i = 0;
    EntityRegistry.registerModEntity(new ResourceLocation(ImmersiveEngineering.MODID, "revolverShot"), EntityRevolvershot.class, "revolverShot", i++, ImmersiveEngineering.instance, 64, 1, true);
    EntityRegistry.registerModEntity(new ResourceLocation(ImmersiveEngineering.MODID, "skylineHook"), EntitySkylineHook.class, "skylineHook", i++, ImmersiveEngineering.instance, 64, 1, true);
    // EntityRegistry.registerModEntity(EntitySkycrate.class, "skylineCrate", 2, ImmersiveEngineering.instance, 64, 1, true);
    EntityRegistry.registerModEntity(new ResourceLocation(ImmersiveEngineering.MODID, "revolverShotHoming"), EntityRevolvershotHoming.class, "revolverShotHoming", i++, ImmersiveEngineering.instance, 64, 1, true);
    EntityRegistry.registerModEntity(new ResourceLocation(ImmersiveEngineering.MODID, "revolverShotWolfpack"), EntityWolfpackShot.class, "revolverShotWolfpack", i++, ImmersiveEngineering.instance, 64, 1, true);
    EntityRegistry.registerModEntity(new ResourceLocation(ImmersiveEngineering.MODID, "chemthrowerShot"), EntityChemthrowerShot.class, "chemthrowerShot", i++, ImmersiveEngineering.instance, 64, 1, true);
    EntityRegistry.registerModEntity(new ResourceLocation(ImmersiveEngineering.MODID, "railgunShot"), EntityRailgunShot.class, "railgunShot", i++, ImmersiveEngineering.instance, 64, 5, true);
    EntityRegistry.registerModEntity(new ResourceLocation(ImmersiveEngineering.MODID, "revolverShotFlare"), EntityRevolvershotFlare.class, "revolverShotFlare", i++, ImmersiveEngineering.instance, 64, 1, true);
    EntityRegistry.registerModEntity(new ResourceLocation(ImmersiveEngineering.MODID, "explosive"), EntityIEExplosive.class, "explosive", i++, ImmersiveEngineering.instance, 64, 1, true);
    EntityRegistry.registerModEntity(new ResourceLocation(ImmersiveEngineering.MODID, "fluorescentTube"), EntityFluorescentTube.class, "fluorescentTube", i++, ImmersiveEngineering.instance, 64, 1, true);
    CapabilityShader.register();
    CapabilitySkyhookData.register();
    ShaderRegistry.itemShader = IEContent.itemShader;
    ShaderRegistry.itemShaderBag = IEContent.itemShaderBag;
    ShaderRegistry.itemExamples.add(new ItemStack(IEContent.itemRevolver));
    ShaderRegistry.itemExamples.add(new ItemStack(IEContent.itemDrill));
    ShaderRegistry.itemExamples.add(new ItemStack(IEContent.itemChemthrower));
    ShaderRegistry.itemExamples.add(new ItemStack(IEContent.itemRailgun));
    /*SMELTING*/
    itemMaterial.setBurnTime(6, 3200);
    Item itemBlockStoneDecoration = Item.getItemFromBlock(blockStoneDecoration);
    if (itemBlockStoneDecoration instanceof ItemBlockIEBase)
        ((ItemBlockIEBase) itemBlockStoneDecoration).setBurnTime(3, 3200 * 10);
    /*BANNERS*/
    addBanner("hammer", "hmr", new ItemStack(itemTool, 1, 0));
    addBanner("bevels", "bvl", "plateIron");
    addBanner("ornate", "orn", "dustSilver");
    addBanner("treated_wood", "twd", "plankTreatedWood");
    addBanner("windmill", "wnd", new ItemStack[] { new ItemStack(blockWoodenDevice1, 1, BlockTypes_WoodenDevice1.WINDMILL.getMeta()) });
    if (!BulletHandler.homingCartridges.isEmpty()) {
        ItemStack wolfpackCartridge = BulletHandler.getBulletStack("wolfpack");
        addBanner("wolf_r", "wlfr", wolfpackCartridge, 1);
        addBanner("wolf_l", "wlfl", wolfpackCartridge, -1);
        addBanner("wolf", "wlf", wolfpackCartridge, 0, 0);
    }
    /*ASSEMBLER RECIPE ADAPTERS*/
    // Fluid Ingredients
    AssemblerHandler.registerSpecialQueryConverters((o) -> {
        if (o instanceof IngredientFluidStack)
            return new RecipeQuery(((IngredientFluidStack) o).getFluid(), ((IngredientFluidStack) o).getFluid().amount);
        else
            return null;
    });
    // Potion bullets
    AssemblerHandler.registerRecipeAdapter(RecipePotionBullets.class, new IRecipeAdapter<RecipePotionBullets>() {

        @Nullable
        @Override
        public RecipeQuery[] getQueriedInputs(RecipePotionBullets recipe, NonNullList<ItemStack> input) {
            RecipeQuery bullet = null;
            RecipeQuery potion = null;
            for (int i = 0; i < input.size() - 1; ++i) {
                ItemStack s = input.get(i);
                if (!s.isEmpty()) {
                    if (bullet == null && RecipePotionBullets.isPotionBullet(s))
                        bullet = AssemblerHandler.createQueryFromItemStack(s);
                    else if (potion == null && s.getItem() instanceof ItemPotion)
                        potion = AssemblerHandler.createQuery(MixerPotionHelper.getFluidStackForType(PotionUtils.getPotionFromItem(s), 250));
                    else
                        return null;
                }
            }
            if (bullet == null || potion == null)
                return null;
            return new RecipeQuery[] { bullet, potion };
        }
    });
    DieselHandler.registerFuel(fluidBiodiesel, 125);
    DieselHandler.registerFuel(FluidRegistry.getFluid("fuel"), 375);
    DieselHandler.registerFuel(FluidRegistry.getFluid("diesel"), 175);
    DieselHandler.registerDrillFuel(fluidBiodiesel);
    DieselHandler.registerDrillFuel(FluidRegistry.getFluid("fuel"));
    DieselHandler.registerDrillFuel(FluidRegistry.getFluid("diesel"));
    blockFluidCreosote.setPotionEffects(new PotionEffect(IEPotions.flammable, 100, 0));
    blockFluidEthanol.setPotionEffects(new PotionEffect(MobEffects.NAUSEA, 40, 0));
    blockFluidBiodiesel.setPotionEffects(new PotionEffect(IEPotions.flammable, 100, 1));
    blockFluidConcrete.setPotionEffects(new PotionEffect(MobEffects.SLOWNESS, 20, 3, false, false));
    ChemthrowerHandler.registerEffect(FluidRegistry.WATER, new ChemthrowerEffect_Extinguish());
    ChemthrowerHandler.registerEffect(fluidPotion, new ChemthrowerEffect() {

        @Override
        public void applyToEntity(EntityLivingBase target, @Nullable EntityPlayer shooter, ItemStack thrower, FluidStack fluid) {
            if (fluid.tag != null) {
                List<PotionEffect> effects = PotionUtils.getEffectsFromTag(fluid.tag);
                for (PotionEffect e : effects) {
                    PotionEffect newEffect = new PotionEffect(e.getPotion(), (int) Math.ceil(e.getDuration() * .05), e.getAmplifier());
                    newEffect.setCurativeItems(new ArrayList(e.getCurativeItems()));
                    target.addPotionEffect(newEffect);
                }
            }
        }

        @Override
        public void applyToEntity(EntityLivingBase target, @Nullable EntityPlayer shooter, ItemStack thrower, Fluid fluid) {
        }

        @Override
        public void applyToBlock(World world, RayTraceResult mop, @Nullable EntityPlayer shooter, ItemStack thrower, FluidStack fluid) {
        }

        @Override
        public void applyToBlock(World world, RayTraceResult mop, @Nullable EntityPlayer shooter, ItemStack thrower, Fluid fluid) {
        }
    });
    ChemthrowerHandler.registerEffect(fluidConcrete, new ChemthrowerEffect() {

        @Override
        public void applyToEntity(EntityLivingBase target, @Nullable EntityPlayer shooter, ItemStack thrower, FluidStack fluid) {
            hit(target.world, target.getPosition(), EnumFacing.UP);
        }

        @Override
        public void applyToEntity(EntityLivingBase target, @Nullable EntityPlayer shooter, ItemStack thrower, Fluid fluid) {
        }

        @Override
        public void applyToBlock(World world, RayTraceResult mop, @Nullable EntityPlayer shooter, ItemStack thrower, FluidStack fluid) {
            IBlockState hit = world.getBlockState(mop.getBlockPos());
            if (hit.getBlock() != blockStoneDecoration || hit.getBlock().getMetaFromState(hit) != BlockTypes_StoneDecoration.CONCRETE_SPRAYED.getMeta()) {
                BlockPos pos = mop.getBlockPos().offset(mop.sideHit);
                if (!world.isAirBlock(pos))
                    return;
                AxisAlignedBB aabb = new AxisAlignedBB(pos);
                List<EntityChemthrowerShot> otherProjectiles = world.getEntitiesWithinAABB(EntityChemthrowerShot.class, aabb);
                if (otherProjectiles.size() >= 8)
                    hit(world, pos, mop.sideHit);
            }
        }

        @Override
        public void applyToBlock(World world, RayTraceResult mop, @Nullable EntityPlayer shooter, ItemStack thrower, Fluid fluid) {
        }

        private void hit(World world, BlockPos pos, EnumFacing side) {
            AxisAlignedBB aabb = new AxisAlignedBB(pos);
            List<EntityChemthrowerShot> otherProjectiles = world.getEntitiesWithinAABB(EntityChemthrowerShot.class, aabb);
            for (EntityChemthrowerShot shot : otherProjectiles) shot.setDead();
            world.setBlockState(pos, blockStoneDecoration.getStateFromMeta(BlockTypes_StoneDecoration.CONCRETE_SPRAYED.getMeta()));
            for (EntityLivingBase living : world.getEntitiesWithinAABB(EntityLivingBase.class, aabb)) living.addPotionEffect(new PotionEffect(IEPotions.concreteFeet, Integer.MAX_VALUE));
        }
    });
    ChemthrowerHandler.registerEffect(fluidCreosote, new ChemthrowerEffect_Potion(null, 0, IEPotions.flammable, 140, 0));
    ChemthrowerHandler.registerFlammable(fluidCreosote);
    ChemthrowerHandler.registerEffect(fluidBiodiesel, new ChemthrowerEffect_Potion(null, 0, IEPotions.flammable, 140, 1));
    ChemthrowerHandler.registerFlammable(fluidBiodiesel);
    ChemthrowerHandler.registerFlammable(fluidEthanol);
    ChemthrowerHandler.registerEffect("oil", new ChemthrowerEffect_Potion(null, 0, new PotionEffect(IEPotions.flammable, 140, 0), new PotionEffect(MobEffects.BLINDNESS, 80, 1)));
    ChemthrowerHandler.registerFlammable("oil");
    ChemthrowerHandler.registerEffect("fuel", new ChemthrowerEffect_Potion(null, 0, IEPotions.flammable, 100, 1));
    ChemthrowerHandler.registerFlammable("fuel");
    ChemthrowerHandler.registerEffect("diesel", new ChemthrowerEffect_Potion(null, 0, IEPotions.flammable, 140, 1));
    ChemthrowerHandler.registerFlammable("diesel");
    ChemthrowerHandler.registerEffect("kerosene", new ChemthrowerEffect_Potion(null, 0, IEPotions.flammable, 100, 1));
    ChemthrowerHandler.registerFlammable("kerosene");
    ChemthrowerHandler.registerEffect("biofuel", new ChemthrowerEffect_Potion(null, 0, IEPotions.flammable, 140, 1));
    ChemthrowerHandler.registerFlammable("biofuel");
    ChemthrowerHandler.registerEffect("rocket_fuel", new ChemthrowerEffect_Potion(null, 0, IEPotions.flammable, 60, 2));
    ChemthrowerHandler.registerFlammable("rocket_fuel");
    RailgunHandler.registerProjectileProperties(new IngredientStack("stickIron"), 15, 1.25).setColourMap(new int[][] { { 0xd8d8d8, 0xd8d8d8, 0xd8d8d8, 0xa8a8a8, 0x686868, 0x686868 } });
    RailgunHandler.registerProjectileProperties(new IngredientStack("stickAluminum"), 13, 1.05).setColourMap(new int[][] { { 0xd8d8d8, 0xd8d8d8, 0xd8d8d8, 0xa8a8a8, 0x686868, 0x686868 } });
    RailgunHandler.registerProjectileProperties(new IngredientStack("stickSteel"), 18, 1.25).setColourMap(new int[][] { { 0xb4b4b4, 0xb4b4b4, 0xb4b4b4, 0x7a7a7a, 0x555555, 0x555555 } });
    RailgunHandler.registerProjectileProperties(new ItemStack(itemGraphiteElectrode), 24, .9).setColourMap(new int[][] { { 0x242424, 0x242424, 0x242424, 0x171717, 0x171717, 0x0a0a0a } });
    ExternalHeaterHandler.defaultFurnaceEnergyCost = IEConfig.Machines.heater_consumption;
    ExternalHeaterHandler.defaultFurnaceSpeedupCost = IEConfig.Machines.heater_speedupConsumption;
    ExternalHeaterHandler.registerHeatableAdapter(TileEntityFurnace.class, new DefaultFurnaceAdapter());
    BelljarHandler.DefaultPlantHandler hempBelljarHandler = new BelljarHandler.DefaultPlantHandler() {

        private HashSet<ComparableItemStack> validSeeds = new HashSet<>();

        @Override
        protected HashSet<ComparableItemStack> getSeedSet() {
            return validSeeds;
        }

        @Override
        @SideOnly(Side.CLIENT)
        public IBlockState[] getRenderedPlant(ItemStack seed, ItemStack soil, float growth, TileEntity tile) {
            int age = Math.min(4, Math.round(growth * 4));
            if (age == 4)
                return new IBlockState[] { blockCrop.getStateFromMeta(age), blockCrop.getStateFromMeta(age + 1) };
            return new IBlockState[] { blockCrop.getStateFromMeta(age) };
        }

        @Override
        @SideOnly(Side.CLIENT)
        public float getRenderSize(ItemStack seed, ItemStack soil, float growth, TileEntity tile) {
            return .6875f;
        }
    };
    BelljarHandler.registerHandler(hempBelljarHandler);
    hempBelljarHandler.register(new ItemStack(itemSeeds), new ItemStack[] { new ItemStack(itemMaterial, 4, 4), new ItemStack(itemSeeds, 2) }, new ItemStack(Blocks.DIRT), blockCrop.getDefaultState());
    ThermoelectricHandler.registerSource(new IngredientStack(new ItemStack(Blocks.MAGMA)), 1300);
    ThermoelectricHandler.registerSourceInKelvin("blockIce", 273);
    ThermoelectricHandler.registerSourceInKelvin("blockPackedIce", 200);
    ThermoelectricHandler.registerSourceInKelvin("blockUranium", 2000);
    ThermoelectricHandler.registerSourceInKelvin("blockYellorium", 2000);
    ThermoelectricHandler.registerSourceInKelvin("blockPlutonium", 4000);
    ThermoelectricHandler.registerSourceInKelvin("blockBlutonium", 4000);
    /*MULTIBLOCKS*/
    MultiblockHandler.registerMultiblock(MultiblockCokeOven.instance);
    MultiblockHandler.registerMultiblock(MultiblockAlloySmelter.instance);
    MultiblockHandler.registerMultiblock(MultiblockBlastFurnace.instance);
    MultiblockHandler.registerMultiblock(MultiblockBlastFurnaceAdvanced.instance);
    MultiblockHandler.registerMultiblock(MultiblockMetalPress.instance);
    MultiblockHandler.registerMultiblock(MultiblockCrusher.instance);
    MultiblockHandler.registerMultiblock(MultiblockSheetmetalTank.instance);
    MultiblockHandler.registerMultiblock(MultiblockSilo.instance);
    MultiblockHandler.registerMultiblock(MultiblockAssembler.instance);
    MultiblockHandler.registerMultiblock(MultiblockAutoWorkbench.instance);
    MultiblockHandler.registerMultiblock(MultiblockBottlingMachine.instance);
    MultiblockHandler.registerMultiblock(MultiblockSqueezer.instance);
    MultiblockHandler.registerMultiblock(MultiblockFermenter.instance);
    MultiblockHandler.registerMultiblock(MultiblockRefinery.instance);
    MultiblockHandler.registerMultiblock(MultiblockDieselGenerator.instance);
    MultiblockHandler.registerMultiblock(MultiblockExcavator.instance);
    MultiblockHandler.registerMultiblock(MultiblockBucketWheel.instance);
    MultiblockHandler.registerMultiblock(MultiblockArcFurnace.instance);
    MultiblockHandler.registerMultiblock(MultiblockLightningrod.instance);
    MultiblockHandler.registerMultiblock(MultiblockMixer.instance);
    MultiblockHandler.registerMultiblock(MultiblockFeedthrough.instance);
    /*VILLAGE*/
    IEVillagerHandler.initIEVillagerHouse();
    IEVillagerHandler.initIEVillagerTrades();
    /*LOOT*/
    if (IEConfig.villagerHouse)
        LootTableList.register(VillageEngineersHouse.woodenCrateLoot);
    for (ResourceLocation rl : EventHandler.lootInjections) LootTableList.register(rl);
    // //Railcraft Compat
    // if(Loader.isModLoaded("Railcraft"))
    // {
    // Block rcCube = GameRegistry.findBlock("Railcraft", "cube");
    // if(rcCube!=null)
    // OreDictionary.registerOre("blockFuelCoke", new ItemStack(rcCube,1,0));
    // }
    /*BLOCK ITEMS FROM CRATES*/
    IEApi.forbiddenInCrates.add((stack) -> {
        if (stack.getItem() == IEContent.itemToolbox)
            return true;
        if (stack.getItem() == IEContent.itemToolbox)
            return true;
        if (OreDictionary.itemMatches(new ItemStack(IEContent.blockWoodenDevice0, 1, 0), stack, true))
            return true;
        if (OreDictionary.itemMatches(new ItemStack(IEContent.blockWoodenDevice0, 1, 5), stack, true))
            return true;
        return stack.getItem() instanceof ItemShulkerBox;
    });
    TileEntityFluidPipe.initCovers();
    IEDataFixers.register();
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) ItemPotion(net.minecraft.item.ItemPotion) FluidStack(net.minecraftforge.fluids.FluidStack) EnumFacing(net.minecraft.util.EnumFacing) ItemShulkerBox(net.minecraft.item.ItemShulkerBox) World(net.minecraft.world.World) ChemthrowerEffect_Potion(blusunrize.immersiveengineering.api.tool.ChemthrowerHandler.ChemthrowerEffect_Potion) TileEntity(net.minecraft.tileentity.TileEntity) Item(net.minecraft.item.Item) ChemthrowerEffect_Extinguish(blusunrize.immersiveengineering.api.tool.ChemthrowerHandler.ChemthrowerEffect_Extinguish) ResourceLocation(net.minecraft.util.ResourceLocation) NonNullList(net.minecraft.util.NonNullList) LootTableList(net.minecraft.world.storage.loot.LootTableList) BlockPos(net.minecraft.util.math.BlockPos) ChemthrowerEffect(blusunrize.immersiveengineering.api.tool.ChemthrowerHandler.ChemthrowerEffect) IBlockState(net.minecraft.block.state.IBlockState) Fluid(net.minecraftforge.fluids.Fluid) IEFluid(blusunrize.immersiveengineering.common.util.IEFluid) RayTraceResult(net.minecraft.util.math.RayTraceResult) DefaultFurnaceAdapter(blusunrize.immersiveengineering.api.tool.ExternalHeaterHandler.DefaultFurnaceAdapter) RecipeQuery(blusunrize.immersiveengineering.api.tool.AssemblerHandler.RecipeQuery) EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ItemStack(net.minecraft.item.ItemStack) Nullable(javax.annotation.Nullable)

Example 15 with NonNullList

use of net.minecraft.util.NonNullList in project ImmersiveEngineering by BluSunrize.

the class TileEntityArcFurnace method update.

@Override
public void update() {
    super.update();
    if (isDummy())
        return;
    if (world.isRemote) {
        if (pouringMetal > 0)
            pouringMetal--;
        if (shouldRenderAsActive())
            for (int i = 0; i < 4; i++) {
                if (Utils.RAND.nextInt(6) == 0)
                    ImmersiveEngineering.proxy.spawnSparkFX(world, getPos().getX() + .5 - .25 * facing.getXOffset(), getPos().getY() + 2.9, getPos().getZ() + .5 - .25 * facing.getZOffset(), Utils.RAND.nextDouble() * .05 - .025, .025, Utils.RAND.nextDouble() * .05 - .025);
                if (Utils.RAND.nextInt(6) == 0)
                    ImmersiveEngineering.proxy.spawnSparkFX(world, getPos().getX() + .5 + (facing == EnumFacing.EAST ? -.25 : .25), getPos().getY() + 2.9, getPos().getZ() + .5 + (facing == EnumFacing.SOUTH ? .25 : -.25), Utils.RAND.nextDouble() * .05 - .025, .025, Utils.RAND.nextDouble() * .05 - .025);
                if (Utils.RAND.nextInt(6) == 0)
                    ImmersiveEngineering.proxy.spawnSparkFX(world, getPos().getX() + .5 + (facing == EnumFacing.WEST ? .25 : -.25), getPos().getY() + 2.9, getPos().getZ() + .5 + (facing == EnumFacing.NORTH ? -.25 : .25), Utils.RAND.nextDouble() * .05 - .025, .025, Utils.RAND.nextDouble() * .05 - .025);
            }
    } else if (!isRSDisabled() && energyStorage.getEnergyStored() > 0) {
        if (this.tickedProcesses > 0)
            for (int i = 23; i < 26; i++) if (this.inventory.get(i).attemptDamageItem(1, Utils.RAND, null)) {
                this.inventory.set(i, ItemStack.EMPTY);
            // updateClient = true;
            // update = true;
            }
        if (this.processQueue.size() < this.getProcessQueueMaxLength()) {
            Map<Integer, Integer> usedInvSlots = new HashMap<Integer, Integer>();
            for (MultiblockProcess<ArcFurnaceRecipe> process : processQueue) if (process instanceof MultiblockProcessInMachine) {
                int[] inputSlots = ((MultiblockProcessInMachine<ArcFurnaceRecipe>) process).getInputSlots();
                int[] inputAmounts = ((MultiblockProcessInMachine<ArcFurnaceRecipe>) process).getInputAmounts();
                if (inputAmounts != null)
                    for (int i = 0; i < inputSlots.length; i++) if (usedInvSlots.containsKey(inputSlots[i]))
                        usedInvSlots.put(inputSlots[i], usedInvSlots.get(inputSlots[i]) + inputAmounts[i]);
                    else
                        usedInvSlots.put(inputSlots[i], inputAmounts[i]);
            }
            NonNullList<ItemStack> additives = NonNullList.withSize(4, ItemStack.EMPTY);
            for (int i = 0; i < 4; i++) if (!inventory.get(12 + i).isEmpty()) {
                additives.set(i, inventory.get(12 + i).copy());
                if (usedInvSlots.containsKey(12 + i))
                    additives.get(i).shrink(usedInvSlots.get(12 + i));
            }
            for (int slot = 0; slot < 12; slot++) if (!usedInvSlots.containsKey(slot)) {
                ItemStack stack = this.getInventory().get(slot);
                if (!stack.isEmpty() && stack.getCount() > 0) {
                    ArcFurnaceRecipe recipe = ArcFurnaceRecipe.findRecipe(stack, additives);
                    if (recipe != null) {
                        MultiblockProcessArcFurnace process = new MultiblockProcessArcFurnace(recipe, slot, 12, 13, 14, 15);
                        if (this.addProcessToQueue(process, true)) {
                            this.addProcessToQueue(process, false);
                            int[] consumedAdditives = recipe.getConsumedAdditives(additives, true);
                            if (consumedAdditives != null)
                                process.setInputAmounts(recipe.input.inputSize, consumedAdditives[0], consumedAdditives[1], consumedAdditives[2], consumedAdditives[3]);
                        // update = true;
                        }
                    }
                }
            }
        }
        if (world.getTotalWorldTime() % 8 == 0) {
            BlockPos outputPos = this.getBlockPosForPos(2).offset(facing, -1);
            TileEntity outputTile = Utils.getExistingTileEntity(world, outputPos);
            if (outputTile != null)
                for (int j = 16; j < 22; j++) if (!inventory.get(j).isEmpty()) {
                    ItemStack stack = Utils.copyStackWithAmount(inventory.get(j), 1);
                    stack = Utils.insertStackIntoInventory(outputTile, stack, facing.getOpposite());
                    if (stack.isEmpty()) {
                        this.inventory.get(j).shrink(1);
                        if (this.inventory.get(j).getCount() <= 0)
                            this.inventory.set(j, ItemStack.EMPTY);
                    }
                }
            outputPos = this.getBlockPosForPos(22).offset(facing);
            outputTile = Utils.getExistingTileEntity(world, outputPos);
            if (outputTile != null)
                if (!inventory.get(22).isEmpty()) {
                    int out = Math.min(inventory.get(22).getCount(), 16);
                    ItemStack stack = Utils.copyStackWithAmount(inventory.get(22), out);
                    stack = Utils.insertStackIntoInventory(outputTile, stack, facing);
                    if (!stack.isEmpty())
                        out -= stack.getCount();
                    this.inventory.get(22).shrink(out);
                    if (this.inventory.get(22).getCount() <= 0)
                        this.inventory.set(22, ItemStack.EMPTY);
                }
        }
    }
}
Also used : ArcFurnaceRecipe(blusunrize.immersiveengineering.api.crafting.ArcFurnaceRecipe) TileEntity(net.minecraft.tileentity.TileEntity) NonNullList(net.minecraft.util.NonNullList) BlockPos(net.minecraft.util.math.BlockPos) ItemStack(net.minecraft.item.ItemStack)

Aggregations

NonNullList (net.minecraft.util.NonNullList)42 ItemStack (net.minecraft.item.ItemStack)37 List (java.util.List)13 EntityPlayer (net.minecraft.entity.player.EntityPlayer)8 Item (net.minecraft.item.Item)8 TileEntity (net.minecraft.tileentity.TileEntity)8 BlockPos (net.minecraft.util.math.BlockPos)7 ArrayList (java.util.ArrayList)6 Collectors (java.util.stream.Collectors)6 ResourceLocation (net.minecraft.util.ResourceLocation)6 Iterator (java.util.Iterator)5 Map (java.util.Map)5 Nonnull (javax.annotation.Nonnull)5 Nullable (javax.annotation.Nullable)5 CreativeTabs (net.minecraft.creativetab.CreativeTabs)5 World (net.minecraft.world.World)5 Block (net.minecraft.block.Block)4 IBlockState (net.minecraft.block.state.IBlockState)4 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)4 RayTraceResult (net.minecraft.util.math.RayTraceResult)4