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


Java IInventory類代碼示例

本文整理匯總了Java中net.minecraft.inventory.IInventory的典型用法代碼示例。如果您正苦於以下問題:Java IInventory類的具體用法?Java IInventory怎麽用?Java IInventory使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: fillInventory

import net.minecraft.inventory.IInventory; //導入依賴的package包/類
public void fillInventory(IInventory inventory, Random rand, LootContext context)
{
    List<ItemStack> list = this.generateLootForPools(rand, context);
    List<Integer> list1 = this.getEmptySlotsRandomized(inventory, rand);
    this.shuffleItems(list, list1.size(), rand);

    for (ItemStack itemstack : list)
    {
        if (list1.isEmpty())
        {
            LOGGER.warn("Tried to over-fill a container");
            return;
        }

        if (itemstack == null)
        {
            inventory.setInventorySlotContents(((Integer)list1.remove(list1.size() - 1)).intValue(), (ItemStack)null);
        }
        else
        {
            inventory.setInventorySlotContents(((Integer)list1.remove(list1.size() - 1)).intValue(), itemstack);
        }
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:25,代碼來源:LootTable.java

示例2: writeToNBT

import net.minecraft.inventory.IInventory; //導入依賴的package包/類
@Override
public NBTTagCompound writeToNBT(NBTTagCompound compound) {

    if (this.customName != null) {
        compound.setString("CustomName", this.getCustomName());
    }
    
	if (this instanceof IInventory) {
		RezolveNBT.writeInventory(compound, (IInventory)this);
	}
	
	if (this.storedEnergy >= 0)
		compound.setInteger("RF", this.storedEnergy);
	
	return super.writeToNBT(compound);
}
 
開發者ID:astronautlabs,項目名稱:rezolve,代碼行數:17,代碼來源:TileEntityBase.java

示例3: pullItemFromSlot

import net.minecraft.inventory.IInventory; //導入依賴的package包/類
/**
 * Pulls from the specified slot in the inventory and places in any available slot in the hopper. Returns true if
 * the entire stack was moved
 */
private static boolean pullItemFromSlot(IHopper hopper, IInventory inventoryIn, int index, EnumFacing direction)
{
    ItemStack itemstack = inventoryIn.getStackInSlot(index);

    if (itemstack != null && canExtractItemFromSlot(inventoryIn, itemstack, index, direction))
    {
        ItemStack itemstack1 = itemstack.copy();
        ItemStack itemstack2 = putStackInInventoryAllSlots(hopper, inventoryIn.decrStackSize(index, 1), (EnumFacing)null);

        if (itemstack2 == null || itemstack2.stackSize == 0)
        {
            inventoryIn.markDirty();
            return true;
        }

        inventoryIn.setInventorySlotContents(index, itemstack1);
    }

    return false;
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:25,代碼來源:TileEntityHopper.java

示例4: getComparatorInputOverride

import net.minecraft.inventory.IInventory; //導入依賴的package包/類
public int getComparatorInputOverride(IBlockState blockState, World worldIn, BlockPos pos)
{
    if (((Boolean)blockState.getValue(POWERED)).booleanValue())
    {
        List<EntityMinecartCommandBlock> list = this.<EntityMinecartCommandBlock>findMinecarts(worldIn, pos, EntityMinecartCommandBlock.class, new Predicate[0]);

        if (!list.isEmpty())
        {
            return ((EntityMinecartCommandBlock)list.get(0)).getCommandBlockLogic().getSuccessCount();
        }

        List<EntityMinecart> list1 = this.<EntityMinecart>findMinecarts(worldIn, pos, EntityMinecart.class, new Predicate[] {EntitySelectors.HAS_INVENTORY});

        if (!list1.isEmpty())
        {
            return Container.calcRedstoneFromInventory((IInventory)list1.get(0));
        }
    }

    return 0;
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:22,代碼來源:BlockRailDetector.java

示例5: findStack

import net.minecraft.inventory.IInventory; //導入依賴的package包/類
@Nullable
public BeltGetter findStack(EntityPlayer player)
{
    IInventory playerInv = player.inventory;
    for (int i = 0; i < playerInv.getSizeInventory(); i++)
    {
        ItemStack inSlot = playerInv.getStackInSlot(i);
        if (inSlot.getCount() > 0)
        {
            if (inSlot.getItem() instanceof ItemToolBelt)
            {
                return new InventoryBeltGetter(player, i);
            }
        }
    }

    return null;
}
 
開發者ID:gigaherz,項目名稱:ToolBelt,代碼行數:19,代碼來源:BeltFinder.java

示例6: bindPlayerInventory

import net.minecraft.inventory.IInventory; //導入依賴的package包/類
private void bindPlayerInventory(IInventory playerInventory, int blockedSlot)
{
    for (int l = 0; l < 3; ++l)
    {
        for (int j1 = 0; j1 < 9; ++j1)
        {
            int index = j1 + l * 9 + 9;
            this.addSlotToContainer(
                    blockedSlot == index
                            ? new SlotLocked(playerInventory, index, 8 + j1 * 18, l * 18 + 51)
                            : new Slot(playerInventory, index, 8 + j1 * 18, l * 18 + 51)
            );
        }
    }

    for (int i1 = 0; i1 < 9; ++i1)
    {
        this.addSlotToContainer(
                blockedSlot == i1
                        ? new SlotLocked(playerInventory, i1, 8 + i1 * 18, 109)
                        : new Slot(playerInventory, i1, 8 + i1 * 18, 109)
        );
    }
}
 
開發者ID:gigaherz,項目名稱:ToolBelt,代碼行數:25,代碼來源:ContainerBelt.java

示例7: getSlotToPushTo

import net.minecraft.inventory.IInventory; //導入依賴的package包/類
protected int getSlotToPushTo(IInventory inventory) {
	int slot = 0;
	for(; slot < inventory.getSizeInventory(); ++slot) {
		if(debug) {
			FMLLog.log(Level.INFO, "E " + (inventory.getStackInSlot(slot) != null));
			if(inventory.getStackInSlot(slot) != null) {
				FMLLog.log(Level.INFO, "E " + slot + " " + inventory.getStackInSlot(slot).toString());
				FMLLog.log(Level.INFO, "E-true " + (inventory.getStackInSlot(slot) == null));
				FMLLog.log(Level.INFO, "E-true " + (inventory.getStackInSlot(slot).getItem() == blockItemStack.getItem()));
				FMLLog.log(Level.INFO, "E-true " + (inventory.getStackInSlot(slot).getItemDamage() == blockItemStack.getItemDamage()));
				FMLLog.log(Level.INFO, "E-true " + inventory.getStackInSlot(slot).stackSize + " < " + inventory.getStackInSlot(slot).getItem().getItemStackLimit(inventory.getStackInSlot(slot)));
			}
		}
		if(inventory.getStackInSlot(slot) == null || inventory.getStackInSlot(slot).getItem() == blockItemStack.getItem() && inventory.getStackInSlot(slot).getItemDamage() == blockItemStack.getItemDamage()
				&& inventory.getStackInSlot(slot).stackSize < inventory.getStackInSlot(slot).getItem().getItemStackLimit(inventory.getStackInSlot(slot)))
			break;
	}

	if(slot > inventory.getSizeInventory() - 1)
		slot = inventory.getSizeInventory() - 1;

	if(debug)
		FMLLog.log(Level.INFO, "E" + slot);

	return slot;
}
 
開發者ID:viddeno,項目名稱:Technical,代碼行數:27,代碼來源:TileEntityGrabber.java

示例8: ContainerMotor

import net.minecraft.inventory.IInventory; //導入依賴的package包/類
public ContainerMotor(IInventory player, IInventory container, TileEntity te) {
	super(player, container);
	
	this.setTitleColor(0xFFFFFFFF);
	this.setColor(0xCC707070);
	
	WGridPanel panel = new WGridPanel();
	super.setRootPanel(panel);
	
	if (Thermionics.isAprilFools()) {
		panel.add(new WPlasma(), 0, 0, 9, 4);
	}
	
	panel.add(new WPBar(container, 3, 2, 4), 1, 1);
	
	panel.add(new WBar(
			new ResourceLocation("thermionics","textures/gui/progress.heat.bg.png"),
			new ResourceLocation("thermionics","textures/gui/progress.heat.bar.png"),
			container, 0, 1, WBar.Direction.RIGHT
			), 1, 2, 7, 1);
	
	panel.add(this.createPlayerInventoryPanel(), 0, 4);
}
 
開發者ID:elytra,項目名稱:Thermionics,代碼行數:24,代碼來源:ContainerMotor.java

示例9: pushItemIInventory

import net.minecraft.inventory.IInventory; //導入依賴的package包/類
protected boolean pushItemIInventory(IInventory inventory, int slot) {
	if(inventory.getStackInSlot(slot) == null) {
		if(debug)
			FMLLog.log(Level.INFO, "F");
		inventory.setInventorySlotContents(slot, blockItemStack.copy());
		blockItemStack = null;
		markDirty = true;
	} else if(inventory.getStackInSlot(slot).getItem() == blockItemStack.getItem() && inventory.getStackInSlot(slot).stackSize < inventory.getInventoryStackLimit() && inventory.getStackInSlot(slot).stackSize < inventory.getStackInSlot(slot).getMaxStackSize()) {
		if(debug)
			FMLLog.log(Level.INFO, "G");
		blockItemStack.stackSize = blockItemStack.stackSize + inventory.getStackInSlot(slot).stackSize;
		inventory.setInventorySlotContents(slot, blockItemStack.copy());
		blockItemStack = null;
		markDirty = true;
	} else {
		if(debug)
			FMLLog.log(Level.INFO, "Ga");
	}
	return markDirty;
}
 
開發者ID:viddeno,項目名稱:Technical,代碼行數:21,代碼來源:TileEntityGrabber.java

示例10: load

import net.minecraft.inventory.IInventory; //導入依賴的package包/類
/**
 * Load inventory data from NBT tag
 * @param inventory Target inventory
 * @param tag tag to load
 * @param seed Loading seed
 */
private static void load(IInventory inventory, NBTTagCompound tag, long seed) {
    if (tag == null || !Configurator.NATIVE_LOOT) {
        return;
    }
    Random random = new Random(seed);
    NBTTagList items = tag.getTagList("Items", Constants.NBT.TAG_COMPOUND);
    for (int i = 0; i < items.tagCount() && i < inventory.getSizeInventory(); ++i) {
        NBTTagCompound stackTag = items.getCompoundTagAt(i);
        String itemName = stackTag.getString("id").replaceAll(".*:", "");
        itemName = itemName.isEmpty() ? String.valueOf(stackTag.getShort("id")) : itemName;
        Pattern iPattern = Pattern.compile(Pattern.quote(itemName), Pattern.CASE_INSENSITIVE);
        UItem item = Utils.select(UItems.items.select(iPattern), random.nextLong());
        byte count = items.getCompoundTagAt(i).getByte("Count");
        int damage = items.getCompoundTagAt(i).getShort("Damage");
        int slot = stackTag.hasKey("Slot", Constants.NBT.TAG_BYTE) ? stackTag.getByte("Slot") : i;
        slot = (slot < 0 || slot >= inventory.getSizeInventory()) ? i : slot;
        if (item != null && count > 0 && UItems.getPossibleMeta(item).contains(damage)) {
            inventory.setInventorySlotContents(slot, new UItemStack(item, count, damage).getItemStack());
        }
    }
}
 
開發者ID:ternsip,項目名稱:StructPro,代碼行數:28,代碼來源:Tiles.java

示例11: getItemRandom

import net.minecraft.inventory.IInventory; //導入依賴的package包/類
private int getItemRandom(GuiChest chest) {
    try {
        if (Wrapper.player_inventory() == null) return -1;
        List<Integer> items = new ArrayList<>();
        for (int i = 0; i < ((IInventory) ReflectionUtil.getFieldValue("field_147015_w", chest)).func_70302_i_(); i++) {
            ItemStack stack = ((IInventory) ReflectionUtil.getFieldValue("field_147015_w", chest)).func_70301_a(i);
            if (stack != null && ((itemFilter.getValue() && !ItemUtil.isUseless(stack, itemFilterMode.getCurrent())) || !itemFilter.getValue()))
                items.add(i);
        }
        if (items.isEmpty()) return -1;
        Collections.shuffle(items);
        return items.get(0);
    } catch (Exception e) {
        return -1;
    }
}
 
開發者ID:Ygore,項目名稱:bit-client,代碼行數:17,代碼來源:ModuleChestStealer.java

示例12: displayVillagerTradeGui

import net.minecraft.inventory.IInventory; //導入依賴的package包/類
public void displayVillagerTradeGui(IMerchant villager)
{
    this.getNextWindowId();
    this.openContainer = new ContainerMerchant(this.inventory, villager, this.worldObj);
    this.openContainer.windowId = this.currentWindowId;
    this.openContainer.onCraftGuiOpened(this);
    IInventory iinventory = ((ContainerMerchant)this.openContainer).getMerchantInventory();
    IChatComponent ichatcomponent = villager.getDisplayName();
    this.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(this.currentWindowId, "minecraft:villager", ichatcomponent, iinventory.getSizeInventory()));
    MerchantRecipeList merchantrecipelist = villager.getRecipes(this);

    if (merchantrecipelist != null)
    {
        PacketBuffer packetbuffer = new PacketBuffer(Unpooled.buffer());
        packetbuffer.writeInt(this.currentWindowId);
        merchantrecipelist.writeToBuf(packetbuffer);
        this.playerNetServerHandler.sendPacket(new S3FPacketCustomPayload("MC|TrList", packetbuffer));
    }
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:20,代碼來源:EntityPlayerMP.java

示例13: fillInventory

import net.minecraft.inventory.IInventory; //導入依賴的package包/類
@Override
public void fillInventory(IInventory inventory, Random rand, LootContext context)
{
	TileEntityChest chest = (TileEntityChest) inventory;
    CustomLootContext.Builder context$builder = new CustomLootContext.Builder((WorldServer) chest.getWorld());
    context$builder.withChestPos(chest.getPos());
    CustomLootContext customContext = context$builder.build();
	
    List<ItemStack> list = this.generateLootForPools(rand, customContext);
    List<Integer> list1 = this.getEmptySlotsRandomized(inventory, rand);
    this.shuffleItems(list, list1.size(), rand);

    for (ItemStack itemstack : list)
    {
        if (list1.isEmpty())
        {
        	LootSlashConquer.LOGGER.warn("Tried to over-fill a container");
            return;
        }
        
        if (itemstack.isEmpty())
        {
            inventory.setInventorySlotContents(((Integer)list1.remove(list1.size() - 1)).intValue(), ItemStack.EMPTY);
        }
        else
        {
            inventory.setInventorySlotContents(((Integer)list1.remove(list1.size() - 1)).intValue(), itemstack);
        }
    }
}
 
開發者ID:TheXFactor117,項目名稱:Loot-Slash-Conquer,代碼行數:31,代碼來源:CustomLootTable.java

示例14: onCraftMatrixChanged

import net.minecraft.inventory.IInventory; //導入依賴的package包/類
/**
 * Callback for when the crafting matrix is changed.
 */
@Override
public void onCraftMatrixChanged(IInventory inventory)
{
	craftResult.setInventorySlotContents(0,
										 CraftingManager.findMatchingRecipe(craftMatrix, worldObj).getCraftingResult(craftMatrix));
}
 
開發者ID:einsteinsci,項目名稱:BetterBeginningsReborn,代碼行數:10,代碼來源:ContainerSimpleWorkbench.java

示例15: pushItemIInventory

import net.minecraft.inventory.IInventory; //導入依賴的package包/類
protected boolean pushItemIInventory(IInventory inventory, int slot) {
	if(blockItemStack.stackSize > 1) {
		ItemStack oldStack = blockItemStack.copy();
		ItemStack newStack = blockItemStack.splitStack(1);
		
		if(inventory.getStackInSlot(slot) == null) {
			if(debug)
				FMLLog.log(Level.INFO, "fF");
			inventory.setInventorySlotContents(slot, newStack.copy());
			newStack = null;
			markDirty = true;
		} else if(inventory.getStackInSlot(slot).getItem() == newStack.getItem() && inventory.getStackInSlot(slot).stackSize < inventory.getInventoryStackLimit() && inventory.getStackInSlot(slot).stackSize < inventory.getStackInSlot(slot).getMaxStackSize()) {
			if(debug)
				FMLLog.log(Level.INFO, "fG");
			newStack.stackSize += inventory.getStackInSlot(slot).stackSize;
			inventory.setInventorySlotContents(slot, newStack.copy());
			newStack = null;
			markDirty = true;
		} else {
			if(debug)
				FMLLog.log(Level.INFO, "fGa");
		}
		
		if(newStack == null || newStack.stackSize == 0) {
			if(debug)
				FMLLog.log(Level.INFO, "fDa");
			markDirty = true;
		} else {
			blockItemStack = oldStack;
		}
	}
	return markDirty;
}
 
開發者ID:viddeno,項目名稱:Technical,代碼行數:34,代碼來源:TileEntityGrabberFiltering.java


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