本文整理汇总了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");
}
示例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);
}
示例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());
}
示例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_;
}
示例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;
}
示例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);
}
}
示例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;
}
}
示例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;
}
示例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;
}
}
}
示例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;
}
}
}
}
示例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;
}
}
示例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());
}
}
}
示例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_;
}
示例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;
}