當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。