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


Java InventoryHelper类代码示例

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


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

示例1: onBlockActivated

import net.minecraft.inventory.InventoryHelper; //导入依赖的package包/类
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
{
	ItemStack item = playerIn.getHeldItem(hand);
	TileEntity tileEntity = worldIn.getTileEntity(pos);
	if(tileEntity instanceof BaseTileEntityHarshenSingleItemInventory)
		if(((BaseTileEntityHarshenSingleItemInventory)tileEntity).canAddItem() && Item.getItemFromBlock(Blocks.AIR) != item.getItem())
		{
			int i =  item.getCount() - 1;
			if(((BaseTileEntityHarshenSingleItemInventory)tileEntity).setItem(item))
				playerIn.setHeldItem(hand, new ItemStack(item.getItem(), i, item.getMetadata(), item.serializeNBT()));
		}
		else if (!((BaseTileEntityHarshenSingleItemInventory) tileEntity).canAddItem())
		{
			ItemStack stack = ((BaseTileEntityHarshenSingleItemInventory)tileEntity).getItem();
			((BaseTileEntityHarshenSingleItemInventory)tileEntity).setItemAir();
			if(!worldIn.isRemote)
				InventoryHelper.spawnItemStack(worldIn, pos.getX(), pos.getY() + 0.7f, pos.getZ(), stack);
		}

	return true;
}
 
开发者ID:kenijey,项目名称:harshencastle,代码行数:23,代码来源:BaseBlockHarshenSingleInventory.java

示例2: breakBlock

import net.minecraft.inventory.InventoryHelper; //导入依赖的package包/类
@Override
public void breakBlock(World world, BlockPos pos, IBlockState state)
{
	TileEntityInfusionAltar te = (TileEntityInfusionAltar) world.getTileEntity(pos);
	IItemHandler cap = te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);

	for (int i = 0; i < cap.getSlots(); ++i)
	{
		ItemStack itemstack = cap.getStackInSlot(i);

		if (!itemstack.isEmpty())
		{
			InventoryHelper.spawnItemStack(world, pos.getX(), pos.getY(), pos.getZ(), itemstack);
		}
	}

	super.breakBlock(world, pos, state);
}
 
开发者ID:raphydaphy,项目名称:ArcaneMagic,代码行数:19,代码来源:BlockInfusionAltar.java

示例3: breakBlock

import net.minecraft.inventory.InventoryHelper; //导入依赖的package包/类
@Override
public void breakBlock(World world, BlockPos pos, IBlockState state)
{
	TileEntityAnimusMaterializer te = (TileEntityAnimusMaterializer) world.getTileEntity(pos);
	IItemHandler cap = te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);

	for (int i = 0; i < cap.getSlots(); ++i)
	{
		ItemStack itemstack = cap.getStackInSlot(i);

		if (!itemstack.isEmpty())
		{
			InventoryHelper.spawnItemStack(world, pos.getX(), pos.getY(), pos.getZ(), itemstack);
		}
	}

	super.breakBlock(world, pos, state);
}
 
开发者ID:raphydaphy,项目名称:ArcaneMagic,代码行数:19,代码来源:BlockAnimusMaterializer.java

示例4: breakBlock

import net.minecraft.inventory.InventoryHelper; //导入依赖的package包/类
@Override
public void breakBlock(World world, BlockPos pos, IBlockState state)
{
	TileEntityAnalyzer te = (TileEntityAnalyzer) world.getTileEntity(pos);

	if (!te.getStack(0).isEmpty())
	{
		InventoryHelper.spawnItemStack(world, pos.getX(), pos.getY(), pos.getZ(), te.getStack(0).copy());
	}

	if (!te.getStack(1).isEmpty())
	{
		InventoryHelper.spawnItemStack(world, pos.getX(), pos.getY(), pos.getZ(), te.getStack(1).copy());
	}
	super.breakBlock(world, pos, state);
}
 
开发者ID:raphydaphy,项目名称:ArcaneMagic,代码行数:17,代码来源:BlockAnalyzer.java

示例5: breakBlock

import net.minecraft.inventory.InventoryHelper; //导入依赖的package包/类
@Override
public void breakBlock(World world, BlockPos pos, IBlockState state)
{
	TileEntityArcaneTransfigurationTable te = (TileEntityArcaneTransfigurationTable) world.getTileEntity(pos);
	IItemHandler cap = te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);

	for (int i = 0; i < cap.getSlots(); ++i)
	{
		ItemStack itemstack = cap.getStackInSlot(i);

		if (!itemstack.isEmpty())
		{
			InventoryHelper.spawnItemStack(world, pos.getX(), pos.getY(), pos.getZ(), itemstack);
		}
	}

	super.breakBlock(world, pos, state);
}
 
开发者ID:raphydaphy,项目名称:ArcaneMagic,代码行数:19,代码来源:BlockArcaneTransfigurationTable.java

示例6: breakBlock

import net.minecraft.inventory.InventoryHelper; //导入依赖的package包/类
@Override
public void breakBlock(World world, BlockPos pos, IBlockState state)
{
	TileEntityInfernalSmelter te = (TileEntityInfernalSmelter) world.getTileEntity(pos);
	IItemHandler cap = te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
	for (int i = 0; i < cap.getSlots(); ++i)
	{
		ItemStack itemstack = cap.getStackInSlot(i);

		if (!itemstack.isEmpty())
		{
			InventoryHelper.spawnItemStack(world, pos.getX(), pos.getY(), pos.getZ(), itemstack);
		}
	}

	super.breakBlock(world, pos, state);
}
 
开发者ID:raphydaphy,项目名称:ArcaneMagic,代码行数:18,代码来源:BlockInfernalSmelter.java

示例7: breakBlock

import net.minecraft.inventory.InventoryHelper; //导入依赖的package包/类
@Override
public void breakBlock(World world, BlockPos pos, IBlockState state)
{
	TileEntityWritingDesk te = (TileEntityWritingDesk) world.getTileEntity(pos);
	IItemHandler cap = te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);

	for (int i = 0; i < cap.getSlots(); ++i)
	{
		ItemStack itemstack = cap.getStackInSlot(i);

		if (!itemstack.isEmpty())
		{
			InventoryHelper.spawnItemStack(world, pos.getX(), pos.getY(), pos.getZ(), itemstack);
		}
	}

	super.breakBlock(world, pos, state);
}
 
开发者ID:raphydaphy,项目名称:ArcaneMagic,代码行数:19,代码来源:BlockWritingDesk.java

示例8: breakBlock

import net.minecraft.inventory.InventoryHelper; //导入依赖的package包/类
@Override
public void breakBlock(World worldIn, BlockPos pos, IBlockState state) {
    if (!keepInventory) {
        TileEntity tileEntity = worldIn.getTileEntity(pos);
        if (tileEntity instanceof CraftiniumForgeTileEntity) {
            CraftiniumForgeTileEntity entity = (CraftiniumForgeTileEntity) tileEntity;
            InventoryHelper.spawnItemStack(worldIn, pos.getX(), pos.getY(), pos.getZ(), entity.getFuel().getStackInSlot(0));
            InventoryHelper.spawnItemStack(worldIn, pos.getX(), pos.getY(), pos.getZ(), entity.getOutput().getStackInSlot(0));
            InventoryHelper.spawnItemStack(worldIn, pos.getX(), pos.getY(), pos.getZ(), entity.getInput().getStackInSlot(0));

            if(!entity.isBrokenByCreative()) {
                List<ItemStack> drops = this.getDrops(worldIn, pos, state, 0);
                for (ItemStack stack : drops) {
                    spawnAsEntity(worldIn, pos, stack);
                }
            }
            worldIn.updateComparatorOutputLevel(pos, this);
        }
    }

    super.breakBlock(worldIn, pos, state);
}
 
开发者ID:Randores,项目名称:Randores2,代码行数:23,代码来源:CraftiniumForge.java

示例9: slotClick

import net.minecraft.inventory.InventoryHelper; //导入依赖的package包/类
@Nullable
public ItemStack slotClick(int slotId, int dragType, ClickType clickTypeIn, EntityPlayer player)
{
    if(inventorySlots.get(slotId) != null)
    {
        if(!inventorySlots.get(slotId).getStack().isEmpty())
        {
            if(!player.world.isRemote)
            {
                InventoryHelper.spawnItemStack(player.world, inventory.getPos().getX() + 0.5D, inventory.getPos().getY() + 1D, inventory.getPos().getZ() + 0.5D, inventorySlots.get(slotId).getStack());
            }
            player.world.playSound(null, inventory.getPos().getX() + 0.5D, inventory.getPos().getY() + 1D, inventory.getPos().getZ() + 0.5D, SoundEvents.ENTITY_ITEM_PICKUP, SoundCategory.PLAYERS, 0.2F, ((player.world.rand.nextFloat() - player.world.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F);
            inventorySlots.get(slotId).putStack(ItemStack.EMPTY);
            inventory.setInventorySlotContents(slotId, ItemStack.EMPTY);
            inventory.markDirty();
        }
    }
    return super.slotClick(slotId, dragType, clickTypeIn, player);
}
 
开发者ID:iChun,项目名称:Clef,代码行数:20,代码来源:ContainerInstrumentPlayer.java

示例10: breakBlock

import net.minecraft.inventory.InventoryHelper; //导入依赖的package包/类
@Override
public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
{
    TileEntity tile = worldIn.getTileEntity(pos);

    if (tile != null)
    {
        IItemHandler itemHandler = tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
        if (itemHandler != null)
        {
            for (int i = 0; i < itemHandler.getSlots(); i++)
            {
                ItemStack stack = itemHandler.getStackInSlot(i);
                if (!stack.isEmpty())
                {
                    InventoryHelper.spawnItemStack(worldIn, pos.getX(), pos.getY(), pos.getZ(), stack);
                }
            }
        }
    }

    super.breakBlock(worldIn, pos, state);
}
 
开发者ID:cubex2,项目名称:customstuff4,代码行数:24,代码来源:BlockMixin.java

示例11: breakBlock

import net.minecraft.inventory.InventoryHelper; //导入依赖的package包/类
@Override
public void breakBlock(World worldIn, BlockPos pos, IBlockState state) {
       TileEntity tileentity = worldIn.getTileEntity(pos);
       
       if (tileentity!=null && tileentity.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null)) {
       	IItemHandler inventory = tileentity.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
       	for (int i=0; i<inventory.getSlots(); i++) {
               ItemStack itemstack = inventory.getStackInSlot(i);

               if (!itemstack.isEmpty()) {
                   InventoryHelper.spawnItemStack(worldIn, pos.getX(), pos.getY(), pos.getZ(), itemstack);
               }
           }
       	worldIn.updateComparatorOutputLevel(pos, this);
       }
       super.breakBlock(worldIn, pos, state);
   }
 
开发者ID:elytra,项目名称:Thermionics,代码行数:18,代码来源:BlockMachineBase.java

示例12: breakBlock

import net.minecraft.inventory.InventoryHelper; //导入依赖的package包/类
/**
 * Called serverside after this block is replaced with another in Chunk, but before the Tile Entity is updated
 */
public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
{
    if (!keepInventory)
    {
        TileEntity tileentity = worldIn.getTileEntity(pos);

        if (tileentity instanceof TileEntityFurnace)
        {
            InventoryHelper.dropInventoryItems(worldIn, pos, (TileEntityFurnace)tileentity);
            worldIn.updateComparatorOutputLevel(pos, this);
        }
    }

    super.breakBlock(worldIn, pos, state);
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:19,代码来源:BlockFurnace.java

示例13: killMinecart

import net.minecraft.inventory.InventoryHelper; //导入依赖的package包/类
@Override
public void killMinecart(DamageSource source)
   {
	this.setDead();

       if (this.getEntityWorld().getGameRules().getBoolean("doEntityDrops"))
       {
           ItemStack itemstack = new ItemStack(Items.MINECART, 1);

           if (this.getName() != null)
           {
               itemstack.setStackDisplayName(this.getName());
           }

           this.entityDropItem(itemstack, 0.0F);
           
           if (this.dropContentsWhenDead)
           {
           	if(!getEntityWorld().isRemote)InventoryHelper.dropInventoryItems(this.getEntityWorld(), this, this);
           }
           entityDropItem(new ItemStack(ModBlocks.crystalChest, 1, getChestType().ordinal()), 0.0F);
       }
   }
 
开发者ID:Alec-WAM,项目名称:CrystalMod,代码行数:24,代码来源:EntityCrystalChestMinecartBase.java

示例14: handle

import net.minecraft.inventory.InventoryHelper; //导入依赖的package包/类
@Override
protected void handle(final EntityPlayer sender)
{
    if (sender.inventoryContainer != null)
    {
        ItemStack stack = sender.openContainer.getSlot(slotID).getStack();

        if (stack.getItem() == QBarItems.MULTIBLOCK_BOX && stack.hasTagCompound())
        {
            NonNullList<ItemStack> items = NonNullList
                    .withSize(stack.getTagCompound().getTagList("Items", 10).tagCount(), ItemStack.EMPTY);
            ItemUtils.loadAllItems(stack.getTagCompound(), items);
            for (ItemStack item : items)
            {
                if (!sender.addItemStackToInventory(item))
                    InventoryHelper.spawnItemStack(sender.world, sender.posX, sender.posY, sender.posZ, item);
            }
            stack.setCount(0);
        }
    }
}
 
开发者ID:OPMCorp,项目名称:Qbar,代码行数:22,代码来源:MultiblockBoxPacket.java

示例15: breakBlock

import net.minecraft.inventory.InventoryHelper; //导入依赖的package包/类
@Override
public void breakBlock(final World w, final BlockPos pos, final IBlockState state)
{
    final ITileMultiblock tile = (ITileMultiblock) w.getTileEntity(pos);
    if (tile != null)
    {
        if (tile.isCore())
        {
            if (tile instanceof IInventory)
            {
                InventoryHelper.dropInventoryItems(w, pos, (IInventory) tile);
                w.updateComparatorOutputLevel(pos, this);
            }
            this.dropBlockAsItem(w, pos, state, 0);
        }
        else
            tile.breakCore();
    }
    super.breakBlock(w, pos, state);
}
 
开发者ID:OPMCorp,项目名称:Qbar,代码行数:21,代码来源:BlockMultiblockBase.java


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