类net.minecraft.util.SoundCategory源码实例Demo

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

源代码1 项目: AgriCraft   文件: TileEntityCrop.java
@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;
}
 
源代码2 项目: ExNihiloAdscensio   文件: ItemPebble.java
@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);
}
 
源代码3 项目: seppuku   文件: AutoFishModule.java
@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);
                }
            }
        }
    }
}
 
源代码4 项目: GregTech   文件: RecipeLogicSteam.java
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);
    }
}
 
源代码5 项目: GregTech   文件: SteamBoiler.java
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;
    }
}
 
源代码6 项目: GT-Classic   文件: GTTileCharcoalPit.java
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);
	}
}
 
源代码7 项目: GT-Classic   文件: GTTileCharcoalPit.java
@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);
		}
	}
}
 
源代码8 项目: AdvancedRocketry   文件: TileOxygenVent.java
@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;
}
 
@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);
}
 
源代码10 项目: customstuff4   文件: ItemSlab.java
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;
}
 
源代码11 项目: enderutilities   文件: TileEntityHandyChest.java
@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());
    }
}
 
源代码12 项目: Wizardry   文件: ModuleShapeProjectile.java
/**
 * {@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;
}
 
源代码13 项目: Wizardry   文件: ModuleEffectLight.java
@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;
}
 
源代码14 项目: Wizardry   文件: ModuleEffectGrace.java
@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;
}
 
源代码15 项目: enderutilities   文件: TileEntityBarrel.java
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;
}
 
源代码16 项目: Wizardry   文件: ModuleEffectLowGravity.java
@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;
}
 
源代码17 项目: Wizardry   文件: ModuleEffectBouncing.java
@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;
}
 
源代码18 项目: Sakura_mod   文件: ItemBroom.java
/**
    * 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;
   }
 
源代码19 项目: Sakura_mod   文件: BlockTaiko.java
@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);
}
 
源代码20 项目: Sakura_mod   文件: BlockWindBell.java
@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);
        }
}
 
源代码21 项目: enderutilities   文件: TileEntityEnderUtilities.java
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();
    }
}
 
源代码22 项目: enderutilities   文件: BlockEnderUtilitiesPortal.java
@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);
    }
}
 
源代码23 项目: enderutilities   文件: TileEntityPortalPanel.java
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);
        }
    }
}
 
源代码24 项目: Cyberware   文件: TileEntityEngineeringTable.java
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()) } );
	}
}
 
源代码25 项目: Wizardry   文件: ModuleEffectBurn.java
@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;
}
 
源代码26 项目: GregTech   文件: BlockFoam.java
@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;
}
 
源代码27 项目: GT-Classic   文件: GTUtility.java
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;
}
 
源代码28 项目: EnderZoo   文件: BlockConfusingCharge.java
@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);
}
 
源代码29 项目: enderutilities   文件: BlockElevator.java
@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);
    }
}
 
源代码30 项目: Kettle   文件: CraftWorld.java
@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
}
 
 类所在包
 类方法
 同包方法