Java Code Examples for net.minecraft.world.World.playAuxSFX()

The following are Jave code examples for showing how to use playAuxSFX() of the net.minecraft.world.World class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: DecompiledMinecraft   File: BlockDispenser.java   Source Code and License Vote up 6 votes
protected void dispense(World worldIn, BlockPos pos)
{
    BlockSourceImpl blocksourceimpl = new BlockSourceImpl(worldIn, pos);
    TileEntityDispenser tileentitydispenser = (TileEntityDispenser)blocksourceimpl.getBlockTileEntity();

    if (tileentitydispenser != null)
    {
        int i = tileentitydispenser.getDispenseSlot();

        if (i < 0)
        {
            worldIn.playAuxSFX(1001, pos, 0);
        }
        else
        {
            ItemStack itemstack = tileentitydispenser.getStackInSlot(i);
            IBehaviorDispenseItem ibehaviordispenseitem = this.getBehavior(itemstack);

            if (ibehaviordispenseitem != IBehaviorDispenseItem.itemDispenseBehaviorProvider)
            {
                ItemStack itemstack1 = ibehaviordispenseitem.dispense(blocksourceimpl, itemstack);
                tileentitydispenser.setInventorySlotContents(i, itemstack1.stackSize <= 0 ? null : itemstack1);
            }
        }
    }
}
 
Example 2
Project: BaseClient   File: BlockDispenser.java   Source Code and License Vote up 6 votes
protected void dispense(World worldIn, BlockPos pos)
{
    BlockSourceImpl blocksourceimpl = new BlockSourceImpl(worldIn, pos);
    TileEntityDispenser tileentitydispenser = (TileEntityDispenser)blocksourceimpl.getBlockTileEntity();

    if (tileentitydispenser != null)
    {
        int i = tileentitydispenser.getDispenseSlot();

        if (i < 0)
        {
            worldIn.playAuxSFX(1001, pos, 0);
        }
        else
        {
            ItemStack itemstack = tileentitydispenser.getStackInSlot(i);
            IBehaviorDispenseItem ibehaviordispenseitem = this.getBehavior(itemstack);

            if (ibehaviordispenseitem != IBehaviorDispenseItem.itemDispenseBehaviorProvider)
            {
                ItemStack itemstack1 = ibehaviordispenseitem.dispense(blocksourceimpl, itemstack);
                tileentitydispenser.setInventorySlotContents(i, itemstack1.stackSize <= 0 ? null : itemstack1);
            }
        }
    }
}
 
Example 3
Project: DecompiledMinecraft   File: BlockDispenser.java   Source Code and License Vote up 6 votes
protected void dispense(World worldIn, BlockPos pos)
{
    BlockSourceImpl blocksourceimpl = new BlockSourceImpl(worldIn, pos);
    TileEntityDispenser tileentitydispenser = (TileEntityDispenser)blocksourceimpl.getBlockTileEntity();

    if (tileentitydispenser != null)
    {
        int i = tileentitydispenser.getDispenseSlot();

        if (i < 0)
        {
            worldIn.playAuxSFX(1001, pos, 0);
        }
        else
        {
            ItemStack itemstack = tileentitydispenser.getStackInSlot(i);
            IBehaviorDispenseItem ibehaviordispenseitem = this.getBehavior(itemstack);

            if (ibehaviordispenseitem != IBehaviorDispenseItem.itemDispenseBehaviorProvider)
            {
                ItemStack itemstack1 = ibehaviordispenseitem.dispense(blocksourceimpl, itemstack);
                tileentitydispenser.setInventorySlotContents(i, itemstack1.stackSize <= 0 ? null : itemstack1);
            }
        }
    }
}
 
Example 4
Project: BaseClient   File: BlockDispenser.java   Source Code and License Vote up 6 votes
protected void dispense(World worldIn, BlockPos pos)
{
    BlockSourceImpl blocksourceimpl = new BlockSourceImpl(worldIn, pos);
    TileEntityDispenser tileentitydispenser = (TileEntityDispenser)blocksourceimpl.getBlockTileEntity();

    if (tileentitydispenser != null)
    {
        int i = tileentitydispenser.getDispenseSlot();

        if (i < 0)
        {
            worldIn.playAuxSFX(1001, pos, 0);
        }
        else
        {
            ItemStack itemstack = tileentitydispenser.getStackInSlot(i);
            IBehaviorDispenseItem ibehaviordispenseitem = this.getBehavior(itemstack);

            if (ibehaviordispenseitem != IBehaviorDispenseItem.itemDispenseBehaviorProvider)
            {
                ItemStack itemstack1 = ibehaviordispenseitem.dispense(blocksourceimpl, itemstack);
                tileentitydispenser.setInventorySlotContents(i, itemstack1.stackSize <= 0 ? null : itemstack1);
            }
        }
    }
}
 
Example 5
Project: DecompiledMinecraft   File: BlockSponge.java   Source Code and License Vote up 5 votes
protected void tryAbsorb(World worldIn, BlockPos pos, IBlockState state)
{
    if (!((Boolean)state.getValue(WET)).booleanValue() && this.absorb(worldIn, pos))
    {
        worldIn.setBlockState(pos, state.withProperty(WET, Boolean.valueOf(true)), 2);
        worldIn.playAuxSFX(2001, pos, Block.getIdFromBlock(Blocks.water));
    }
}
 
Example 6
Project: BaseClient   File: BlockSponge.java   Source Code and License Vote up 5 votes
protected void tryAbsorb(World worldIn, BlockPos pos, IBlockState state)
{
    if (!((Boolean)state.getValue(WET)).booleanValue() && this.absorb(worldIn, pos))
    {
        worldIn.setBlockState(pos, state.withProperty(WET, Boolean.valueOf(true)), 2);
        worldIn.playAuxSFX(2001, pos, Block.getIdFromBlock(Blocks.water));
    }
}
 
Example 7
Project: DecompiledMinecraft   File: BlockJukebox.java   Source Code and License Vote up 5 votes
private void dropRecord(World worldIn, BlockPos pos, IBlockState state)
{
    if (!worldIn.isRemote)
    {
        TileEntity tileentity = worldIn.getTileEntity(pos);

        if (tileentity instanceof BlockJukebox.TileEntityJukebox)
        {
            BlockJukebox.TileEntityJukebox blockjukebox$tileentityjukebox = (BlockJukebox.TileEntityJukebox)tileentity;
            ItemStack itemstack = blockjukebox$tileentityjukebox.getRecord();

            if (itemstack != null)
            {
                worldIn.playAuxSFX(1005, pos, 0);
                worldIn.playRecord(pos, (String)null);
                blockjukebox$tileentityjukebox.setRecord((ItemStack)null);
                float f = 0.7F;
                double d0 = (double)(worldIn.rand.nextFloat() * f) + (double)(1.0F - f) * 0.5D;
                double d1 = (double)(worldIn.rand.nextFloat() * f) + (double)(1.0F - f) * 0.2D + 0.6D;
                double d2 = (double)(worldIn.rand.nextFloat() * f) + (double)(1.0F - f) * 0.5D;
                ItemStack itemstack1 = itemstack.copy();
                EntityItem entityitem = new EntityItem(worldIn, (double)pos.getX() + d0, (double)pos.getY() + d1, (double)pos.getZ() + d2, itemstack1);
                entityitem.setDefaultPickupDelay();
                worldIn.spawnEntityInWorld(entityitem);
            }
        }
    }
}
 
Example 8
Project: DecompiledMinecraft   File: BlockSponge.java   Source Code and License Vote up 5 votes
protected void tryAbsorb(World worldIn, BlockPos pos, IBlockState state)
{
    if (!((Boolean)state.getValue(WET)).booleanValue() && this.absorb(worldIn, pos))
    {
        worldIn.setBlockState(pos, state.withProperty(WET, Boolean.valueOf(true)), 2);
        worldIn.playAuxSFX(2001, pos, Block.getIdFromBlock(Blocks.water));
    }
}
 
Example 9
Project: DecompiledMinecraft   File: ItemDye.java   Source Code and License Vote up 4 votes
/**
 * Called when a Block is right-clicked with this Item
 */
public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)
{
    if (!playerIn.canPlayerEdit(pos.offset(side), side, stack))
    {
        return false;
    }
    else
    {
        EnumDyeColor enumdyecolor = EnumDyeColor.byDyeDamage(stack.getMetadata());

        if (enumdyecolor == EnumDyeColor.WHITE)
        {
            if (applyBonemeal(stack, worldIn, pos))
            {
                if (!worldIn.isRemote)
                {
                    worldIn.playAuxSFX(2005, pos, 0);
                }

                return true;
            }
        }
        else if (enumdyecolor == EnumDyeColor.BROWN)
        {
            IBlockState iblockstate = worldIn.getBlockState(pos);
            Block block = iblockstate.getBlock();

            if (block == Blocks.log && iblockstate.getValue(BlockPlanks.VARIANT) == BlockPlanks.EnumType.JUNGLE)
            {
                if (side == EnumFacing.DOWN)
                {
                    return false;
                }

                if (side == EnumFacing.UP)
                {
                    return false;
                }

                pos = pos.offset(side);

                if (worldIn.isAirBlock(pos))
                {
                    IBlockState iblockstate1 = Blocks.cocoa.onBlockPlaced(worldIn, pos, side, hitX, hitY, hitZ, 0, playerIn);
                    worldIn.setBlockState(pos, iblockstate1, 2);

                    if (!playerIn.capabilities.isCreativeMode)
                    {
                        --stack.stackSize;
                    }
                }

                return true;
            }
        }

        return false;
    }
}
 
Example 10
Project: DecompiledMinecraft   File: BlockDropper.java   Source Code and License Vote up 4 votes
protected void dispense(World worldIn, BlockPos pos)
{
    BlockSourceImpl blocksourceimpl = new BlockSourceImpl(worldIn, pos);
    TileEntityDispenser tileentitydispenser = (TileEntityDispenser)blocksourceimpl.getBlockTileEntity();

    if (tileentitydispenser != null)
    {
        int i = tileentitydispenser.getDispenseSlot();

        if (i < 0)
        {
            worldIn.playAuxSFX(1001, pos, 0);
        }
        else
        {
            ItemStack itemstack = tileentitydispenser.getStackInSlot(i);

            if (itemstack != null)
            {
                EnumFacing enumfacing = (EnumFacing)worldIn.getBlockState(pos).getValue(FACING);
                BlockPos blockpos = pos.offset(enumfacing);
                IInventory iinventory = TileEntityHopper.getInventoryAtPosition(worldIn, (double)blockpos.getX(), (double)blockpos.getY(), (double)blockpos.getZ());
                ItemStack itemstack1;

                if (iinventory == null)
                {
                    itemstack1 = this.dropBehavior.dispense(blocksourceimpl, itemstack);

                    if (itemstack1 != null && itemstack1.stackSize <= 0)
                    {
                        itemstack1 = null;
                    }
                }
                else
                {
                    itemstack1 = TileEntityHopper.putStackInInventoryAllSlots(iinventory, itemstack.copy().splitStack(1), enumfacing.getOpposite());

                    if (itemstack1 == null)
                    {
                        itemstack1 = itemstack.copy();

                        if (--itemstack1.stackSize <= 0)
                        {
                            itemstack1 = null;
                        }
                    }
                    else
                    {
                        itemstack1 = itemstack.copy();
                    }
                }

                tileentitydispenser.setInventorySlotContents(i, itemstack1);
            }
        }
    }
}
 
Example 11
Project: DecompiledMinecraft   File: BlockAnvil.java   Source Code and License Vote up 4 votes
public void onEndFalling(World worldIn, BlockPos pos)
{
    worldIn.playAuxSFX(1022, pos, 0);
}
 
Example 12
Project: DecompiledMinecraft   File: ItemDye.java   Source Code and License Vote up 4 votes
/**
 * Called when a Block is right-clicked with this Item
 */
public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)
{
    if (!playerIn.canPlayerEdit(pos.offset(side), side, stack))
    {
        return false;
    }
    else
    {
        EnumDyeColor enumdyecolor = EnumDyeColor.byDyeDamage(stack.getMetadata());

        if (enumdyecolor == EnumDyeColor.WHITE)
        {
            if (applyBonemeal(stack, worldIn, pos))
            {
                if (!worldIn.isRemote)
                {
                    worldIn.playAuxSFX(2005, pos, 0);
                }

                return true;
            }
        }
        else if (enumdyecolor == EnumDyeColor.BROWN)
        {
            IBlockState iblockstate = worldIn.getBlockState(pos);
            Block block = iblockstate.getBlock();

            if (block == Blocks.log && iblockstate.getValue(BlockPlanks.VARIANT) == BlockPlanks.EnumType.JUNGLE)
            {
                if (side == EnumFacing.DOWN)
                {
                    return false;
                }

                if (side == EnumFacing.UP)
                {
                    return false;
                }

                pos = pos.offset(side);

                if (worldIn.isAirBlock(pos))
                {
                    IBlockState iblockstate1 = Blocks.cocoa.onBlockPlaced(worldIn, pos, side, hitX, hitY, hitZ, 0, playerIn);
                    worldIn.setBlockState(pos, iblockstate1, 2);

                    if (!playerIn.capabilities.isCreativeMode)
                    {
                        --stack.stackSize;
                    }
                }

                return true;
            }
        }

        return false;
    }
}
 
Example 13
Project: DecompiledMinecraft   File: BlockAnvil.java   Source Code and License Vote up 4 votes
public void onEndFalling(World worldIn, BlockPos pos)
{
    worldIn.playAuxSFX(1022, pos, 0);
}
 
Example 14
Project: DecompiledMinecraft   File: PlayerControllerMP.java   Source Code and License Vote up 4 votes
/**
 * Called when a player completes the destruction of a block
 */
public boolean onPlayerDestroyBlock(BlockPos pos, EnumFacing side)
{
    if (this.currentGameType.isAdventure())
    {
        if (this.currentGameType == WorldSettings.GameType.SPECTATOR)
        {
            return false;
        }

        if (!this.mc.thePlayer.isAllowEdit())
        {
            Block block = this.mc.theWorld.getBlockState(pos).getBlock();
            ItemStack itemstack = this.mc.thePlayer.getCurrentEquippedItem();

            if (itemstack == null)
            {
                return false;
            }

            if (!itemstack.canDestroy(block))
            {
                return false;
            }
        }
    }

    if (this.currentGameType.isCreative() && this.mc.thePlayer.getHeldItem() != null && this.mc.thePlayer.getHeldItem().getItem() instanceof ItemSword)
    {
        return false;
    }
    else
    {
        World world = this.mc.theWorld;
        IBlockState iblockstate = world.getBlockState(pos);
        Block block1 = iblockstate.getBlock();

        if (block1.getMaterial() == Material.air)
        {
            return false;
        }
        else
        {
            world.playAuxSFX(2001, pos, Block.getStateId(iblockstate));
            boolean flag = world.setBlockToAir(pos);

            if (flag)
            {
                block1.onBlockDestroyedByPlayer(world, pos, iblockstate);
            }

            this.currentBlock = new BlockPos(this.currentBlock.getX(), -1, this.currentBlock.getZ());

            if (!this.currentGameType.isCreative())
            {
                ItemStack itemstack1 = this.mc.thePlayer.getCurrentEquippedItem();

                if (itemstack1 != null)
                {
                    itemstack1.onBlockDestroyed(world, block1, pos, this.mc.thePlayer);

                    if (itemstack1.stackSize == 0)
                    {
                        this.mc.thePlayer.destroyCurrentEquippedItem();
                    }
                }
            }

            return flag;
        }
    }
}
 
Example 15
Project: BaseClient   File: ItemDye.java   Source Code and License Vote up 4 votes
/**
 * Called when a Block is right-clicked with this Item
 */
public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)
{
    if (!playerIn.canPlayerEdit(pos.offset(side), side, stack))
    {
        return false;
    }
    else
    {
        EnumDyeColor enumdyecolor = EnumDyeColor.byDyeDamage(stack.getMetadata());

        if (enumdyecolor == EnumDyeColor.WHITE)
        {
            if (applyBonemeal(stack, worldIn, pos))
            {
                if (!worldIn.isRemote)
                {
                    worldIn.playAuxSFX(2005, pos, 0);
                }

                return true;
            }
        }
        else if (enumdyecolor == EnumDyeColor.BROWN)
        {
            IBlockState iblockstate = worldIn.getBlockState(pos);
            Block block = iblockstate.getBlock();

            if (block == Blocks.log && iblockstate.getValue(BlockPlanks.VARIANT) == BlockPlanks.EnumType.JUNGLE)
            {
                if (side == EnumFacing.DOWN)
                {
                    return false;
                }

                if (side == EnumFacing.UP)
                {
                    return false;
                }

                pos = pos.offset(side);

                if (worldIn.isAirBlock(pos))
                {
                    IBlockState iblockstate1 = Blocks.cocoa.onBlockPlaced(worldIn, pos, side, hitX, hitY, hitZ, 0, playerIn);
                    worldIn.setBlockState(pos, iblockstate1, 2);

                    if (!playerIn.capabilities.isCreativeMode)
                    {
                        --stack.stackSize;
                    }
                }

                return true;
            }
        }

        return false;
    }
}
 
Example 16
Project: connor41-etfuturum2   File: Sponge.java   Source Code and License Vote up 4 votes
protected void tryAbsorb(World worldIn, int x, int y, int z, boolean wet) {
	if (!wet && absorb(worldIn, x, y, z)) {
		worldIn.setBlockMetadataWithNotify(x, y, z, 1, 2);
		worldIn.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(Blocks.water));
	}
}
 
Example 17
Project: BaseClient   File: ItemDye.java   Source Code and License Vote up 4 votes
/**
 * Called when a Block is right-clicked with this Item
 */
public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)
{
    if (!playerIn.canPlayerEdit(pos.offset(side), side, stack))
    {
        return false;
    }
    else
    {
        EnumDyeColor enumdyecolor = EnumDyeColor.byDyeDamage(stack.getMetadata());

        if (enumdyecolor == EnumDyeColor.WHITE)
        {
            if (applyBonemeal(stack, worldIn, pos))
            {
                if (!worldIn.isRemote)
                {
                    worldIn.playAuxSFX(2005, pos, 0);
                }

                return true;
            }
        }
        else if (enumdyecolor == EnumDyeColor.BROWN)
        {
            IBlockState iblockstate = worldIn.getBlockState(pos);
            Block block = iblockstate.getBlock();

            if (block == Blocks.log && iblockstate.getValue(BlockPlanks.VARIANT) == BlockPlanks.EnumType.JUNGLE)
            {
                if (side == EnumFacing.DOWN)
                {
                    return false;
                }

                if (side == EnumFacing.UP)
                {
                    return false;
                }

                pos = pos.offset(side);

                if (worldIn.isAirBlock(pos))
                {
                    IBlockState iblockstate1 = Blocks.cocoa.onBlockPlaced(worldIn, pos, side, hitX, hitY, hitZ, 0, playerIn);
                    worldIn.setBlockState(pos, iblockstate1, 2);

                    if (!playerIn.capabilities.isCreativeMode)
                    {
                        --stack.stackSize;
                    }
                }

                return true;
            }
        }

        return false;
    }
}
 
Example 18
Project: BaseClient   File: BlockDropper.java   Source Code and License Vote up 4 votes
protected void dispense(World worldIn, BlockPos pos)
{
    BlockSourceImpl blocksourceimpl = new BlockSourceImpl(worldIn, pos);
    TileEntityDispenser tileentitydispenser = (TileEntityDispenser)blocksourceimpl.getBlockTileEntity();

    if (tileentitydispenser != null)
    {
        int i = tileentitydispenser.getDispenseSlot();

        if (i < 0)
        {
            worldIn.playAuxSFX(1001, pos, 0);
        }
        else
        {
            ItemStack itemstack = tileentitydispenser.getStackInSlot(i);

            if (itemstack != null)
            {
                EnumFacing enumfacing = (EnumFacing)worldIn.getBlockState(pos).getValue(FACING);
                BlockPos blockpos = pos.offset(enumfacing);
                IInventory iinventory = TileEntityHopper.getInventoryAtPosition(worldIn, (double)blockpos.getX(), (double)blockpos.getY(), (double)blockpos.getZ());
                ItemStack itemstack1;

                if (iinventory == null)
                {
                    itemstack1 = this.dropBehavior.dispense(blocksourceimpl, itemstack);

                    if (itemstack1 != null && itemstack1.stackSize <= 0)
                    {
                        itemstack1 = null;
                    }
                }
                else
                {
                    itemstack1 = TileEntityHopper.putStackInInventoryAllSlots(iinventory, itemstack.copy().splitStack(1), enumfacing.getOpposite());

                    if (itemstack1 == null)
                    {
                        itemstack1 = itemstack.copy();

                        if (--itemstack1.stackSize <= 0)
                        {
                            itemstack1 = null;
                        }
                    }
                    else
                    {
                        itemstack1 = itemstack.copy();
                    }
                }

                tileentitydispenser.setInventorySlotContents(i, itemstack1);
            }
        }
    }
}
 
Example 19
Project: BaseClient   File: PlayerControllerMP.java   Source Code and License Vote up 4 votes
/**
 * Called when a player completes the destruction of a block
 */
public boolean onPlayerDestroyBlock(BlockPos pos, EnumFacing side)
{
    if (this.currentGameType.isAdventure())
    {
        if (this.currentGameType == WorldSettings.GameType.SPECTATOR)
        {
            return false;
        }

        if (!this.mc.thePlayer.isAllowEdit())
        {
            Block block = this.mc.theWorld.getBlockState(pos).getBlock();
            ItemStack itemstack = this.mc.thePlayer.getCurrentEquippedItem();

            if (itemstack == null)
            {
                return false;
            }

            if (!itemstack.canDestroy(block))
            {
                return false;
            }
        }
    }

    if (this.currentGameType.isCreative() && this.mc.thePlayer.getHeldItem() != null && this.mc.thePlayer.getHeldItem().getItem() instanceof ItemSword)
    {
        return false;
    }
    else
    {
        World world = this.mc.theWorld;
        IBlockState iblockstate = world.getBlockState(pos);
        Block block1 = iblockstate.getBlock();

        if (block1.getMaterial() == Material.air)
        {
            return false;
        }
        else
        {
            world.playAuxSFX(2001, pos, Block.getStateId(iblockstate));
            boolean flag = world.setBlockToAir(pos);

            if (flag)
            {
                block1.onBlockDestroyedByPlayer(world, pos, iblockstate);
            }

            this.currentBlock = new BlockPos(this.currentBlock.getX(), -1, this.currentBlock.getZ());

            if (!this.currentGameType.isCreative())
            {
                ItemStack itemstack1 = this.mc.thePlayer.getCurrentEquippedItem();

                if (itemstack1 != null)
                {
                    itemstack1.onBlockDestroyed(world, block1, pos, this.mc.thePlayer);

                    if (itemstack1.stackSize == 0)
                    {
                        this.mc.thePlayer.destroyCurrentEquippedItem();
                    }
                }
            }

            return flag;
        }
    }
}
 
Example 20
Project: BaseClient   File: BlockAnvil.java   Source Code and License Vote up 4 votes
public void onEndFalling(World worldIn, BlockPos pos)
{
    worldIn.playAuxSFX(1022, pos, 0);
}