Skip to content

Commit

Permalink
Updated to 1.17
Browse files Browse the repository at this point in the history
  • Loading branch information
Minenash committed Jun 1, 2021
1 parent 9177cd4 commit ca5796e
Show file tree
Hide file tree
Showing 17 changed files with 87 additions and 93 deletions.
37 changes: 17 additions & 20 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
plugins {
id 'fabric-loom' version '0.5-SNAPSHOT'
id 'fabric-loom' version '0.8-SNAPSHOT'
id 'maven-publish'
}

sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility = JavaVersion.VERSION_16
targetCompatibility = JavaVersion.VERSION_16

archivesBaseName = project.archives_base_name
version = project.mod_version
group = project.maven_group

repositories {
maven {
url "https://www.cursemaven.com"
url "https://maven.terraformersmc.com/releases/"
}
}

Expand All @@ -21,14 +21,14 @@ dependencies {
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"

// Fabric API. This is technically optional, but you probably want it anyway.
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
modImplementation "curse.maven:bedrockify-403858:3152545"
modImplementation ("io.github.prospector:modmenu:${project.modmenu_version}") {

// modImplementation "curse.maven:bedrockify-403858:3152545"
modImplementation ("com.terraformersmc:modmenu:${project.modmenu_version}") {
exclude module: "fabric-api"
}

// PSA: Some older mods, compiled on Loom 0.2.1, might have outdated Maven POMs.
// You may need to force-disable transitiveness on them.
}

processResources {
Expand All @@ -46,13 +46,8 @@ tasks.withType(JavaCompile).configureEach {
// If Javadoc is generated, this must be specified in that task too.
it.options.encoding = "UTF-8"

// The Minecraft launcher currently installs Java 8 for users, so your mod probably wants to target Java 8 too
// JDK 9 introduced a new way of specifying this that will make sure no newer classes or methods are used.
// We'll use that if it's available, but otherwise we'll use the older option.
def targetVersion = 8
if (JavaVersion.current().isJava9Compatible()) {
it.options.release = targetVersion
}
// Minecraft 1.17 (21w19a) upwards uses Java 16.
it.options.release = 16
}

java {
Expand Down Expand Up @@ -82,9 +77,11 @@ publishing {
}
}

// Select the repositories you want to publish to
// To publish to maven local, no extra repositories are necessary. Just use the task `publishToMavenLocal`.
// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
repositories {
// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
// Add repositories to publish to here.
// Notice: This block does NOT have the same function as the block in the top level.
// The repositories here will be used for publishing your artifact, not for
// retrieving dependencies.
}
}
}
13 changes: 7 additions & 6 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ org.gradle.jvmargs=-Xmx1G

# Fabric Properties
# check these on https://fabricmc.net/use
minecraft_version=1.16.4
yarn_mappings=1.16.4+build.6
loader_version=0.10.6+build.214
modmenu_version = 1.14.6+build.31
fabric_version=0.30.0+1.16
minecraft_version=1.17-pre1
yarn_mappings=1.17-pre1+build.1
loader_version=0.11.3

modmenu_version = 2.0.0-beta.7
fabric_version=0.34.8+1.17

# Mod Properties
mod_version = 1.3.4
mod_version = 1.3.4+1.17
maven_group = com.minenash
archives_base_name = seamless-loading-screen
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@
import net.minecraft.client.gui.screen.TitleScreen;
import net.minecraft.client.gui.screen.multiplayer.MultiplayerScreen;
import net.minecraft.client.network.ClientPlayNetworkHandler;
import net.minecraft.client.realms.gui.screen.RealmsBridgeScreen;
import net.minecraft.client.realms.gui.screen.RealmsMainScreen;
import net.minecraft.client.texture.NativeImage;
import net.minecraft.client.util.ScreenshotUtils;
import net.minecraft.client.util.Screenshooter;
import net.minecraft.client.util.Window;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.Text;
Expand Down Expand Up @@ -74,7 +73,7 @@ public void render(MatrixStack matrices, int _mouseX, int _mouseY, float _delta)

String name = ScreenshotLoader.getFileName();

NativeImage nativeImage = ScreenshotUtils.takeScreenshot(0, 0, client.getFramebuffer()); //width and height args do nothing
NativeImage nativeImage = Screenshooter.takeScreenshot(0, 0, client.getFramebuffer()); //width and height args do nothing

try {
nativeImage.writeFile(new File(name));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import net.minecraft.client.gui.DrawableHelper;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.render.BufferBuilder;
import net.minecraft.client.render.GameRenderer;
import net.minecraft.client.render.Tessellator;
import net.minecraft.client.render.VertexFormats;
import net.minecraft.client.texture.NativeImage;
Expand Down Expand Up @@ -55,6 +56,7 @@ public static void setRealmScreenshot(String realmName) {
private static void setScreenshot() {
loaded = false;
try (InputStream in = new FileInputStream(ScreenshotLoader.fileName)) {
System.out.println("Name: " + ScreenshotLoader.fileName);
NativeImageBackedTexture image = new NativeImageBackedTexture(NativeImage.read(in));
MinecraftClient.getInstance().getTextureManager().registerTexture(SCREENSHOT, image);
imageRatio = image.getImage().getWidth() / (double) image.getImage().getHeight();
Expand All @@ -80,7 +82,8 @@ private static String cleanFileName(String fileName) {

public static void render(Screen screen, MatrixStack stack) {
if (loaded) {
MinecraftClient.getInstance().getTextureManager().bindTexture(ScreenshotLoader.SCREENSHOT);
RenderSystem.setShader(GameRenderer::getPositionTexShader);
RenderSystem.setShaderTexture(0, SCREENSHOT);

int w = (int) (imageRatio * screen.height);
DrawableHelper.drawTexture(stack, screen.width / 2 - w / 2, 0, 0.0F, 0.0F, w, screen.height, w, screen.height);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.client.options.KeyBinding;
import net.minecraft.client.option.KeyBinding;
import net.minecraft.client.util.InputUtil;
import org.lwjgl.glfw.GLFW;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
package com.minenash.seamless_loading_screen.config;

import io.github.prospector.modmenu.api.ConfigScreenFactory;
import io.github.prospector.modmenu.api.ModMenuApi;
import net.minecraft.client.MinecraftClient;
import com.terraformersmc.modmenu.api.ConfigScreenFactory;
import com.terraformersmc.modmenu.api.ModMenuApi;

public class ModMenuEntryPoint implements ModMenuApi {

@Override
public String getModId() {
return "seamless_loading_screen";
}

@Override
public ConfigScreenFactory<?> getModConfigScreenFactory() {
return Config::getScreen;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ protected TinyConfigScreen(Screen parent) {
protected void init() {
super.init();

ButtonWidget done = this.addButton(new ButtonWidget(this.width/2 - 100,this.height - 28,200,20,
ButtonWidget done = addDrawableChild(new ButtonWidget(this.width/2 - 100,this.height - 28,200,20,
new TranslatableText("gui.done"), (button) -> {
for (EntryInfo info : entries)
try { info.field.set(null, info.value); }
Expand All @@ -197,17 +197,17 @@ protected void init() {
for (EntryInfo info : entries) {
if (info.widget instanceof Map.Entry) {
Map.Entry<ButtonWidget.PressAction,Function<Object,Text>> widget = (Map.Entry<ButtonWidget.PressAction, Function<Object, Text>>) info.widget;
addButton(new ButtonWidget(width-85,y,info.width,20, widget.getValue().apply(info.value), widget.getKey()));
addDrawableChild(new ButtonWidget(width-85,y,info.width,20, widget.getValue().apply(info.value), widget.getKey()));
}
else {
TextFieldWidget widget = addButton(new TextFieldWidget(textRenderer, width-85, y, info.width, 20, null));
TextFieldWidget widget = addDrawableChild(new TextFieldWidget(textRenderer, width-85, y, info.width, 20, null));
widget.setText(info.tempValue);

Predicate<String> processor = ((BiFunction<TextFieldWidget, ButtonWidget, Predicate<String>>) info.widget).apply(widget,done);
widget.setTextPredicate(processor);
processor.test(info.tempValue);

children.add(widget);
addSelectableChild(widget);
}
y += 30;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ public class ClientPlayNetworkHandlerMixin {

@Shadow @Final private Screen loginScreen;

@Shadow @Final private static Text field_26620;

@Redirect(method = "onGameJoin", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/MinecraftClient;joinWorld(Lnet/minecraft/client/world/ClientWorld;)V"))
private void setChangeWorldJoinScreen(MinecraftClient client, ClientWorld world) {
if (ScreenshotLoader.loaded) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.minenash.seamless_loading_screen.mixin;

import com.minenash.seamless_loading_screen.ScreenshotLoader;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.ConnectScreen;
import net.minecraft.client.network.ServerAddress;
import net.minecraft.client.util.math.MatrixStack;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
Expand All @@ -18,8 +20,8 @@ public void render(ConnectScreen screen, MatrixStack stack) {
ScreenshotLoader.render(screen,stack);
}

@Inject(method = "connect", at = @At("HEAD"), cancellable = true)
public void getImage(String address, int port, CallbackInfo info) {
ScreenshotLoader.setScreenshot(address, port);
@Inject(method = "connect(Lnet/minecraft/client/MinecraftClient;Lnet/minecraft/client/network/ServerAddress;)V", at = @At("HEAD"), cancellable = true)
public void getImage(MinecraftClient client, ServerAddress address, CallbackInfo _info) {
ScreenshotLoader.setScreenshot(address.getAddress(), address.getPort());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,16 @@ private MatrixStack getStack() {
@Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/profiler/Profiler;pop()V"), cancellable = true)
private void fade(float tickDelta, long startTime, boolean tick, CallbackInfo info) {
if (ScreenshotLoader.loaded && ScreenshotLoader.time > 0) {
client.getTextureManager().bindTexture(ScreenshotLoader.SCREENSHOT);
RenderSystem.setShader(GameRenderer::getPositionTexShader);
RenderSystem.setShaderTexture(0, ScreenshotLoader.SCREENSHOT);

int height = client.getWindow().getScaledHeight();
int width = client.getWindow().getScaledWidth();
int w = (int) (ScreenshotLoader.imageRatio * height);
boolean doFade = ScreenshotLoader.time <= Config.fade;

if (doFade)
RenderSystem.color4f(1.0F, 1.0F, 1.0F, ScreenshotLoader.timeDelta * ScreenshotLoader.time);
RenderSystem.clearColor(1.0F, 1.0F, 1.0F, ScreenshotLoader.timeDelta * ScreenshotLoader.time);
DrawableHelper.drawTexture(stack, width/2 - w/2, 0, 0.0F, 0.0F, w, height, w, height);
//ScreenshotLoader.renderVignette();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.minenash.seamless_loading_screen.ScreenshotLoader;
import com.minenash.seamless_loading_screen.ScreenshotWithTextScreen;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.world.WorldListWidget;
import net.minecraft.text.TranslatableText;
import net.minecraft.world.level.storage.LevelSummary;
Expand All @@ -24,8 +25,8 @@ public void setFilename(CallbackInfo info) {
ScreenshotLoader.setScreenshot(level.getName());
}

@Redirect(method = "start", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/world/WorldListWidget$Entry;method_29990()V"))
private void changeScreen(WorldListWidget.Entry entry) {
MinecraftClient.getInstance().method_29970(new ScreenshotWithTextScreen(new TranslatableText("selectWorld.data_read")));
@Redirect(method = "openReadingWorldScreen", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/MinecraftClient;method_29970(Lnet/minecraft/client/gui/screen/Screen;)V"))
private void changeScreen(MinecraftClient client, Screen screen) {
client.method_29970(new ScreenshotWithTextScreen(new TranslatableText("selectWorld.data_read")));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ private ButtonWidget buttonCancel(int x, int y, int width, int height, Text mess

@Inject(method = "init", at = @At("HEAD"))
private void buttonAllowCustomScreenshot(CallbackInfo info) {
buttonAllowCustomScreenshot = addButton(new ButtonWidget(width / 2 - 100, height / 4 + 72 + 24, 200, 20,
buttonAllowCustomScreenshot = addDrawableChild(new ButtonWidget(width / 2 - 100, height / 4 + 72 + 24, 200, 20,
getText(), buttonWidget -> {
((ServerInfoExtras)server).setAllowCustomScreenshots(!((ServerInfoExtras)server).getAllowCustomScreenshot());
buttonAllowCustomScreenshot.setMessage(getText());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.minenash.seamless_loading_screen.ServerInfoExtras;
import net.minecraft.client.network.ServerInfo;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtCompound;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
Expand All @@ -16,15 +16,15 @@ public class ServerInfoMixin implements ServerInfoExtras {
@Unique
private boolean allowCustomScreenshots = false;

@Inject(method = "serialize", at = @At("RETURN"), cancellable = true)
private void serialize(CallbackInfoReturnable<CompoundTag> callback) {
CompoundTag tag = callback.getReturnValue();
@Inject(method = "toNbt", at = @At("RETURN"), cancellable = true)
private void serialize(CallbackInfoReturnable<NbtCompound> callback) {
NbtCompound tag = callback.getReturnValue();
tag.putBoolean("allowCustomScreenshots", allowCustomScreenshots);
callback.setReturnValue(tag);
}

@Inject(method = "deserialize", at = @At("RETURN"), cancellable = true)
private static void deserialize(CompoundTag tag, CallbackInfoReturnable<ServerInfo> callback) {
@Inject(method = "fromNbt", at = @At("RETURN"), cancellable = true)
private static void deserialize(NbtCompound tag, CallbackInfoReturnable<ServerInfo> callback) {
if (!tag.contains("allowCustomScreenshots", 1)) return;

ServerInfo info = callback.getReturnValue();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
package com.minenash.seamless_loading_screen.mixin.mod_compat.bedrockify;

import com.minenash.seamless_loading_screen.ScreenshotLoader;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.Text;
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.CallbackInfo;

@Mixin(targets = "me.juancarloscp52.bedrockify.client.features.loadingScreens.LoadingScreenWidget", remap = false)
public class LoadingScreenWidgetMixin {

@Inject(method = "render", at = @At("HEAD"))
private void renderBackground(MatrixStack matrices, int _width, int _height, Text _title, Text _message, int _progress, CallbackInfo _info) {
if (ScreenshotLoader.loaded)
ScreenshotLoader.render(MinecraftClient.getInstance().currentScreen, matrices);
}

}
//package com.minenash.seamless_loading_screen.mixin.mod_compat.bedrockify;
//
//import com.minenash.seamless_loading_screen.ScreenshotLoader;
//import net.minecraft.client.MinecraftClient;
//import net.minecraft.client.util.math.MatrixStack;
//import net.minecraft.text.Text;
//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.CallbackInfo;
//
//@Mixin(targets = "me.juancarloscp52.bedrockify.client.features.loadingScreens.LoadingScreenWidget", remap = false)
//public class LoadingScreenWidgetMixin {
//
// @Inject(method = "render", at = @At("HEAD"))
// private void renderBackground(MatrixStack matrices, int _width, int _height, Text _title, Text _message, int _progress, CallbackInfo _info) {
// if (ScreenshotLoader.loaded)
// ScreenshotLoader.render(MinecraftClient.getInstance().currentScreen, matrices);
// }
//
//}
4 changes: 2 additions & 2 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
},

"depends": {
"fabricloader": ">=0.7.4",
"fabricloader": ">=0.11.3",
"fabric": "*",
"minecraft": "1.16.x"
"minecraft": "1.17.x"
}
}
Loading

0 comments on commit ca5796e

Please sign in to comment.