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


Java TileEntityDispenser.getSizeInventory方法代码示例

本文整理汇总了Java中net.minecraft.tileentity.TileEntityDispenser.getSizeInventory方法的典型用法代码示例。如果您正苦于以下问题:Java TileEntityDispenser.getSizeInventory方法的具体用法?Java TileEntityDispenser.getSizeInventory怎么用?Java TileEntityDispenser.getSizeInventory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.minecraft.tileentity.TileEntityDispenser的用法示例。


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

示例1: dispenseStack

import net.minecraft.tileentity.TileEntityDispenser; //导入方法依赖的package包/类
@Override
public ItemStack dispenseStack(IBlockSource blocksource, ItemStack itemstack)
{

	BlockPos blockpos = blocksource.getBlockPos();
	boolean canfire = false;
	normalDispense = false;

	// / double x = MathHelper.floor_double(blockpos.getX());
	// double y = MathHelper.floor_double(blockpos.getY());
	// double z = MathHelper.floor_double(blockpos.getZ());

	TileEntity tileentity = blocksource.getWorld().getTileEntity(blockpos);
	if (tileentity instanceof TileEntityDispenser)
	{
		TileEntityDispenser dispenser = ((TileEntityDispenser) tileentity);
		Item itemtocheck = null;
		if (itemstack.getItem() == Items.gunpowder)
		{
			itemtocheck = WeaponModule.items.ballista_bolt;
		}
		else if (itemstack.getItem() == WeaponModule.items.ballista_bolt)
		{
			itemtocheck = Items.gunpowder;
		}

		for (int i = 0; i < dispenser.getSizeInventory(); i++)
		{
			ItemStack itemstack1 = dispenser.getStackInSlot(i);
			if (itemstack1 != null && itemstack1.getItem() == itemtocheck)
			{
				dispenser.decrStackSize(i, 1);
				canfire = true;
				break;
			}
		}
	}

	if (!canfire)
	{
		normalDispense = true;
		return super.dispenseStack(blocksource, itemstack);
	}

	EnumFacing face = BlockDispenser.getFacing(blocksource.getBlockMetadata());
	double xvel = face.getFrontOffsetX() * 1.5D;
	double yvel = face.getFrontOffsetY() * 1.5D;
	double zvel = face.getFrontOffsetZ() * 1.5D;
	IPosition pos = BlockDispenser.getDispensePosition(blocksource);

	EntityBallistaBolt entityballistabolt = new EntityBallistaBolt(blocksource.getWorld(),
			pos.getX() + xvel, pos.getY() + yvel, pos.getZ() + zvel);
	entityballistabolt.setThrowableHeading(xvel, yvel + 0.15D, zvel, 2.0F, 2.0F);
	blocksource.getWorld().spawnEntityInWorld(entityballistabolt);
	itemstack.splitStack(1);
	return itemstack;
}
 
开发者ID:Archiving,项目名称:ARKCraft-Code,代码行数:58,代码来源:DispenseBallistaBolt.java

示例2: breakBlock

import net.minecraft.tileentity.TileEntityDispenser; //导入方法依赖的package包/类
public void breakBlock(World p_149749_1_, int p_149749_2_, int p_149749_3_, int p_149749_4_, Block p_149749_5_, int p_149749_6_)
{
    TileEntityDispenser var7 = (TileEntityDispenser)p_149749_1_.getTileEntity(p_149749_2_, p_149749_3_, p_149749_4_);

    if (var7 != null)
    {
        for (int var8 = 0; var8 < var7.getSizeInventory(); ++var8)
        {
            ItemStack var9 = var7.getStackInSlot(var8);

            if (var9 != null)
            {
                float var10 = this.field_149942_b.nextFloat() * 0.8F + 0.1F;
                float var11 = this.field_149942_b.nextFloat() * 0.8F + 0.1F;
                float var12 = this.field_149942_b.nextFloat() * 0.8F + 0.1F;

                while (var9.stackSize > 0)
                {
                    int var13 = this.field_149942_b.nextInt(21) + 10;

                    if (var13 > var9.stackSize)
                    {
                        var13 = var9.stackSize;
                    }

                    var9.stackSize -= var13;
                    EntityItem var14 = new EntityItem(p_149749_1_, (double)((float)p_149749_2_ + var10), (double)((float)p_149749_3_ + var11), (double)((float)p_149749_4_ + var12), new ItemStack(var9.getItem(), var13, var9.getItemDamage()));

                    if (var9.hasTagCompound())
                    {
                        var14.getEntityItem().setTagCompound((NBTTagCompound)var9.getTagCompound().copy());
                    }

                    float var15 = 0.05F;
                    var14.motionX = (double)((float)this.field_149942_b.nextGaussian() * var15);
                    var14.motionY = (double)((float)this.field_149942_b.nextGaussian() * var15 + 0.2F);
                    var14.motionZ = (double)((float)this.field_149942_b.nextGaussian() * var15);
                    p_149749_1_.spawnEntityInWorld(var14);
                }
            }
        }

        p_149749_1_.func_147453_f(p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_);
    }

    super.breakBlock(p_149749_1_, p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_, p_149749_6_);
}
 
开发者ID:MinecraftModdedClients,项目名称:Resilience-Client-Source,代码行数:48,代码来源:BlockDispenser.java

示例3: dispenseStack

import net.minecraft.tileentity.TileEntityDispenser; //导入方法依赖的package包/类
@Override
public ItemStack dispenseStack(IBlockSource blocksource, ItemStack itemstack)
{
	boolean canfire = false;
	normalDispense = false;
	TileEntity tileentity = blocksource.getWorld().getTileEntity(MathHelper.floor_double(blocksource.getXInt()), MathHelper.floor_double(blocksource.getYInt()), MathHelper.floor_double(blocksource.getZInt()));
	if (tileentity instanceof TileEntityDispenser)
	{
		TileEntityDispenser dispenser = ((TileEntityDispenser) tileentity);
		Item itemtocheck = null;
		if (itemstack.getItem() == Items.gunpowder)
		{
			itemtocheck = BalkonsWeaponMod.cannonBall;
		} else if (itemstack.getItem() == BalkonsWeaponMod.cannonBall)
		{
			itemtocheck = Items.gunpowder;
		}
		
		for (int i = 0; i < dispenser.getSizeInventory(); i++)
		{
			ItemStack itemstack1 = dispenser.getStackInSlot(i);
			if (itemstack1 != null && itemstack1.getItem() == itemtocheck)
			{
				dispenser.decrStackSize(i, 1);
				canfire = true;
				break;
			}
		}
	}
	
	if (!canfire)
	{
		normalDispense = true;
		return super.dispenseStack(blocksource, itemstack);
	}
	
	EnumFacing face = BlockDispenser.func_149937_b(blocksource.getBlockMetadata());
	double xvel = face.getFrontOffsetX() * 1.5D;
	double yvel = face.getFrontOffsetY() * 1.5D;
	double zvel = face.getFrontOffsetZ() * 1.5D;
	IPosition pos = BlockDispenser.func_149939_a(blocksource);
	
	EntityCannonBall entitycannonball = new EntityCannonBall(blocksource.getWorld(), pos.getX() + xvel, pos.getY() + yvel, pos.getZ() + zvel);
	entitycannonball.setThrowableHeading(xvel, yvel + 0.15D, zvel, 2.0F, 2.0F);
	blocksource.getWorld().spawnEntityInWorld(entitycannonball);
	itemstack.splitStack(1);
	return itemstack;
}
 
开发者ID:Ckathode,项目名称:balkons-weaponmod,代码行数:49,代码来源:DispenseCannonBall.java

示例4: breakBlock

import net.minecraft.tileentity.TileEntityDispenser; //导入方法依赖的package包/类
public void breakBlock(World p_149749_1_, int p_149749_2_, int p_149749_3_, int p_149749_4_, Block p_149749_5_, int p_149749_6_)
{
    TileEntityDispenser tileentitydispenser = (TileEntityDispenser)p_149749_1_.getTileEntity(p_149749_2_, p_149749_3_, p_149749_4_);

    if (tileentitydispenser != null)
    {
        for (int i1 = 0; i1 < tileentitydispenser.getSizeInventory(); ++i1)
        {
            ItemStack itemstack = tileentitydispenser.getStackInSlot(i1);

            if (itemstack != null)
            {
                float f = this.field_149942_b.nextFloat() * 0.8F + 0.1F;
                float f1 = this.field_149942_b.nextFloat() * 0.8F + 0.1F;
                float f2 = this.field_149942_b.nextFloat() * 0.8F + 0.1F;

                while (itemstack.stackSize > 0)
                {
                    int j1 = this.field_149942_b.nextInt(21) + 10;

                    if (j1 > itemstack.stackSize)
                    {
                        j1 = itemstack.stackSize;
                    }

                    itemstack.stackSize -= j1;
                    EntityItem entityitem = new EntityItem(p_149749_1_, (double)((float)p_149749_2_ + f), (double)((float)p_149749_3_ + f1), (double)((float)p_149749_4_ + f2), new ItemStack(itemstack.getItem(), j1, itemstack.getItemDamage()));

                    if (itemstack.hasTagCompound())
                    {
                        entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy());
                    }

                    float f3 = 0.05F;
                    entityitem.motionX = (double)((float)this.field_149942_b.nextGaussian() * f3);
                    entityitem.motionY = (double)((float)this.field_149942_b.nextGaussian() * f3 + 0.2F);
                    entityitem.motionZ = (double)((float)this.field_149942_b.nextGaussian() * f3);
                    p_149749_1_.spawnEntityInWorld(entityitem);
                }
            }
        }

        p_149749_1_.func_147453_f(p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_);
    }

    super.breakBlock(p_149749_1_, p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_, p_149749_6_);
}
 
开发者ID:xtrafrancyz,项目名称:Cauldron,代码行数:48,代码来源:BlockDispenser.java

示例5: breakBlock

import net.minecraft.tileentity.TileEntityDispenser; //导入方法依赖的package包/类
/**
 * Called on server worlds only when the block has been replaced by a different block ID, or the same block with a
 * different metadata value, but before the new metadata value is set. Args: World, x, y, z, old block ID, old
 * metadata
 */
public void breakBlock(World par1World, int par2, int par3, int par4, int par5, int par6)
{
    TileEntityDispenser tileentitydispenser = (TileEntityDispenser)par1World.getBlockTileEntity(par2, par3, par4);

    if (tileentitydispenser != null)
    {
        for (int j1 = 0; j1 < tileentitydispenser.getSizeInventory(); ++j1)
        {
            ItemStack itemstack = tileentitydispenser.getStackInSlot(j1);

            if (itemstack != null)
            {
                float f = this.random.nextFloat() * 0.8F + 0.1F;
                float f1 = this.random.nextFloat() * 0.8F + 0.1F;
                float f2 = this.random.nextFloat() * 0.8F + 0.1F;

                while (itemstack.stackSize > 0)
                {
                    int k1 = this.random.nextInt(21) + 10;

                    if (k1 > itemstack.stackSize)
                    {
                        k1 = itemstack.stackSize;
                    }

                    itemstack.stackSize -= k1;
                    EntityItem entityitem = new EntityItem(par1World, (double)((float)par2 + f), (double)((float)par3 + f1), (double)((float)par4 + f2), new ItemStack(itemstack.itemID, k1, itemstack.getItemDamage()));

                    if (itemstack.hasTagCompound())
                    {
                        entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy());
                    }

                    float f3 = 0.05F;
                    entityitem.motionX = (double)((float)this.random.nextGaussian() * f3);
                    entityitem.motionY = (double)((float)this.random.nextGaussian() * f3 + 0.2F);
                    entityitem.motionZ = (double)((float)this.random.nextGaussian() * f3);
                    par1World.spawnEntityInWorld(entityitem);
                }
            }
        }

        par1World.func_96440_m(par2, par3, par4, par5);
    }

    super.breakBlock(par1World, par2, par3, par4, par5, par6);
}
 
开发者ID:HATB0T,项目名称:RuneCraftery,代码行数:53,代码来源:BlockDispenser.java

示例6: breakBlock

import net.minecraft.tileentity.TileEntityDispenser; //导入方法依赖的package包/类
/**
 * ejects contained items into the world, and notifies neighbours of an update, as appropriate
 */
@Override
public void breakBlock(World par1World, int par2, int par3, int par4, Block block, int par6)
{
    TileEntityDispenser tileentitydispenser = (TileEntityDispenser)par1World.getTileEntity(par2, par3, par4);

    if (!par1World.isRemote && tileentitydispenser != null)
    {
        for (int j1 = 0; j1 < tileentitydispenser.getSizeInventory(); ++j1)
        {
            ItemStack itemstack = tileentitydispenser.getStackInSlot(j1);

            if (itemstack != null)
            {
                float f = this.random.nextFloat() * 0.8F + 0.1F;
                float f1 = this.random.nextFloat() * 0.8F + 0.1F;
                float f2 = this.random.nextFloat() * 0.8F + 0.1F;

                while (itemstack.stackSize > 0)
                {
                    int k1 = this.random.nextInt(21) + 10;

                    if (k1 > itemstack.stackSize)
                    {
                        k1 = itemstack.stackSize;
                    }

                    itemstack.stackSize -= k1;
                    EntityItem entityitem = new EntityItem(par1World, (double)((float)par2 + f), (double)((float)par3 + f1), (double)((float)par4 + f2), new ItemStack(itemstack.getItem(), k1, itemstack.getItemDamage()));

                    if (itemstack.hasTagCompound())
                    {
                        entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy());
                    }

                    float f3 = 0.05F;
                    entityitem.motionX = (double)((float)this.random.nextGaussian() * f3);
                    entityitem.motionY = (double)((float)this.random.nextGaussian() * f3 + 0.2F);
                    entityitem.motionZ = (double)((float)this.random.nextGaussian() * f3);
                    par1World.spawnEntityInWorld(entityitem);
                }
            }
        }

        par1World.func_147453_f(par2, par3, par4, block);
    }

    super.breakBlock(par1World, par2, par3, par4, block, par6);
}
 
开发者ID:Draco18s,项目名称:Artifacts,代码行数:52,代码来源:BlockTrap.java


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