Java Code Examples for net.minecraft.util.SoundCategory

The following examples show how to use net.minecraft.util.SoundCategory. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: AgriCraft   Source File: TileEntityCrop.java    License: MIT License 6 votes vote down vote up
@Override
public boolean setCrossCrop(boolean status) {
    // If remote, change was failure.
    if (this.isRemote()) {
        return false;
    }

    // If we have a plant, change was a failure.
    if (this.hasSeed()) {
        return false;
    }

    // If the new state does not differ, change was a failure.
    if (this.crossCrop == status) {
        return false;
    }

    // Otherwise perform change.
    this.crossCrop = status;
    SoundType type = Blocks.PLANKS.getSoundType(null, null, null, null);
    this.getWorld().playSound(null, (double) ((float) xCoord() + 0.5F), (double) ((float) yCoord() + 0.5F), (double) ((float) zCoord() + 0.5F), type.getPlaceSound(), SoundCategory.BLOCKS, (type.getVolume() + 1.0F) / 2.0F, type.getPitch() * 0.8F);
    this.markForUpdate();

    // Operation was a success!
    return true;
}
 
Example 2
Source Project: ExNihiloAdscensio   Source File: ItemPebble.java    License: MIT License 6 votes vote down vote up
@Override
public ActionResult<ItemStack> onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand)
{
    stack.stackSize--;
    
    world.playSound(player, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_SNOWBALL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
    
    if (!world.isRemote)
    {
        ItemStack thrown = stack.copy();
        thrown.stackSize = 1;
        
        ProjectileStone projectile = new ProjectileStone(world, player);
        projectile.setStack(thrown);
        projectile.setHeadingFromThrower(player, player.rotationPitch, player.rotationYaw, 0.0F, 1.5F, 0.5F);
        world.spawnEntity(projectile);
    }
    
    return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, stack);
}
 
Example 3
Source Project: seppuku   Source File: AutoFishModule.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Listener
public void receivePacket(EventReceivePacket event) {
    if (event.getStage() == EventStageable.EventStage.PRE) {

        if(event.getPacket() instanceof SPacketSoundEffect) {
            final SPacketSoundEffect packet = (SPacketSoundEffect) event.getPacket();
            if(packet.getCategory() == SoundCategory.NEUTRAL && packet.getSound() == SoundEvents.ENTITY_BOBBER_SPLASH) {
                final Minecraft mc = Minecraft.getMinecraft();

                if (mc.player.getHeldItemMainhand().getItem() instanceof ItemFishingRod) {
                    mc.player.connection.sendPacket(new CPacketPlayerTryUseItem(EnumHand.MAIN_HAND));
                    mc.player.swingArm(EnumHand.MAIN_HAND);
                    mc.player.connection.sendPacket(new CPacketPlayerTryUseItem(EnumHand.MAIN_HAND));
                    mc.player.swingArm(EnumHand.MAIN_HAND);
                }
            }
        }
    }
}
 
Example 4
protected void tryDoVenting() {
    BlockPos machinePos = metaTileEntity.getPos();
    EnumFacing ventingSide = getVentingSide();
    BlockPos ventingBlockPos = machinePos.offset(ventingSide);
    IBlockState blockOnPos = metaTileEntity.getWorld().getBlockState(ventingBlockPos);
    if (blockOnPos.getCollisionBoundingBox(metaTileEntity.getWorld(), ventingBlockPos) == Block.NULL_AABB) {
        metaTileEntity.getWorld()
            .getEntitiesWithinAABB(EntityLivingBase.class, new AxisAlignedBB(ventingBlockPos), EntitySelectors.CAN_AI_TARGET)
            .forEach(entity -> entity.attackEntityFrom(DamageSources.getHeatDamage(), 6.0f));
        WorldServer world = (WorldServer) metaTileEntity.getWorld();
        double posX = machinePos.getX() + 0.5 + ventingSide.getFrontOffsetX() * 0.6;
        double posY = machinePos.getY() + 0.5 + ventingSide.getFrontOffsetY() * 0.6;
        double posZ = machinePos.getZ() + 0.5 + ventingSide.getFrontOffsetZ() * 0.6;

        world.spawnParticle(EnumParticleTypes.SMOKE_LARGE, posX, posY, posZ,
            7 + world.rand.nextInt(3),
            ventingSide.getFrontOffsetX() / 2.0,
            ventingSide.getFrontOffsetY() / 2.0,
            ventingSide.getFrontOffsetZ() / 2.0, 0.1);
        world.playSound(null, posX, posY, posZ, SoundEvents.BLOCK_LAVA_EXTINGUISH, SoundCategory.BLOCKS, 1.0f, 1.0f);
        setNeedsVenting(false);
    } else if (!ventingStuck) {
        setVentingStuck(true);
    }
}
 
Example 5
Source Project: GregTech   Source File: SteamBoiler.java    License: GNU Lesser General Public License v3.0 6 votes vote down vote up
private void generateSteam() {
    if(currentTemperature >= 100) {
        if (getTimer() % getBoilingCycleLength() == 0) {
            int fillAmount = (int) (baseSteamOutput * (currentTemperature / (getMaxTemperate() * 1.0)));
            boolean hasDrainedWater = waterFluidTank.drain(1, true) != null;
            int filledSteam = 0;
            if (hasDrainedWater) {
                filledSteam = steamFluidTank.fill(ModHandler.getSteam(fillAmount), true);
            }
            if (this.hasNoWater && hasDrainedWater) {
                getWorld().setBlockToAir(getPos());
                getWorld().createExplosion(null,
                    getPos().getX() + 0.5, getPos().getY() + 0.5, getPos().getZ() + 0.5,
                    2.0f, true);
            } else this.hasNoWater = !hasDrainedWater;
            if (filledSteam == 0 && hasDrainedWater) {
                getWorld().playSound(null, getPos().getX() + 0.5, getPos().getY() + 0.5, getPos().getZ() + 0.5,
                    SoundEvents.BLOCK_LAVA_EXTINGUISH, SoundCategory.BLOCKS, 1.0f, 1.0f);
                steamFluidTank.drain(4000, true);
            }
        }
    } else {
        this.hasNoWater = false;
    }
}
 
Example 6
private void updateProgress() {
	progress = progress + 1.0F;
	if (progress >= recipeOperation) {
		if (hasLogs()) {
			for (BlockPos logs : logPositions) {
				if (isLog(logs)) {
					world.setBlockState(logs, GTBlocks.brittleCharcoal.getDefaultState());
				}
			}
		}
		this.progress = 0;
		this.setActive(false);
		logPositions.clear();
		world.playSound((EntityPlayer) null, pos, SoundEvents.BLOCK_SAND_PLACE, SoundCategory.BLOCKS, 1.0F, 1.0F);
	}
}
 
Example 7
@SideOnly(Side.CLIENT)
@Override
public void randomTickDisplay(IBlockState stateIn, World worldIn, BlockPos pos, Random rand) {
	if (this.isActive) {
		if (rand.nextInt(16) == 0) {
			worldIn.playSound((double) ((float) pos.getX() + 0.5F), (double) ((float) pos.getY()
					+ 0.5F), (double) ((float) pos.getZ()
							+ 0.5F), SoundEvents.BLOCK_FIRE_AMBIENT, SoundCategory.BLOCKS, 1.0F
									+ rand.nextFloat(), rand.nextFloat() * 0.7F + 0.3F, false);
		}
		for (int i = 0; i < 3; ++i) {
			double d0 = (double) pos.getX() + rand.nextDouble();
			double d1 = (double) pos.getY() + rand.nextDouble() * 0.5D + 0.5D;
			double d2 = (double) pos.getZ() + rand.nextDouble();
			worldIn.spawnParticle(EnumParticleTypes.SMOKE_LARGE, d0, d1, d2, 0.0D, 0.0D, 0.0D);
		}
	}
}
 
Example 8
Source Project: AdvancedRocketry   Source File: TileOxygenVent.java    License: MIT License 6 votes vote down vote up
@Override
public void update() {

	if(canPerformFunction()) {

		if(hasEnoughEnergy(getPowerPerOperation())) {
			performFunction();
			if(!world.isRemote && isSealed) this.energy.extractEnergy(getPowerPerOperation(), false);
		}
		else
			notEnoughEnergyForFunction();
	}
	else
		radius = -1;
	if(!soundInit && world.isRemote) {
		LibVulpes.proxy.playSound(new RepeatingSound(AudioRegistry.airHissLoop, SoundCategory.BLOCKS, this));
	}
	soundInit = true;
}
 
Example 9
Source Project: Production-Line   Source File: ThrowableUranium238Handler.java    License: MIT License 6 votes vote down vote up
@Override
public ActionResult<ItemStack> onRightClick(ItemStack itemStack, EntityPlayer entityPlayer, EnumHand hand) {
    ItemStack target = IC2Items.getItem("nuclear", "uranium_238");
    if (itemStack.isItemEqual(target)) {
        if (PLConfig.instance.throwableUran238) {
            if (!entityPlayer.capabilities.isCreativeMode) {
                --itemStack.stackSize;
            }

            entityPlayer.world.playSound(entityPlayer, entityPlayer.getPosition(),
                    SoundEvents.ENTITY_ARROW_SHOOT, SoundCategory.PLAYERS,
                    0.5F, 0.4F / (new Random().nextFloat() * 0.4F + 0.8F));
            if (!entityPlayer.world.isRemote) {
                entityPlayer.world.spawnEntity(new EntityThrownItem(entityPlayer.world, entityPlayer, itemStack));
            }
        }
        return ActionResult.newResult(EnumActionResult.SUCCESS, itemStack);
    }
    return ActionResult.newResult(EnumActionResult.PASS, itemStack);
}
 
Example 10
Source Project: customstuff4   Source File: ItemSlab.java    License: GNU General Public License v3.0 6 votes vote down vote up
private boolean tryPlace(EntityPlayer player, ItemStack stack, World worldIn, BlockPos pos, int subtype)
{
    IBlockState iblockstate = worldIn.getBlockState(pos);

    if (iblockstate.getBlock() == this.singleSlab)
    {
        int subtype1 = singleSlabCS.getSubtype(iblockstate);

        if (subtype1 == subtype)
        {
            IBlockState stateDouble = this.makeState(subtype1);
            AxisAlignedBB axisalignedbb = stateDouble == null ? Block.NULL_AABB : stateDouble.getCollisionBoundingBox(worldIn, pos);

            if (stateDouble != null && axisalignedbb != Block.NULL_AABB && worldIn.checkNoEntityCollision(axisalignedbb.offset(pos)) && worldIn.setBlockState(pos, stateDouble, 11))
            {
                SoundType soundtype = stateDouble.getBlock().getSoundType(stateDouble, worldIn, pos, player);
                worldIn.playSound(player, pos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F);
                stack.shrink(1);
            }

            return true;
        }
    }

    return false;
}
 
Example 11
@Override
public void onLeftClickBlock(EntityPlayer player)
{
    if (this.getWorld().isRemote)
    {
        return;
    }

    Long last = this.clickTimes.get(player.getUniqueID());

    if (last != null && this.getWorld().getTotalWorldTime() - last < 5)
    {
        // Double left clicked fast enough (< 5 ticks) - do the selected item moving action
        this.performGuiAction(player, GUI_ACTION_MOVE_ITEMS, this.actionMode);
        this.getWorld().playSound(null, this.getPos(), SoundEvents.ENTITY_ENDERMEN_TELEPORT, SoundCategory.BLOCKS, 0.2f, 1.8f);
        this.clickTimes.remove(player.getUniqueID());
    }
    else
    {
        this.clickTimes.put(player.getUniqueID(), this.getWorld().getTotalWorldTime());
    }
}
 
Example 12
/**
 * {@inheritDoc}
 */
@Override
public boolean run(@NotNull World world, ModuleInstanceShape instance, @Nonnull SpellData spell, @Nonnull SpellRing spellRing) {
	if (world.isRemote) return true;

	Vec3d origin = spell.getOriginWithFallback(world);
	if (origin == null) return false;

	double dist = spellRing.getAttributeValue(world, AttributeRegistry.RANGE, spell);
	double speed = spellRing.getAttributeValue(world, AttributeRegistry.SPEED, spell);

	if (!spellRing.taxCaster(world, spell, true)) return false;
	
	IShapeOverrides overrides = spellRing.getOverrideHandler().getConsumerInterface(IShapeOverrides.class);

	EntitySpellProjectile proj = new EntitySpellProjectile(world, spellRing, spell, (float) dist, (float) speed, (float) 0.1, !overrides.onRunProjectile(world, spell, spellRing));
	proj.setPosition(origin.x, origin.y, origin.z);
	proj.velocityChanged = true;

	boolean success = world.spawnEntity(proj);
	if (success)
		world.playSound(null, new BlockPos(origin), ModSounds.PROJECTILE_LAUNCH, SoundCategory.PLAYERS, 1f, (float) RandUtil.nextDouble(1, 1.5));
	return success;
}
 
Example 13
@Override
public boolean run(@NotNull World world, ModuleInstanceEffect instance, @Nonnull SpellData spell, @Nonnull SpellRing spellRing) {
	BlockPos targetPos = spell.getTargetPos();
	EnumFacing facing = spell.getFaceHit();
	Entity caster = spell.getCaster(world);

	BlockPos finalPos = targetPos;
	if (facing != null && world.isAirBlock(targetPos.offset(facing))) finalPos = targetPos.offset(facing);
	if (!world.isAirBlock(finalPos)) return false;

	if (!spellRing.taxCaster(world, spell, true)) return false;

	if (targetPos == null) return true;

	BlockUtils.placeBlock(world, finalPos, ModBlocks.LIGHT.getDefaultState(), BlockUtils.makePlacer(world, finalPos, caster));
	TileLight te = BlockUtils.getTileEntity(world, finalPos, TileLight.class);
	if( te != null ) {
		// Should be always the case.
		te.setModule(instance);
	}

	world.playSound(null, targetPos, ModSounds.SPARKLE, SoundCategory.AMBIENT, 1f, 1f);

	return true;
}
 
Example 14
@Override
public boolean runOnStart(@Nonnull World world, @Nonnull SpellData spell, @Nonnull SpellRing spellRing) {
	Entity entity = spell.getVictim(world);
	BlockPos pos = spell.getTargetPos();

	if (pos == null) return true;

	double time = spellRing.getAttributeValue(world, AttributeRegistry.DURATION, spell) * 10;

	if (!spellRing.taxCaster(world, spell, true)) return false;

	world.playSound(null, pos, ModSounds.GRACE, SoundCategory.NEUTRAL, RandUtil.nextFloat(0.6f, 1f), RandUtil.nextFloat(0.5f, 1f));
	if (entity instanceof EntityLivingBase) {
		((EntityLivingBase) entity).addPotionEffect(new PotionEffect(ModPotions.GRACE, (int) time, 0, true, false));
	}

	return true;
}
 
Example 15
private boolean toggleCreativeMode(EntityPlayer player, boolean isStorageKey)
{
    if (isStorageKey || player.capabilities.isCreativeMode)
    {
        this.setCreative(! this.isCreative());
        this.markDirty();

        IBlockState state = this.getWorld().getBlockState(this.getPos());
        state = state.withProperty(BlockBarrel.CREATIVE, this.isCreative());
        this.getWorld().setBlockState(this.getPos(), state);

        if (isStorageKey)
        {
            this.getWorld().playSound(null, this.getPos(), SoundEvents.ENTITY_ITEMFRAME_REMOVE_ITEM, SoundCategory.BLOCKS, 0.7f, 1f);
        }

        return true;
    }

    return false;
}
 
Example 16
@Override
@SuppressWarnings("unused")
public boolean run(@NotNull World world, ModuleInstanceEffect instance, @Nonnull SpellData spell, @Nonnull SpellRing spellRing) {
	Entity targetEntity = spell.getVictim(world);
	BlockPos targetPos = spell.getTargetPos();
	Entity caster = spell.getCaster(world);

	double potency = spellRing.getAttributeValue(world, AttributeRegistry.POTENCY, spell);
	double duration = spellRing.getAttributeValue(world, AttributeRegistry.DURATION, spell) * 10;

	if (!spellRing.taxCaster(world, spell, true)) return false;

	if (targetEntity != null) {
		world.playSound(null, targetEntity.getPosition(), ModSounds.TELEPORT, SoundCategory.NEUTRAL, 1, 1);
		((EntityLivingBase) targetEntity).addPotionEffect(new PotionEffect(ModPotions.LOW_GRAVITY, (int) duration, (int) potency, true, false));
	}
	return true;
}
 
Example 17
@Override
public boolean runOnStart(@Nonnull World world, @Nonnull SpellData spell, @Nonnull SpellRing spellRing) {
	Entity entity = spell.getVictim(world);

	BlockPos pos = spell.getTargetPos();
	if (pos == null) return true;

	double time = spellRing.getAttributeValue(world, AttributeRegistry.DURATION, spell) * 10;

	if (!spellRing.taxCaster(world, spell, true)) return false;

	if (entity instanceof EntityLivingBase) {
		BounceManager.INSTANCE.forEntity((EntityLivingBase) entity, (int) time);
	} else if (!BlockUtils.isAnyAir(world, pos)) {
		BounceManager.INSTANCE.forBlock(world, pos, (int) time);
		PacketHandler.NETWORK.sendToAll(new PacketAddBouncyBlock(world, pos, (int) time));
	}

	world.playSound(null, pos, ModSounds.SLIME_SQUISHING, SoundCategory.NEUTRAL, RandUtil.nextFloat(0.6f, 1f), RandUtil.nextFloat(0.5f, 1f));
	return true;
}
 
Example 18
Source Project: Sakura_mod   Source File: ItemBroom.java    License: MIT License 5 votes vote down vote up
/**
    * Called when a Block is right-clicked with this Item
    */
@Override
   public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
   {
       ItemStack itemstack = player.getHeldItem(hand);

       if (!player.canPlayerEdit(pos.offset(facing), facing, itemstack))
       {
           return EnumActionResult.FAIL;
       }
	IBlockState iblockstate = worldIn.getBlockState(pos);
	Block block = iblockstate.getBlock();

	if (facing != EnumFacing.DOWN && worldIn.getBlockState(pos.up()).getMaterial() == Material.AIR && ((worldIn.getBlockState(pos).getMaterial() == Material.GROUND||worldIn.getBlockState(pos).getMaterial() ==Material.GRASS) && !(block instanceof BlockFarmland||block instanceof BlockGrassPath)))
	{
	    IBlockState iblockstate1 = Blocks.GRASS_PATH.getDefaultState();
	    worldIn.playSound(player, pos, SoundEvents.BLOCK_GRASS_STEP, SoundCategory.BLOCKS, 1.2F, 1.2F);
	    worldIn.playSound(player, pos, SoundEvents.BLOCK_GRASS_PLACE, SoundCategory.BLOCKS, 1.2F, 1.2F);
	    if (!worldIn.isRemote)
	    {
	        worldIn.setBlockState(pos, iblockstate1, 11);
	        itemstack.damageItem(1, player);
	    }

	    return EnumActionResult.SUCCESS;
	}
	return EnumActionResult.PASS;
   }
 
Example 19
Source Project: Sakura_mod   Source File: BlockTaiko.java    License: MIT License 5 votes vote down vote up
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn,
		EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
	if(RecipesUtil.containsMatch(false, OreDictionary.getOres("stickWood"), playerIn.getHeldItem(hand))){
		worldIn.playSound(playerIn, pos, CommonProxy.TAIKO, SoundCategory.BLOCKS, 1.2F, 1.2F);
		playerIn.swingArm(hand);
		}
	return super.onBlockActivated(worldIn, pos, state, playerIn, hand, facing, hitX, hitY, hitZ);
}
 
Example 20
Source Project: Sakura_mod   Source File: BlockWindBell.java    License: MIT License 5 votes vote down vote up
@Override
public void randomDisplayTick(IBlockState stateIn, World worldIn, BlockPos pos, Random rand) {
	if (rand.nextInt(50) == 0) {
           worldIn.playSound(pos.getX(), pos.getY(), pos.getZ(), SoundEvents.ENTITY_EXPERIENCE_ORB_PICKUP, SoundCategory.BLOCKS, 1F, 1.5F * ((rand.nextFloat() - rand.nextFloat()) * 0.7F + 1.8F), 
        		   true);
        }
}
 
Example 21
private void removeCamouflage()
{
    if (this.getWorld().isRemote == false && this.camoState != null)
    {
        this.camoState = null;
        this.getWorld().playSound(null, this.getPos(), SoundEvents.ENTITY_ITEMFRAME_REMOVE_ITEM, SoundCategory.BLOCKS, 1f, 1f);
        this.notifyBlockUpdate(this.getPos());
        // Check light changes in case the camo block emits light
        this.getWorld().checkLightFor(EnumSkyBlock.BLOCK, this.getPos());
        this.markDirty();
    }
}
 
Example 22
@Override
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
    if (worldIn.isRemote == false && this.checkCanStayAndScheduleBreaking(worldIn, pos, state) == false)
    {
        worldIn.playSound(null, pos, SoundEvents.BLOCK_GLASS_BREAK, SoundCategory.BLOCKS, 0.2f, 0.8f);
        worldIn.setBlockToAir(pos);
    }
}
 
Example 23
public void tryTogglePortal()
{
    World world = this.getWorld();
    BlockPos posPanel = this.getPos();
    BlockEnderUtilities blockPanel = EnderUtilitiesBlocks.PORTAL_PANEL;
    BlockPos posFrame = posPanel.offset(world.getBlockState(posPanel).getValue(blockPanel.propFacing).getOpposite());

    PortalFormer portalFormer = new PortalFormer(world, posFrame, EnderUtilitiesBlocks.PORTAL_FRAME, EnderUtilitiesBlocks.PORTAL);
    PortalData data = new PortalData(this.getActiveTarget(), this.getOwner(), this.getPortalColor(), this.targetIsPortal());
    portalFormer.setPortalData(data);
    portalFormer.analyzePortal();
    boolean state = portalFormer.getPortalState();
    boolean recreate = this.activeTargetId != this.portalTargetId;

    // Portal was inactive
    if (state == false)
    {
        if (portalFormer.togglePortalState(false))
        {
            this.portalTargetId = this.activeTargetId;
            world.playSound(null, posPanel, SoundEvents.ENTITY_BLAZE_SHOOT, SoundCategory.BLOCKS, 0.5f, 1.0f);
        }
    }
    // Portal was active
    else if (portalFormer.togglePortalState(recreate))
    {
        // Portal was active but the target id has changed, so it was just updated
        if (recreate)
        {
            this.portalTargetId = this.activeTargetId;
            world.playSound(null, posPanel, SoundEvents.ENTITY_BLAZE_SHOOT, SoundCategory.BLOCKS, 0.5f, 1.0f);
        }
        // Portal was active and the target id hasn't changed, so it was shut down
        else
        {
            world.playSound(null, posPanel, SoundEvents.BLOCK_GLASS_BREAK, SoundCategory.BLOCKS, 0.4f, 0.85f);
        }
    }
}
 
Example 24
Source Project: Cyberware   Source File: TileEntityEngineeringTable.java    License: MIT License 5 votes vote down vote up
public void smashSounds()
{
	int x = pos.getX();
	int y = pos.getY();
	int z = pos.getZ();
	clickedTime = Minecraft.getMinecraft().thePlayer.ticksExisted + Minecraft.getMinecraft().getRenderPartialTicks();
	worldObj.playSound(x, y, z, SoundEvents.BLOCK_PISTON_EXTEND, SoundCategory.BLOCKS, 1F, 1F, false);
	worldObj.playSound(x, y, z, SoundEvents.ENTITY_ITEM_BREAK, SoundCategory.BLOCKS, 1F, .5F, false);
	for (int i = 0; i < 10; i++)
	{
		worldObj.spawnParticle(EnumParticleTypes.ITEM_CRACK, x + .5F, y, z + .5F, .25F * (worldObj.rand.nextFloat() - .5F), .1F, .25F * (worldObj.rand.nextFloat() - .5F), 
				new int[] { Item.getIdFromItem(slots.getStackInSlot(0).getItem()) } );
	}
}
 
Example 25
@Override
public boolean run(@NotNull World world, ModuleInstanceEffect instance, @Nonnull SpellData spell, @Nonnull SpellRing spellRing) {

	Entity targetEntity = spell.getVictim(world);
	BlockPos targetPos = spell.getTargetPos();
	Entity caster = spell.getCaster(world);
	EnumFacing facing = spell.getData(FACE_HIT);

	double area = spellRing.getAttributeValue(world, AttributeRegistry.AREA, spell) / 2.0;
	double time = spellRing.getAttributeValue(world, AttributeRegistry.DURATION, spell);

	if (!spellRing.taxCaster(world, spell, true)) return false;

	if (targetEntity != null) {
		targetEntity.setFire((int) time);
		world.playSound(null, targetEntity.getPosition(), ModSounds.FIRE, SoundCategory.NEUTRAL, RandUtil.nextFloat(0.35f, 0.75f), RandUtil.nextFloat(0.35f, 1.5f));
	}

	if (targetPos != null) {
		for (int x = (int) area; x >= -area; x--)
			for (int y = (int) area; y >= -area; y--)
				for (int z = (int) area; z >= -area; z--) {
					BlockPos pos = targetPos.add(x, y, z);
					double dist = pos.getDistance(targetPos.getX(), targetPos.getY(), targetPos.getZ());
					if (dist > area) continue;
					if (facing != null) {
						if (!world.isAirBlock(pos.offset(facing))) continue;
						BlockUtils.placeBlock(world, pos.offset(facing), Blocks.FIRE.getDefaultState(), BlockUtils.makePlacer(world, pos, caster));
					} else for (EnumFacing face : EnumFacing.VALUES) {
						if (world.isAirBlock(pos.offset(face)) || world.getBlockState(pos.offset(face)).getBlock() == Blocks.SNOW_LAYER) {
							BlockUtils.placeBlock(world, pos.offset(face), Blocks.AIR.getDefaultState(), BlockUtils.makePlacer(world, pos, caster));
						}
					}
				}
		world.playSound(null, targetPos, ModSounds.FIRE, SoundCategory.AMBIENT, 0.5f, RandUtil.nextFloat());
	}
	return true;
}
 
Example 26
Source Project: GregTech   Source File: BlockFoam.java    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    ItemStack stackInHand = playerIn.getHeldItem(hand);
    if (!stackInHand.isEmpty() && OreDictUnifier.getOreDictionaryNames(stackInHand).contains("sand")) {
        worldIn.setBlockState(pos, getPetrifiedBlock(state));
        worldIn.playSound(playerIn, pos, SoundEvents.BLOCK_SAND_PLACE, SoundCategory.BLOCKS, 1.0f, 1.0f);
        if (!playerIn.capabilities.isCreativeMode)
            stackInHand.shrink(1);
        return true;
    }
    return false;
}
 
Example 27
Source Project: GT-Classic   Source File: GTUtility.java    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
public static boolean resetEndPortalFrame(World world, BlockPos pos, IBlockState portalFrameState) {
	if (portalFrameState.getBlock() == Blocks.END_PORTAL_FRAME
			&& portalFrameState.getValue(BlockEndPortalFrame.EYE).booleanValue()) {
		world.setBlockState(pos, portalFrameState.withProperty(BlockEndPortalFrame.EYE, false));
		world.playSound((EntityPlayer) null, pos, SoundEvents.BLOCK_END_PORTAL_FRAME_FILL, SoundCategory.BLOCKS, 0.5F, 0.5F
				+ world.rand.nextFloat());
		return true;
	}
	return false;
}
 
Example 28
@Override
public void explode(EntityPrimedCharge entity) {
  World world = entity.getEntityWorld();

  world.playSound((EntityPlayer)null, entity.posX, entity.posY, entity.posZ, SoundEvents.ENTITY_TNT_PRIMED, SoundCategory.BLOCKS, 3F, 1.4f + ((world.rand.nextFloat() - world.rand.nextFloat()) * 0.2F));

  PacketHandler.sendToAllAround(new PacketExplodeEffect(entity, this), entity);
}
 
Example 29
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player,
        EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ)
{
    ItemStack stack = EntityUtils.getHeldItemOfType(player, ItemDye.class);

    if (stack.isEmpty() == false)
    {
        EnumDyeColor stackColor = EnumDyeColor.byDyeDamage(stack.getMetadata());

        if (state.getValue(COLOR) != stackColor)
        {
            if (world.isRemote == false)
            {
                world.setBlockState(pos, state.withProperty(COLOR, stackColor), 3);
                world.playSound(null, pos, SoundEvents.ENTITY_ITEMFRAME_ADD_ITEM, SoundCategory.BLOCKS, 1f, 1f);

                if (player.capabilities.isCreativeMode == false)
                {
                    stack.shrink(1);
                }
            }

            return true;
        }

        return false;
    }
    else
    {
        return super.onBlockActivated(world, pos, state, player, hand, side, hitX, hitY, hitZ);
    }
}
 
Example 30
Source Project: Kettle   Source File: CraftWorld.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public void playSound(Location loc, Sound sound, org.bukkit.SoundCategory category, float volume, float pitch) {
    if (loc == null || sound == null || category == null) {
        return;
    }

    double x = loc.getX();
    double y = loc.getY();
    double z = loc.getZ();

    getHandle().playSound(null, x, y, z, CraftSound.getSoundEffect(CraftSound.getSound(sound)), SoundCategory.valueOf(category.name()), volume, pitch); // PAIL: rename
}