From 890a2f9afd28988ea9d1f98cd2baee5a8a0e6e37 Mon Sep 17 00:00:00 2001 From: PeytonPlayz595 <106421860+PeytonPlayz595@users.noreply.github.com> Date: Mon, 29 Jul 2024 15:00:33 -0400 Subject: [PATCH] Fix some crashes --- src/net/minecraft/client/Minecraft.java | 4 ++-- src/net/minecraft/src/NetworkManager.java | 4 ++-- src/net/minecraft/src/SoundManager.java | 25 ++++++++++++++++------- 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/src/net/minecraft/client/Minecraft.java b/src/net/minecraft/client/Minecraft.java index 4d85a56..63ba314 100644 --- a/src/net/minecraft/client/Minecraft.java +++ b/src/net/minecraft/client/Minecraft.java @@ -429,13 +429,13 @@ public class Minecraft implements Runnable { } } } catch (MinecraftError var20) { - } catch (Throwable var21) { + } /*catch (Throwable var21) { this.func_28002_e(); var21.printStackTrace(); this.onMinecraftCrash(new UnexpectedThrowable("Unexpected error", var21)); } finally { this.shutdownMinecraftApplet(); - } + }*/ } diff --git a/src/net/minecraft/src/NetworkManager.java b/src/net/minecraft/src/NetworkManager.java index 2e76cc3..dd14577 100644 --- a/src/net/minecraft/src/NetworkManager.java +++ b/src/net/minecraft/src/NetworkManager.java @@ -168,10 +168,10 @@ public class NetworkManager { } catch(EOFException e) { stream.reset(); break; - } catch(IOException e) { + } catch(Exception e) { continue; } catch(Throwable t) { - t.printStackTrace(); + continue; } } diff --git a/src/net/minecraft/src/SoundManager.java b/src/net/minecraft/src/SoundManager.java index 82b1ae6..7d046ef 100644 --- a/src/net/minecraft/src/SoundManager.java +++ b/src/net/minecraft/src/SoundManager.java @@ -77,14 +77,20 @@ public class SoundManager { if(loaded && this.options.musicVolume != 0.0F) { if(!GL11.isPlaying(BgMusic)) { - if(this.ticksBeforeMusic > 0) { - --this.ticksBeforeMusic; + try { + if(this.ticksBeforeMusic > 0) { + --this.ticksBeforeMusic; + return; + } + + //Apparently I DO NOT know how to use random.nextInt + int var1 = rand.nextInt(music.length); + this.ticksBeforeMusic = this.rand.nextInt(12000) + 12000; + BgMusic = GL11.beginPlaybackStatic(music[var1].replace(".", "/").replace("_", "."), this.options.musicVolume, 1.0F); + } catch(Exception e) { + BgMusic = -1; return; } - - int var1 = rand.nextInt((music.length - 1) + 1) + 1; - this.ticksBeforeMusic = this.rand.nextInt(12000) + 12000; - BgMusic = GL11.beginPlaybackStatic(music[var1].replace(".", "/").replace("_", "."), this.options.musicVolume, 1.0F); } } } @@ -124,7 +130,12 @@ public class SoundManager { } if(loaded && this.options.soundVolume != 0.0F) { - String var7 = "sounds/" + var1.replace(".", "/") + number + ".ogg"; + if(var1 == null) { + return; + } + + String var7; + var7 = "sounds/" + var1.replace(".", "/") + number + ".ogg"; if(var7 != null && var5 > 0.0F) { if(var5 > 1.0F) { var5 = 1.0F;