Skip to content

Commit

Permalink
Port to 1.20.4 (Fix #58 )
Browse files Browse the repository at this point in the history
  • Loading branch information
dima-dencep committed Jan 3, 2024
1 parent 1998dae commit e6c48a1
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ public interface SplashAccessor {
default void rrls$reload() {
}

default void rrls$endhook() {
}

default void rrls$progress(float progress) {
}

enum AttachType {
DEFAULT,
HIDE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ public class ModConfig implements ConfigData {
public boolean reInitScreen = true;

@ConfigEntry.Gui.Tooltip(count = 2)
@ConfigEntry.Gui.EnumHandler(option = ConfigEntry.Gui.EnumHandler.EnumDisplayOption.BUTTON)
public PackStatus earlyPackStatus = PackStatus.SEND;
public boolean earlyPackStatusSend = true;

@ConfigEntry.Gui.Tooltip
public float animationSpeed = 1000.0F;
Expand Down Expand Up @@ -90,16 +89,6 @@ public enum Type {
TEXT
}

public enum PackStatus {
DISABLED,
SEND,
SEND_DENY;

public boolean earlySend() {
return this == SEND || this == SEND_DENY;
}
}

public enum AprilFool {
ON_APRIL,
ALWAYS,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.github.dimadencep.mods.rrls.Rrls;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.MessageScreen;
import net.minecraft.client.gui.screen.Overlay;
import net.minecraft.client.gui.screen.SplashOverlay;
import net.minecraft.resource.ResourceReload;
Expand Down Expand Up @@ -72,7 +73,7 @@ public abstract class SplashOverlayMixin extends Overlay {
if (reloading) {
this.rrls$attach = AttachType.HIDE;
} else {
this.rrls$attach = client.currentScreen != null ? AttachType.HIDE : AttachType.WAIT;
this.rrls$attach = client.currentScreen != null && !(client.currentScreen instanceof MessageScreen /* FORGE COMPAT */) ? AttachType.HIDE : AttachType.WAIT;
}
}
}
Expand Down Expand Up @@ -131,9 +132,12 @@ public abstract class SplashOverlayMixin extends Overlay {

float t = this.reload.getProgress();
this.progress = MathHelper.clamp(this.progress * 0.95f + t * 0.050000012f, 0.0f, 1.0f);
rrls$progress(this.progress);

if (f >= 2.0f) {
this.client.setOverlay(null);

rrls$endhook();
}

if (this.reloadCompleteTime == -1L && this.reload.isComplete()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,35 +11,34 @@
package com.github.dimadencep.mods.rrls.mixins.compat;

import com.github.dimadencep.mods.rrls.Rrls;
import com.github.dimadencep.mods.rrls.config.ModConfig;
import net.minecraft.client.network.ClientCommonNetworkHandler;
import net.minecraft.network.ClientConnection;
import net.minecraft.network.packet.c2s.common.ResourcePackStatusC2SPacket;
import net.minecraft.network.packet.s2c.common.ResourcePackSendS2CPacket;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import java.util.concurrent.CompletableFuture;

@Mixin(ClientCommonNetworkHandler.class)
public abstract class ClientCommonNetworkHandlerMixin {
@Shadow
protected abstract void sendResourcePackStatus(ResourcePackStatusC2SPacket.Status status);
@Final
protected ClientConnection connection;

@Inject(
method = "sendResourcePackStatusAfter",
method = "onResourcePackSend",
at = @At(
value = "HEAD"
),
cancellable = true
value = "INVOKE",
target = "Lnet/minecraft/network/packet/s2c/common/ResourcePackSendS2CPacket;required()Z",
shift = At.Shift.AFTER
)
)
public void earlyResourcePackStatusSend(CompletableFuture<?> future, CallbackInfo ci) {
if (Rrls.MOD_CONFIG.earlyPackStatus.earlySend()) {
sendResourcePackStatus(ResourcePackStatusC2SPacket.Status.SUCCESSFULLY_LOADED);
}
if (Rrls.MOD_CONFIG.earlyPackStatus == ModConfig.PackStatus.SEND_DENY) {
ci.cancel();
public void earlyResourcePackStatusSend(ResourcePackSendS2CPacket packet, CallbackInfo ci) {
if (Rrls.MOD_CONFIG.earlyPackStatusSend) {
this.connection.send(new ResourcePackStatusC2SPacket(packet.id(), ResourcePackStatusC2SPacket.Status.SUCCESSFULLY_LOADED));
}
}
}
6 changes: 3 additions & 3 deletions common/src/main/resources/assets/rrls/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
"text.autoconfig.rrls.option.resetResources": "Reset resources when failed load",
"text.autoconfig.rrls.option.reInitScreen": "Reinitializing the current screen after a reload",
"text.autoconfig.rrls.option.reInitScreen.@Tooltip": "Disabling this feature may eliminate the hang-up after the reload is complete",
"text.autoconfig.rrls.option.earlyPackStatus": "Early sending of status about server resourcepack",
"text.autoconfig.rrls.option.earlyPackStatus.@Tooltip[0]": "Some servers specifically wait for the player to load resources, because of this the game may be displayed incorrectly",
"text.autoconfig.rrls.option.earlyPackStatus.@Tooltip[1]": "Example: You were underground while reloading resources",
"text.autoconfig.rrls.option.earlyPackStatusSend": "Early sending of status about server resourcepack",
"text.autoconfig.rrls.option.earlyPackStatusSend.@Tooltip[0]": "Some servers specifically wait for the player to load resources, because of this the game may be displayed incorrectly",
"text.autoconfig.rrls.option.earlyPackStatusSend.@Tooltip[1]": "Example: You were underground while reloading resources",
"text.autoconfig.rrls.option.animationSpeed": "Splash animation speed",
"text.autoconfig.rrls.option.animationSpeed.@Tooltip": "In milliseconds"
}
6 changes: 3 additions & 3 deletions common/src/main/resources/assets/rrls/lang/ru_ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
"text.autoconfig.rrls.option.resetResources": "Сброс ресурсов при неудачной загрузке",
"text.autoconfig.rrls.option.reInitScreen": "Повторная инициализация текущего экрана после перезагрузки",
"text.autoconfig.rrls.option.reInitScreen.@Tooltip": "Отключение этой функции может устранить зависание после завершения перезагрузки",
"text.autoconfig.rrls.option.earlyPackStatus": "Ранняя отправка статуса о состоянии ресурспака сервера",
"text.autoconfig.rrls.option.earlyPackStatus.@Tooltip[0]": "Некоторые серверы специально ждут, пока игрок загрузит ресурсы, из-за этого игра может отображаться некорректно",
"text.autoconfig.rrls.option.earlyPackStatus.@Tooltip[1]": "Например: Вы оказались под землей во время перезагрузки ресурсов",
"text.autoconfig.rrls.option.earlyPackStatusSend": "Ранняя отправка статуса о состоянии ресурспака сервера",
"text.autoconfig.rrls.option.earlyPackStatusSend.@Tooltip[0]": "Некоторые серверы специально ждут, пока игрок загрузит ресурсы, из-за этого игра может отображаться некорректно",
"text.autoconfig.rrls.option.earlyPackStatusSend.@Tooltip[1]": "Например: Вы оказались под землей во время перезагрузки ресурсов",
"text.autoconfig.rrls.option.animationSpeed": "Скорость анимации сплеша",
"text.autoconfig.rrls.option.animationSpeed.@Tooltip": "В милисекундах"
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.SplashOverlay;
import net.minecraft.client.gui.screen.TitleScreen;
import net.minecraft.resource.ResourceReload;
import net.neoforged.fml.earlydisplay.DisplayWindow;
import net.neoforged.fml.loading.progress.ProgressMeter;
import net.neoforged.neoforge.client.loading.NeoForgeLoadingOverlay;
import org.spongepowered.asm.mixin.Final;
Expand All @@ -37,12 +39,28 @@ public abstract class ForgeLoadingOverlayMixin extends SplashOverlay {
private MinecraftClient minecraft;
@Shadow
@Final
private ProgressMeter progress;
private ProgressMeter progressMeter;
@Shadow
@Final
private DisplayWindow displayWindow;
@Shadow
private float currentProgress;

public ForgeLoadingOverlayMixin(MinecraftClient client, ResourceReload monitor, Consumer<Optional<Throwable>> exceptionHandler, boolean reloading) {
super(client, monitor, exceptionHandler, reloading);
}

@Override
public void rrls$endhook() {
progressMeter.complete();
displayWindow.close();
}

@Override
public void rrls$progress(float progress) {
currentProgress = progress;
}

@Inject(
method = "render",
at = @At(
Expand All @@ -51,13 +69,11 @@ public ForgeLoadingOverlayMixin(MinecraftClient client, ResourceReload monitor,
cancellable = true
)
public void rrls$render(DrawContext context, int mouseX, int mouseY, float delta, CallbackInfo ci) {
if (this.minecraft.currentScreen != null && rrls$getAttachType() == SplashAccessor.AttachType.WAIT) {
if (this.minecraft.currentScreen instanceof TitleScreen && rrls$getAttachType() == SplashAccessor.AttachType.WAIT) {
rrls$setAttachType(SplashAccessor.AttachType.HIDE);
}

if (rrls$getAttachType() == SplashAccessor.AttachType.HIDE) {
this.progress.complete();

ci.cancel();
}
}
Expand Down
6 changes: 3 additions & 3 deletions forge/src/main/resources/META-INF/mods.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,21 @@ config = "rrls-common.mixins.json"

[[dependencies.rrls]]
modId = "neoforge"
mandatory = true
type = "required"
versionRange = "*"
ordering = "NONE"
side = "BOTH"

[[dependencies.rrls]]
modId = "minecraft"
mandatory = true
type = "required"
versionRange = "[1.20,)"
ordering = "NONE"
side = "BOTH"

[[dependencies.rrls]]
modId = "cloth_config"
mandatory = true
type = "required"
versionRange = "*"
ordering = "NONE"
side = "CLIENT"
14 changes: 7 additions & 7 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
org.gradle.jvmargs=-Xmx4G

# Properties
minecraft_version = 1.20.2
yarn_mappings = 1.20.2+build.4
minecraft_version = 1.20.4
yarn_mappings = 1.20.4+build.3
loader_version = 0.15.3
forge_version = 20.2.88
forge_version = 20.4.73-beta

# Mod Properties
mod_version = 3.2.4
mod_version = 3.2.5
maven_group = com.github.dima_dencep.mods
archives_base_name = rrls

# Dependencies
modmenu_version = 8.0.1
fabric_api_version = 0.91.2+1.20.2
cloth_config_version = 12.0.119
modmenu_version = 9.0.0
fabric_api_version = 0.92.0+1.20.4
cloth_config_version = 13.0.121

0 comments on commit e6c48a1

Please sign in to comment.