net.minecraft.util.NonNullList Java Examples

The following examples show how to use net.minecraft.util.NonNullList. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BlockSnow.java    From customstuff4 with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void getDrops(NonNullList<ItemStack> drops, IBlockAccess world, BlockPos pos, IBlockState state, int fortune)
{
    if (content.snowball != null)
    {
        ItemStack stack = content.snowball.getItemStack().copy();
        stack.setCount((state.getValue(LAYERS) + 1) * stack.getCount());

        drops.add(stack);
    }

    Optional<BlockDrop[]> blockDrops = getContent().drop.get(getSubtype(state));
    if (blockDrops.isPresent())
    {
        drops.addAll(ItemHelper.getDroppedStacks(blockDrops.get(), fortune));
    }
}
 
Example #2
Source File: ItemHelper.java    From customstuff4 with GNU General Public License v3.0 6 votes vote down vote up
public static NonNullList<ItemStack> createSubItems(Item item, CreativeTabs creativeTab, Attribute<String> tabLabels, int[] subtypes)
{
    NonNullList<ItemStack> list = NonNullList.create();

    if (item.getHasSubtypes())
    {
        for (int meta : subtypes)
        {
            tabLabels.get(meta)
                     .ifPresent(tabLabel ->
                                {
                                    if (creativeTab == null || creativeTab == CreativeTabs.SEARCH || Objects.equals(tabLabel, getTabLabel(creativeTab)))
                                    {
                                        list.add(new ItemStack(item, 1, meta));
                                    }
                                });
        }
    } else
    {
        list.add(new ItemStack(item, 1, 0));
    }

    return list;
}
 
Example #3
Source File: ClientProxy.java    From enderutilities with GNU Lesser General Public License v3.0 6 votes vote down vote up
private static void registerAllItemBlockModels(BlockEnderUtilities blockIn, String variantPre, String variantPost)
{
    if (blockIn.isEnabled())
    {
        NonNullList<ItemStack> stacks = NonNullList.create();
        blockIn.getSubBlocks(blockIn.getCreativeTab(), stacks);
        String[] names = blockIn.getUnlocalizedNames();

        for (ItemStack stack : stacks)
        {
            Item item = stack.getItem();
            int meta = stack.getMetadata();
            ModelResourceLocation mrl = new ModelResourceLocation(item.getRegistryName(), variantPre + names[meta] + variantPost);
            ModelLoader.setCustomModelResourceLocation(item, meta, mrl);
        }
    }
}
 
Example #4
Source File: DamageableShapelessOreRecipeTest.java    From customstuff4 with GNU General Public License v3.0 6 votes vote down vote up
@Test
public void test_useUpItem()
{
    DamageableShapelessOreRecipe recipe = new DamageableShapelessOreRecipe(new ResourceLocation("group"),
                                                                           new int[] {60}, new ItemStack(Blocks.DIRT), new ItemStack(Items.WOODEN_SWORD));
    InventoryCrafting inv = new InventoryCrafting(new Container()
    {
        @Override
        public boolean canInteractWith(EntityPlayer playerIn)
        {
            return false;
        }
    }, 3, 3);
    inv.setInventorySlotContents(3, new ItemStack(Items.WOODEN_SWORD));

    assertTrue(recipe.matches(inv, null));
    NonNullList<ItemStack> remaining = recipe.getRemainingItems(inv);
    assertTrue(remaining.get(3).isEmpty());
}
 
Example #5
Source File: RecipeShapedFluid.java    From Wizardry with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public NonNullList<ItemStack> getRemainingItems(InventoryCrafting inv) {
	NonNullList<ItemStack> remains = ForgeHooks.defaultRecipeGetRemainingItems(inv);
	for (int i = 0; i < height * width; i++) {
		ItemStack stack = inv.getStackInSlot(i);
		NonNullList<Ingredient> matchedIngredients = this.input;
		if (matchedIngredients.get(i) instanceof IngredientFluidStack) {
			if (!stack.isEmpty()) {
				ItemStack copy = stack.copy();
				copy.setCount(1);
				remains.set(i, copy);
			}
			IFluidHandlerItem handler = FluidUtil.getFluidHandler(remains.get(i));
			if (handler != null) {
				FluidStack fluid = ((IngredientFluidStack) matchedIngredients.get(i)).getFluid();
				handler.drain(fluid.amount, true);
				remains.set(i, handler.getContainer());
			}
		}
	}
	return remains;
}
 
Example #6
Source File: Recipe.java    From GregTech with GNU Lesser General Public License v3.0 6 votes vote down vote up
public Recipe(List<CountableIngredient> inputs, List<ItemStack> outputs, List<ChanceEntry> chancedOutputs,
              List<FluidStack> fluidInputs, List<FluidStack> fluidOutputs,
              Map<String, Object> recipeProperties, int duration, int EUt, boolean hidden) {
    this.recipeProperties = ImmutableMap.copyOf(recipeProperties);
    this.inputs = NonNullList.create();
    this.inputs.addAll(inputs);
    this.outputs = NonNullList.create();
    this.outputs.addAll(outputs);
    this.chancedOutputs = new ArrayList<>(chancedOutputs);
    this.fluidInputs = ImmutableList.copyOf(fluidInputs);
    this.fluidOutputs = ImmutableList.copyOf(fluidOutputs);
    this.duration = duration;
    this.EUt = EUt;
    this.hidden = hidden;
    //sort input elements in descending order (i.e not consumables inputs are last)
    this.inputs.sort(Comparator.comparing(CountableIngredient::getCount).reversed());
}
 
Example #7
Source File: BlockLeekCrop.java    From TofuCraftReload with MIT License 6 votes vote down vote up
public void getDrops(NonNullList<ItemStack> drops, IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
    Random rand = world instanceof World ? ((World) world).rand : RANDOM;

    int age = getAge(state);
    int count = quantityDropped(state, fortune, rand);
    for (int i = 0; i < count; i++) {
        Item item = this.getItemDropped(state, rand, fortune);
        if (item != Items.AIR) {
            drops.add(new ItemStack(item, 1, this.damageDropped(state)));
        }
    }

    if (age >= getMaxAge()) {
        int k = 3 + fortune;
        for (int i = 0; i < k; ++i) {
            if (rand.nextInt(2 * getMaxAge()) <= age) {
                drops.add(new ItemStack(this.getSeed(), 1, this.damageDropped(state)));
            }
        }
    }
}
 
Example #8
Source File: CraftingHelper.java    From malmo with MIT License 6 votes vote down vote up
/**
 * Inspect a player's inventory to see whether they have enough items to form the supplied list of ItemStacks.<br>
 * The ingredients list MUST be amalgamated such that no two ItemStacks contain the same type of item.
 *
 * @param player
 * @param ingredients an amalgamated list of ingredients
 * @return true if the player's inventory contains sufficient quantities of all the required items.
 */
public static boolean playerHasIngredients(EntityPlayerMP player, List<ItemStack> ingredients) {
    NonNullList<ItemStack> main = player.inventory.mainInventory;
    NonNullList<ItemStack> arm = player.inventory.armorInventory;

    for (ItemStack isIngredient : ingredients) {
        int target = isIngredient.getCount();
        for (int i = 0; i < main.size() + arm.size() && target > 0; i++) {
            ItemStack isPlayer = (i >= main.size()) ? arm.get(i - main.size()) : main.get(i);
            if (isPlayer != null && isIngredient != null && itemStackIngredientsMatch(isPlayer, isIngredient))
                target -= isPlayer.getCount();
        }
        if (target > 0)
            return false;   // Don't have enough of this.
    }
    return true;
}
 
Example #9
Source File: MachineRecipeDeserializerTest.java    From customstuff4 with GNU General Public License v3.0 6 votes vote down vote up
@Test
public void test_deserializer()
{
    MachineRecipeImpl recipe = gson.fromJson("{" +
                                             "\"recipeList\": \"cs4examplemod:machine\"," +
                                             "\"input\": [\"minecraft:apple\", \"minecraft:gold_ingot\"]," +
                                             "\"output\": \"minecraft:golden_apple\"," +
                                             "\"inputFluid\": [\"water@500\"]," +
                                             "\"cookTime\": 400" + "}", MachineRecipeImpl.class);
    recipe.init(InitPhase.PRE_INIT, null);

    List<RecipeInput> inputItems = recipe.getRecipeInput();
    List<FluidStack> inputFluids = recipe.getFluidRecipeInput();
    NonNullList<MachineRecipeOutput> outputs = recipe.getOutputs();
    MachineRecipeOutput output = outputs.get(0);

    assertEquals(400, recipe.getCookTime());
    assertEquals(2, inputItems.size());
    assertEquals(1, inputFluids.size());
    assertEquals(1, outputs.size());
    assertEquals(1, output.getWeight());
    assertEquals(1, output.getOutputItems().size());
    assertEquals(0, output.getOutputFluids().size());
}
 
Example #10
Source File: ItemHelperTests.java    From customstuff4 with GNU General Public License v3.0 6 votes vote down vote up
@Test
public void test_createSubItems_differentTabs()
{
    HashMap<Integer, String> map = Maps.newHashMap();
    map.put(0, "tools");
    map.put(1, "redstone");

    Attribute<String> tabLabels = Attribute.map(map);
    int[] subtypes = new int[] {0, 1};

    Item item = new Item();
    item.setHasSubtypes(true);

    NonNullList<ItemStack> subItems = ItemHelper.createSubItems(item, CreativeTabs.TOOLS, tabLabels, subtypes);

    assertSame(1, subItems.size());
    assertSame(0, subItems.get(0).getItemDamage());
}
 
Example #11
Source File: ItemOrb.java    From Wizardry with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void getSubItems(@Nullable CreativeTabs tab, @Nonnull NonNullList<ItemStack> subItems) {
	if (isInCreativeTab(tab)) {

		subItems.add(new ItemStack(this));

		for (int i = 1; i < 10; i++) {
			ItemStack stack = new ItemStack(this, 1, 1);
			ManaManager.forObject(stack)
					.setMana(ManaManager.getMaxMana(stack) * i / 10.0)
					.close();
			subItems.add(stack);
		}

		subItems.add(new ItemStack(this, 1, 1));
	}
}
 
Example #12
Source File: ItemHelperTests.java    From customstuff4 with GNU General Public License v3.0 6 votes vote down vote up
@Test
public void test_createSubItems_search_tab()
{
    HashMap<Integer, String> map = Maps.newHashMap();
    map.put(0, "tools");
    map.put(1, "redstone");

    Attribute<String> tabLabels = Attribute.map(map);
    int[] subtypes = new int[] {0, 1};

    Item item = new Item();
    item.setHasSubtypes(true);

    NonNullList<ItemStack> subItems = ItemHelper.createSubItems(item, CreativeTabs.SEARCH, tabLabels, subtypes);

    assertEquals(2, subItems.size());
    assertEquals(0, subItems.get(0).getItemDamage());
    assertEquals(1, subItems.get(1).getItemDamage());
}
 
Example #13
Source File: FacadeItem.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void getSubItems(ItemStack itemStack, CreativeTabs creativeTab, NonNullList<ItemStack> subItems) {
    List<ItemStack> validFacades;
    if (creativeTab == CreativeTabs.SEARCH && !ConfigHolder.hideFacadesInJEI) {
        validFacades = FacadeHelper.getValidFacadeItems();
    } else {
        validFacades = ImmutableList.of(new ItemStack(Blocks.STONE));
    }
    for (ItemStack facadeStack : validFacades) {
        ItemStack resultStack = itemStack.copy();
        setFacadeStack(resultStack, facadeStack);
        subItems.add(resultStack);
    }
}
 
Example #14
Source File: ItemBlockCustomWood.java    From AgriCraft with MIT License 5 votes vote down vote up
@Override
@SideOnly(Side.CLIENT)
public void getSubItems(CreativeTabs tab, NonNullList<ItemStack> list) {
    if (tab == this.getCreativeTab() || tab == CreativeTabs.SEARCH) {
        this.getSubItems(list);
    }
}
 
Example #15
Source File: TileEntityCreationStation.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Adds one more of each item in the recipe into the crafting grid, if possible
 * @param invId
 * @param recipeId
 */
protected boolean addOneSetOfRecipeItemsIntoGrid(IItemHandler invCrafting, int invId, int recipeId, EntityPlayer player)
{
    invId = MathHelper.clamp(invId, 0, 1);
    int maskOreDict = invId == 1 ? MODE_BIT_RIGHT_CRAFTING_OREDICT : MODE_BIT_LEFT_CRAFTING_OREDICT;
    boolean useOreDict = (this.modeMask & maskOreDict) != 0;

    IItemHandlerModifiable playerInv = (IItemHandlerModifiable) player.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.UP);
    IItemHandler invWrapper = new CombinedInvWrapper(this.itemInventory, playerInv);

    NonNullList<ItemStack> template = this.getRecipeItems(invId);
    InventoryUtils.clearInventoryToMatchTemplate(invCrafting, invWrapper, template);

    return InventoryUtils.restockInventoryBasedOnTemplate(invCrafting, invWrapper, template, 1, true, useOreDict);
}
 
Example #16
Source File: ArmorHooks.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static void damageArmor(float damage, EntityLivingBase entity, NonNullList<ItemStack> inventory, DamageSource damageSource) {
    double armorDamage = Math.max(1.0F, damage / 4.0F);
    for (int i = 0; i < inventory.size(); i++) {
        ItemStack itemStack = inventory.get(i);
        if (itemStack.getItem() instanceof IArmorItem) {
            ((IArmorItem) itemStack.getItem()).damageArmor(entity, itemStack, damageSource, (int) armorDamage, i);
            if (inventory.get(i).getCount() == 0) {
                inventory.set(i, ItemStack.EMPTY);
            }
        }
    }
}
 
Example #17
Source File: Core.java    From TFC2 with GNU General Public License v3.0 5 votes vote down vote up
public static int getEncumbrance(NonNullList<ItemStack> stackList)
{
	int out = 0;
	for(ItemStack i :stackList)
	{
		if(!i.isEmpty())
			out += SizeWeightRegistry.GetInstance().getProperty(i).weight.encumbrance;
	}
	return out;
}
 
Example #18
Source File: BlockInserter.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void getSubBlocks(CreativeTabs tab, NonNullList<ItemStack> list)
{
    for (int i = 0; i < InserterType.values().length; i++)
    {
        list.add(new ItemStack(this, 1, InserterType.values()[i].getMeta()));
    }
}
 
Example #19
Source File: MetaTileEntityFisher.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void update() {
    super.update();
    ItemStack baitStack = importItems.getStackInSlot(0);
    if (!getWorld().isRemote && energyContainer.getEnergyStored() >= energyAmountPerFish && getTimer() % fishingTicks == 0L && !baitStack.isEmpty()) {
        WorldServer world = (WorldServer) this.getWorld();
        int waterCount = 0;
        int edgeSize = (int) Math.sqrt(WATER_CHECK_SIZE);
        for (int x = 0; x < edgeSize; x++){
            for (int z = 0; z < edgeSize; z++){
                BlockPos waterCheckPos = getPos().down().add(x - edgeSize / 2, 0, z - edgeSize / 2);
                if (world.getBlockState(waterCheckPos).getBlock() instanceof BlockLiquid &&
                    world.getBlockState(waterCheckPos).getMaterial() == Material.WATER) {
                    waterCount++;
                }
            }
        }
        if (waterCount == WATER_CHECK_SIZE) {
            LootTable table = world.getLootTableManager().getLootTableFromLocation(LootTableList.GAMEPLAY_FISHING);
            NonNullList<ItemStack> itemStacks = NonNullList.create();
            itemStacks.addAll(table.generateLootForPools(world.rand, new LootContext.Builder(world).build()));
            if(addItemsToItemHandler(exportItems, true, itemStacks)) {
                addItemsToItemHandler(exportItems, false, itemStacks);
                energyContainer.removeEnergy(energyAmountPerFish);
                baitStack.shrink(1);
            }
        }
    }
    if(!getWorld().isRemote && getTimer() % 5 == 0) {
        pushItemsIntoNearbyHandlers(getFrontFacing());
    }
}
 
Example #20
Source File: DamageableShapedOreRecipe.java    From customstuff4 with GNU General Public License v3.0 5 votes vote down vote up
@Override
public NonNullList<ItemStack> getRemainingItems(InventoryCrafting inv)
{
    NonNullList<ItemStack> items = NonNullList.withSize(inv.getSizeInventory(), ItemStack.EMPTY);

    getMatch(inv);

    int[] amounts = getAmounts(wasMirrored);

    for (int col = 0; col < getWidth(); col++)
    {
        for (int row = 0; row < getHeight(); row++)
        {
            int amountIndex = col + row * getWidth();
            int invIndex = matchX + col + (row + matchY) * inv.getWidth();
            int amount = amounts[amountIndex];
            if (amount > 0)
            {
                ItemStack stack = inv.getStackInSlot(invIndex).copy();
                stack.setItemDamage(stack.getItemDamage() + amount);
                if (stack.getItemDamage() > stack.getMaxDamage())
                {
                    stack = ForgeHooks.getContainerItem(stack);
                }
                items.set(invIndex, stack);
            } else
            {
                items.set(invIndex, ForgeHooks.getContainerItem(inv.getStackInSlot(invIndex)));
            }
        }
    }

    return items;
}
 
Example #21
Source File: GTItemCreativeScanner.java    From GT-Classic with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void getSubItems(CreativeTabs tab, NonNullList<ItemStack> items) {
	if (this.isInCreativeTab(tab)) {
		ItemStack full = new ItemStack(this, 1, 0);
		ElectricItem.manager.charge(full, 2.147483647E9D, Integer.MAX_VALUE, true, false);
		items.add(full);
	}
}
 
Example #22
Source File: CmdPeek.java    From bleachhack-1.14 with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onCommand(String command, String[] args) throws Exception {
	ItemStack item = mc.player.inventory.getCurrentItem();
	
	if (!(item.getItem() instanceof BlockItem)) {
		BleachLogger.errorMessage("Must be holding a containter to peek.");
		return;
	}
	
	if (!(((BlockItem) item.getItem()).getBlock() instanceof ContainerBlock)) {
		BleachLogger.errorMessage("Must be holding a containter to peek.");
		return;
	}
	
	NonNullList<ItemStack> items = NonNullList.withSize(27, new ItemStack(Items.AIR));
	CompoundNBT nbt = item.getTag();
	
	if (nbt != null && nbt.contains("BlockEntityTag")) {
		CompoundNBT itemnbt = nbt.getCompound("BlockEntityTag");
		if (itemnbt.contains("Items")) ItemStackHelper.loadAllItems(itemnbt, items);
	}
	
	Inventory inv = new Inventory(items.toArray(new ItemStack[27]));
	
	BleachQueue.queue.add(() -> {
		mc.displayGuiScreen(new ShulkerBoxScreen(
				new ShulkerBoxContainer(420, mc.player.inventory, inv),
				mc.player.inventory,
				item.getDisplayName()));
	});
}
 
Example #23
Source File: TileEntityCreationStation.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void restockCraftingGrid(IItemHandler invCrafting, int invId)
{
    invId = MathHelper.clamp(invId, 0, 1);
    NonNullList<ItemStack> template = this.craftingGridTemplates.get(invId);

    if (invCrafting == null || template == null)
    {
        return;
    }

    this.recipeLoadClickCount = 0;
    int maskAutoUse = invId == 1 ? MODE_BIT_RIGHT_CRAFTING_AUTOUSE : MODE_BIT_LEFT_CRAFTING_AUTOUSE;

    // Auto-use feature not enabled
    if ((this.modeMask & maskAutoUse) == 0)
    {
        return;
    }

    int maskOreDict = invId == 1 ? MODE_BIT_RIGHT_CRAFTING_OREDICT : MODE_BIT_LEFT_CRAFTING_OREDICT;
    boolean useOreDict = (this.modeMask & maskOreDict) != 0;

    InventoryUtils.clearInventoryToMatchTemplate(invCrafting, this.itemInventory, template);
    InventoryUtils.restockInventoryBasedOnTemplate(invCrafting, this.itemInventory, template, 1, true, useOreDict);

    this.craftingGridTemplates.set(invId, null);
}
 
Example #24
Source File: MetaTileEntityPrimitiveBlastFurnace.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
private boolean tryPickNewRecipe() {
    ItemStack inputStack = importItems.getStackInSlot(0);
    ItemStack fuelStack = importItems.getStackInSlot(1);
    if (inputStack.isEmpty() || (fuelStack.isEmpty() && fuelUnitsLeft == 0)) {
        return false;
    }
    float fuelUnitsPerItem = getFuelUnits(fuelStack);
    float totalFuelUnits = fuelUnitsLeft + fuelUnitsPerItem * fuelStack.getCount();
    PrimitiveBlastFurnaceRecipe currentRecipe = getOrRefreshRecipe(inputStack);
    if (currentRecipe != null && setupRecipe(inputStack, (int) totalFuelUnits, currentRecipe)) {
        inputStack.shrink(currentRecipe.getInput().getCount());
        float fuelUnitsToConsume = currentRecipe.getFuelAmount();
        float remainderConsumed = Math.min(fuelUnitsToConsume, fuelUnitsLeft);
        fuelUnitsToConsume -= remainderConsumed;

        int fuelItemsToConsume = (int) Math.ceil(fuelUnitsToConsume / (fuelUnitsPerItem * 1.0));
        float remainderAdded = fuelItemsToConsume * fuelUnitsPerItem - fuelUnitsToConsume;

        this.fuelUnitsLeft += (remainderAdded - remainderConsumed);
        fuelStack.shrink(fuelItemsToConsume);
        this.maxProgressDuration = currentRecipe.getDuration();
        this.currentProgress = 0;
        NonNullList<ItemStack> outputs = NonNullList.create();
        outputs.add(currentRecipe.getOutput().copy());
        outputs.add(getAshForRecipeFuelConsumption(currentRecipe.getFuelAmount()));
        this.outputsList = outputs;
        markDirty();
        return true;
    }
    return false;
}
 
Example #25
Source File: TileEntityBarrel.java    From Sakura_mod with MIT License 5 votes vote down vote up
public void readPacketNBT(NBTTagCompound cmp) {
	this.inventory = NonNullList.<ItemStack>withSize(this.getSizeInventory(), ItemStack.EMPTY);
	ItemStackHelper.loadAllItems(cmp, this.inventory);

	processTimer = cmp.getInteger(TAG_PROCESS);

	this.tank.readFromNBT(cmp.getCompoundTag("Tank"));
	this.resultTank.readFromNBT(cmp.getCompoundTag("ResultTank"));
}
 
Example #26
Source File: MCCraftingRecipe.java    From NOVA-Core with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void consumeItems(CraftingGrid craftingGrid) {
	NonNullList<ItemStack> remainder = recipe.getRemainingItems(new NovaCraftingGrid(craftingGrid));
	for (int i = 0; i < remainder.size(); i++) {
		Optional<Item> result = Optional.of(remainder.get(i)).filter(item -> !item.isEmpty()).map(ItemConverter.instance()::toNova);
		if (!result.isPresent()) {
			result = craftingGrid.getCrafting(i).filter(item -> item.count() > 1).map(item -> item.withAmount(item.count() - 1));
		}
		craftingGrid.setCrafting(i, result);
	}
}
 
Example #27
Source File: CraftShapelessRecipe.java    From Kettle with GNU General Public License v3.0 5 votes vote down vote up
public void addToCraftingManager() {
    List<ItemStack> ingred = this.getIngredientList();
    NonNullList<Ingredient> data = NonNullList.withSize(ingred.size(), Ingredient.EMPTY);
    for (int i = 0; i < ingred.size(); i++) {
        data.set(i, Ingredient.fromStacks(new net.minecraft.item.ItemStack[]{CraftItemStack.asNMSCopy(ingred.get(i))}));
    }
    // TODO: Check if it's correct way to register recipes
    ForgeRegistries.RECIPES.register(new ShapelessRecipes("", CraftItemStack.asNMSCopy(this.getResult()), data));
    // CraftingManager.a(CraftNamespacedKey.toMinecraft(this.getKey()), new ShapelessRecipes("", CraftItemStack.asNMSCopy(this.getResult()), data));
}
 
Example #28
Source File: GTItemLightHelmet.java    From GT-Classic with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void getSubItems(CreativeTabs tab, NonNullList<ItemStack> items) {
	if (!isInCreativeTab(tab)) {
		return;
	}
	ItemStack empty = new ItemStack(this, 1, 0);
	ItemStack full = new ItemStack(this, 1, 0);
	ElectricItem.manager.discharge(empty, 2.147483647E9D, Integer.MAX_VALUE, true, false, false);
	ElectricItem.manager.charge(full, 2.147483647E9D, Integer.MAX_VALUE, true, false);
	items.add(empty);
	items.add(full);
}
 
Example #29
Source File: GTItemRockCutter.java    From GT-Classic with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void getSubItems(CreativeTabs tab, NonNullList<ItemStack> items) {
	if (!isInCreativeTab(tab)) {
		return;
	}
	ItemStack empty = new ItemStack(this, 1, 0);
	ItemStack full = new ItemStack(this, 1, 0);
	ElectricItem.manager.discharge(empty, 2.147483647E9D, Integer.MAX_VALUE, true, false, false);
	ElectricItem.manager.charge(full, 2.147483647E9D, Integer.MAX_VALUE, true, false);
	empty.addEnchantment(Enchantments.SILK_TOUCH, 1);
	full.addEnchantment(Enchantments.SILK_TOUCH, 1);
	items.add(empty);
	items.add(full);
}
 
Example #30
Source File: ShapedRecipe.java    From customstuff4 with GNU General Public License v3.0 5 votes vote down vote up
private boolean isSameInputs(NonNullList<Ingredient> targetInput)
{
    Object[] sourceInput = getRecipeInput();

    for (int i = 0; i < targetInput.size(); i++)
    {
        Ingredient target = targetInput.get(i);
        Object source = sourceInput[i];

        if (!ItemHelper.isSameRecipeInput(target, source))
            return false;
    }
    return true;
}