diff --git a/build.gradle b/build.gradle index 04b81e8..69b8303 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ plugins { - id 'fabric-loom' version '0.12-SNAPSHOT' + id 'fabric-loom' version '1.1.+' } apply from: 'https://raw.githubusercontent.com/TerraformersMC/GradleScripts/2.5/ferry.gradle' @@ -12,9 +12,10 @@ dependencies { mappings "net.fabricmc:yarn:$project.yarn_mappings:v2" mod "fabric-loader", "net.fabricmc:fabric-loader:$project.loader_version" + mod "fabric-api", "net.fabricmc.fabric-api:fabric-api:$project.fabric_version" + mod "modmenu", "com.terraformersmc:modmenu:$project.modmenu_version" - includeMod "fabric-api", "net.fabricmc.fabric-api:fabric-api:$project.fabric_version" - includeMod "cloth-config-2", "me.shedaniel.cloth:cloth-config-fabric:$project.clothconfig_version" + includeMod "cloth-config", "me.shedaniel.cloth:cloth-config-fabric:${project.clothconfig_version}" } repositories { diff --git a/gradle.properties b/gradle.properties index cbbda06..9d90b87 100644 --- a/gradle.properties +++ b/gradle.properties @@ -21,15 +21,16 @@ default_release_type=beta # CurseForge Metadata curseforge_slug=vistas curseforge_id=423659 -curseforge_game_versions=1.19, 1.19.1, 1.19.2, Fabric -curseforge_required_dependencies= +curseforge_game_versions=1.19.4, Fabric, Quilt +curseforge_required_dependencies=fabric-api curseforge_optional_dependencies= # Modrinth Metadata modrinth_slug=vistas modrinth_id=itzZXRxq -modrinth_game_versions=1.19, 1.19.1, 1.19.2 -modrinth_mod_loaders=fabric +modrinth_game_versions=1.19.4 +modrinth_mod_loaders=fabric, quilt +modrinth_required_dependencies=fabric-api # Mod Loader Metadata loader_icon=https://fabricmc.net/assets/logo.png diff --git a/src/main/java/com/terraformersmc/vistas/mixin/GameRendererMixin.java b/src/main/java/com/terraformersmc/vistas/mixin/GameRendererMixin.java index f44f157..1810d8c 100644 --- a/src/main/java/com/terraformersmc/vistas/mixin/GameRendererMixin.java +++ b/src/main/java/com/terraformersmc/vistas/mixin/GameRendererMixin.java @@ -29,7 +29,6 @@ import net.minecraft.client.MinecraftClient; import net.minecraft.client.gl.Framebuffer; import net.minecraft.client.gl.SimpleFramebuffer; -import net.minecraft.client.render.Camera; import net.minecraft.client.render.GameRenderer; import net.minecraft.client.texture.NativeImage; import net.minecraft.client.util.ScreenshotRecorder; @@ -45,17 +44,14 @@ public abstract class GameRendererMixin { @Shadow @Final - private MinecraftClient client; + MinecraftClient client; @Shadow private boolean renderingPanorama; - @Shadow - @Final - private Camera camera; - @Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/GameRenderer;renderWorld(FJLnet/minecraft/client/util/math/MatrixStack;)V", shift = Shift.BEFORE)) public void vistas$render(float delta, long startTime, boolean tick, CallbackInfo ci) { + assert client.player != null; if (PanoramicScreenshots.timeSinceLastKeyPress >= 0.0D) { PanoramicScreenshots.timeSinceLastKeyPress -= delta; } @@ -63,7 +59,7 @@ public abstract class GameRendererMixin { PanoramicScreenshots.time += delta; } if (PanoramicScreenshots.time > 375.0D) { - if (!PanoramicScreenshots.startingRotation.isEmpty()) { + if (PanoramicScreenshots.startingRotation.isPresent()) { client.player.setPitch(PanoramicScreenshots.startingRotation.get().getFirst()); client.player.setYaw(PanoramicScreenshots.startingRotation.get().getSecond()); } @@ -88,6 +84,7 @@ public abstract class GameRendererMixin { } File rootFile = root.toFile(); if (!rootFile.exists()) { + //noinspection ResultOfMethodCallIgnored rootFile.mkdirs(); } diff --git a/src/main/java/com/terraformersmc/vistas/mixin/TitleScreenMixin.java b/src/main/java/com/terraformersmc/vistas/mixin/TitleScreenMixin.java index 2766624..7b07584 100644 --- a/src/main/java/com/terraformersmc/vistas/mixin/TitleScreenMixin.java +++ b/src/main/java/com/terraformersmc/vistas/mixin/TitleScreenMixin.java @@ -77,6 +77,7 @@ protected TitleScreenMixin(Text title) { @Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/RotatingCubeMapRenderer;render(FF)V", shift = Shift.BEFORE), locals = LocalCapture.CAPTURE_FAILHARD) private void vistas$render(MatrixStack matrices, int mouseX, int mouseY, float delta, CallbackInfo ci, float f) { + assert this.client != null; PanoramaRenderer.time += delta; VistasTitle.CURRENT.getValue().getCubemaps().forEach((cubemap) -> { PanoramaRenderer panoramaRenderer = new PanoramaRenderer(cubemap); diff --git a/src/main/java/com/terraformersmc/vistas/panorama/Cubemap.java b/src/main/java/com/terraformersmc/vistas/panorama/Cubemap.java index 40942f0..a27630c 100644 --- a/src/main/java/com/terraformersmc/vistas/panorama/Cubemap.java +++ b/src/main/java/com/terraformersmc/vistas/panorama/Cubemap.java @@ -7,6 +7,7 @@ import net.minecraft.util.Identifier; +@SuppressWarnings("unused") public class Cubemap { public static final Cubemap DEFAULT = new Cubemap(); @@ -39,6 +40,7 @@ public Cubemap(Identifier cubemapId, RotationControl rotationControl, VisualCont this.visualControl = visualControl; } + @SuppressWarnings("OptionalUsedAsFieldOrParameterType") public Cubemap(Optional cubemapId, Optional rotationControl, Optional visualControl) { this.cubemapId = cubemapId.orElse(new Identifier("textures/gui/title/background/panorama")); this.rotationControl = rotationControl.orElse(RotationControl.DEFAULT); diff --git a/src/main/java/com/terraformersmc/vistas/resource/PanoramicScreenshots.java b/src/main/java/com/terraformersmc/vistas/resource/PanoramicScreenshots.java index 7a9374f..2b366b8 100644 --- a/src/main/java/com/terraformersmc/vistas/resource/PanoramicScreenshots.java +++ b/src/main/java/com/terraformersmc/vistas/resource/PanoramicScreenshots.java @@ -30,6 +30,7 @@ import org.joml.Quaternionf; //TODO: rewrite; i dont know what im doing! +@SuppressWarnings("OptionalUsedAsFieldOrParameterType") public class PanoramicScreenshots { private static final DateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd_HH.mm.ss"); @@ -60,16 +61,18 @@ public static void registerKeyBinding() { public static void saveScreenshot(NativeImage screenshot, Path folder, int i) { Util.getIoWorkerExecutor().execute(() -> { - try { + try (screenshot) { int width = screenshot.getWidth(); int height = screenshot.getHeight(); int x = 0; int y = 0; if (width > height) { x = (width - height) / 2; + //noinspection SuspiciousNameCombination width = height; } else { y = (height - width) / 2; + //noinspection SuspiciousNameCombination height = width; } NativeImage saved = new NativeImage(width, height, false); @@ -77,8 +80,6 @@ public static void saveScreenshot(NativeImage screenshot, Path folder, int i) { saved.writeTo(folder.resolve("panorama_" + i + ".png")); } catch (IOException exception) { Vistas.LOGGER.warn("Couldn't save screenshot", exception); - } finally { - screenshot.close(); } }); } @@ -89,6 +90,7 @@ public static Path getPanoramicScreenshotFolder() { } File rootFile = FabricLoader.getInstance().getGameDir().resolve("screenshots/panoramas/").toFile(); if (!rootFile.exists()) { + //noinspection ResultOfMethodCallIgnored rootFile.mkdirs(); } String string = DATE_FORMAT.format(new Date()); @@ -97,6 +99,7 @@ public static Path getPanoramicScreenshotFolder() { while (true) { File file = new File(rootFile, string + (i == 1 ? "" : "_" + i)); if (!file.exists()) { + //noinspection ResultOfMethodCallIgnored file.mkdir(); return file.toPath(); } diff --git a/src/main/java/com/terraformersmc/vistas/title/PanoramaRenderer.java b/src/main/java/com/terraformersmc/vistas/title/PanoramaRenderer.java index 99b261b..b9d13bf 100644 --- a/src/main/java/com/terraformersmc/vistas/title/PanoramaRenderer.java +++ b/src/main/java/com/terraformersmc/vistas/title/PanoramaRenderer.java @@ -26,6 +26,7 @@ public PanoramaRenderer(Cubemap cubemap) { this.client = MinecraftClient.getInstance(); } + @SuppressWarnings("unused") public void render(float delta, float alpha) { Tessellator tessellator = Tessellator.getInstance(); BufferBuilder bufferBuilder = tessellator.getBuffer(); diff --git a/src/main/java/com/terraformersmc/vistas/title/VistasTitle.java b/src/main/java/com/terraformersmc/vistas/title/VistasTitle.java index 635aa65..e1de0f2 100644 --- a/src/main/java/com/terraformersmc/vistas/title/VistasTitle.java +++ b/src/main/java/com/terraformersmc/vistas/title/VistasTitle.java @@ -18,13 +18,14 @@ import net.minecraft.util.InvalidIdentifierException; import net.minecraft.util.profiler.Profiler; +@SuppressWarnings("unused") public class VistasTitle { public static final ConcurrentMap BUILTIN_PANORAMAS = Maps.newConcurrentMap(); public static final ConcurrentMap PANORAMAS = Maps.newConcurrentMap(); public static final ConcurrentMap PANORAMAS_INVERT = Maps.newConcurrentMap(); public static final List DISTRIBUTION = Lists.newArrayList(); - public static final MutableObject CURRENT = new MutableObject(Panorama.DEFAULT); + public static final MutableObject CURRENT = new MutableObject<>(Panorama.DEFAULT); public static void choose() { choose(MinecraftClient.getInstance().getProfiler()); diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 37adba6..3339e2d 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -29,7 +29,8 @@ "vistas.mixins.json" ], "depends": { - "fabricloader": ">=0.12.12", - "fabric": "*" + "fabricloader": ">=0.13.3", + "fabric": "*", + "minecraft": ">=1.19.4 <1.20" } }