Skip to content

Commit

Permalink
Merge branch 'pr/117' into 1.21.x
Browse files Browse the repository at this point in the history
  • Loading branch information
Dragon-Seeker committed Oct 1, 2024
2 parents 1f723f1 + 3339009 commit 321980a
Show file tree
Hide file tree
Showing 26 changed files with 278 additions and 187 deletions.
13 changes: 8 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id "architectury-plugin" version "3.4-SNAPSHOT"
id "dev.architectury.loom" version "1.4-SNAPSHOT" apply false
id "dev.architectury.loom" version "1.7-SNAPSHOT" apply false
}

architectury {
Expand All @@ -16,7 +16,10 @@ subprojects {

dependencies {
minecraft "com.mojang:minecraft:${rootProject.minecraft_version}"
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
mappings loom.layered {
it.mappings("net.fabricmc:yarn:$rootProject.yarn_mappings:v2")
it.mappings("dev.architectury:yarn-mappings-patch-neoforge:$rootProject.yarn_mappings_patch_neoforge_version")
}
}
}

Expand All @@ -25,8 +28,8 @@ allprojects {
apply plugin: "architectury-plugin"
apply plugin: "maven-publish"

sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21

archivesBaseName = rootProject.archives_base_name
version = rootProject.mod_version
Expand Down Expand Up @@ -65,7 +68,7 @@ allprojects {

tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
options.release = 17
options.release = 21
}

java {
Expand Down
2 changes: 1 addition & 1 deletion common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ dependencies {
// We depend on fabric loader here to use the fabric @Environment annotations and get the mixin dependencies
// Do NOT use other classes from fabric loader
modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}"
modImplementation "dev.isxander.yacl:yet-another-config-lib-fabric:${rootProject.yacl_version}"
modImplementation "dev.isxander:yet-another-config-lib:${rootProject.yacl_version}-fabric"
}

publishing {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,14 @@ public void render(DrawContext context, int mouseX, int mouseY, float delta) {
loadQuad(context, color, x, y, x + w, y + h);

if (w < width) {
RenderSystem.setShaderTexture(0, OPTIONS_BACKGROUND_TEXTURE);
RenderSystem.setShaderTexture(0, 0);
// 0.25f is from Screen.renderBackgroundTexture vertex colors
color.set(0.25f, 0.25f, 0.25f, alpha);
loadQuad(context, color, 0, 0, x, height, 0, 0, x / 32f, height / 32f);
loadQuad(context, color, x + w, 0, width, height, (x + w) / 32f, 0, width / 32f, height / 32f);
}
} else {
RenderSystem.setShaderTexture(0, OPTIONS_BACKGROUND_TEXTURE);
RenderSystem.setShaderTexture(0, 0);
color.set(0.25f, 0.25f, 0.25f, alpha);
loadQuad(context, color, 0, 0, width, height, 0, 0, width / 32f, height / 32f);
}
Expand Down Expand Up @@ -142,13 +142,12 @@ private void loadQuad(DrawContext context, Vector4f color, int x0, int y0, int x
MatrixStack stack = context.getMatrices();

Tessellator tessellator = Tessellator.getInstance();
BufferBuilder bufferBuilder = tessellator.getBuffer();
bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE_COLOR);
BufferBuilder builder = tessellator.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE_COLOR);
Matrix4f modelMat = stack.peek().getPositionMatrix();
bufferBuilder.vertex(modelMat, x0, y1, 0).texture(u0, v1).color(color.x(), color.y(), color.z(), color.w()).next();
bufferBuilder.vertex(modelMat, x1, y1, 0).texture(u1, v1).color(color.x(), color.y(), color.z(), color.w()).next();
bufferBuilder.vertex(modelMat, x1, y0, 0).texture(u1, v0).color(color.x(), color.y(), color.z(), color.w()).next();
bufferBuilder.vertex(modelMat, x0, y0, 0).texture(u0, v0).color(color.x(), color.y(), color.z(), color.w()).next();
tessellator.draw();
builder.vertex(modelMat, x0, y1, 0).texture(u0, v1).color(color.x(), color.y(), color.z(), color.w());
builder.vertex(modelMat, x1, y1, 0).texture(u1, v1).color(color.x(), color.y(), color.z(), color.w());
builder.vertex(modelMat, x1, y0, 0).texture(u1, v0).color(color.x(), color.y(), color.z(), color.w());
builder.vertex(modelMat, x0, y0, 0).texture(u0, v0).color(color.x(), color.y(), color.z(), color.w());
BufferRenderer.drawWithGlobalProgram(builder.end());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.option.Perspective;
import net.minecraft.client.render.GameRenderer;
import net.minecraft.client.render.RenderTickCounter;
import net.minecraft.client.texture.NativeImage;
import net.minecraft.client.util.ScreenshotRecorder;
import net.minecraft.util.Util;
Expand Down Expand Up @@ -77,7 +78,7 @@ public static void beginScreenshotTask(Runnable runnable) {
}

/**
* Inject after World Rendering within {@link GameRenderer#render(float, long, boolean)} method before {@link MinecraftClient#getWindow()}
* Inject after World Rendering within {@link GameRenderer#render(RenderTickCounter, boolean)} method before {@link MinecraftClient#getWindow()}
*/
public static void takeScreenShot() {
var client = MinecraftClient.getInstance();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
import net.minecraft.client.gl.SimpleFramebuffer;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.render.Tessellator;
import net.minecraft.client.render.VertexFormat;
import net.minecraft.client.render.VertexFormats;
import net.minecraft.client.render.*;
import net.minecraft.client.texture.NativeImage;
import net.minecraft.client.texture.NativeImageBackedTexture;
import net.minecraft.client.util.Window;
Expand All @@ -33,7 +31,7 @@ public class ScreenshotLoader {

private static final Logger LOGGER = LogUtils.getLogger();
private static final Pattern RESERVED_FILENAMES_PATTERN = Pattern.compile(".*\\.|(?:COM|CLOCK\\$|CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9])(?:\\..*)?", Pattern.CASE_INSENSITIVE);
public static Identifier SCREENSHOT = new Identifier(SeamlessLoadingScreen.MODID, "screenshot");
public static Identifier SCREENSHOT = Identifier.of(SeamlessLoadingScreen.MODID, "screenshot");
public static double imageRatio = 1;
public static boolean loaded = false;
public static DisplayMode displayMode = DisplayMode.ENABLED;
Expand Down Expand Up @@ -152,19 +150,19 @@ public static int getArgb(int alpha, int red, int green, int blue) {
//-----

public static void renderBlur(Screen screen, DrawContext context, float size, float quality) {
var buffer = Tessellator.getInstance().getBuffer();
Tessellator tessellator = Tessellator.getInstance();
var matrix = context.getMatrices().peek().getPositionMatrix();

buffer.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION);
buffer.vertex(matrix, 0, 0, 0).next();
buffer.vertex(matrix, 0, screen.height, 0).next();
buffer.vertex(matrix, screen.width, screen.height, 0).next();
buffer.vertex(matrix, screen.width, 0, 0).next();
BufferBuilder builder = tessellator.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION);
builder.vertex(matrix, 0, 0, 0);
builder.vertex(matrix, 0, screen.height, 0);
builder.vertex(matrix, screen.width, screen.height, 0);
builder.vertex(matrix, screen.width, 0, 0);

SeamlessLoadingScreen.BLUR_PROGRAM.setParameters(16, quality, size);
SeamlessLoadingScreen.BLUR_PROGRAM.use();

Tessellator.getInstance().draw();
BufferRenderer.drawWithGlobalProgram(builder.end());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class SeamlessLoadingScreenConfig {
private static final SafeColorTypeAdapter colorAdapter = new SafeColorTypeAdapter(() -> getDefaults().tintColor);
private static final ConfigClassHandler<SeamlessLoadingScreenConfig> CONFIG_CLASS_HANDLER = ConfigClassHandler
.createBuilder(SeamlessLoadingScreenConfig.class)
.id(new Identifier("seamless_loading_screen", "config"))
.id(Identifier.of("seamless_loading_screen", "config"))
.serializer(config -> GsonConfigSerializerBuilder.create(config)
.appendGsonBuilder(builder -> builder.setPrettyPrinting()
.disableHtmlEscaping()
Expand Down Expand Up @@ -100,7 +100,7 @@ private static Text getDesc(String id) {
return Text.translatable("seamless_loading_screen.config." + id + ".description");
}
private static Identifier getImg(String id) {
return new Identifier("seamless_loading_screen", "textures/config/" + id + ".webp");
return Identifier.of("seamless_loading_screen", "textures/config/" + id + ".webp");
}

public static YetAnotherConfigLib getInstance() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import com.minenash.seamless_loading_screen.OnLeaveHelper;
import net.minecraft.client.network.ClientCommonNetworkHandler;
import net.minecraft.network.DisconnectionInfo;
import net.minecraft.network.packet.s2c.common.DisconnectS2CPacket;
import net.minecraft.text.Text;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
Expand All @@ -12,17 +14,17 @@

@Mixin(ClientCommonNetworkHandler.class)
public abstract class ClientCommonNetworkHandlerMixin {
@Shadow public abstract void onDisconnected(Text reason);
@Shadow public abstract void onDisconnected(DisconnectionInfo info);

@Unique
private boolean seamless_loading_screen$haltDisconnect = true;

@Inject(method = "onDisconnected", at = @At("HEAD"), cancellable = true)
private void onServerOrderedDisconnect(Text reason, CallbackInfo info) {
private void onServerOrderedDisconnect(DisconnectionInfo info, CallbackInfo ci) {
if (seamless_loading_screen$haltDisconnect) {
OnLeaveHelper.beginScreenshotTask(() -> this.onDisconnected(reason));
OnLeaveHelper.beginScreenshotTask(() -> this.onDisconnected(info));

info.cancel();
ci.cancel();
}

seamless_loading_screen$haltDisconnect = !seamless_loading_screen$haltDisconnect;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

@Mixin(ClientPlayNetworkHandler.class)
public abstract class ClientPlayNetworkHandlerMixin {
@Inject(method = "onGameJoin", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/MinecraftClient;joinWorld(Lnet/minecraft/client/world/ClientWorld;)V"))
@Inject(method = "onGameJoin", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/MinecraftClient;joinWorld(Lnet/minecraft/client/world/ClientWorld;Lnet/minecraft/client/gui/screen/DownloadingTerrainScreen$WorldEntryReason;)V"))
private void setChangeWorldJoinScreen(GameJoinS2CPacket packet, CallbackInfo ci) {
if (ScreenshotLoader.loaded) SeamlessLoadingScreen.changeWorldJoinScreen = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.minenash.seamless_loading_screen.ServerInfoExtension;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.multiplayer.ConnectScreen;
import net.minecraft.client.network.CookieStorage;
import net.minecraft.client.network.ServerAddress;
import net.minecraft.client.network.ServerInfo;
import org.spongepowered.asm.mixin.Mixin;
Expand All @@ -14,8 +15,8 @@
@Mixin(ConnectScreen.class)
public class ConnectScreenMixin {

@Inject(method = "connect(Lnet/minecraft/client/MinecraftClient;Lnet/minecraft/client/network/ServerAddress;Lnet/minecraft/client/network/ServerInfo;)V", at = @At("HEAD"))
public void getImage(MinecraftClient client, ServerAddress address, ServerInfo info, CallbackInfo ci) {
@Inject(method = "connect(Lnet/minecraft/client/MinecraftClient;Lnet/minecraft/client/network/ServerAddress;Lnet/minecraft/client/network/ServerInfo;Lnet/minecraft/client/network/CookieStorage;)V", at = @At("HEAD"))
public void getImage(MinecraftClient client, ServerAddress address, ServerInfo info, CookieStorage cookieStorage, CallbackInfo ci) {
ScreenshotLoader.displayMode = ((ServerInfoExtension) info).getDisplayMode();

ScreenshotLoader.setScreenshot(address.getAddress(), address.getPort());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.minenash.seamless_loading_screen.OnLeaveHelper;
import net.minecraft.client.render.GameRenderer;
import net.minecraft.client.render.RenderTickCounter;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
Expand All @@ -12,7 +13,7 @@ public class GameRendererMixin {

@Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gl/Framebuffer;beginWrite(Z)V", shift = At.Shift.BY, by = 2))
//
private void attemptToTakeScreenshot(float tickDelta, long startTime, boolean tick, CallbackInfo ci) {
private void attemptToTakeScreenshot(RenderTickCounter tickCounter, boolean tick, CallbackInfo ci) {
if (OnLeaveHelper.attemptScreenShot) OnLeaveHelper.takeScreenShot();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public abstract class MinecraftClientMixin {
public abstract void setScreen(@Nullable Screen screen);

@Inject(method = "joinWorld", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/MinecraftClient;reset(Lnet/minecraft/client/gui/screen/Screen;)V"))
private void changeScreen(ClientWorld world, CallbackInfo ci) {
private void changeScreen(ClientWorld world, DownloadingTerrainScreen.WorldEntryReason worldEntryReason, CallbackInfo ci) {
if (SeamlessLoadingScreen.changeWorldJoinScreen) {
SeamlessLoadingScreen.changeWorldJoinScreen = false;
ScreenshotLoader.inFade = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
@Mixin(value = Screen.class, priority = 900)
public class ScreenMixin {

@Inject(method = "renderBackgroundTexture", at = @At("HEAD"), cancellable = true)
@Inject(method = "renderDarkening(Lnet/minecraft/client/gui/DrawContext;)V", at = @At("HEAD"), cancellable = true)
private void renderScreenBackground_AfterTexture(DrawContext context, CallbackInfo ci) {
if (!ScreenshotLoader.replacebg) return;

Expand Down
2 changes: 1 addition & 1 deletion fabric/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ dependencies {

modCompileOnly("maven.modrinth:bedrockify:${rootProject.bedrockify_version}")

modImplementation ("dev.isxander.yacl:yet-another-config-lib-fabric:${rootProject.yacl_version}")
modImplementation ("dev.isxander:yet-another-config-lib:${rootProject.yacl_version}-fabric")
//include "dev.isxander.yacl:yet-another-config-lib-fabric:${rootProject.yacl_version}"

//modLocalRuntime ("maven.modrinth:fastload:3.4.0")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public void onInitializeClient() {
SeamlessLoadingScreen.onInitializeClient();

CoreShaderRegistrationCallback.EVENT.register(context -> {
context.register(new Identifier(SeamlessLoadingScreen.MODID, "blur"), VertexFormats.POSITION, shaderProgram -> {
context.register(Identifier.of(SeamlessLoadingScreen.MODID, "blur"), VertexFormats.POSITION, shaderProgram -> {
SeamlessLoadingScreen.BLUR_PROGRAM.load(shaderProgram);
});
});
Expand Down
2 changes: 1 addition & 1 deletion fabric/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"depends": {
"fabricloader": "*",
"fabric": "*",
"minecraft": ">=1.20.3",
"minecraft": ">=1.21",
"yet_another_config_lib_v3": "*"
},
"conflicts": {
Expand Down
21 changes: 11 additions & 10 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
# Done to increase the memory available to gradle.
org.gradle.jvmargs=-Xmx4G
# Mod Properties
mod_version=2.1.1+1.20.4
mod_version=2.2.0+1.21
maven_group=com.minenash
archives_base_name=seamless-loading-screen
# Common Properties
minecraft_version=1.20.4
minecraft_version=1.21
enabled_platforms=fabric,neoforge
yarn_mappings=1.20.4+build.3
yacl_version=3.3.1+1.20.4
yarn_mappings=1.21+build.9
yarn_mappings_patch_neoforge_version = 1.21+build.4
yacl_version=3.5.0+1.21

# Fabric
fabric_loader_version=0.15.3
fabric_api_version=0.92.0+1.20.4
fabric_loader_version=0.16.5
fabric_api_version=0.102.0+1.21

modmenu_version=9.0.0
bedrockify_version=1.9.1+mc1.20.2
modmenu_version=11.0.2
bedrockify_version=1.10.1+mc1.21

# NeoForge
neoforge_version=20.4.73-beta
neoforge_version=21.0.167

# Forge
forge_version=1.20.4-49.0.12
forge_version=1.21-51.0.33

Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
4 changes: 3 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit 321980a

Please sign in to comment.