当前位置: 首页>>代码示例>>Java>>正文


Java NonNullList类代码示例

本文整理汇总了Java中net.minecraft.util.NonNullList的典型用法代码示例。如果您正苦于以下问题:Java NonNullList类的具体用法?Java NonNullList怎么用?Java NonNullList使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


NonNullList类属于net.minecraft.util包,在下文中一共展示了NonNullList类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getSubBlocks

import net.minecraft.util.NonNullList; //导入依赖的package包/类
@SideOnly(Side.CLIENT)
@Override
public void getSubBlocks(CreativeTabs tab, NonNullList<ItemStack> list)
{
	for (int i = 0; i < EnumRockClass.values().length; ++i)
	{
		list.add(new ItemStack(this, 1, i));
	}
}
 
开发者ID:V0idWa1k3r,项目名称:ExPetrum,代码行数:10,代码来源:BlockSeaweed.java

示例2: getSubItems

import net.minecraft.util.NonNullList; //导入依赖的package包/类
@Override
@SideOnly(Side.CLIENT)
public void getSubItems(CreativeTabs tab, NonNullList<ItemStack> subItems) {
	if(!Config.DISABLED_TOOLS.contains("hammer")) {
		ItemStack stack1 = new ItemStack(this);
		NBTTagCompound tag = new NBTTagCompound();
		tag.setString(HEAD_TAG, Materials.randomHead().getName());
		tag.setString(HAFT_TAG, Materials.randomHaft().getName());
		tag.setString(HANDLE_TAG, Materials.randomHandle().getName());
		tag.setString(ADORNMENT_TAG, Materials.randomAdornment().getName());
		stack1.setTagCompound(tag);
		if (isInCreativeTab(tab)) {
			subItems.add(stack1);
		}
	}
}
 
开发者ID:the-realest-stu,项目名称:Adventurers-Toolbox,代码行数:17,代码来源:ItemATHammer.java

示例3: getSearchEntries

import net.minecraft.util.NonNullList; //导入依赖的package包/类
/**
 * Lazy cache.
 * @return
 */
private Stream<SearchEntry> getSearchEntries(){
    if(cachedSearchEntries == null){
        NonNullList<ItemStack> itemList = NonNullList.create();

        for(Item item : Item.REGISTRY){
            if (item != null && item.getCreativeTab() != null) {
                item.getSubItems(item.getCreativeTab(), itemList);
            }
        }

        for (Enchantment enchantment : Enchantment.REGISTRY) {
            if (enchantment != null && enchantment.type != null) {
                getAllEnchantedBooks(enchantment, itemList);
            }
        }

        cachedSearchEntries = itemList.stream().map(SearchEntry::new).collect(Collectors.toList());
    }
    return cachedSearchEntries.stream();
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:25,代码来源:GuiSearcher.java

示例4: reArrangeStacks

import net.minecraft.util.NonNullList; //导入依赖的package包/类
public static void reArrangeStacks(InventoryDankNull inventory) {
	if (inventory != null) {
		int count = 0;
		NonNullList<ItemStack> stackList = NonNullList.withSize(inventory.getSizeInventory(), ItemStack.EMPTY);
		for (int i = 0; i < inventory.getSizeInventory(); i++) {
			ItemStack stack = inventory.getStackInSlot(i);
			if (!stack.isEmpty()) {
				stackList.set(count, inventory.getStackInSlot(i));
				count++;
			}
		}
		if (stackList.size() == 0) {
			setSelectedStackIndex(inventory, -1);
		}
		else {
			for (int i = 0; i < stackList.size(); i++) {
				inventory.setInventorySlotContents(i, stackList.get(i));
			}
			for (int i = stackList.size(); i < inventory.getSizeInventory(); i++) {
				inventory.setInventorySlotContents(i, ItemStack.EMPTY);
			}
		}
		setSelectedIndexApplicable(inventory);
	}
}
 
开发者ID:p455w0rd,项目名称:DankNull,代码行数:26,代码来源:DankNullUtils.java

示例5: createElementalInput

import net.minecraft.util.NonNullList; //导入依赖的package包/类
/**
 * Creates a list of ingredients based on an Object[].  Valid types are {@link String}, {@link ItemStack}, {@link Item}, and {@link Block}.
 * Used for elemental recipes.
 */
private static NonNullList<Ingredient> createElementalInput(Object[] input)
{
	if (input[0] instanceof List)
		input = ((List<?>) input[0]).toArray();
	else if (input[0] instanceof Object[])
		input = (Object[]) input[0];
	NonNullList<Ingredient> inputL = NonNullList.withSize(9, Ingredient.EMPTY);
	for (int i = 0; i < input.length; i++)
	{
		Object k = input[i];
		if (k instanceof String)
			inputL.set(i, new OreIngredient((String) k));
		else if (k instanceof ItemStack && !((ItemStack) k).isEmpty())
			inputL.set(i, Ingredient.fromStacks((ItemStack) k));
		else if (k instanceof IForgeRegistryEntry)
			inputL.set(i, Ingredient.fromStacks(makeStack((IForgeRegistryEntry<?>) k)));
	}
	return inputL;
}
 
开发者ID:raphydaphy,项目名称:ArcaneMagic,代码行数:24,代码来源:RecipeHelper.java

示例6: getBlocksFromString

import net.minecraft.util.NonNullList; //导入依赖的package包/类
public static ArrayList<Block> getBlocksFromString(String blockName)
{
	ArrayList<Block> blocks = new ArrayList<>();
	if(!HarshenUtils.toArray(Blocks.AIR, null).contains(Block.getBlockFromName(blockName)))
		blocks.add(Block.getBlockFromName(blockName));
	for(ItemStack oreStack : OreDictionary.getOres(blockName))
		if(oreStack.getItem() instanceof ItemBlock)
			blocks.add(((ItemBlock)oreStack.getItem()).getBlock());
	ArrayList<Block> finalBlocks = new ArrayList<>();
	for(Block b : blocks)
	{
		NonNullList<ItemStack> items = NonNullList.create();
		b.getSubBlocks(CreativeTabs.SEARCH, items);
		for(ItemStack stack : items)
			if(!stack.isEmpty())
				finalBlocks.add(Block.getBlockFromItem(stack.getItem()));
			else
				finalBlocks.add(b);
	}
	return finalBlocks;
}
 
开发者ID:kenijey,项目名称:harshencastle,代码行数:22,代码来源:HarshenUtils.java

示例7: handleServerMessage

import net.minecraft.util.NonNullList; //导入依赖的package包/类
@Override
public IMessage handleServerMessage(EntityPlayer player, MessageSyncClearList message, MessageContext ctx) {
	if ((player != null) && (message != null) && (ctx != null)) {
		EntityPlayer en = (EntityPlayer) player.getEntityWorld().getEntityByID(message.entityId);
		if (en != null) {
			if (player.getEntityId() == en.getEntityId() && en.getEntityWorld() != null && en.hasCapability(Currency.CART_DATA, null)) {
				CartCapability entityData = en.getCapability(Currency.CART_DATA, null);

				entityData.setCart(NonNullList.withSize(entityData.getSizeInventory(), ItemStack.EMPTY), true);
				List<Float> prices = Arrays.asList(new Float[25]);
				for (int i = 0; i < prices.size(); i++) {
					prices.set(i, (float) 0);
				}
			}
		}
	}
	return null;
}
 
开发者ID:Zundrel,项目名称:Never-Enough-Currency,代码行数:19,代码来源:MessageSyncClearList.java

示例8: getSubItems

import net.minecraft.util.NonNullList; //导入依赖的package包/类
@Override
public void getSubItems(CreativeTabs tab, NonNullList<ItemStack> list) {
	if (tab.equals(this.getCreativeTab())) {
		{ //Construct a sample scarf
			NBTTagCompound tag = new NBTTagCompound();
			NBTTagList leftScarf = new NBTTagList();
			NBTTagList rightScarf = new NBTTagList();
			for(int i=0; i<14; i++) {
				NBTTagCompound node = new NBTTagCompound();
				int col = 0x60d9bb;
				if (i%2==1) col = 0x1b5c64;
				node.setInteger("Color", col);
				leftScarf.appendTag(node);
				rightScarf.appendTag(node.copy());
			}
			tag.setTag("LeftScarf", leftScarf);
			tag.setTag("RightScarf", rightScarf);
			ItemStack stack = new ItemStack(this, 1);
			stack.setTagCompound(tag);
			list.add(stack);
		}
	}
}
 
开发者ID:elytra,项目名称:Thermionics,代码行数:24,代码来源:ItemScarf.java

示例9: getSubItems

import net.minecraft.util.NonNullList; //导入依赖的package包/类
@Override
@SideOnly(Side.CLIENT)

/**
 * returns a list of items with the same ID, but different meta (eg: dye
 * returns 16 items)
 */
public void getSubItems(CreativeTabs par2CreativeTabs, NonNullList<ItemStack> par3List) {
	if(!this.isInCreativeTab(par2CreativeTabs))
		return;
	for (int i = 0; i < 18; i++)
		par3List.add(new ItemStack(this, 1, i));
	par3List.add(new ItemStack(this, 1, 26));
	par3List.add(new ItemStack(this, 1, 27));
	par3List.add(new ItemStack(this, 1, 28));
	par3List.add(new ItemStack(this, 1, 29));
	par3List.add(new ItemStack(this, 1, 30));
}
 
开发者ID:rafradek,项目名称:Mods,代码行数:19,代码来源:ItemMonsterPlacerPlus.java

示例10: matches

import net.minecraft.util.NonNullList; //导入依赖的package包/类
/**
 * For every ingredient, we need to check each itemstack.
 * Then, if we find a match, mark that itemstack so it cannot be checked again.
 */

@Override
public boolean matches(EntityPlayer player, ItemStack wand, NonNullList<ItemStack> stacks, World world)
{
	List<ItemStack> toCheck = Lists.newArrayList(stacks);
	for (Ingredient i : this.inputs)
	{
		for (int ix = 0; ix < toCheck.size(); ix++)
		{
			if (i.apply(toCheck.get(ix)))
			{
				toCheck.remove(ix);
				break;
			} else if (i == Ingredient.EMPTY && toCheck.get(ix).isEmpty())
				toCheck.remove(ix);
		}
	}

	IArcaneTransfigurationItem crafter = (IArcaneTransfigurationItem) wand.getItem();
	if (!crafter.matches(this, player, wand, stacks, world))
		return false;
	return toCheck.isEmpty() && (anima.isEmpty() || (crafter.containsAnimus()
			&& wand.getCapability(IAnimaStorage.CAP, null).take(anima, true) == null));
}
 
开发者ID:raphydaphy,项目名称:ArcaneMagic,代码行数:29,代码来源:ShapelessArcaneTransfigurationRecipe.java

示例11: displayAllRelevantItems

import net.minecraft.util.NonNullList; //导入依赖的package包/类
@Override
public void displayAllRelevantItems(NonNullList<ItemStack> items) {
	for (int i = 0; i < 6; i++) {
		items.add(new ItemStack(ModItems.DANK_NULL, 1, i));
	}
	for (Item item : ModItems.getList()) {
		if (!(item instanceof ItemDankNull) && !(item instanceof ItemDankNullHolder) && !(item instanceof ItemBlock) && !(item instanceof ItemDankNullPanel)) {
			items.add(new ItemStack(item));
		}
	}
	for (int i = 0; i < 6; i++) {
		items.add(new ItemStack(ModItems.DANK_NULL_PANEL, 1, i));
	}
	for (Block block : ModBlocks.getList()) {
		items.add(new ItemStack(block));
	}
}
 
开发者ID:p455w0rd,项目名称:DankNull,代码行数:18,代码来源:ModCreativeTab.java

示例12: getSubItems

import net.minecraft.util.NonNullList; //导入依赖的package包/类
@Override
@SideOnly(Side.CLIENT)
public void getSubItems(CreativeTabs tab, NonNullList<ItemStack> subItems) {
	if(!Config.DISABLED_TOOLS.contains("shovel")) {
		ItemStack stack1 = new ItemStack(this);
		NBTTagCompound tag = new NBTTagCompound();
		tag.setString(HEAD_TAG, Materials.randomHead().getName());
		tag.setString(HAFT_TAG, Materials.randomHaft().getName());
		tag.setString(HANDLE_TAG, Materials.randomHandle().getName());
		tag.setString(ADORNMENT_TAG, Materials.randomAdornment().getName());
		stack1.setTagCompound(tag);
		if (isInCreativeTab(tab)) {
			subItems.add(stack1);
		}
	}
}
 
开发者ID:the-realest-stu,项目名称:Adventurers-Toolbox,代码行数:17,代码来源:ItemATShovel.java

示例13: getRemainingItems

import net.minecraft.util.NonNullList; //导入依赖的package包/类
public NonNullList<ItemStack> getRemainingItems(InventoryCrafting inv)
{
    NonNullList<ItemStack> nonnulllist = NonNullList.<ItemStack>func_191197_a(inv.getSizeInventory(), ItemStack.field_190927_a);

    for (int i = 0; i < nonnulllist.size(); ++i)
    {
        ItemStack itemstack = inv.getStackInSlot(i);

        if (itemstack.getItem().hasContainerItem())
        {
            nonnulllist.set(i, new ItemStack(itemstack.getItem().getContainerItem()));
        }
    }

    return nonnulllist;
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:17,代码来源:RecipeFireworks.java

示例14: readEntityFromNBT

import net.minecraft.util.NonNullList; //导入依赖的package包/类
/**
 * (abstract) Protected helper method to read subclass entity data from NBT.
 */
protected void readEntityFromNBT(NBTTagCompound compound)
{
    super.readEntityFromNBT(compound);
    this.minecartContainerItems = NonNullList.<ItemStack>func_191197_a(this.getSizeInventory(), ItemStack.field_190927_a);

    if (compound.hasKey("LootTable", 8))
    {
        this.lootTable = new ResourceLocation(compound.getString("LootTable"));
        this.lootTableSeed = compound.getLong("LootTableSeed");
    }
    else
    {
        ItemStackHelper.func_191283_b(compound, this.minecartContainerItems);
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:19,代码来源:EntityMinecartContainer.java

示例15: innerUpdate

import net.minecraft.util.NonNullList; //导入依赖的package包/类
@Override
protected void innerUpdate() {
    if (this.world.isRemote) return;
    ++tick;
    if (crafting.getLocked() && tick >= 40 && hasOnlyOneFluid()) {
        Fluid fluid = getRecipeFluid();
        if (fluid == null) return;
        int bucketAmount = getFluidAmount(fluid);
        FluidStack stack = tank.drain(bucketAmount * 1000, false);
        if (stack != null && stack.getFluid().equals(fluid) && stack.amount == bucketAmount * 1000) {
            IRecipe recipe = CraftingUtils.findRecipe(world, simulateRecipeEntries(fluid));
            if (recipe == null || recipe.getRecipeOutput().isEmpty()) return;
            if (ItemHandlerHelper.insertItem(this.output, recipe.getRecipeOutput().copy(), true).isEmpty() && areAllSolidsPresent(fluid)) {
                NonNullList<ItemStack> remaining = recipe.getRemainingItems(CraftingUtils.genCraftingInventory(world, simulateRecipeEntries(fluid)));
                for (int i = 0; i < crafting.getSlots(); ++i) {
                    if (isStackCurrentFluid(fluid, crafting.getFilterStack(i))) continue;
                    if (remaining.get(i).isEmpty()) crafting.getStackInSlot(i).shrink(1);
                    else crafting.setStackInSlot(i, remaining.get(i).copy());
                }
                tank.drain(bucketAmount * 1000, true);
                ItemHandlerHelper.insertItem(this.output, recipe.getRecipeOutput().copy(), false);
            }
        }
        tick = 0;
    }
}
 
开发者ID:Buuz135,项目名称:Industrial-Foregoing,代码行数:27,代码来源:FluidCrafterTile.java


注:本文中的net.minecraft.util.NonNullList类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。