Skip to content

Commit

Permalink
Fix resourcepack status send
Browse files Browse the repository at this point in the history
  • Loading branch information
dima-dencep committed Dec 31, 2023
1 parent b2e5a09 commit 1003500
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ public class ModConfig implements ConfigData {
@ConfigEntry.Gui.Tooltip
public boolean reInitScreen = true;

@ConfigEntry.Gui.Tooltip
public PackStatus earlyPackStatus = PackStatus.SEND_DENY;

@ConfigEntry.Gui.Tooltip
public float animationSpeed = 1000.0F;

Expand Down Expand Up @@ -80,4 +83,14 @@ public enum Type {
PROGRESS,
TEXT
}

public enum PackStatus {
DISABLED,
SEND,
SEND_DENY;

public boolean earlySend() {
return this == SEND || this == SEND_DENY;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Copyright 2023 dima_dencep.
*
* Licensed under the Open Software License, Version 3.0 (the "License");
* you may not use this file except in compliance with the License.
*
* You may obtain a copy of the License at
* https://github.com/dima-dencep/rrls/blob/HEAD/LICENSE
*/

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.packet.c2s.common.ResourcePackStatusC2SPacket;
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);

@Inject(
method = "sendResourcePackStatusAfter",
at = @At(
value = "HEAD"
),
cancellable = true
)
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();
}
}
}
2 changes: 2 additions & 0 deletions common/src/main/resources/assets/rrls/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
"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": "Some servers specifically wait for the player to load resources, because of this the game may be displayed incorrectly, for example, you were underground while reloading resources",
"text.autoconfig.rrls.option.animationSpeed": "Splash animation speed",
"text.autoconfig.rrls.option.animationSpeed.@Tooltip": "In milliseconds"
}
2 changes: 2 additions & 0 deletions common/src/main/resources/assets/rrls/lang/ru_ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
"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": "Некоторые серверы специально ждут, пока игрок загрузит ресурсы, из-за этого игра может отображаться некорректно, например, вы оказались под землей во время перезагрузки ресурсов",
"text.autoconfig.rrls.option.animationSpeed": "Скорость анимации сплеша",
"text.autoconfig.rrls.option.animationSpeed.@Tooltip": "В милисекундах"
}
1 change: 1 addition & 0 deletions common/src/main/resources/rrls-common.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"MinecraftClientMixin",
"SplashOverlayMixin",
"TitleScreenMixin",
"compat.ClientCommonNetworkHandlerMixin",
"compat.OverlayMixin",
"compat.SplashUseFix"
],
Expand Down
12 changes: 6 additions & 6 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ org.gradle.jvmargs=-Xmx4G
# Properties
minecraft_version = 1.20.2
yarn_mappings = 1.20.2+build.4
loader_version = 0.15.0
forge_version = 20.2.83-beta
loader_version = 0.15.3
forge_version = 20.2.88

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

# Dependencies
modmenu_version = 8.0.0
fabric_api_version = 0.91.1+1.20.2
cloth_config_version = 12.0.111
modmenu_version = 8.0.1
fabric_api_version = 0.91.2+1.20.2
cloth_config_version = 12.0.119

0 comments on commit 1003500

Please sign in to comment.