Advertisement
Camellias_

kill me

Sep 9th, 2019
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.20 KB | None | 0 0
  1.     @SubscribeEvent
  2.     public void onSoundPlayed(PlaySoundAtEntityEvent event)
  3.     {
  4.         World world = Minecraft.getMinecraft().world;
  5.        
  6.         if(SoundReverbHandler.shouldEcho(world))
  7.         {
  8.             try
  9.             {
  10.                 LibraryLWJGLOpenAL lib = new LibraryLWJGLOpenAL();
  11.                 SoundSystem system = new SoundSystem();
  12.                
  13.                 Field floatBuffer = ReflectionHelper.findField(LibraryLWJGLOpenAL.class, "listenerPositionAL");
  14.                 Field bufferMap = ReflectionHelper.findField(LibraryLWJGLOpenAL.class, "ALBufferMap");
  15.                 Field soundLibrary = ReflectionHelper.findField(SoundSystem.class, "soundLibrary");
  16.                 Field sndBffrMap = ReflectionHelper.findField(Library.class, "bufferMap");
  17.                
  18.                 try
  19.                 {
  20.                     FloatBuffer buffer = (FloatBuffer) floatBuffer.get(lib);
  21.                     HashMap<String, IntBuffer> map = (HashMap) bufferMap.get(lib);
  22.                     Library library = (Library) soundLibrary.get(system);
  23.                     HashMap<String, SoundBuffer> bffrMap = (HashMap) sndBffrMap.get(library);
  24.                     HashMap<String, Source> srcMap = library.getSources();
  25.                     Set<String> keys = srcMap.keySet();
  26.                     Iterator<String> iter = keys.iterator();
  27.                     String sourcename;
  28.                     Source source;
  29.                     SoundBuffer soundBuffer;
  30.                    
  31.                     while(iter.hasNext())
  32.                     {
  33.                         sourcename = iter.next();
  34.                         source = srcMap.get(sourcename);
  35.                         soundBuffer = bffrMap.get(source.filenameURL.getFilename());
  36.                        
  37.                         Field channelAL = ReflectionHelper.findField(SourceLWJGLOpenAL.class, "channelOpenAL");
  38.                         channelAL.setAccessible(true);
  39.                        
  40.                         try
  41.                         {
  42.                             ChannelLWJGLOpenAL channelOpenAL = (ChannelLWJGLOpenAL) channelAL.get(
  43.                                     new SourceLWJGLOpenAL(buffer, map.get(source.filenameURL.getFilename()),
  44.                                             source, soundBuffer));
  45.                            
  46.                             SoundReverbHandler.onPlaySound(channelOpenAL.ALSource.get());
  47.                         }
  48.                         catch (IllegalArgumentException | IllegalAccessException e)
  49.                         {
  50.                             e.printStackTrace();
  51.                         }
  52.                     }
  53.                 }
  54.                 catch(IllegalArgumentException | IllegalAccessException e1)
  55.                 {
  56.                     e1.printStackTrace();
  57.                 }
  58.             }
  59.             catch (SoundSystemException e2)
  60.             {
  61.                 e2.printStackTrace();
  62.             }
  63.            
  64.             event.setVolume(event.getVolume() * 5F);
  65.         }
  66.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement