diff --git a/src/main/java/com/github/kisaragieffective/signpictureported/InternalSpecialUtility.java b/src/main/java/com/github/kisaragieffective/signpictureported/InternalSpecialUtility.java index 88ee981..7f8cad8 100644 --- a/src/main/java/com/github/kisaragieffective/signpictureported/InternalSpecialUtility.java +++ b/src/main/java/com/github/kisaragieffective/signpictureported/InternalSpecialUtility.java @@ -1,7 +1,6 @@ package com.github.kisaragieffective.signpictureported; import net.minecraft.block.entity.SignBlockEntity; -import net.minecraft.client.texture.NativeImage; import net.minecraft.nbt.CompoundTag; import net.minecraft.util.JsonHelper; @@ -22,7 +21,7 @@ private static List lineTags(CompoundTag dest) { )); } - public static T dummy() { + public static T never() { throw new AssertionError("This statement shouldn't reached!"); } @@ -51,34 +50,8 @@ public static List getPlaintextLines(SignBlockEntity sbe) { .collect(Collectors.toList()); } - /** - * Flip horizontally. This method is in-place. - * Converts - *
-     * 1 2 3
-     * 4 5 6
-     * 7 8 9
-     * 
- * to - *
-     * 3 2 1
-     * 6 5 4
-     * 9 8 7
-     * 
- * where 1 to 9 are its pixels. - * @param ni - * @return the flipped image - */ - public static NativeImage mirrorHorizontally(NativeImage ni) { - for (int y = 0; y < ni.getHeight(); y++) { - for (int x = 0; x < ni.getWidth() / 2; x++) { - int color1 = ni.getPixelColor(x, y); - final int destX1 = ni.getWidth() - 1 - x; - int color2 = ni.getPixelColor(destX1, y); - ni.setPixelColor(destX1, y, color1); - ni.setPixelColor(x, y, color2); - } - } - return ni; + @SuppressWarnings("unchecked") + public static T implicitCast(Object o) { + return (T) o; } } diff --git a/src/main/java/com/github/kisaragieffective/signpictureported/mixin/SignBlockEntityRenderMixin.java b/src/main/java/com/github/kisaragieffective/signpictureported/mixin/SignBlockEntityRenderMixin.java index 99e198d..b815f4d 100644 --- a/src/main/java/com/github/kisaragieffective/signpictureported/mixin/SignBlockEntityRenderMixin.java +++ b/src/main/java/com/github/kisaragieffective/signpictureported/mixin/SignBlockEntityRenderMixin.java @@ -26,19 +26,21 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.UncheckedIOException; import java.lang.ref.SoftReference; import java.net.HttpURLConnection; import java.net.MalformedURLException; -import java.net.URI; import java.net.URL; -import java.net.http.HttpClient; -import java.net.http.HttpRequest; -import java.net.http.HttpResponse; import java.util.*; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutionException; +import java.util.function.Supplier; -import static com.github.kisaragieffective.signpictureported.InternalSpecialUtility.dummy; +import static com.github.kisaragieffective.signpictureported.InternalSpecialUtility.implicitCast; +import static com.github.kisaragieffective.signpictureported.InternalSpecialUtility.never; @Mixin(SignBlockEntityRenderer.class) public class SignBlockEntityRenderMixin { @@ -280,7 +282,7 @@ private NativeImageBackedTexture registerFrom(URL url) { try { HttpURLConnection huc1; if (url.getHost() == null || url.getProtocol() == null) return null; - huc1 = cast(url.openConnection()); + huc1 = implicitCast(url.openConnection()); huc1.setInstanceFollowRedirects(true); huc1.connect(); final int code = huc1.getResponseCode();