Skip to content

Commit

Permalink
Update for Minecraft 1.20.4 (#35)
Browse files Browse the repository at this point in the history
Forward port to 1.20.4 by RyanThePinkHacker.

- Updated to 1.20 (thanks to RyanThePinkHacker)
* Resolves #34

* Bumb dependencies to 1.20.1
* Fix compile errors in mixins
* Bump fabric version
* Fix crash from incorrect type for splash text
* Reimplement vistas logo easter egg
* Add SplashTextRenderer mixin
* Fix easter egg logo
  • Loading branch information
the-pink-hacker authored Feb 8, 2024
1 parent 23176d2 commit 57c58d4
Show file tree
Hide file tree
Showing 12 changed files with 122 additions and 102 deletions.
12 changes: 6 additions & 6 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ org.gradle.jvmargs=-Xmx1G
maven_group=com.terraformersmc
archive_name=vistas

minecraft_version=1.19.4
yarn_mappings=1.19.4+build.2
loader_version=0.14.21
fabric_version=0.83.0+1.19.4
modmenu_version=6.2.3
clothconfig_version=10.0.96
minecraft_version=1.20.4
yarn_mappings=1.20.4+build.3
loader_version=0.15.3
fabric_version=0.92.1+1.20.4
modmenu_version=9.0.0
clothconfig_version=13.0.121

# Project Metadata
project_name=Vistas
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,10 @@
*/
package com.terraformersmc.vistas.mixin;

import java.io.File;
import java.nio.file.Path;
import java.util.Optional;

import net.minecraft.text.Text;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.At.Shift;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import com.mojang.datafixers.util.Pair;
import com.terraformersmc.vistas.Vistas;
import com.terraformersmc.vistas.config.VistasConfig;
import com.terraformersmc.vistas.resource.PanoramicScreenshots;

import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gl.Framebuffer;
import net.minecraft.client.gl.SimpleFramebuffer;
Expand All @@ -34,9 +19,22 @@
import net.minecraft.client.util.ScreenshotRecorder;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.ClickEvent;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
import net.minecraft.util.Util;
import net.minecraft.util.math.Direction;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.At.Shift;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import java.io.File;
import java.nio.file.Path;
import java.util.Optional;

// TODO: rewrite; i dont know what im doing!
@Mixin(GameRenderer.class)
Expand Down
60 changes: 34 additions & 26 deletions src/main/java/com/terraformersmc/vistas/mixin/LogoDrawerMixin.java
Original file line number Diff line number Diff line change
@@ -1,37 +1,36 @@
package com.terraformersmc.vistas.mixin;

import com.mojang.blaze3d.systems.RenderSystem;
import com.terraformersmc.vistas.Vistas;
import com.terraformersmc.vistas.panorama.LogoControl;
import com.terraformersmc.vistas.panorama.Panorama;
import com.terraformersmc.vistas.title.LogoDrawerAccessor;
import com.terraformersmc.vistas.title.VistasTitle;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.gui.DrawableHelper;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.LogoDrawer;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.TitleScreen;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.RotationAxis;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;

import java.util.function.BiConsumer;

@Environment(EnvType.CLIENT)
@Mixin(LogoDrawer.class)
public abstract class LogoDrawerMixin implements LogoDrawerAccessor {
@Shadow @Final public static Identifier LOGO_TEXTURE;
@Unique
private boolean isVistas = false;
private boolean isVistas = true;

@Redirect(method = "draw(Lnet/minecraft/client/util/math/MatrixStack;IFI)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/LogoDrawer;drawWithOutline(IILjava/util/function/BiConsumer;)V"))
private void vistas$render$drawOutline(int x, int y, BiConsumer<Integer, Integer> renderAction, MatrixStack matrices, int screenWidth, float alpha, int z) {
@Redirect(method = "draw(Lnet/minecraft/client/gui/DrawContext;IFI)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/DrawContext;drawTexture(Lnet/minecraft/util/Identifier;IIFFIIII)V", ordinal = 0))
private void vistas$render$drawOutline(DrawContext context, Identifier texture, int x, int y, float u, float v, int width, int height, int textureWidth, int textureHeight, DrawContext _context, int screenWidth) {
Panorama panorama = VistasTitle.CURRENT.getValue();
LogoControl logo = panorama.getLogoControl();
MatrixStack matrices = context.getMatrices();

matrices.push();
matrices.translate(logo.getLogoX(), logo.getLogoY(), 0.0D);
Expand All @@ -40,50 +39,59 @@ public abstract class LogoDrawerMixin implements LogoDrawerAccessor {
matrices.multiply(RotationAxis.POSITIVE_Z.rotationDegrees((float) logo.getLogoRot()));
matrices.translate(-(screenWidth / 2.0D), -(y * 2.0D) + (y / 2.0D), 0.0D);

if (!logo.getLogoId().equals(new Identifier("textures/gui/title/minecraft.png")) || this.isVistas) {
RenderSystem.setShaderTexture(0, this.isVistas ? Vistas.id("textures/vistas_logo.png") : logo.getLogoId());
// TODO: Outline rendering no longer works
if (!logo.getLogoId().equals(LOGO_TEXTURE) || this.isVistas) {
//RenderSystem.setShaderTexture(0, this.isVistas ? Vistas.id("textures/vistas_logo.png") : logo.getLogoId());
int rx = (screenWidth / 2) - 256;
int ry = 52 - 256;
BiConsumer<Integer, Integer> render = (ix, iy) -> Screen.drawTexture(matrices, ix, iy, 0, 0, 0, 512, 512, 512, 512);
if (logo.isOutlined()) {
DrawableHelper.drawWithOutline(rx, ry, render);
} else {
render.accept(rx, ry);
}
// BiConsumer<Integer, Integer> render = (ix, iy) -> Screen.drawTexture(matrices, ix, iy, 0, 0, 0, 512, 512, 512, 512);
// if (logo.isOutlined()) {
// DrawableHelper.drawWithOutline(rx, ry, render);
// } else {
// render.accept(rx, ry);
// }
Identifier logoTexture = this.isVistas ? Vistas.id("textures/vistas_logo.png") : logo.getLogoId();
context.drawTexture(logoTexture, rx, ry, 0, 0, 512, 512, 512, 512, 512);
} else {
if (logo.isOutlined()) {
DrawableHelper.drawWithOutline(x, y, renderAction);
} else {
renderAction.accept(x, y);
}
// if (logo.isOutlined()) {
// DrawableHelper.drawWithOutline(x, y, renderAction);
// } else {
// renderAction.accept(x, y);
// }

context.drawTexture(logo.getLogoId(), x, y, u, v, width, height, textureWidth, textureHeight);
}



matrices.pop();
}

@Redirect(method = "draw(Lnet/minecraft/client/util/math/MatrixStack;IFI)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/LogoDrawer;drawTexture(Lnet/minecraft/client/util/math/MatrixStack;IIFFIIII)V"))
private void vistas$render(MatrixStack matrices, int x, int y, float u, float v, int width, int height, int textureWidth, int textureHeight, MatrixStack matrices1, int screenWidth) {
@Redirect(method = "draw(Lnet/minecraft/client/gui/DrawContext;IFI)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/DrawContext;drawTexture(Lnet/minecraft/util/Identifier;IIFFIIII)V", ordinal = 1))
private void vistas$render(DrawContext context, Identifier texture, int x, int y, float u, float v, int width, int height, int textureWidth, int textureHeight, DrawContext _context, int screenWidth) {
Panorama panorama = VistasTitle.CURRENT.getValue();
LogoControl logo = panorama.getLogoControl();

if (!logo.doesShowEdition()) {
return;
}

MatrixStack matrices = context.getMatrices();

matrices.push();
matrices.translate(logo.getLogoX(), logo.getLogoY(), 0.0D);

matrices.translate((screenWidth / 2.0D), 45, 0.0D);
matrices.multiply(RotationAxis.POSITIVE_Z.rotationDegrees((float) logo.getLogoRot()));
matrices.translate(-(screenWidth / 2.0D), -45, 0.0D);

TitleScreen.drawTexture(matrices, x, y, u, v, width, height, textureWidth, textureHeight);
context.drawTexture(texture, x, y, u, v, width, height, textureWidth, textureHeight);

matrices.pop();
}

@Override
public void setIsVistas(boolean value) {
public void vistas$setIsVistas(boolean value) {
this.isVistas = value;
}
}
Original file line number Diff line number Diff line change
@@ -1,27 +1,25 @@
package com.terraformersmc.vistas.mixin;

import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.At.Shift;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

import com.terraformersmc.vistas.access.MinecraftClientAccess;
import com.terraformersmc.vistas.resource.PanoramaResourceReloader;
import com.terraformersmc.vistas.title.VistasTitle;

import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.RunArgs;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.resource.ReloadableResourceManagerImpl;
import net.minecraft.sound.MusicSound;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.At.Shift;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Environment(EnvType.CLIENT)
@Mixin(MinecraftClient.class)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.terraformersmc.vistas.mixin;

import com.terraformersmc.vistas.panorama.LogoControl;
import com.terraformersmc.vistas.panorama.Panorama;
import com.terraformersmc.vistas.title.VistasTitle;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.SplashTextRenderer;
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.ModifyArg;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Environment(EnvType.CLIENT)
@Mixin(SplashTextRenderer.class)
public abstract class SplashTextRendererMixin {
@ModifyArg(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/math/RotationAxis;rotationDegrees(F)Lorg/joml/Quaternionf;"))
private float vistas$render$changeAngle(float in) {
return (float) VistasTitle.CURRENT.getValue().getLogoControl().getSplashRot();
}

@Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/util/math/MatrixStack;multiply(Lorg/joml/Quaternionf;)V", shift = At.Shift.BEFORE))
private void vistas$render(DrawContext context, int screenWidth, TextRenderer textRenderer, int alpha, CallbackInfo ci) {
Panorama panorama = VistasTitle.CURRENT.getValue();
LogoControl logo = panorama.getLogoControl();

context.getMatrices().translate(logo.getSplashX(), logo.getSplashY(), 0.0D);
}
}
Original file line number Diff line number Diff line change
@@ -1,41 +1,40 @@
package com.terraformersmc.vistas.mixin;

import com.terraformersmc.vistas.title.VistasTitle;
import net.minecraft.util.Identifier;
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.CallbackInfoReturnable;

import com.terraformersmc.vistas.access.MinecraftClientAccess;
import com.terraformersmc.vistas.resource.PanoramaResourceReloader;

import com.terraformersmc.vistas.title.VistasTitle;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.SplashTextRenderer;
import net.minecraft.client.resource.SplashTextResourceSupplier;
import net.minecraft.util.Identifier;
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.CallbackInfoReturnable;

@Environment(EnvType.CLIENT)
@Mixin(SplashTextResourceSupplier.class)
public class SplashTextResourceSupplierMixin {

@Inject(method = "get", at = @At(value = "RETURN", ordinal = 4), cancellable = true)
private void vistas$get$4(CallbackInfoReturnable<String> ci) {
private void vistas$get$4(CallbackInfoReturnable<SplashTextRenderer> ci) {
vistas$get(ci);
}

@Inject(method = "get", at = @At(value = "RETURN", ordinal = 5), cancellable = true)
private void vistas$get$5(CallbackInfoReturnable<String> ci) {
private void vistas$get$5(CallbackInfoReturnable<SplashTextRenderer> ci) {
vistas$get(ci);
}

private void vistas$get(CallbackInfoReturnable<String> ci) {
private void vistas$get(CallbackInfoReturnable<SplashTextRenderer> ci) {
MinecraftClient client = MinecraftClient.getInstance();
PanoramaResourceReloader resourceReloader = ((MinecraftClientAccess) client).getPanoramaResourceReloader();
Identifier panoramaId = VistasTitle.PANORAMAS_INVERT.get(VistasTitle.CURRENT.getValue());

if (resourceReloader != null && panoramaId != null) {
ci.setReturnValue(resourceReloader.get());
ci.setReturnValue(new SplashTextRenderer(resourceReloader.get()));
}
}

Expand Down
Loading

0 comments on commit 57c58d4

Please sign in to comment.