当前位置: 首页>>代码示例>>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;未经允许,请勿转载。