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


Java InventoryBasic类代码示例

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


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

示例1: onEntityDeath

import net.minecraft.inventory.InventoryBasic; //导入依赖的package包/类
@SubscribeEvent
public static void onEntityDeath(LivingDeathEvent event)
{
	// if villager death drops are enabled, if the newly dead entity is a villager, and that villager was killed by a player...
	if ((ModConfiguration.enableDeathDrops) && (event.getEntityLiving() instanceof EntityVillager) && (event.getSource().getTrueSource() instanceof EntityPlayerMP))
	{
		// iterate through the itemstacks in the villager's inventory
		InventoryBasic inventory = ((EntityVillager)event.getEntityLiving()).getVillagerInventory();
		for (int i = 0; i < inventory.getSizeInventory(); i++)
		{
			// remove the stack from the inventory and spawn it in the world
			ItemStack stack = inventory.getStackInSlot(i);
			if (stack != ItemStack.EMPTY)
			{
				event.getEntityLiving().entityDropItem(stack, 0.0F);
			}
		}
	}
}
 
开发者ID:crazysnailboy,项目名称:VillagerInventory,代码行数:20,代码来源:VillagerInventoryMod.java

示例2: onInventoryChanged

import net.minecraft.inventory.InventoryBasic; //导入依赖的package包/类
/**
 * Called by InventoryBasic.onInventoryChanged() on a array that is never filled.
 */
public void onInventoryChanged(InventoryBasic p_76316_1_)
{
    int i = this.getHorseArmorIndexSynced();
    boolean flag = this.isHorseSaddled();
    this.updateHorseSlots();

    if (this.ticksExisted > 20)
    {
        if (i == 0 && i != this.getHorseArmorIndexSynced())
        {
            this.playSound("mob.horse.armor", 0.5F, 1.0F);
        }
        else if (i != this.getHorseArmorIndexSynced())
        {
            this.playSound("mob.horse.armor", 0.5F, 1.0F);
        }

        if (!flag && this.isHorseSaddled())
        {
            this.playSound("mob.horse.leather", 0.5F, 1.0F);
        }
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:27,代码来源:EntityHorse.java

示例3: EntityVillager

import net.minecraft.inventory.InventoryBasic; //导入依赖的package包/类
public EntityVillager(World worldIn, int professionId)
{
    super(worldIn);
    this.villagerInventory = new InventoryBasic("Items", false, 8);
    this.setProfession(professionId);
    this.setSize(0.6F, 1.8F);
    ((PathNavigateGround)this.getNavigator()).setBreakDoors(true);
    ((PathNavigateGround)this.getNavigator()).setAvoidsWater(true);
    this.tasks.addTask(0, new EntityAISwimming(this));
    this.tasks.addTask(1, new EntityAIAvoidEntity(this, EntityZombie.class, 8.0F, 0.6D, 0.6D));
    this.tasks.addTask(1, new EntityAITradePlayer(this));
    this.tasks.addTask(1, new EntityAILookAtTradePlayer(this));
    this.tasks.addTask(2, new EntityAIMoveIndoors(this));
    this.tasks.addTask(3, new EntityAIRestrictOpenDoor(this));
    this.tasks.addTask(4, new EntityAIOpenDoor(this, true));
    this.tasks.addTask(5, new EntityAIMoveTowardsRestriction(this, 0.6D));
    this.tasks.addTask(6, new EntityAIVillagerMate(this));
    this.tasks.addTask(7, new EntityAIFollowGolem(this));
    this.tasks.addTask(9, new EntityAIWatchClosest2(this, EntityPlayer.class, 3.0F, 1.0F));
    this.tasks.addTask(9, new EntityAIVillagerInteract(this));
    this.tasks.addTask(9, new EntityAIWander(this, 0.6D));
    this.tasks.addTask(10, new EntityAIWatchClosest(this, EntityLiving.class, 8.0F));
    this.setCanPickUpLoot(true);
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:25,代码来源:EntityVillager.java

示例4: onInventoryChanged

import net.minecraft.inventory.InventoryBasic; //导入依赖的package包/类
/**
 * Called by InventoryBasic.onInventoryChanged() on a array that is never filled.
 */
public void onInventoryChanged(InventoryBasic invBasic)
{
    HorseArmorType horsearmortype = this.getHorseArmorType();
    boolean flag = this.isHorseSaddled();
    this.updateHorseSlots();

    if (this.ticksExisted > 20)
    {
        if (horsearmortype == HorseArmorType.NONE && horsearmortype != this.getHorseArmorType())
        {
            this.playSound(SoundEvents.ENTITY_HORSE_ARMOR, 0.5F, 1.0F);
        }
        else if (horsearmortype != this.getHorseArmorType())
        {
            this.playSound(SoundEvents.ENTITY_HORSE_ARMOR, 0.5F, 1.0F);
        }

        if (!flag && this.isHorseSaddled())
        {
            this.playSound(SoundEvents.ENTITY_HORSE_SADDLE, 0.5F, 1.0F);
        }
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:27,代码来源:EntityHorse.java

示例5: writeInventoryBasicToNBT

import net.minecraft.inventory.InventoryBasic; //导入依赖的package包/类
public static NBTTagCompound writeInventoryBasicToNBT(final NBTTagCompound tag, final InventoryBasic inventoryBasic) {
    if (inventoryBasic.hasCustomInventoryName()) {
        tag.setString("CustomName", inventoryBasic.getInventoryName());
    }
    final NBTTagList nbttaglist = new NBTTagList();
    for (int i = 0; i < inventoryBasic.getSizeInventory(); ++i) {
        final ItemStack stackInSlot = inventoryBasic.getStackInSlot(i);
        if (stackInSlot != null) {
            final NBTTagCompound itemTag = new NBTTagCompound();
            itemTag.setByte("Slot", (byte)i);
            stackInSlot.writeToNBT(itemTag);
            nbttaglist.appendTag((NBTBase)itemTag);
        }
    }
    tag.setTag("Items", (NBTBase)nbttaglist);
    return tag;
}
 
开发者ID:sameer,项目名称:ExtraUtilities,代码行数:18,代码来源:XUHelper.java

示例6: convert

import net.minecraft.inventory.InventoryBasic; //导入依赖的package包/类
public TMultiPart convert(final World world, final BlockCoord pos) {
    final Block id = world.getBlock(pos.x, pos.y, pos.z);
    int meta = world.getBlockMetadata(pos.x, pos.y, pos.z);
    if (id != ExtraUtils.transferPipe && id != ExtraUtils.transferPipe2) {
        return null;
    }
    if (id == ExtraUtils.transferPipe2) {
        meta += 16;
    }
    if (meta != 9) {
        return (TMultiPart)new PipePart(meta);
    }
    if (world.getTileEntity(pos.x, pos.y, pos.z) instanceof TileEntityFilterPipe) {
        final InventoryBasic t = ((TileEntityFilterPipe)world.getTileEntity(pos.x, pos.y, pos.z)).items;
        return (TMultiPart)new FilterPipePart(t);
    }
    return (TMultiPart)new FilterPipePart();
}
 
开发者ID:sameer,项目名称:ExtraUtilities,代码行数:19,代码来源:RegisterPipeParts.java

示例7: createListOfItemsInExpandableBackpack

import net.minecraft.inventory.InventoryBasic; //导入依赖的package包/类
private void createListOfItemsInExpandableBackpack()
{
    if (!TombManyGraves.isExpandableBackpacksInstalled)
    {
        expandableBackpackItems = new ArrayList<>();
        return;
    }
    NBTTagCompound tag = deathList.getTagCompound().getCompoundTag("ExpandableBackpack");
    ItemStack stack = ItemStack.loadItemStackFromNBT(tag);
    if (stack == null || stack.stackSize == 0)
    {
        expandableBackpackItems = new ArrayList<>();
        return;
    }

    IInventory inventory = new InventoryBasic("temp",false,1);
    inventory.setInventorySlotContents(0,stack);
    expandableBackpackItems = createListFromInventory(inventory, EXPANDABLE);
}
 
开发者ID:M4thG33k,项目名称:TombManyGraves,代码行数:20,代码来源:GuiDeathItems.java

示例8: createListOfItemsInEydamosBackpack

import net.minecraft.inventory.InventoryBasic; //导入依赖的package包/类
private void createListOfItemsInEydamosBackpack()
    {
        if (!TombManyGraves.isEydamosBackpacksInstalled)
        {
            eydamosBackpackItems = new ArrayList<>();
            return;
        }
        NBTTagCompound tag = deathList.getTagCompound().getCompoundTag("EydamosBackpack");
        ItemStack stack = ItemStack.loadItemStackFromNBT(tag);
        if (stack == null || stack.stackSize == 0)
        {
            eydamosBackpackItems = new ArrayList<>();
            return;
        }

//        BackpackSave instance = BackpackSave.loadBackpack(player.worldObj, stack, player, false);
//
//        eydamosBackpackItems = createListFromInventory(instance, EYDAMOS);
//        return;
        IInventory inventory = new InventoryBasic("temp",false,1);
        inventory.setInventorySlotContents(0, stack);

        eydamosBackpackItems = createListFromInventory(inventory, EYDAMOS);

    }
 
开发者ID:M4thG33k,项目名称:TombManyGraves,代码行数:26,代码来源:GuiDeathItems.java

示例9: writeInventoryToNBT

import net.minecraft.inventory.InventoryBasic; //导入依赖的package包/类
/**
 * Writes an inventory to an NBTTagCompound. Can be used to save an inventory in a
 * TileEntity, or perhaps an ItemStack.
 *
 * @param tag: The NBTTagCompound to write the inventory to.
 * @param inventory: The inventory to write to the NBTTagCompound.
 * @return NBTTagCompound: The same NBTTagCompound that was passed to this method.
 */
public static NBTTagCompound writeInventoryToNBT (NBTTagCompound tag, InventoryBasic inventory) {
    if (inventory.hasCustomName())
        tag.setString("CustomName", inventory.getName());
    final NBTTagList nbttaglist = new NBTTagList();
    for (int slotCount = 0; slotCount < inventory.getSizeInventory(); slotCount++) {
        final ItemStack stackInSlot = inventory.getStackInSlot(slotCount);
        if (stackInSlot != null) {
            final NBTTagCompound itemTag = new NBTTagCompound();
            itemTag.setByte("Slot", (byte) slotCount);
            stackInSlot.writeToNBT(itemTag);
            nbttaglist.appendTag(itemTag);
        }
    }
    tag.setTag("Items", nbttaglist);
    return tag;
}
 
开发者ID:MinecraftModDevelopmentMods,项目名称:MMDLib-old,代码行数:25,代码来源:NBTUtils.java

示例10: ContainerStorageCore

import net.minecraft.inventory.InventoryBasic; //导入依赖的package包/类
public ContainerStorageCore(EntityPlayer player, World world, int x, int y, int z) {
	this.tileEntity = ((TileEntityStorageCore) world.getTileEntity(new BlockPos(x, y, z)));
	int startingY = 18;
	int startingX = 8;

	// the EZStorage slots
	IInventory inventory = new InventoryBasic("title", false, this.rowCount() * 9);
	for (int i = 0; i < this.rowCount(); i++) {
		for (int j = 0; j < 9; j++) {
			addSlotToContainer(new Slot(inventory, j + i * 9, startingX + j * 18, startingY + i * 18));
		}
	}

	// the player inventory
	bindPlayerInventory(player.inventory);
}
 
开发者ID:zerofall,项目名称:EZStorage2,代码行数:17,代码来源:ContainerStorageCore.java

示例11: addPlayerSlots

import net.minecraft.inventory.InventoryBasic; //导入依赖的package包/类
public void addPlayerSlots(InventoryPlayer player) {
	for (int i = 0; i < 3; ++i) {
           for (int j = 0; j < 9; ++j) {
               this.addSlotToContainer(new Slot(player, j + i * 9 + 9, 8 + j * 18, 51 + i * 18));
           }
       }

       for (int i = 0; i < 9; ++i)
           this.addSlotToContainer(new Slot(player, i, 8 + i * 18, 109));
       
       IInventory tableInventory = new InventoryBasic("Trash", false, 1) {
       	public void setInventorySlotContents(int index, ItemStack stack) {
       		
           }
       };
       this.addSlotToContainer(new Slot(tableInventory, 0, 80, 20));
}
 
开发者ID:TEAMModding,项目名称:KalStuff,代码行数:18,代码来源:ContainerTrashCan.java

示例12: writeInventoryToNBT

import net.minecraft.inventory.InventoryBasic; //导入依赖的package包/类
/**
 * Writes an inventory to an NBTTagCompound. Can be used to save an inventory in a
 * TileEntity, or perhaps an ItemStack.
 *
 * @param tag: The NBTTagCompound to write the inventory to.
 * @param inventory: The inventory to write to the NBTTagCompound.
 * @return NBTTagCompound: The same NBTTagCompound that was passed to this method.
 */
public static NBTTagCompound writeInventoryToNBT (NBTTagCompound tag, InventoryBasic inventory) {

    if (inventory.hasCustomName()) {
        tag.setString("CustomName", inventory.getName());
    }

    final NBTTagList nbttaglist = new NBTTagList();

    for (int slotCount = 0; slotCount < inventory.getSizeInventory(); slotCount++) {

        final ItemStack stackInSlot = inventory.getStackInSlot(slotCount);

        if (!stackInSlot.isEmpty()) {

            final NBTTagCompound itemTag = new NBTTagCompound();
            itemTag.setByte("Slot", (byte) slotCount);
            stackInSlot.writeToNBT(itemTag);
            nbttaglist.appendTag(itemTag);
        }
    }

    tag.setTag("Items", nbttaglist);

    return tag;
}
 
开发者ID:Darkhax-Minecraft,项目名称:Bookshelf,代码行数:34,代码来源:NBTUtils.java

示例13: readInventoryFromNBT

import net.minecraft.inventory.InventoryBasic; //导入依赖的package包/类
/**
 * Reads an inventory from an NBTTagCompound. Can be used to load an Inventory from a
 * TileEntity or perhaps an ItemStak.
 *
 * @param tag: The NBTTagCompound to read the inventory data from.
 * @param inventory: The inventory to set all of the inventory data to.
 * @return InventoryBasic: The same instance of InventoryBasic that was passed to this
 *         method.
 */
public static InventoryBasic readInventoryFromNBT (NBTTagCompound tag, InventoryBasic inventory) {

    if (tag.hasKey("CustomName", 8)) {
        inventory.setCustomName(tag.getString("CustomName"));
    }

    final NBTTagList items = tag.getTagList("Items", 10);

    for (int storedCount = 0; storedCount < items.tagCount(); storedCount++) {

        final NBTTagCompound itemTag = items.getCompoundTagAt(storedCount);
        final int slotCount = itemTag.getByte("Slot") & 0xFF;

        if (slotCount >= 0 && slotCount < inventory.getSizeInventory()) {
            inventory.setInventorySlotContents(slotCount, new ItemStack(itemTag));
        }
    }

    return inventory;
}
 
开发者ID:Darkhax-Minecraft,项目名称:Bookshelf,代码行数:30,代码来源:NBTUtils.java

示例14: onInventoryChanged

import net.minecraft.inventory.InventoryBasic; //导入依赖的package包/类
/**
 * Called by InventoryBasic.onInventoryChanged() on a array that is never filled.
 */
public void onInventoryChanged(InventoryBasic par1InventoryBasic)
{
    int var2 = this.func_110241_cb();
    boolean var3 = this.isHorseSaddled();
    this.func_110232_cE();

    if (this.ticksExisted > 20)
    {
        if (var2 == 0 && var2 != this.func_110241_cb())
        {
            this.playSound("mob.horse.armor", 0.5F, 1.0F);
        }
        else if (var2 != this.func_110241_cb())
        {
            this.playSound("mob.horse.armor", 0.5F, 1.0F);
        }

        if (!var3 && this.isHorseSaddled())
        {
            this.playSound("mob.horse.leather", 0.5F, 1.0F);
        }
    }
}
 
开发者ID:MinecraftModdedClients,项目名称:Resilience-Client-Source,代码行数:27,代码来源:EntityHorse.java

示例15: EntityGreenVillager

import net.minecraft.inventory.InventoryBasic; //导入依赖的package包/类
public EntityGreenVillager(World worldIn, int professionId)
{
    super(worldIn);
    this.villagerInventory = new InventoryBasic("Items", false, 8);
    this.setProfession(professionId);
    this.setSize(0.6F, 1.8F);
    ((PathNavigateGround)this.getNavigator()).setBreakDoors(true);
    ((PathNavigateGround)this.getNavigator()).setAvoidsWater(true);
    this.tasks.addTask(0, new EntityAISwimming(this));
    this.tasks.addTask(1, new EntityAIAvoidEntity(this, EntityZombie.class, 8.0F, 0.6D, 0.6D));
    this.tasks.addTask(1, new EntityAITradeGreen(this));
    this.tasks.addTask(1, new EntityAILookAtTradeGreen(this));
    this.tasks.addTask(2, new EntityAIMoveIndoors(this));
    this.tasks.addTask(3, new EntityAIRestrictOpenDoor(this));
    this.tasks.addTask(4, new EntityAIOpenDoor(this, true));
    this.tasks.addTask(5, new EntityAIMoveTowardsRestriction(this, 0.6D));
    this.tasks.addTask(9, new EntityAIWatchClosest2(this, EntityPlayer.class, 3.0F, 1.0F));
    this.tasks.addTask(9, new EntityAIWander(this, 0.6D));
    this.tasks.addTask(10, new EntityAIWatchClosest(this, EntityLiving.class, 8.0F));
    this.setCanPickUpLoot(true);
}
 
开发者ID:Stormister,项目名称:Rediscovered-Mod-1.8.8,代码行数:22,代码来源:EntityGreenVillager.java


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