本文整理匯總了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));
}
}
示例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);
}
}
}
示例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();
}
示例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);
}
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
}
示例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));
}
示例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));
}
示例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));
}
}
示例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);
}
}
}
示例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;
}
示例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);
}
}
示例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;
}
}