當前位置: 首頁>>代碼示例>>Java>>正文


Java NonNullList.get方法代碼示例

本文整理匯總了Java中net.minecraft.util.NonNullList.get方法的典型用法代碼示例。如果您正苦於以下問題:Java NonNullList.get方法的具體用法?Java NonNullList.get怎麽用?Java NonNullList.get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在net.minecraft.util.NonNullList的用法示例。


在下文中一共展示了NonNullList.get方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: Ritual

import net.minecraft.util.NonNullList; //導入方法依賴的package包/類
/**
 * Constructs a new ritual. To be registered within the registry
 *
 * @param input       a NonNullList<ItemStack> with all and every itemstack required to be a valid ritual
 * @param output      a NonNullList<ItemStack> with all and every itemstack that should get dropped on the ground when the ritual stops
 * @param timeInTicks the time in ticks that the ritual takes to stop. Negative values will have the ritual going on indefinitely. Zero means that the effect/crafting is applied immediately
 * @param circles     is the byte annotation to define what circles are needed. It follows this pattern 332211TT where 33, 22, 11 are the glyph type of the nth circle, and TT the number of required circles, 0 being 1, 2 being 3. 3 (11) will always return a failed circle
 */
public Ritual(ResourceLocation registryName, @Nonnull NonNullList<Ingredient> input, @Nonnull NonNullList<ItemStack> output, int timeInTicks, int circles, int altarStartingPower, int powerPerTick) {
	this.time = timeInTicks;

	for (int i = 0; i < input.size(); i++) {
		Ingredient ing = input.get(i);
		if (ing.getMatchingStacks().length == 0)
			throw new IllegalArgumentException("Ritual inputs must be valid: ingredient #" + i + " for " + registryName + " has no matching items");
	}

	this.input = input;
	this.output = output;
	this.circles = circles;
	this.altarStartingPower = altarStartingPower;
	this.tickPower = powerPerTick;
	setRegistryName(registryName);
	if (input.size() == 0) throw new IllegalArgumentException("Cannot have an empty input in a ritual");
}
 
開發者ID:Um-Mitternacht,項目名稱:Bewitchment,代碼行數:26,代碼來源:Ritual.java

示例2: findMatchingFuel

import net.minecraft.util.NonNullList; //導入方法依賴的package包/類
public static MachineFuel findMatchingFuel(ResourceLocation list, NonNullList<ItemStack> input)
{
    if (list.toString().equals("minecraft:vanilla"))
    {
        if (input.size() == 1 && !input.get(0).isEmpty())
        {
            ItemStack stack = input.get(0);
            int burnTime = TileEntityFurnace.getItemBurnTime(stack);
            if (burnTime > 0)
                return new VanillaFurnaceFuel(stack, burnTime);
        }

        return MachineFuel.EMPTY;
    }

    return findMatchingFuel(getInstance(list).fuels, input);
}
 
開發者ID:cubex2,項目名稱:customstuff4,代碼行數:18,代碼來源:MachineManager.java

示例3: test_getDrops

import net.minecraft.util.NonNullList; //導入方法依賴的package包/類
@Test
public void test_getDrops()
{
    ContentBlockSnow content = new ContentBlockSnow();
    content.id = "test_getDrops";
    content.snowball = new WrappedItemStackConstant(new ItemStack(Items.APPLE, 3));
    content.drop = Attribute.constant(new BlockDrop[] {new BlockDrop(new WrappedItemStackConstant(new ItemStack(Items.STICK)), IntRange.create(2, 2))});

    Block block = content.createBlock();

    NonNullList<ItemStack> drops = NonNullList.create();
    block.getDrops(drops, null, null, block.getDefaultState().withProperty(BlockSnow.LAYERS, 5), 0);
    ItemStack drop1 = drops.get(0);
    ItemStack drop2 = drops.get(1);

    assertEquals(2, drops.size());

    assertSame(Items.APPLE, drop1.getItem());
    assertEquals(18, drop1.getCount());

    assertSame(Items.STICK, drop2.getItem());
    assertEquals(2, drop2.getCount());
}
 
開發者ID:cubex2,項目名稱:customstuff4,代碼行數:24,代碼來源:BlockSnowTest.java

示例4: func_191281_a

import net.minecraft.util.NonNullList; //導入方法依賴的package包/類
public static NBTTagCompound func_191281_a(NBTTagCompound p_191281_0_, NonNullList<ItemStack> p_191281_1_, boolean p_191281_2_)
{
    NBTTagList nbttaglist = new NBTTagList();

    for (int i = 0; i < p_191281_1_.size(); ++i)
    {
        ItemStack itemstack = (ItemStack)p_191281_1_.get(i);

        if (!itemstack.func_190926_b())
        {
            NBTTagCompound nbttagcompound = new NBTTagCompound();
            nbttagcompound.setByte("Slot", (byte)i);
            itemstack.writeToNBT(nbttagcompound);
            nbttaglist.appendTag(nbttagcompound);
        }
    }

    if (!nbttaglist.hasNoTags() || p_191281_2_)
    {
        p_191281_0_.setTag("Items", nbttaglist);
    }

    return p_191281_0_;
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:25,代碼來源:ItemStackHelper.java

示例5: asItemStackArray

import net.minecraft.util.NonNullList; //導入方法依賴的package包/類
private static ItemStack[] asItemStackArray(NonNullList<ItemStack> stacks) {
    ItemStack[] result = new ItemStack[stacks.size()];
    for (int i = 0; i < stacks.size(); i++) {
        result[i] = stacks.get(i);
    }
    return result;
}
 
開發者ID:TeamPneumatic,項目名稱:pnc-repressurized,代碼行數:8,代碼來源:EntityTrackHandler.java

示例6: addDrops

import net.minecraft.util.NonNullList; //導入方法依賴的package包/類
@Override
public void addDrops(NonNullList<ItemStack> drops) {
    super.addDrops(drops);

    boolean shouldAddTag = false;
    for (int i = 0; i < filters.getSlots(); i++) {
        if (!filters.getStackInSlot(i).isEmpty()) { //Only set a tag when there are requests.
            shouldAddTag = true;
            break;
        }
    }

    for (FluidTank fluidFilter : fluidFilters) {
        if (fluidFilter.getFluidAmount() > 0) {
            shouldAddTag = true;
            break;
        }
    }

    if (invisible) shouldAddTag = true;

    if (shouldAddTag) {
        ItemStack drop = drops.get(0);
        NBTTagCompound tag = new NBTTagCompound();
        writeToNBT(tag);
        drop.setTagCompound(tag);
    }
}
 
開發者ID:TeamPneumatic,項目名稱:pnc-repressurized,代碼行數:29,代碼來源:SemiBlockLogistics.java

示例7: onTake

import net.minecraft.util.NonNullList; //導入方法依賴的package包/類
public ItemStack onTake(EntityPlayer thePlayer, ItemStack stack) {
    CraftiniumRecipe recipe = CraftiniumRecipeRegistry.findMatching(this.craftMatrix, thePlayer.world, this.table, thePlayer);
    if(recipe == null) {
        this.inventory.setInventorySlotContents(0, ItemStack.EMPTY);
        return ItemStack.EMPTY;
    } else {
        this.onCrafting(stack);
        net.minecraftforge.common.ForgeHooks.setCraftingPlayer(thePlayer);
        NonNullList<ItemStack> nonnulllist = recipe.remaining(this.craftMatrix, thePlayer.world, this.table, thePlayer);
        net.minecraftforge.common.ForgeHooks.setCraftingPlayer(null);

        for (int i = 0; i < nonnulllist.size(); ++i) {
            ItemStack itemstack = this.craftMatrix.getStackInSlot(i);
            ItemStack itemstack1 = nonnulllist.get(i);

            if (!itemstack.isEmpty()) {
                this.craftMatrix.decrStackSize(i, 1);
                itemstack = this.craftMatrix.getStackInSlot(i);
            }

            if (!itemstack1.isEmpty()) {
                if (itemstack.isEmpty()) {
                    this.craftMatrix.setInventorySlotContents(i, itemstack1);
                } else if (ItemStack.areItemsEqual(itemstack, itemstack1) && ItemStack.areItemStackTagsEqual(itemstack, itemstack1)) {
                    itemstack1.grow(itemstack.getCount());
                    this.craftMatrix.setInventorySlotContents(i, itemstack1);
                } else if (!this.player.inventory.addItemStackToInventory(itemstack1)) {
                    this.player.dropItem(itemstack1, false);
                }
            }
        }

        return stack;
    }
}
 
開發者ID:Randores,項目名稱:Randores2,代碼行數:36,代碼來源:CraftiniumSlotCrafting.java

示例8: isSameInputs

import net.minecraft.util.NonNullList; //導入方法依賴的package包/類
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;
}
 
開發者ID:cubex2,項目名稱:customstuff4,代碼行數:15,代碼來源:ShapedRecipe.java

示例9: onUpdate

import net.minecraft.util.NonNullList; //導入方法依賴的package包/類
public void onUpdate(EntityPlayerSP player) {
	if(isEnabled()) {
		if(timer > 0) {
			timer--;
			return;
		}
			
           NonNullList<ItemStack> inv;
           ItemStack offhand = player.getItemStackFromSlot(EntityEquipmentSlot.OFFHAND);

           int inventoryIndex;

           inv = player.inventory.mainInventory;
           
           for(inventoryIndex = 0; inventoryIndex < inv.size(); inventoryIndex++) {
              	if (inv.get(inventoryIndex) != ItemStack.field_190927_a) { //ItemStack.EMPTY
           		if ((offhand == null) || (offhand.getItem() != Items.field_190929_cY)) { //ItemStack.TOTEM
           			if (inv.get(inventoryIndex).getItem() == Items.field_190929_cY) { //ItemStack.TOTEM
           				replaceTotem(inventoryIndex);
           	            break;
           			}
           		}
               }
			timer = 3;
           }
	}
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:28,代碼來源:AutoTotem.java

示例10: deleteStack

import net.minecraft.util.NonNullList; //導入方法依賴的package包/類
public void deleteStack(ItemStack stack)
{
    for (NonNullList<ItemStack> nonnulllist : this.allInventories)
    {
        for (int i = 0; i < nonnulllist.size(); ++i)
        {
            if (nonnulllist.get(i) == stack)
            {
                nonnulllist.set(i, ItemStack.field_190927_a);
                break;
            }
        }
    }
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:15,代碼來源:InventoryPlayer.java

示例11: removeStackFromSlot

import net.minecraft.util.NonNullList; //導入方法依賴的package包/類
/**
 * Removes a stack from the given slot and returns it.
 */
public ItemStack removeStackFromSlot(int index)
{
    NonNullList<ItemStack> nonnulllist = null;

    for (NonNullList<ItemStack> nonnulllist1 : this.allInventories)
    {
        if (index < nonnulllist1.size())
        {
            nonnulllist = nonnulllist1;
            break;
        }

        index -= nonnulllist1.size();
    }

    if (nonnulllist != null && !((ItemStack)nonnulllist.get(index)).func_190926_b())
    {
        ItemStack itemstack = (ItemStack)nonnulllist.get(index);
        nonnulllist.set(index, ItemStack.field_190927_a);
        return itemstack;
    }
    else
    {
        return ItemStack.field_190927_a;
    }
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:30,代碼來源:InventoryPlayer.java

示例12: SPacketWindowItems

import net.minecraft.util.NonNullList; //導入方法依賴的package包/類
public SPacketWindowItems(int p_i47317_1_, NonNullList<ItemStack> p_i47317_2_)
{
    this.windowId = p_i47317_1_;
    this.itemStacks = NonNullList.<ItemStack>func_191197_a(p_i47317_2_.size(), ItemStack.field_190927_a);

    for (int i = 0; i < this.itemStacks.size(); ++i)
    {
        ItemStack itemstack = (ItemStack)p_i47317_2_.get(i);

        if (!itemstack.func_190926_b())
        {
            this.itemStacks.set(i, itemstack.copy());
        }
    }
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:16,代碼來源:SPacketWindowItems.java

示例13: func_190901_a

import net.minecraft.util.NonNullList; //導入方法依賴的package包/類
public ItemStack func_190901_a(EntityPlayer p_190901_1_, ItemStack p_190901_2_)
{
    this.onCrafting(p_190901_2_);
    NonNullList<ItemStack> nonnulllist = CraftingManager.getInstance().getRemainingItems(this.craftMatrix, p_190901_1_.world);

    for (int i = 0; i < nonnulllist.size(); ++i)
    {
        ItemStack itemstack = this.craftMatrix.getStackInSlot(i);
        ItemStack itemstack1 = (ItemStack)nonnulllist.get(i);

        if (!itemstack.func_190926_b())
        {
            this.craftMatrix.decrStackSize(i, 1);
            itemstack = this.craftMatrix.getStackInSlot(i);
        }

        if (!itemstack1.func_190926_b())
        {
            if (itemstack.func_190926_b())
            {
                this.craftMatrix.setInventorySlotContents(i, itemstack1);
            }
            else if (ItemStack.areItemsEqual(itemstack, itemstack1) && ItemStack.areItemStackTagsEqual(itemstack, itemstack1))
            {
                itemstack1.func_190917_f(itemstack.func_190916_E());
                this.craftMatrix.setInventorySlotContents(i, itemstack1);
            }
            else if (!this.thePlayer.inventory.addItemStackToInventory(itemstack1))
            {
                this.thePlayer.dropItem(itemstack1, false);
            }
        }
    }

    return p_190901_2_;
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:37,代碼來源:SlotCrafting.java

示例14: onTake

import net.minecraft.util.NonNullList; //導入方法依賴的package包/類
@Override
public ItemStack onTake(EntityPlayer playerIn, ItemStack stack) {
	if (stack.getItem() == TF2weapons.itemTF2 && stack.getMetadata() == 9) {
		stack = ItemFromData.getRandomWeapon(playerIn.getRNG(), ItemFromData.VISIBLE_WEAPON);
		//playerIn.addStat(TF2Achievements.HOME_MADE);
		playerIn.inventory.setItemStack(stack);
	} else if (stack.getItem() == TF2weapons.itemTF2 && stack.getMetadata() == 10) {
		stack = ItemFromData.getRandomWeaponOfClass("cosmetic", playerIn.getRNG(), false);
		playerIn.inventory.setItemStack(stack);
	}
	if(stack.hasTagCompound()&&stack.getTagCompound().getBoolean("Australium")){
		//playerIn.addStat(TF2Achievements.SHINY);
	}
	net.minecraftforge.fml.common.FMLCommonHandler.instance().firePlayerCraftingEvent(playerIn, stack, craftMatrix);
	this.onCrafting(stack);
	net.minecraftforge.common.ForgeHooks.setCraftingPlayer(playerIn);
	NonNullList<ItemStack> aitemstack = TF2CraftingManager.INSTANCE.getRemainingItems(this.craftMatrix, playerIn.world);
	net.minecraftforge.common.ForgeHooks.setCraftingPlayer(null);

	for (int i = 0; i < aitemstack.size(); ++i) {
		ItemStack itemstack = this.craftMatrix.getStackInSlot(i);
		ItemStack itemstack1 = aitemstack.get(i);

		if (!itemstack.isEmpty()) {
			this.craftMatrix.decrStackSize(i, 1);
			itemstack = this.craftMatrix.getStackInSlot(i);
		}

		if (!itemstack1.isEmpty())
			if (itemstack.isEmpty())
				this.craftMatrix.setInventorySlotContents(i, itemstack1);
			else if (ItemStack.areItemsEqual(itemstack, itemstack1)
					&& ItemStack.areItemStackTagsEqual(itemstack, itemstack1)) {
				itemstack1.grow(itemstack.getCount());
				this.craftMatrix.setInventorySlotContents(i, itemstack1);
			} else if (!this.player.inventory.addItemStackToInventory(itemstack1))
				this.player.dropItem(itemstack1, false);
	}
	return stack;
}
 
開發者ID:rafradek,項目名稱:Mods,代碼行數:41,代碼來源:SlotCraftingTF2.java


注:本文中的net.minecraft.util.NonNullList.get方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。