Java 类net.minecraft.util.SoundEvent 实例源码

项目:Backmemed    文件:RenderGlobal.java   
public void playRecord(@Nullable SoundEvent soundIn, BlockPos pos)
{
    ISound isound = (ISound)this.mapSoundPositions.get(pos);

    if (isound != null)
    {
        this.mc.getSoundHandler().stopSound(isound);
        this.mapSoundPositions.remove(pos);
    }

    if (soundIn != null)
    {
        ItemRecord itemrecord = ItemRecord.getBySound(soundIn);

        if (itemrecord != null)
        {
            this.mc.ingameGUI.setRecordPlayingMessage(itemrecord.getRecordNameLocal());
        }

        PositionedSoundRecord positionedsoundrecord = PositionedSoundRecord.getRecordSoundRecord(soundIn, (float)pos.getX(), (float)pos.getY(), (float)pos.getZ());
        this.mapSoundPositions.put(pos, positionedsoundrecord);
        this.mc.getSoundHandler().playSound(positionedsoundrecord);
    }
}
项目:Backmemed    文件:EntityLivingBase.java   
protected void playEquipSound(ItemStack stack)
{
    if (!stack.func_190926_b())
    {
        SoundEvent soundevent = SoundEvents.ITEM_ARMOR_EQUIP_GENERIC;
        Item item = stack.getItem();

        if (item instanceof ItemArmor)
        {
            soundevent = ((ItemArmor)item).getArmorMaterial().getSoundEvent();
        }
        else if (item == Items.ELYTRA)
        {
            soundevent = SoundEvents.field_191258_p;
        }

        this.playSound(soundevent, 1.0F, 1.0F);
    }
}
项目:ArcaneMagic    文件:ModRegistry.java   
@SubscribeEvent
public void registerSounds(Register<SoundEvent> event)
{
    IForgeRegistry<SoundEvent> registry = event.getRegistry();
    ArcaneMagicSoundHandler.register("spell", registry);
    ArcaneMagicSoundHandler.register("scepter_1", registry);
    ArcaneMagicSoundHandler.register("scepter_2", registry);
    ArcaneMagicSoundHandler.register("scepter_3", registry);
    ArcaneMagicSoundHandler.register("page_1", registry);
    ArcaneMagicSoundHandler.register("page_2", registry);
    ArcaneMagicSoundHandler.register("arcane_transfiguration_success", registry);
    ArcaneMagicSoundHandler.register("write_1", registry);
    ArcaneMagicSoundHandler.register("write_2", registry);
    ArcaneMagicSoundHandler.register("learn_1", registry);
    ArcaneMagicSoundHandler.register("learn_2", registry);
    ArcaneMagicSoundHandler.register("reconstruct", registry);
    ArcaneMagicSoundHandler.register("clack", registry);
}
项目:CustomWorldGen    文件:RenderGlobal.java   
public void playRecord(@Nullable SoundEvent soundIn, BlockPos pos)
{
    ISound isound = (ISound)this.mapSoundPositions.get(pos);

    if (isound != null)
    {
        this.mc.getSoundHandler().stopSound(isound);
        this.mapSoundPositions.remove(pos);
    }

    if (soundIn != null)
    {
        ItemRecord itemrecord = ItemRecord.getBySound(soundIn);

        if (itemrecord != null)
        {
            this.mc.ingameGUI.setRecordPlayingMessage(itemrecord.getRecordNameLocal());
        }

        PositionedSoundRecord positionedsoundrecord = PositionedSoundRecord.getRecordSoundRecord(soundIn, (float)pos.getX(), (float)pos.getY(), (float)pos.getZ());
        this.mapSoundPositions.put(pos, positionedsoundrecord);
        this.mc.getSoundHandler().playSound(positionedsoundrecord);
    }
}
项目:Mods    文件:EntityBuilding.java   
@Override
public void notifyDataManagerChange(DataParameter<?> key) {
    this.adjustSize();

    // System.out.println("Watcher update: "+data);
    if (!this.world.isRemote && key == CONSTRUCTING) {
        this.setSoundState(this.dataManager.get(CONSTRUCTING) >= this.getConstructionTime()? 0 : 25);
    }
    if (this.world.isRemote && key == SOUND_STATE) {
        SoundEvent sound = this.getSoundNameForState(this.getSoundState());
        if (sound != null) {
            // System.out.println("Playing Sound: "+sound);
            if (this.buildingSound != null)
                this.buildingSound.stopPlaying();
            this.buildingSound = new BuildingSound(this, sound, this.getSoundState());
            ClientProxy.playBuildingSound(buildingSound);
        }
        else{
            if(this.buildingSound != null)
                this.buildingSound.stopPlaying();
        }
    }
}
项目:pnc-repressurized    文件:PacketPlaySound.java   
@Override
public void fromBytes(ByteBuf buffer) {
    super.fromBytes(buffer);
    soundEvent = new SoundEvent(new ResourceLocation(ByteBufUtils.readUTF8String(buffer)));
    category = SoundCategory.values()[buffer.readInt()];
    volume = buffer.readFloat();
    pitch = buffer.readFloat();
    bool = buffer.readBoolean();
}
项目:CustomWorldGen    文件:FluidUtil.java   
/**
 * Takes a filled container and tries to empty it into the given tank.
 *
 * @param container        The filled container. Will not be modified.
 * @param fluidDestination The fluid handler to be filled by the container.
 * @param maxAmount        The largest amount of fluid that should be transferred.
 * @param player           Player for making the bucket drained sound. Pass null for no noise.
 * @param doDrain          true if the container should actually be drained, false if it should be simulated.
 * @return The empty container if successful, null if the fluid handler couldn't be filled.
 *         NOTE The empty container will have a stackSize of 0 when a filled container is consumable,
 *              i.e. it has a "null" empty container but has successfully been emptied.
 */
@Nullable
public static ItemStack tryEmptyContainer(ItemStack container, IFluidHandler fluidDestination, int maxAmount, @Nullable EntityPlayer player, boolean doDrain)
{
    container = container.copy(); // do not modify the input
    container.stackSize = 1;
    IFluidHandler containerFluidHandler = getFluidHandler(container);
    if (containerFluidHandler != null)
    {
        FluidStack simulatedTransfer = tryFluidTransfer(fluidDestination, containerFluidHandler, maxAmount, false);
        if (simulatedTransfer != null)
        {
            if (doDrain)
            {
                tryFluidTransfer(fluidDestination, containerFluidHandler, maxAmount, true);
                if (player != null)
                {
                    SoundEvent soundevent = simulatedTransfer.getFluid().getEmptySound(simulatedTransfer);
                    player.playSound(soundevent, 1f, 1f);
                }
            }
            else
            {
                containerFluidHandler.drain(simulatedTransfer, true);
            }
            return container;
        }
    }
    return null;
}
项目:CustomWorldGen    文件:EntityHorse.java   
public void makeHorseRearWithSound()
{
    this.makeHorseRear();
    SoundEvent soundevent = this.getAngrySound();

    if (soundevent != null)
    {
        this.playSound(soundevent, this.getSoundVolume(), this.getSoundPitch());
    }
}
项目:Backmemed    文件:WorldClient.java   
public void playSound(@Nullable EntityPlayer player, double x, double y, double z, SoundEvent soundIn, SoundCategory category, float volume, float pitch)
{
    if (player == this.mc.player)
    {
        this.playSound(x, y, z, soundIn, category, volume, pitch, false);
    }
}
项目:GeneralLaymansAestheticSpyingScreen    文件:SoundGlassAmbience.java   
public SoundGlassAmbience(SoundEvent soundIn, SoundCategory categoryIn, float volume, float pitch, TerminalPlacement placement)
{
    super(soundIn, categoryIn);
    this.volume = volume;
    this.pitch = pitch;
    this.repeat = true;
    this.repeatDelay = 0;

    this.xPosF = (float)placement.master.getPos().getX();
    this.yPosF = (float)placement.master.getPos().getY();
    this.zPosF = (float)placement.master.getPos().getZ();

    this.placement = placement;
}
项目:Backmemed    文件:AbstractHorse.java   
public void func_190687_dF()
{
    this.makeHorseRear();
    SoundEvent soundevent = this.getAngrySound();

    if (soundevent != null)
    {
        this.playSound(soundevent, this.getSoundVolume(), this.getSoundPitch());
    }
}
项目:Torched    文件:EventHandlerServer.java   
@SubscribeEvent
public void onRegisterSound(RegistryEvent.Register<SoundEvent> event)
{
    Torched.soundRPT = new SoundEvent(new ResourceLocation("torched", "rpt")).setRegistryName(new ResourceLocation("torched", "rpt"));
    Torched.soundTube = new SoundEvent(new ResourceLocation("torched", "tube")).setRegistryName(new ResourceLocation("torched", "tube"));

    event.getRegistry().register(Torched.soundRPT);
    event.getRegistry().register(Torched.soundTube);
}
项目:Lector    文件:ImmersiveSound.java   
public ImmersiveSound(SoundEvent event, World world, BlockPos pos, float baseVolume, boolean repeat) {
    super(event, SoundCategory.BLOCKS);
    this.world = world;
    this.pos = pos;
    this.xPosF = pos.getX();
    this.yPosF = pos.getY();
    this.zPosF = pos.getZ();
    this.attenuationType = AttenuationType.LINEAR;
    this.repeat = repeat;
    this.repeatDelay = 0;
    this.sound = event;
    this.baseVolume = baseVolume;
}
项目:UniversalRemote    文件:WorldServerProxy.java   
@Override
public void playSound(EntityPlayer player, BlockPos pos, SoundEvent soundIn, SoundCategory category, float volume,
        float pitch) {
    if (m_proxyWorld != null && Util.isPrefixInCallStack(m_modPrefix)) {
        m_proxyWorld.playSound(player, pos, soundIn, category, volume, pitch);
    } else if (m_realWorld != null) {
        m_realWorld.playSound(player, pos, soundIn, category, volume, pitch);
    } else {
        super.playSound(player, pos, soundIn, category, volume, pitch);
    }
}
项目:UniversalRemote    文件:WorldServerProxy.java   
@Override
public void playRecord(BlockPos blockPositionIn, SoundEvent soundEventIn) {
    if (m_proxyWorld != null && Util.isPrefixInCallStack(m_modPrefix)) {
        m_proxyWorld.playRecord(blockPositionIn, soundEventIn);
    } else if (m_realWorld != null) {
        m_realWorld.playRecord(blockPositionIn, soundEventIn);
    } else {
        super.playRecord(blockPositionIn, soundEventIn);
    }
}
项目:CustomWorldGen    文件:EntityHorse.java   
@Nullable
protected SoundEvent getAngrySound()
{
    this.openHorseMouth();
    this.makeHorseRear();
    HorseType horsetype = this.getType();
    return horsetype.isUndead() ? null : (horsetype.hasMuleEars() ? SoundEvents.ENTITY_DONKEY_ANGRY : SoundEvents.ENTITY_HORSE_ANGRY);
}
项目:CustomWorldGen    文件:SoundEvents.java   
private static SoundEvent getRegisteredSoundEvent(String id)
{
    SoundEvent soundevent = (SoundEvent)SoundEvent.REGISTRY.getObject(new ResourceLocation(id));

    if (soundevent == null)
    {
        throw new IllegalStateException("Invalid Sound requested: " + id);
    }
    else
    {
        return soundevent;
    }
}
项目:Backmemed    文件:AbstractHorse.java   
@Nullable
protected SoundEvent getAmbientSound()
{
    this.openHorseMouth();

    if (this.rand.nextInt(10) == 0 && !this.isMovementBlocked())
    {
        this.makeHorseRear();
    }

    return null;
}
项目:Backmemed    文件:SoundEvents.java   
private static SoundEvent getRegisteredSoundEvent(String id)
{
    SoundEvent soundevent = (SoundEvent)SoundEvent.REGISTRY.getObject(new ResourceLocation(id));

    if (soundevent == null)
    {
        throw new IllegalStateException("Invalid Sound requested: " + id);
    }
    else
    {
        return soundevent;
    }
}
项目:Backmemed    文件:World.java   
public void playSound(@Nullable EntityPlayer player, double x, double y, double z, SoundEvent soundIn, SoundCategory category, float volume, float pitch)
{
    for (int i = 0; i < this.eventListeners.size(); ++i)
    {
        ((IWorldEventListener)this.eventListeners.get(i)).playSoundToAllNearExcept(player, soundIn, category, x, y, z, volume, pitch);
    }
}
项目:CustomWorldGen    文件:SPacketSoundEffect.java   
public SPacketSoundEffect(SoundEvent soundIn, SoundCategory categoryIn, double xIn, double yIn, double zIn, float volumeIn, float pitchIn)
{
    Validate.notNull(soundIn, "sound", new Object[0]);
    this.sound = soundIn;
    this.category = categoryIn;
    this.posX = (int)(xIn * 8.0D);
    this.posY = (int)(yIn * 8.0D);
    this.posZ = (int)(zIn * 8.0D);
    this.soundVolume = volumeIn;
    this.soundPitch = pitchIn;
}
项目:Backmemed    文件:EntityLiving.java   
/**
 * Plays living's sound at its position
 */
public void playLivingSound()
{
    SoundEvent soundevent = this.getAmbientSound();

    if (soundevent != null)
    {
        this.playSound(soundevent, this.getSoundVolume(), this.getSoundPitch());
    }
}
项目:Backmemed    文件:BlockNote.java   
private SoundEvent getInstrument(int p_185576_1_)
{
    if (p_185576_1_ < 0 || p_185576_1_ >= INSTRUMENTS.size())
    {
        p_185576_1_ = 0;
    }

    return (SoundEvent)INSTRUMENTS.get(p_185576_1_);
}
项目:CustomWorldGen    文件:World.java   
public void playSound(@Nullable EntityPlayer player, double x, double y, double z, SoundEvent soundIn, SoundCategory category, float volume, float pitch)
{
    net.minecraftforge.event.entity.PlaySoundAtEntityEvent event = net.minecraftforge.event.ForgeEventFactory.onPlaySoundAtEntity(player, soundIn, category, volume, pitch);
    if (event.isCanceled() || event.getSound() == null) return;
    soundIn = event.getSound();
    category = event.getCategory();
    volume = event.getVolume();
    pitch = event.getPitch();

    for (int i = 0; i < this.eventListeners.size(); ++i)
    {
        ((IWorldEventListener)this.eventListeners.get(i)).playSoundToAllNearExcept(player, soundIn, category, x, y, z, volume, pitch);
    }
}
项目:Backmemed    文件:EntityElderGuardian.java   
protected SoundEvent getHurtSound()
{
    return this.isInWater() ? SoundEvents.ENTITY_ELDER_GUARDIAN_HURT : SoundEvents.ENTITY_ELDER_GUARDIAN_HURT_LAND;
}
项目:Backmemed    文件:SoundType.java   
public SoundEvent getFallSound()
{
    return this.fallSound;
}
项目:Mods    文件:EntitySaxtonHale.java   
@Override
protected SoundEvent getHurtSound(DamageSource source) {
    return SoundEvents.ENTITY_HOSTILE_HURT;
}
项目:Halloween    文件:ItemMonsterDetector.java   
/**
 * Check whether there are any mobs in the vicinity, and play a sound if there are.
 * The sound played changes if the mob is targeting the player, and the sound gets more frequent the closer the mob is to the player.
 */
@Override
public void onUpdate(ItemStack stack, World world, Entity entity, int slot, boolean selected)
{
    if (!world.isRemote && entity instanceof EntityPlayer)
    {
        if (this.timeUntil > 0)
        {
            this.timeUntil--;
            return;
        }

        EntityPlayer player = (EntityPlayer)entity;

        double distance = 100.0D;
        boolean scary = false;

        List<EntityMob> mobs = world.getEntitiesWithinAABB(EntityMob.class, player.getEntityBoundingBox().grow(32.0D, 32.0D, 32.0D));
        for (EntityMob mob : mobs)
        {
            double mobDistance = mob.getDistanceToEntity(player);
            if (mobDistance < distance)
            {
                distance = mobDistance;
                if (mob.getAttackTarget() != null && mob.getAttackTarget() == player)
                {
                    scary = true;
                }
            }
        }

        if (distance <= 32.0D)
        {
            SoundEvent soundEvent = (scary ? ModSoundEvents.ITEM_MONSTER_DETECTOR_HIGH : ModSoundEvents.ITEM_MONSTER_DETECTOR_LOW);
            world.playSound((EntityPlayer)null, player.getPosition(), soundEvent, SoundCategory.NEUTRAL, 0.75F, 1.0F);

            if (distance >= 24.0D)
            {
                this.timeUntil = 40;
            }
            else if (distance >= 18.0D)
            {
                this.timeUntil = 20;
            }
            else if (distance >= 12.0D)
            {
                this.timeUntil = 15;
            }
            else if (distance >= 6.0D)
            {
                this.timeUntil = 10;
            }
            else
            {
                this.timeUntil = 7;
            }
        }
        else this.timeUntil = 80;


    }
}
项目:CustomWorldGen    文件:EntitySheep.java   
protected SoundEvent getHurtSound()
{
    return SoundEvents.ENTITY_SHEEP_HURT;
}
项目:Backmemed    文件:SoundType.java   
public SoundEvent getHitSound()
{
    return this.hitSound;
}
项目:Backmemed    文件:EntityPlayer.java   
protected SoundEvent getDeathSound()
{
    return SoundEvents.ENTITY_PLAYER_DEATH;
}
项目:Backmemed    文件:EntityBlaze.java   
protected SoundEvent getHurtSound()
{
    return SoundEvents.ENTITY_BLAZE_HURT;
}
项目:Backmemed    文件:EntityRabbit.java   
protected SoundEvent getAmbientSound()
{
    return SoundEvents.ENTITY_RABBIT_AMBIENT;
}
项目:Mods    文件:EntityTF2Character.java   
@Override
protected SoundEvent getSplashSound() {
    return SoundEvents.ENTITY_HOSTILE_SPLASH;
}
项目:Backmemed    文件:EntityDragon.java   
protected SoundEvent getAmbientSound()
{
    return SoundEvents.ENTITY_ENDERDRAGON_AMBIENT;
}
项目:Backmemed    文件:EntityHorse.java   
protected SoundEvent getAngrySound()
{
    super.getAngrySound();
    return SoundEvents.ENTITY_HORSE_ANGRY;
}
项目:Lector    文件:ImmersiveSound.java   
protected boolean isSoundType(SoundEvent event){
    return sound == event;
}
项目:Halloween    文件:EntityHaunter.java   
@Override
protected SoundEvent getHurtSound(DamageSource source)
{
    return ModSoundEvents.ENTITY_HAUNTER_HURT;
}
项目:Backmemed    文件:EntitySkeleton.java   
protected SoundEvent getHurtSound()
{
    return SoundEvents.ENTITY_SKELETON_HURT;
}
项目:CustomWorldGen    文件:EntityMagmaCube.java   
protected SoundEvent getSquishSound()
{
    return this.isSmallSlime() ? SoundEvents.ENTITY_SMALL_MAGMACUBE_SQUISH : SoundEvents.ENTITY_MAGMACUBE_SQUISH;
}