Skip to content
This repository has been archived by the owner on Jun 14, 2023. It is now read-only.

Commit

Permalink
fix import
Browse files Browse the repository at this point in the history
  • Loading branch information
KisaragiEffective committed Apr 23, 2021
1 parent 86e92b4 commit b0289da
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 37 deletions.
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -22,7 +21,7 @@ private static List<String> lineTags(CompoundTag dest) {
));
}

public static <T> T dummy() {
public static <T> T never() {
throw new AssertionError("This statement shouldn't reached!");
}

Expand Down Expand Up @@ -51,34 +50,8 @@ public static List<String> getPlaintextLines(SignBlockEntity sbe) {
.collect(Collectors.toList());
}

/**
* Flip horizontally. This method is in-place.
* Converts
* <pre>
* 1 2 3
* 4 5 6
* 7 8 9
* </pre>
* to
* <pre>
* 3 2 1
* 6 5 4
* 9 8 7
* </pre>
* 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> T implicitCast(Object o) {
return (T) o;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit b0289da

Please sign in to comment.