Search in sources :

Example 31 with NonNullList

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

the class MCMod method getItems.

@Override
public IItemStack[] getItems() {
    List<IItemStack> stacks = new ArrayList<>();
    List<Item> items = BracketHandlerItem.getItemNames().values().stream().filter(item -> item.getRegistryName().getResourceDomain().equals(mod.getModId())).collect(Collectors.toList());
    for (Item item : items) {
        if (item == null)
            continue;
        NonNullList<ItemStack> list = NonNullList.create();
        item.getSubItems(CreativeTabs.SEARCH, list);
        for (ItemStack stack : list) {
            stacks.add(CraftTweakerMC.getIItemStack(stack));
        }
    }
    return stacks.toArray(new IItemStack[0]);
}
Also used : BracketHandlerItem(crafttweaker.mc1120.brackets.BracketHandlerItem) IMod(crafttweaker.api.mods.IMod) java.util(java.util) IItemStack(crafttweaker.api.item.IItemStack) CraftTweakerMC(crafttweaker.api.minecraft.CraftTweakerMC) net.minecraft.item(net.minecraft.item) CreativeTabs(net.minecraft.creativetab.CreativeTabs) NonNullList(net.minecraft.util.NonNullList) ModContainer(net.minecraftforge.fml.common.ModContainer) Collectors(java.util.stream.Collectors) BracketHandlerItem(crafttweaker.mc1120.brackets.BracketHandlerItem) IItemStack(crafttweaker.api.item.IItemStack) IItemStack(crafttweaker.api.item.IItemStack)

Example 32 with NonNullList

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

the class FabricatorRecipeManager method addRecipe.

@Override
public void addRecipe(ItemStack plan, FluidStack molten, ItemStack result, Object[] pattern) {
    ShapedRecipeCustom patternRecipe = new ShapedRecipeCustom(result, pattern);
    NonNullList<NonNullList<ItemStack>> ingredients = patternRecipe.getRawIngredients();
    IFabricatorRecipe recipe = new FabricatorRecipe(plan, molten, result, ingredients, patternRecipe.getOreDicts(), patternRecipe.getWidth(), patternRecipe.getHeight());
    addRecipe(recipe);
}
Also used : NonNullList(net.minecraft.util.NonNullList) IFabricatorRecipe(forestry.api.recipes.IFabricatorRecipe) IFabricatorRecipe(forestry.api.recipes.IFabricatorRecipe) ShapedRecipeCustom(forestry.core.recipes.ShapedRecipeCustom)

Example 33 with NonNullList

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

the class FabricatorRecipeWrapper method getIngredients.

@Override
public void getIngredients(IIngredients ingredients) {
    IFabricatorRecipe recipe = getRecipe();
    NonNullList<NonNullList<ItemStack>> itemInputs = recipe.getIngredients();
    List<List<ItemStack>> inputStacks = new ArrayList<>();
    for (List<ItemStack> stacks : itemInputs) {
        List<ItemStack> copy = new ArrayList<>();
        copy.addAll(stacks);
        inputStacks.add(copy);
    }
    ingredients.setInputLists(ItemStack.class, inputStacks);
    ingredients.setInputs(FluidStack.class, Collections.singletonList(getRecipe().getLiquid()));
    ingredients.setOutput(ItemStack.class, recipe.getRecipeOutput());
}
Also used : NonNullList(net.minecraft.util.NonNullList) ArrayList(java.util.ArrayList) List(java.util.List) NonNullList(net.minecraft.util.NonNullList) ArrayList(java.util.ArrayList) IFabricatorRecipe(forestry.api.recipes.IFabricatorRecipe) ItemStack(net.minecraft.item.ItemStack)

Example 34 with NonNullList

use of net.minecraft.util.NonNullList in project BetterWithAddons by DaedalusGame.

the class ModItems method load.

public static void load(FMLPreInitializationEvent event) {
    /*arrowhead = registerItem("arrowhead",new Item());
        midori = registerItem("midori",new Item());
        midori_popped = registerItem("midori_popped",new Item());
        stone_brick = registerItem("stone_brick",new Item());
        bone_ingot = registerItem("bone_ingot",new Item());
        ender_cream = registerItem("ender_cream",new Item());
        thornrose = registerItem("thornrose",new Item());*/
    ironSpade = (ItemSpade) registerItem("iron_spade", new ItemSpade(Item.ToolMaterial.IRON));
    ironMatchPick = (ItemMatchPick) registerItem("iron_matchpick", new ItemMatchPick(Item.ToolMaterial.IRON));
    ironMachete = (ItemMachete) registerItem("iron_machete", new ItemMachete(Item.ToolMaterial.IRON));
    ironKukri = (ItemKukri) registerItem("iron_kukri", new ItemKukri(Item.ToolMaterial.IRON, 8.0f, -3.1f));
    ironCarpenterSaw = (ItemCarpenterSaw) registerItem("iron_carpentersaw", new ItemCarpenterSaw(Item.ToolMaterial.IRON, 8.0f, -3.1f));
    ironMasonPick = (ItemMasonPick) registerItem("iron_masonpick", new ItemMasonPick(Item.ToolMaterial.IRON));
    goldSpade = (ItemSpade) registerItem("gold_spade", new ItemSpade(Item.ToolMaterial.GOLD));
    goldMatchPick = (ItemMatchPick) registerItem("gold_matchpick", new ItemMatchPick(Item.ToolMaterial.GOLD));
    goldMachete = (ItemMachete) registerItem("gold_machete", new ItemMachete(Item.ToolMaterial.GOLD));
    goldKukri = (ItemKukri) registerItem("gold_kukri", new ItemKukri(Item.ToolMaterial.GOLD, 6.0f, -3.0f));
    goldCarpenterSaw = (ItemCarpenterSaw) registerItem("gold_carpentersaw", new ItemCarpenterSaw(Item.ToolMaterial.GOLD, 6.0f, -3.0f));
    goldMasonPick = (ItemMasonPick) registerItem("gold_masonpick", new ItemMasonPick(Item.ToolMaterial.GOLD));
    diamondSpade = (ItemSpade) registerItem("diamond_spade", new ItemSpade(Item.ToolMaterial.DIAMOND));
    diamondMatchPick = (ItemMatchPick) registerItem("diamond_matchpick", new ItemMatchPick(Item.ToolMaterial.DIAMOND));
    diamondMachete = (ItemMachete) registerItem("diamond_machete", new ItemMachete(Item.ToolMaterial.DIAMOND));
    diamondKukri = (ItemKukri) registerItem("diamond_kukri", new ItemKukri(Item.ToolMaterial.DIAMOND, 8.0f, -3.0f));
    diamondCarpenterSaw = (ItemCarpenterSaw) registerItem("diamond_carpentersaw", new ItemCarpenterSaw(Item.ToolMaterial.DIAMOND, 8.0f, -3.0f));
    diamondMasonPick = (ItemMasonPick) registerItem("diamond_masonpick", new ItemMasonPick(Item.ToolMaterial.DIAMOND));
    steelSpade = (ItemSpade) registerItem("steel_spade", new ItemSpade(BWMItems.SOULFORGED_STEEL) {

        @Override
        public boolean getIsRepairable(ItemStack toRepair, ItemStack repair) {
            return ItemUtil.matchesOreDict(repair, "ingotSoulforgedSteel") || super.getIsRepairable(toRepair, repair);
        }
    });
    steelMatchPick = (ItemMatchPick) registerItem("steel_matchpick", new ItemMatchPick(BWMItems.SOULFORGED_STEEL) {

        @Override
        public boolean getIsRepairable(ItemStack toRepair, ItemStack repair) {
            return ItemUtil.matchesOreDict(repair, "ingotSoulforgedSteel") || super.getIsRepairable(toRepair, repair);
        }
    });
    steelMachete = (ItemMachete) registerItem("steel_machete", new ItemMachete(BWMItems.SOULFORGED_STEEL) {

        @Override
        public boolean getIsRepairable(ItemStack toRepair, ItemStack repair) {
            return ItemUtil.matchesOreDict(repair, "ingotSoulforgedSteel") || super.getIsRepairable(toRepair, repair);
        }
    });
    steelKukri = (ItemKukri) registerItem("steel_kukri", new ItemKukri(BWMItems.SOULFORGED_STEEL, 8.0F, -3.0F) {

        @Override
        public boolean getIsRepairable(ItemStack toRepair, ItemStack repair) {
            return ItemUtil.matchesOreDict(repair, "ingotSoulforgedSteel") || super.getIsRepairable(toRepair, repair);
        }
    });
    steelCarpenterSaw = (ItemCarpenterSaw) registerItem("steel_carpentersaw", new ItemCarpenterSaw(BWMItems.SOULFORGED_STEEL, 8.0F, -3.0F) {

        @Override
        public boolean getIsRepairable(ItemStack toRepair, ItemStack repair) {
            return ItemUtil.matchesOreDict(repair, "ingotSoulforgedSteel") || super.getIsRepairable(toRepair, repair);
        }
    });
    steelMasonPick = (ItemMasonPick) registerItem("steel_masonpick", new ItemMasonPick(BWMItems.SOULFORGED_STEEL) {

        @Override
        public boolean getIsRepairable(ItemStack toRepair, ItemStack repair) {
            return ItemUtil.matchesOreDict(repair, "ingotSoulforgedSteel") || super.getIsRepairable(toRepair, repair);
        }
    });
    material = (ItemMaterial) registerItem("material", new ItemMaterial(new String[] { "arrowhead", "midori", "midori_popped", "thornrose", "stone_brick", "bone_ingot", "ender_cream" }));
    worldShard = (ItemWorldScale) registerItem("worldshard", new ItemWorldScale());
    greatbow = (ItemGreatbow) registerItem("greatbow", new ItemGreatbow());
    greatarrow = (ItemGreatarrow) registerItem("greatarrow", new ItemGreatarrow());
    monument = (ItemMonument) registerItem("monument", new ItemMonument());
    // Food
    bakedMushroom = (ItemModFood) registerItem("food_mushroom_baked", new ItemModFood(3, 0.2F, false));
    bakedAmanita = (ItemModFood) registerItem("food_amanita_baked", new ItemModFood(3, 0.2F, false).setPotionEffect(new PotionEffect(MobEffects.POISON, 100, 0), 1.0F));
    cookedBeetroot = (ItemModFood) registerItem("food_beetroot_cooked", new ItemModFood(4, 0.5F, false));
    bakedBeetroot = (ItemModFood) registerItem("food_beetroot_baked", new ItemModFood(5, 0.4F, false));
    cookedCarrot = (ItemModFood) registerItem("food_carrot_cooked", new ItemModFood(3, 0.6F, false));
    bakedCarrot = (ItemModFood) registerItem("food_carrot_baked", new ItemModFood(4, 0.5F, false));
    cookedPotato = (ItemModFood) registerItem("food_potato_cooked", new ItemModFood(4, 0.7F, false));
    cookedEgg = (ItemModFood) registerItem("food_egg_cooked", new ItemModFood(4, 0.3F, false));
    meatballs = (ItemModFood) registerItem("food_meatballs", new ItemModFood(3, 0.6F, true));
    groundMeat = (ItemModFood) registerItem("food_ground_meat", new ItemModFood(1, 0.1F, true));
    pieMushroom = (ItemModFood) registerItem("food_pie_mushroom", new ItemModFood(8, 0.3F, false));
    pieAmanita = (ItemModFood) registerItem("food_pie_amanita", new ItemModFood(8, 0.3F, false).setPotionEffect(new PotionEffect(MobEffects.POISON, 100, 0), 1.0F));
    pieMeat = (ItemModFood) registerItem("food_pie_meat", new ItemModFood(9, 0.5F, true));
    pieMelon = (ItemModFood) registerItem("food_pie_melon", new ItemModFood(8, 0.4F, false));
    cookedClownfish = (ItemModFood) registerItem("food_clownfish_cooked", new ItemModFood(6, 0.5F, false));
    cookedPuffer = (ItemModFood) registerItem("food_pufferfish_baked", new ItemModFood(6, 0.6F, false).setPotionEffect(new PotionEffect(MobEffects.POISON, 500, 1), 0.1F));
    preparedPuffer = (ItemModFood) registerItem("food_pufferfish_prepared", new ItemModFood(2, 0.1F, false));
    preparedCookedPuffer = (ItemModFood) registerItem("food_pufferfish_cooked", new ItemModFood(4, 0.5F, false));
    fuguSac = (ItemModFood) registerItem("food_fugu_sac", new ItemModFood(2, 0.1F, false).setPotionEffect(new PotionEffect(MobEffects.WITHER, 2000, 1), 1.0F));
    sashimi = (ItemModFood) registerItem("food_sashimi", new ItemModFood(2, 0.1F, false));
    rice = (ItemModFood) registerItem("food_cooked_rice", new ItemModFood(2, 0.3F, false));
    riceBowl = (ItemModFood) registerItem("food_bowl_rice", new ItemModFood(9, 0.6F, false).setMaxStackSize(1));
    soulSandPile = registerItem("soulsand_pile", new Item());
    rottenFood = (ItemFood) registerItem("rotten_food", new ItemFood(1, 0.1f, false).setPotionEffect(new PotionEffect(MobEffects.HUNGER, 2000, 1), 1.0F));
    wool = (ItemColored) registerItem("wool", new ItemColored());
    bowls = (ItemMaterial) registerItem("bowl", new ItemMaterial(new String[] { "salt" }));
    bowls.setContainer(new ItemStack(Items.BOWL));
    OreDictionary.registerOre("foodSalt", bowls.getMaterial("salt"));
    artifactFrame = (ItemArtifactFrame) registerItem("artifact_frame", new ItemArtifactFrame());
    brokenArtifact = (ItemToolShard) registerItem("tool_shard", new ItemToolShard().setMaxStackSize(1));
    stainedBrick = (ItemStainedBrick) registerItem("brick_stained", new ItemStainedBrick());
    shinai = (ItemShinai) registerItem("shinai", new ItemShinai());
    katana = (ItemKatana) registerItem("katana", new ItemKatana());
    wakizashi = (ItemWakizashi) registerItem("wakizashi", new ItemWakizashi());
    tanto = (ItemTanto) registerItem("tanto", new ItemTanto());
    yumi = (ItemYumi) registerItem("yumi", new ItemYumi());
    ya = (ItemYa) registerItem("ya", new ItemYa());
    ancestryBottle = (ItemAncestryBottle) registerItem("ancestry_bottle", new ItemAncestryBottle());
    materialJapan = (ItemMaterial) registerItem("japanmat", new ItemMaterial(new String[] { "rice", "soaked_rice", "rice_stalk", "rice_hay", "rice_ash", "rush", "soaked_bamboo", "bamboo_slats", "soaked_mulberry", "mulberry_paste", "mulberry_sheet", "washi", "iron_scales", "lamellar", "paper_lamellar", "tsuka", "half_katana_blade", "ya_head", "yumi_top", "yumi_bottom", "tamahagane", "tamahagane_heated", "tamahagane_folded", "tamahagane_reheated", "tamahagane_finished", "tamahagane_wrapped", "hocho_tetsu", "hocho_tetsu_heated", "hocho_tetsu_fold_1", "hocho_tetsu_fold_2", "hocho_tetsu_finished", "helmet_undecorated", "chest_undecorated", "legs_undecorated", "boots_undecorated", "bark_sakura", "bark_mulberry" }));
    samuraiHelm = (ItemSamuraiArmor) registerItem("helmet_samurai", new ItemSamuraiArmor(EntityEquipmentSlot.HEAD));
    samuraiChestplate = (ItemSamuraiArmor) registerItem("chest_samurai", new ItemSamuraiArmor(EntityEquipmentSlot.CHEST));
    samuraiLeggings = (ItemSamuraiArmor) registerItem("legs_samurai", new ItemSamuraiArmor(EntityEquipmentSlot.LEGS));
    samuraiBoots = (ItemSamuraiArmor) registerItem("boots_samurai", new ItemSamuraiArmor(EntityEquipmentSlot.FEET));
    materialBag = (ItemMaterial) registerItem("bag", new ItemMaterial(new String[] { "seed", "seed_hemp", "seed_melon", "seed_pumpkin", "seed_beets", "cocoa", "redstone", "glowstone", "sugar", "gunpowder", "flour", "sulfur", "nitre", "sawdust", "sawdust_soul", "potash", "hellfire", "kibble" }));
    materialCrate = (ItemMaterial) registerItem("crate", new ItemMaterial(new String[] { "pork", "pork_raw", "chicken", "chicken_raw", "steak", "steak_raw", "mutton", "mutton_raw", "rabbit", "rabbit_raw", "egg", "slime", "enderpearl" }));
    materialCongealed = (ItemMaterial) registerItem("congealed", new ItemMaterial(new String[] { "bone", "flesh", "eye", "amanita", "mushroom", "wart" }));
    materialBolt = (ItemMaterial) registerItem("bolt", new ItemMaterial(new String[] { "fabric", "vine", "paper", "leather", "scoured_leather", "tanned_leather", "string" }));
    materialBundle = (ItemMaterial) registerItem("bundle", new ItemMaterial(new String[] { "feather", "arrows", "blazerods", "oak", "birch", "spruce", "jungle", "acacia", "darkoak" }));
    materialDeco = (ItemMaterial) registerItem("decomat", new ItemMaterial(new String[] { "hemp_oil", "wood_bleach", "wood_stain", "glass_chunk" }));
    materialTweak = (ItemMaterial) registerItem("tweakmat", new ItemMaterial(new String[] { "ash", "ink_and_quill" }));
    explosion = registerItem("explosion", new Item() {

        @Override
        public void getSubItems(Item itemIn, CreativeTabs tab, NonNullList<ItemStack> subItems) {
        // NOOP
        }
    });
}
Also used : PotionEffect(net.minecraft.potion.PotionEffect) ItemSpade(betterwithaddons.item.rbdtools.ItemSpade) CreativeTabs(net.minecraft.creativetab.CreativeTabs) NonNullList(net.minecraft.util.NonNullList)

Example 35 with NonNullList

use of net.minecraft.util.NonNullList in project Almura by AlmuraDev.

the class ExchangeOfferScreen method construct.

@Override
public void construct() {
    this.guiscreenBackground = false;
    // Form
    final BasicForm form = new BasicForm(this, 400, 325, I18n.format("almura.feature.exchange.title.offer"));
    // Fixes issue overlapping draws from parent
    form.setZIndex(10);
    form.setBackgroundAlpha(255);
    // OK/Cancel buttons
    final UIButton buttonOk = new UIButtonBuilder(this).width(40).text(I18n.format("almura.button.ok")).x(1).anchor(Anchor.BOTTOM | Anchor.RIGHT).onClick(this::transact).build("button.ok");
    final UIButton buttonCancel = new UIButtonBuilder(this).width(40).text(I18n.format("almura.button.cancel")).x(getPaddedX(buttonOk, 2, Anchor.RIGHT)).anchor(Anchor.BOTTOM | Anchor.RIGHT).onClick(this::close).build("button.cancel");
    // Swap container
    final NonNullList<ItemStack> mainInventory = Minecraft.getMinecraft().player.inventory.mainInventory;
    final int totalItemsForSale = this.exchange.getForSaleItemsFor(Minecraft.getMinecraft().player.getUniqueID()).map(List::size).orElse(0);
    this.offerContainer = new UIExchangeOfferContainer(this, getPaddedWidth(form), getPaddedHeight(form) - 20, TextFormatting.WHITE + I18n.format("almura.feature.exchange.text.inventory"), TextFormatting.WHITE + I18n.format("almura.feature.exchange.text.unlisted_items"), mainInventory.size(), this.limit, totalItemsForSale);
    this.offerContainer.register(this);
    // Populate offer container
    final List<VanillaStack> inventoryOffers = new ArrayList<>();
    mainInventory.stream().filter(i -> !i.isEmpty() && i.getItem() != null).forEach(i -> inventoryOffers.add(new BasicVanillaStack(i)));
    this.offerContainer.setItems(this.pendingItems, BasicDualListContainer.SideType.RIGHT);
    this.offerContainer.setItems(inventoryOffers, BasicDualListContainer.SideType.LEFT);
    form.add(this.offerContainer, buttonOk, buttonCancel);
    addToScreen(form);
}
Also used : UIButton(net.malisis.core.client.gui.component.interaction.UIButton) VanillaStack(com.almuradev.almura.shared.item.VanillaStack) ClientExchangeManager(com.almuradev.almura.feature.exchange.client.ClientExchangeManager) InventoryAction(com.almuradev.almura.feature.exchange.InventoryAction) TextFormatting(net.minecraft.util.text.TextFormatting) UIButtonBuilder(net.malisis.core.client.gui.component.interaction.button.builder.UIButtonBuilder) UIExchangeOfferContainer(com.almuradev.almura.feature.exchange.client.gui.component.UIExchangeOfferContainer) BasicVanillaStack(com.almuradev.almura.shared.item.BasicVanillaStack) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) BasicForm(net.malisis.core.client.gui.component.container.BasicForm) I18n(net.minecraft.client.resources.I18n) Inject(javax.inject.Inject) ItemStack(net.minecraft.item.ItemStack) List(java.util.List) Minecraft(net.minecraft.client.Minecraft) Side(net.minecraftforge.fml.relauncher.Side) Anchor(net.malisis.core.client.gui.Anchor) BasicDualListContainer(net.malisis.core.client.gui.component.container.BasicDualListContainer) Subscribe(com.google.common.eventbus.Subscribe) BasicScreen(net.malisis.core.client.gui.BasicScreen) NonNullList(net.minecraft.util.NonNullList) SideOnly(net.minecraftforge.fml.relauncher.SideOnly) Exchange(com.almuradev.almura.feature.exchange.Exchange) BasicForm(net.malisis.core.client.gui.component.container.BasicForm) UIButtonBuilder(net.malisis.core.client.gui.component.interaction.button.builder.UIButtonBuilder) UIExchangeOfferContainer(com.almuradev.almura.feature.exchange.client.gui.component.UIExchangeOfferContainer) UIButton(net.malisis.core.client.gui.component.interaction.UIButton) ArrayList(java.util.ArrayList) ItemStack(net.minecraft.item.ItemStack) BasicVanillaStack(com.almuradev.almura.shared.item.BasicVanillaStack) VanillaStack(com.almuradev.almura.shared.item.VanillaStack) BasicVanillaStack(com.almuradev.almura.shared.item.BasicVanillaStack)

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