Java 类net.minecraftforge.client.event.sound.PlaySoundEvent17 实例源码

项目:FiveNightsAtFreddysUniverseMod    文件:ClientEventHandler.java   
@SubscribeEvent
    public void onPlaySound(PlaySoundEvent17 event)
    {
        if (mc.currentScreen instanceof GuiGameOver)
        {
            if (!event.name.equals("static"))
            {
                event.result = null;
            }
        }
 //     else if (mc.currentScreen instanceof GuiMonitor)
//        {
 //         if (event.name.equals("gui.button.press"))
  //        {
   //           event.result = null;
    //      }
    //    }
    }
项目:ExtraUtilities    文件:EventHandlerClient.java   
@SubscribeEvent
public void witherSoundKilling(final PlaySoundEvent17 event) {
    if (!ExtraUtils.disableWitherNoiseUnlessNearby) {
        return;
    }
    if (!"mob.wither.spawn".equals(event.name)) {
        return;
    }
    for (final Entity e : (List<Entity>)(Minecraft.getMinecraft().theWorld.getLoadedEntityList())) {
        if (e.getClass() == EntityWither.class) {
            return;
        }
    }
    event.result = null;
}
项目:ExtraUtilities    文件:EventHandlerClient.java   
@SubscribeEvent
public void soundMufflerPlay(final PlaySoundEvent17 event) {
    if (Minecraft.getMinecraft().theWorld != null && ExtraUtils.soundMuffler != null && event.result != null) {
        final World world = (World)Minecraft.getMinecraft().theWorld;
        if (event.result instanceof ITickableSound) {
            return;
        }
        final float x = event.result.getXPosF();
        final float y = event.result.getYPosF();
        final float z = event.result.getZPosF();
        for (int dx = (int)Math.floor(x - 8.0f) >> 4; dx <= (int)Math.floor(x + 8.0f) >> 4; ++dx) {
            for (int dz = (int)Math.floor(z - 8.0f) >> 4; dz <= (int)Math.floor(z + 8.0f) >> 4; ++dz) {
                for (final TileEntity var19 : (Collection<TileEntity>) world.getChunkFromChunkCoords(dx, dz).chunkTileEntityMap.values()) {
                    if (var19 instanceof TileEntitySoundMuffler) {
                        if (var19.getBlockMetadata() == 1) {
                            continue;
                        }
                        double d = (var19.xCoord + 0.5 - x) * (var19.xCoord + 0.5 - x) + (var19.yCoord + 0.5 - y) * (var19.yCoord + 0.5 - y) + (var19.zCoord + 0.5 - z) * (var19.zCoord + 0.5 - z);
                        if (d > 64.0) {
                            continue;
                        }
                        if (d <= 0.0) {
                            continue;
                        }
                        event.result = (ISound)new SoundMuffled(event.result);
                        d = Math.sqrt(d);
                        if (d != 0.0) {
                            d = 1.0 / d / 8.0;
                        }
                        world.spawnParticle("smoke", (double)x, (double)y, (double)z, (var19.xCoord + 0.5 - x) * d, (var19.yCoord + 0.5 - y) * d, (var19.zCoord + 0.5 - z) * d);
                    }
                }
            }
        }
    }
}
项目:MidgarCrusade    文件:SoundEventM.java   
@SubscribeEvent
@SideOnly(Side.CLIENT)
public void onSoundPlay(PlaySoundEvent17 event)
{
    if (this.mc.thePlayer != null && mc.thePlayer.dimension == Main.DIM_ID && event.category == SoundCategory.MUSIC)
        event.manager.setSoundCategoryVolume(SoundCategory.MUSIC, 0);
}
项目:TRHS_Club_Mod_2016    文件:ForgeHooksClient.java   
public static ISound playSound(SoundManager manager, ISound sound)
{
    SoundEventAccessorComposite accessor = manager.field_148622_c.func_147680_a(sound.func_147650_b());
    PlaySoundEvent17 e = new PlaySoundEvent17(manager, sound, (accessor == null ? null : accessor.func_148728_d()));
    MinecraftForge.EVENT_BUS.post(e);
    return e.result;
}
项目:CauldronGit    文件:ForgeHooksClient.java   
public static ISound playSound(SoundManager manager, ISound sound)
{
    SoundEventAccessorComposite accessor = manager.sndHandler.getSound(sound.getPositionedSoundLocation());
    PlaySoundEvent17 e = new PlaySoundEvent17(manager, sound, (accessor == null ? null : accessor.getSoundCategory()));
    MinecraftForge.EVENT_BUS.post(e);
    return e.result;
}
项目:Cauldron    文件:ForgeHooksClient.java   
public static ISound playSound(SoundManager manager, ISound sound)
{
    SoundEventAccessorComposite accessor = manager.sndHandler.getSound(sound.getPositionedSoundLocation());
    PlaySoundEvent17 e = new PlaySoundEvent17(manager, sound, (accessor == null ? null : accessor.getSoundCategory()));
    MinecraftForge.EVENT_BUS.post(e);
    return e.result;
}
项目:Cauldron    文件:ForgeHooksClient.java   
public static ISound playSound(SoundManager manager, ISound sound)
{
    SoundEventAccessorComposite accessor = manager.sndHandler.getSound(sound.getPositionedSoundLocation());
    PlaySoundEvent17 e = new PlaySoundEvent17(manager, sound, (accessor == null ? null : accessor.getSoundCategory()));
    MinecraftForge.EVENT_BUS.post(e);
    return e.result;
}
项目:Cauldron    文件:ForgeHooksClient.java   
public static ISound playSound(SoundManager manager, ISound sound)
{
    SoundEventAccessorComposite accessor = manager.sndHandler.getSound(sound.getPositionedSoundLocation());
    PlaySoundEvent17 e = new PlaySoundEvent17(manager, sound, (accessor == null ? null : accessor.getSoundCategory()));
    MinecraftForge.EVENT_BUS.post(e);
    return e.result;
}
项目:carpentersblocks    文件:EventHandler.java   
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void onPlaySoundEvent(PlaySoundEvent17 event)
{
    if (event != null && event.name != null && event.name.contains(CarpentersBlocks.MODID))
    {
        if (FMLCommonHandler.instance().getSide() == Side.CLIENT)
        {
            World world = FMLClientHandler.instance().getClient().theWorld;
            int x = MathHelper.floor_double(event.sound.getXPosF());
            int y = MathHelper.floor_double(event.sound.getYPosF());
            int z = MathHelper.floor_double(event.sound.getZPosF());

            // We'll set a default block type to be safe
            Block block = Blocks.planks;

            // Grab approximate origin, and gather accurate block type
            TEBase TE = getApproximateSoundOrigin(world, x, y, z);
            if (TE != null && TE.hasAttribute(TE.ATTR_COVER[6])) {
                block = BlockProperties.toBlock(BlockProperties.getCoverSafe(TE, 6));
            }

            if (event.name.startsWith("step.")) {
                event.result = new PositionedSoundRecord(new ResourceLocation(block.stepSound.getStepResourcePath()), block.stepSound.getVolume() * 0.15F, block.stepSound.getPitch(), x + 0.5F, y + 0.5F, z + 0.5F);
            } else { // "dig." usually
                event.result = new PositionedSoundRecord(new ResourceLocation(block.stepSound.getBreakSound()), (block.stepSound.getVolume() + 1.0F) / 2.0F, block.stepSound.getPitch() * 0.8F, x + 0.5F, y + 0.5F, z + 0.5F);
            }
        }
    }
}
项目:ExtraUtilities    文件:EventHandlerClient.java   
@SubscribeEvent
public void rainKiller(final PlaySoundEvent17 event) {
    if (Minecraft.getMinecraft().theWorld != null && Minecraft.getMinecraft().thePlayer != null && ExtraUtils.soundMuffler != null) {
        if (event == null || !"ambient.weather.rain".equals(event.name)) {
            return;
        }
        final World world = (World)Minecraft.getMinecraft().theWorld;
        NBTTagCompound tags = new NBTTagCompound();
        if (Minecraft.getMinecraft().thePlayer.getEntityData().hasKey("PlayerPersisted")) {
            tags = Minecraft.getMinecraft().thePlayer.getEntityData().getCompoundTag("PlayerPersisted");
        }
        else {
            Minecraft.getMinecraft().thePlayer.getEntityData().setTag("PlayerPersisted", (NBTBase)tags);
        }
        final boolean force = tags.hasKey("ExtraUtilities|Rain") && tags.getBoolean("ExtraUtilities|Rain");
        if (!force && TileEntityRainMuffler.playerNeedsMuffler) {
            TileEntityRainMuffler.playerNeedsMufflerInstantCheck = false;
        }
        else {
            event.result = null;
            if (force) {
                return;
            }
            boolean flag = false;
            if (world.provider.dimensionId != TileEntityRainMuffler.curDimension) {
                flag = true;
            }
            else if (!(world.getTileEntity(TileEntityRainMuffler.curX, TileEntityRainMuffler.curY, TileEntityRainMuffler.curZ) instanceof TileEntityRainMuffler)) {
                flag = true;
            }
            else if (world.getTileEntity(TileEntityRainMuffler.curX, TileEntityRainMuffler.curY, TileEntityRainMuffler.curZ).getDistanceFrom((double)Minecraft.getMinecraft().thePlayer.chunkCoordX, (double)Minecraft.getMinecraft().thePlayer.chunkCoordX, (double)Minecraft.getMinecraft().thePlayer.chunkCoordZ) > 4096.0) {
                flag = true;
            }
            if (flag) {
                TileEntityRainMuffler.playerNeedsMuffler = true;
                TileEntityRainMuffler.playerNeedsMufflerInstantCheck = true;
                TileEntityRainMuffler.curDimension = -100;
            }
        }
    }
}
项目:4Space-5    文件:EventHandlerGC.java   
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void onSoundPlayed(PlaySoundEvent17 event)
{
    //The event.result starts off equal to event.sound, but could have been altered or set to null by another mod
    if (event.result == null) return;

    EntityPlayerSP player = FMLClientHandler.instance().getClient().thePlayer;

    if (player != null && player.worldObj != null && player.worldObj.provider instanceof IGalacticraftWorldProvider && event != null)
    {
        //Only modify standard game sounds, not music
        if (event.result.getAttenuationType() != ISound.AttenuationType.NONE)
        {
            PlayerGearData gearData = ClientProxyCore.playerItemData.get(player.getGameProfile().getName());

            float x = event.result.getXPosF();
            float y = event.result.getYPosF();
            float z = event.result.getZPosF();

            if (gearData == null || gearData.getFrequencyModule() == -1)
            {
                // If the player doesn't have a frequency module, and the player isn't in an oxygenated environment
                // Note: this is a very simplistic approach, and nowhere near realistic, but required for performance reasons
                AxisAlignedBB bb = AxisAlignedBB.getBoundingBox(x - 0.0015D, y - 0.0015D, z - 0.0015D, x + 0.0015D, y + 0.0015D, z + 0.0015D);
                boolean playerInAtmosphere = OxygenUtil.isAABBInBreathableAirBlock(player);
                boolean soundInAtmosphere = OxygenUtil.isAABBInBreathableAirBlock(player.worldObj, bb);
                if ((!playerInAtmosphere || !soundInAtmosphere))
                {
                    float volume = event.result.getVolume();

                    //First check for duplicate firing of PlaySoundEvent17 on this handler's own playing of a reduced volume sound (see below) 
                    for (int i = 0; i < this.soundPlayList.size(); i++)
                    {
                        SoundPlayEntry entry = this.soundPlayList.get(i);

                        if (entry.name.equals(event.name) && entry.x == x && entry.y == y && entry.z == z && entry.volume == volume)
                        {
                            this.soundPlayList.remove(i);
                            return;
                        }
                    }

                    //If it's not a duplicate: play the same sound but at reduced volume
                    float newVolume = volume / Math.max(0.01F, ((IGalacticraftWorldProvider) player.worldObj.provider).getSoundVolReductionAmount());

                    this.soundPlayList.add(new SoundPlayEntry(event.name, x, y, z, newVolume));
                    ISound newSound = new PositionedSoundRecord(event.result.getPositionedSoundLocation(), newVolume, event.result.getPitch(), x, y, z);
                    event.manager.playSound(newSound);
                    event.result = null;
                    return;
                }
            }
        }
    }
}
项目:squeakbox    文件:Squeakbox.java   
@SubscribeEvent
public void onSoundPlaying(PlaySoundEvent17 event) {        
    logger.info("Playing sound: " + event.name);
}