commit 762fb7b76b847ed54670d3cc9d9d01cf634f9f78 parent 9c055a09913ed7cf1b59e9561b8f3413fb552a9e Author: Amb0s <ambos@disroot.org> Date: Sat, 10 Oct 2020 07:23:50 +0200 Fixed crash, stairs and changed some code - Fixed crash when no internet connection were available - Stairs now drop themselves Diffstat:
9 files changed, 44 insertions(+), 13 deletions(-)
diff --git a/src/main/java/ambos/vanillafixes/MinecraftUtil.java b/src/main/java/ambos/vanillafixes/MinecraftUtil.java @@ -11,6 +11,7 @@ import org.shanerx.mojang.PlayerProfile; import java.io.IOException; import java.net.HttpURLConnection; import java.net.URL; +import java.net.UnknownHostException; import java.util.ArrayList; import java.util.Arrays; import java.util.Optional; @@ -65,9 +66,8 @@ public final class MinecraftUtil { } public static String getPlayerSkin(String username) { - Mojang mojang = new Mojang(); - try { + Mojang mojang = new Mojang(); String uuid = mojang.getUUIDOfUsername(username); PlayerProfile playerProfile = mojang.getPlayerProfile(uuid); Optional<URL> playerSkin = playerProfile.getTextures().flatMap(PlayerProfile.TexturesProperty::getSkin); @@ -76,7 +76,7 @@ public final class MinecraftUtil { logger.info("Getting player skin: " + playerSkin.get().toString()); return playerSkin.get().toString(); } - } catch (NullPointerException ignored) { + } catch (RuntimeException ignored) { } @@ -84,9 +84,8 @@ public final class MinecraftUtil { } public static String getPlayerCape(String username) { - Mojang mojang = new Mojang(); - try { + Mojang mojang = new Mojang(); String uuid = mojang.getUUIDOfUsername(username); PlayerProfile playerProfile = mojang.getPlayerProfile(uuid); Optional<URL> playerCape = playerProfile.getTextures().flatMap(PlayerProfile.TexturesProperty::getCape); @@ -95,7 +94,7 @@ public final class MinecraftUtil { logger.info("Getting player cape: " + playerCape.get().toString()); return playerCape.get().toString(); } - } catch (NullPointerException ignored) { + } catch (RuntimeException ignored) { } diff --git a/src/main/java/ambos/vanillafixes/mixin/DeathScreenMixin.java b/src/main/java/ambos/vanillafixes/mixin/DeathScreenMixin.java @@ -10,7 +10,7 @@ import org.spongepowered.asm.mixin.injection.invoke.arg.Args; @Mixin(DeathScreen.class) final class DeathScreenMixin extends Screen { @ModifyArgs(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/DeathScreen;drawTextWithShadowCentred(Lnet/minecraft/client/render/TextRenderer;Ljava/lang/String;III)V")) - public void changeDeathMessage(Args args) { + private void changeDeathMessage(Args args) { if (args.get(1) != "Game over!") { args.set(1, "Score: §e" + minecraft.player.method_481()); } diff --git a/src/main/java/ambos/vanillafixes/mixin/HatchetMixin.java b/src/main/java/ambos/vanillafixes/mixin/HatchetMixin.java @@ -6,7 +6,7 @@ import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @Mixin(Hatchet.class) -public class HatchetMixin { +final class HatchetMixin { @Shadow private static Tile[] effectiveBlocks = new Tile[]{ Tile.WOOD, Tile.BOOKSHELF, Tile.LOG, Tile.CHEST, Tile.WORKBENCH, diff --git a/src/main/java/ambos/vanillafixes/mixin/LoginThreadMixin.java b/src/main/java/ambos/vanillafixes/mixin/LoginThreadMixin.java @@ -9,7 +9,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(Minecraft.LoginThread.class) final class LoginThreadMixin { @Inject(method = "run", at = @At("HEAD"), cancellable = true, remap = false) - private void onRun(CallbackInfo info) { - info.cancel(); + private void onRun(CallbackInfo ci) { + ci.cancel(); } } \ No newline at end of file diff --git a/src/main/java/ambos/vanillafixes/mixin/StairsMixin.java b/src/main/java/ambos/vanillafixes/mixin/StairsMixin.java @@ -0,0 +1,31 @@ +package ambos.vanillafixes.mixin; + +import net.minecraft.level.Level; +import net.minecraft.tile.Stairs; +import net.minecraft.tile.Tile; +import net.minecraft.tile.material.Material; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +import java.util.Random; + +@Mixin(Stairs.class) +final class StairsMixin extends Tile { + private StairsMixin(int id, Material material) { + super(id, material); + } + + @Inject(method = "getDropId", at = @At("RETURN"), cancellable = true) + private void onGetDropId(int meta, Random rand, CallbackInfoReturnable cir) { + cir.setReturnValue(id); + } + + @Inject(method = "beforeDestroyedByExplosion", at = @At("HEAD"), cancellable = true) + private void onBeforeDestroyedByExplosion(Level level, int x, int y, int z, int meta, float dropChance, CallbackInfo ci) { + super.beforeDestroyedByExplosion(level, x, y, z, meta, dropChance); + ci.cancel(); + } +} diff --git a/src/main/java/ambos/vanillafixes/mixin/TitleScreenMixin.java b/src/main/java/ambos/vanillafixes/mixin/TitleScreenMixin.java @@ -9,7 +9,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(TitleScreen.class) final class TitleScreenMixin extends Screen { - @Inject(method = "init", at = @At("HEAD"), cancellable = true) + @Inject(method = "init", at = @At("HEAD")) private void onInit(CallbackInfo ci) { minecraft.isApplet = false; } diff --git a/src/main/java/ambos/vanillafixes/mixin/class_472Mixin.java b/src/main/java/ambos/vanillafixes/mixin/class_472Mixin.java @@ -24,7 +24,7 @@ final class class_472Mixin { @Shadow private int field_2482; - @Inject(method = "method_1912", at = @At("RETURN"), cancellable = true) + @Inject(method = "method_1912", at = @At("RETURN")) private void onMethod_1912(int var1, int var2, int var3, double var4, double var6, double var8, CallbackInfo ci) { this.field_2483_proxy = var4; this.field_2484_proxy = var6; diff --git a/src/main/java/ambos/vanillafixes/mixin/class_520Mixin.java b/src/main/java/ambos/vanillafixes/mixin/class_520Mixin.java @@ -12,7 +12,7 @@ final class class_520Mixin { @Shadow private int field_2187; - @Inject(method = "method_1721", at = @At("RETURN"), cancellable = true) + @Inject(method = "method_1721", at = @At("RETURN")) private void changeHitDelay(CallbackInfo ci) { field_2187 = 0; } diff --git a/src/main/resources/vanillafixes.mixins.json b/src/main/resources/vanillafixes.mixins.json @@ -3,6 +3,7 @@ "package": "ambos.vanillafixes.mixin", "compatibilityLevel": "JAVA_8", "mixins": [ + "StairsMixin" ], "client": [ "AbstractClientPlayerMixin",