本文整理汇总了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;
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
}
示例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);
}
}
}
示例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);
}