类net.minecraft.inventory.InventoryHelper源码实例Demo

下面列出了怎么用net.minecraft.inventory.InventoryHelper的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: TofuCraftReload   文件: BlockSaltFurnace.java
@Override
public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
{
    if (!keepInventory)
    {
        TileEntity tileentity = worldIn.getTileEntity(pos);

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

    super.breakBlock(worldIn, pos, state);
}
 
源代码2 项目: TofuCraftReload   文件: BlockTFOven.java
@Override
public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
{
    if (!keepInventory)
    {
        TileEntity tileentity = worldIn.getTileEntity(pos);

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

    super.breakBlock(worldIn, pos, state);
}
 
源代码3 项目: TofuCraftReload   文件: BlockAdvancedAggregator.java
@Override
public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
{
    if (!keepInventory)
    {
        TileEntity tileentity = worldIn.getTileEntity(pos);

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

    super.breakBlock(worldIn, pos, state);
}
 
源代码4 项目: TofuCraftReload   文件: BlockAggregator.java
@Override
public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
{
    if (!keepInventory)
    {
        TileEntity tileentity = worldIn.getTileEntity(pos);

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

    super.breakBlock(worldIn, pos, state);
}
 
源代码5 项目: TofuCraftReload   文件: BlockTFCrasher.java
@Override
public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
{
    if (!keepInventory)
    {
        TileEntity tileentity = worldIn.getTileEntity(pos);

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

    super.breakBlock(worldIn, pos, state);
}
 
源代码6 项目: TofuCraftReload   文件: BlockTFCompressor.java
@Override
public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
{
    if (!keepInventory)
    {
        TileEntity tileentity = worldIn.getTileEntity(pos);

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

    super.breakBlock(worldIn, pos, state);
}
 
源代码7 项目: EmergingTechnology   文件: PollutedGravel.java
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn,
        EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {

    if (worldIn.isRemote) {
        return true;
    }

    if (facing == EnumFacing.UP) {
        worldIn.setBlockState(pos, Blocks.GRAVEL.getDefaultState(), 3);
        InventoryHelper.spawnItemStack(worldIn, pos.getX(), pos.offset(EnumFacing.UP).getY(), pos.getZ(),
                new ItemStack(ModItems.plasticwaste));
        return true;
    }

    return super.onBlockActivated(worldIn, pos, state, playerIn, hand, facing, hitX, hitY, hitZ);
}
 
源代码8 项目: EmergingTechnology   文件: PollutedDirt.java
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn,
        EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {

    if (worldIn.isRemote) {
        return true;
    }

    if (facing == EnumFacing.UP) {
        worldIn.setBlockState(pos, Blocks.DIRT.getDefaultState(), 3);
        InventoryHelper.spawnItemStack(worldIn, pos.getX(), pos.offset(EnumFacing.UP).getY(), pos.getZ(),
                new ItemStack(ModItems.plasticwaste));
        return true;
    }

    return super.onBlockActivated(worldIn, pos, state, playerIn, hand, facing, hitX, hitY, hitZ);
}
 
源代码9 项目: EmergingTechnology   文件: PollutedSand.java
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn,
        EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {

    if (worldIn.isRemote) {
        return true;
    }

    if (facing == EnumFacing.UP) {
        worldIn.setBlockState(pos, Blocks.SAND.getDefaultState(), 3);
        InventoryHelper.spawnItemStack(worldIn, pos.getX(), pos.offset(EnumFacing.UP).getY(), pos.getZ(),
                new ItemStack(ModItems.plasticwaste));
        return true;
    }

    return super.onBlockActivated(worldIn, pos, state, playerIn, hand, facing, hitX, hitY, hitZ);
}
 
源代码10 项目: customstuff4   文件: BlockMixin.java
@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 项目: Cyberware   文件: BlockBlueprintArchive.java
@Override
public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
{ 
	TileEntity tileentity = worldIn.getTileEntity(pos);

	if (tileentity instanceof TileEntityBlueprintArchive && !worldIn.isRemote)
	{
		TileEntityBlueprintArchive scanner = (TileEntityBlueprintArchive) tileentity;
		
		for (int i = 0; i < scanner.slots.getSlots(); i++)
		{
			ItemStack stack = scanner.slots.getStackInSlot(i);
			if (stack != null)
			{
				InventoryHelper.spawnItemStack(worldIn, pos.getX(), pos.getY(), pos.getZ(), stack);
			}
		}
	}
	super.breakBlock(worldIn, pos, state);

}
 
源代码12 项目: Cyberware   文件: BlockScanner.java
@Override
public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
{ 
	TileEntity tileentity = worldIn.getTileEntity(pos);

	if (tileentity instanceof TileEntityScanner && !worldIn.isRemote)
	{
		TileEntityScanner scanner = (TileEntityScanner) tileentity;
		
		for (int i = 0; i < scanner.slots.getSlots(); i++)
		{
			ItemStack stack = scanner.slots.getStackInSlot(i);
			if (stack != null)
			{
				InventoryHelper.spawnItemStack(worldIn, pos.getX(), pos.getY(), pos.getZ(), stack);
			}
		}
	}
	super.breakBlock(worldIn, pos, state);

}
 
源代码13 项目: Cyberware   文件: BlockEngineeringTable.java
@Override
public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
{ 
	boolean top = state.getValue(HALF) == EnumEngineeringHalf.UPPER;
	if (top)
	{
		TileEntity tileentity = worldIn.getTileEntity(pos);

		if (tileentity instanceof TileEntityEngineeringTable && !worldIn.isRemote)
		{
			TileEntityEngineeringTable engineering = (TileEntityEngineeringTable) tileentity;
			
			for (int i = 0; i < engineering.slots.getSlots(); i++)
			{
				ItemStack stack = engineering.slots.getStackInSlot(i);
				if (stack != null)
				{
					InventoryHelper.spawnItemStack(worldIn, pos.getX(), pos.getY(), pos.getZ(), stack);
				}
			}
		}
		super.breakBlock(worldIn, pos, state);
	}
}
 
源代码14 项目: Cyberware   文件: BlockComponentBox.java
@Override
public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
{ 
	TileEntity tileentity = worldIn.getTileEntity(pos);

	if (tileentity instanceof TileEntityComponentBox && !worldIn.isRemote)
	{
		TileEntityComponentBox box = (TileEntityComponentBox) tileentity;
		if (box.doDrop)
		{
			ItemStack stackToDrop = new ItemStack(ib);
			stackToDrop = getStack(box);
			InventoryHelper.spawnItemStack(worldIn, pos.getX(), pos.getY(), pos.getZ(), stackToDrop);
		}
	}
	

	super.breakBlock(worldIn, pos, state);

}
 
源代码15 项目: Cyberware   文件: BlockSurgery.java
@Override
public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
{ 
	TileEntity tileentity = worldIn.getTileEntity(pos);

	if (tileentity instanceof TileEntitySurgery && !worldIn.isRemote)
	{
		TileEntitySurgery surgery = (TileEntitySurgery) tileentity;
		
		for (int i = 0; i < surgery.slots.getSlots(); i++)
		{
			ItemStack stack = surgery.slots.getStackInSlot(i);
			if (stack != null)
			{
				InventoryHelper.spawnItemStack(worldIn, pos.getX(), pos.getY(), pos.getZ(), stack);
			}
		}
	}
	super.breakBlock(worldIn, pos, state);

}
 
源代码16 项目: TFC2   文件: TileFirepit.java
public void ejectContents(boolean ejectFuel)
{
	if(ejectFuel)
	{
		InventoryHelper.spawnItemStack(world, getPos().getX(), getPos().getY(), getPos().getZ(), this.getStackInSlot(FUEL_SLOT));
		this.setInventorySlotContents(FUEL_SLOT, ItemStack.EMPTY);
	}
	else
	{
		for(int i = TOOL_SLOT; i < this.getSizeInventory(); i++)
		{
			if(i == OUTPUT_SLOT && cookingTimer > 0)
			{
				continue;
			}
			InventoryHelper.spawnItemStack(world, getPos().getX(), getPos().getY(), getPos().getZ(), this.getStackInSlot(i));
			this.setInventorySlotContents(i, ItemStack.EMPTY);
		}
	}

}
 
源代码17 项目: TofuCraftReload   文件: BlockTFBattery.java
@Override
public void breakBlock(World worldIn, BlockPos pos, IBlockState state) {
    TileEntity tileentity = worldIn.getTileEntity(pos);
    if (tileentity instanceof TileEntityTofuBattery) {
        InventoryHelper.dropInventoryItems(worldIn, pos, (TileEntityTofuBattery) tileentity);
        worldIn.updateComparatorOutputLevel(pos, this);
    }
    super.breakBlock(worldIn, pos, state);
}
 
源代码18 项目: TofuCraftReload   文件: BlockTFStorage.java
@Override
public void breakBlock(World worldIn, BlockPos pos, IBlockState state) {
    TileEntity tileentity = worldIn.getTileEntity(pos);
    if (tileentity instanceof TileEntityTFStorage) {
        InventoryHelper.dropInventoryItems(worldIn, pos, (TileEntityTFStorage) tileentity);
        worldIn.updateComparatorOutputLevel(pos, this);
    }

    super.breakBlock(worldIn, pos, state);
}
 
源代码19 项目: Sakura_mod   文件: BlockMapleSyrupCauldron.java
@Override
public void breakBlock(World worldIn, BlockPos pos, IBlockState state) {
    if (!keepInventory) {
        TileEntity te = worldIn.getTileEntity(pos);
        if (te instanceof TileEntityMapleCauldron) {
            InventoryHelper.dropInventoryItems(worldIn, pos, (TileEntityMapleCauldron)te);
            worldIn.updateComparatorOutputLevel(pos, this);
        }
    }
    super.breakBlock(worldIn, pos, state);
}
 
源代码20 项目: Sakura_mod   文件: BlockStoneMortar.java
@Override
public void breakBlock(World worldIn, BlockPos pos, IBlockState state) {
    TileEntity tileentity = worldIn.getTileEntity(pos);
    if (tileentity instanceof TileEntityStoneMortar) {
        InventoryHelper.dropInventoryItems(worldIn, pos, (TileEntityStoneMortar) tileentity);
        worldIn.updateComparatorOutputLevel(pos, this);
    }
    super.breakBlock(worldIn, pos, state);
}
 
源代码21 项目: Sakura_mod   文件: BlockCampfirePot.java
@Override
public void breakBlock(World worldIn, BlockPos pos, IBlockState state) {
    if (!keepInventory) {
        TileEntity te = worldIn.getTileEntity(pos);
        if (te instanceof TileEntityCampfirePot) {
            InventoryHelper.dropInventoryItems(worldIn, pos, (TileEntityCampfirePot)te);
            worldIn.updateComparatorOutputLevel(pos, this);
        }

        spawnAsEntity(worldIn, pos, new ItemStack(Item.getItemFromBlock(BlockLoader.CAMPFIRE_IDLE)));
        spawnAsEntity(worldIn, pos, new ItemStack(ItemLoader.POT));
    }

    super.breakBlock(worldIn, pos, state);
}
 
源代码22 项目: EmergingTechnology   文件: MachineBase.java
@Override
public void breakBlock(World world, BlockPos pos, IBlockState state) {
    TileEntity te = 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);
        }
    }
}
 
源代码23 项目: MiningGadgets   文件: ModificationTable.java
@Override
public void onReplaced(BlockState state, World worldIn, BlockPos pos, BlockState newState, boolean isMoving) {
    if (newState.getBlock() != this) {
        TileEntity tileEntity = worldIn.getTileEntity(pos);
        if (tileEntity != null) {
            LazyOptional<IItemHandler> cap = tileEntity.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY);
            cap.ifPresent(handler -> {
                for(int i = 0; i < handler.getSlots(); ++i) {
                    InventoryHelper.spawnItemStack(worldIn, pos.getX(), pos.getY(), pos.getZ(), handler.getStackInSlot(i));
                }
            });
        }
        super.onReplaced(state, worldIn, pos, newState, isMoving);
    }
}
 
源代码24 项目: Minecoprocessors   文件: BlockMinecoprocessor.java
@Override
public void breakBlock(World worldIn, BlockPos pos, IBlockState state) {
  notifyNeighbors(worldIn, pos, state);

  TileEntity tileentity = worldIn.getTileEntity(pos);
  if (tileentity instanceof TileEntityMinecoprocessor) {
    InventoryHelper.dropInventoryItems(worldIn, pos, (TileEntityMinecoprocessor) tileentity);
  }
  super.breakBlock(worldIn, pos, state);
}
 
源代码25 项目: Cyberware   文件: BlockComponentBox.java
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, @Nullable ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ)
{
	TileEntity tileentity = worldIn.getTileEntity(pos);
	
	if (tileentity instanceof TileEntityComponentBox)
	{
		/*if (player.isCreative() && player.isSneaking())
		{
			TileEntityScanner scanner = ((TileEntityScanner) tileentity);
			scanner.ticks = CyberwareConfig.SCANNER_TIME - 200;
		}*/
		if (player.isSneaking())
		{
			TileEntityComponentBox box = (TileEntityComponentBox) tileentity;
			ItemStack toDrop = this.getStack(box);
			
			if (player.inventory.mainInventory[player.inventory.currentItem] == null)
			{
				player.inventory.mainInventory[player.inventory.currentItem] = toDrop;
			}
			else
			{
				if (!player.inventory.addItemStackToInventory(toDrop))
				{
					InventoryHelper.spawnItemStack(worldIn, pos.getX(), pos.getY(), pos.getZ(), toDrop);
				}
			}
			box.doDrop = false;
			worldIn.setBlockToAir(pos);
		}
		else
		{
			player.openGui(Cyberware.INSTANCE, 5, worldIn, pos.getX(), pos.getY(), pos.getZ());
		}
	}
	
	return true;
	
}
 
源代码26 项目: Valkyrien-Skies   文件: BlockPhysicsInfuser.java
@Override
public void breakBlock(World worldIn, BlockPos pos, IBlockState state) {
    TileEntityPhysicsInfuser tileEntity = (TileEntityPhysicsInfuser) worldIn.getTileEntity(pos);
    // If there's a valid TileEntity, try dropping the contents of it's inventory.
    if (tileEntity != null && !tileEntity.isInvalid()) {
        IItemHandler handler = tileEntity
            .getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
        // Safety in case the capabilities system breaks. If we can't find the handler then
        // there isn't anything to drop anyways.
        if (handler != null) {
            // Drop all the items
            for (int slot = 0; slot < handler.getSlots(); slot++) {
                ItemStack stack = handler.getStackInSlot(slot);
                InventoryHelper
                    .spawnItemStack(worldIn, pos.getX(), pos.getY(), pos.getZ(), stack);
            }
        }
    }
    // Remove the dummy block of this physics infuser, if there is one.
    BlockPos dummyBlockPos = getDummyStatePos(state, pos);
    super.breakBlock(worldIn, pos, state);
    if (worldIn.getBlockState(dummyBlockPos)
        .getBlock() == ValkyrienSkiesMod.INSTANCE.physicsInfuserDummy) {
        worldIn.setBlockToAir(dummyBlockPos);
    }
    // Finally, delete the tile entity.
    worldIn.removeTileEntity(pos);
}
 
源代码27 项目: Survivalist   文件: ChoppingBlock.java
public static void dropInventoryItems(World worldIn, BlockPos pos, IItemHandler inventory)
{
    for (int i = 0; i < inventory.getSlots(); ++i)
    {
        ItemStack itemstack = inventory.getStackInSlot(i);

        if (itemstack.getCount() > 0)
        {
            InventoryHelper.spawnItemStack(worldIn, (double) pos.getX(), (double) pos.getY(), (double) pos.getZ(), itemstack);
        }
    }
}
 
源代码28 项目: Survivalist   文件: SawmillBlock.java
private static void dropInventoryItems(World worldIn, BlockPos pos, IItemHandler inventory)
{
    for (int i = 0; i < inventory.getSlots(); ++i)
    {
        ItemStack itemstack = inventory.getStackInSlot(i);

        if (itemstack.getCount() > 0)
        {
            InventoryHelper.spawnItemStack(worldIn, (double) pos.getX(), (double) pos.getY(), (double) pos.getZ(), itemstack);
        }
    }
}
 
源代码29 项目: Survivalist   文件: DryingRackBlock.java
private static void dropInventoryItems(World worldIn, BlockPos pos, IItemHandler inventory)
{
    for (int i = 0; i < inventory.getSlots(); ++i)
    {
        ItemStack itemstack = inventory.getStackInSlot(i);

        if (itemstack.getCount() > 0)
        {
            InventoryHelper.spawnItemStack(worldIn, (double) pos.getX(), (double) pos.getY(), (double) pos.getZ(), itemstack);
        }
    }
}
 
源代码30 项目: TFC2   文件: BlockFirepit.java
@Override
public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
{
	TileEntity tileentity = worldIn.getTileEntity(pos);

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

	super.breakBlock(worldIn, pos, state);
}