77import com .llamalad7 .mixinextras .injector .wrapoperation .WrapOperation ;
88import net .minecraft .client .MinecraftClient ;
99import net .minecraft .client .gui .DrawContext ;
10- import net .minecraft .client .gui .screen .world . SelectWorldScreen ;
10+ import net .minecraft .client .gui .screen .Screen ;
1111import net .minecraft .client .gui .screen .world .WorldListWidget ;
1212import net .minecraft .world .level .storage .LevelStorage ;
1313import net .minecraft .world .level .storage .LevelSummary ;
1919import org .spongepowered .asm .mixin .injection .callback .CallbackInfo ;
2020
2121@ Mixin (WorldListWidget .WorldEntry .class )
22- public abstract class WorldListWidgetWorldEntryMixin {
22+ public abstract class WorldListWidgetWorldEntryMixin extends WorldListWidget . Entry {
2323
2424 @ Shadow
2525 @ Final
26- private SelectWorldScreen screen ;
26+ private Screen screen ;
2727 @ Shadow
2828 @ Final
2929 private MinecraftClient client ;
3030 @ Shadow
3131 @ Final
3232 LevelSummary level ;
3333
34+ @ Shadow
35+ protected abstract int getTextX ();
36+
3437 @ WrapOperation (
3538 method = {
3639 "edit" ,
@@ -69,24 +72,18 @@ public abstract class WorldListWidgetWorldEntryMixin {
6972 this .client .setScreen (this .screen );
7073 }
7174
72- @ Inject (
73- method = "render" ,
74- at = @ At (
75- value = "INVOKE" ,
76- target = "Lnet/minecraft/client/gui/DrawContext;drawTextWithShadow(Lnet/minecraft/client/font/TextRenderer;Lnet/minecraft/text/Text;III)V" ,
77- ordinal = 0 ,
78- shift = At .Shift .AFTER
79- )
80- )
81- private void fastquit$renderSavingTimeOnWorldList (DrawContext context , int index , int y , int x , int entryWidth , int entryHeight , int mouseX , int mouseY , boolean hovered , float tickDelta , CallbackInfo ci ) {
75+ @ Inject (method = "render" , at = @ At ("TAIL" ))
76+ private void fastquit$renderSavingTimeOnWorldList (DrawContext context , int mouseX , int mouseY , boolean hovered , float tickDelta , CallbackInfo ci ) {
8277 if (FastQuit .CONFIG .showSavingTime == FastQuitConfig .ShowSavingTime .TRUE ) {
8378 FastQuit .getSavingWorld (this .client .getLevelStorage ().getSavesDirectory ().resolve (this .level .getName ())).ifPresent (server -> {
84- WorldInfo info = FastQuit .savingWorlds .get (server );
85- if (info != null ) {
86- String time = info .getTimeSaving () + " ⌛" ;
87- context .drawText (this .client .textRenderer , time , x + entryWidth - this .client .textRenderer .getWidth (time ) - 4 , y + 1 , -6939106 , false );
88- }
89- });
79+ WorldInfo info = FastQuit .savingWorlds .get (server );
80+ if (info != null ) {
81+ String time = info .getTimeSaving () + " ⌛" ;
82+ int x = this .getTextX ();
83+ int y = this .getContentY () + 1 ;
84+ context .drawText (this .client .textRenderer , time , x + 200 - this .client .textRenderer .getWidth (time ) - 4 , y , -6939106 , false );
85+ }
86+ });
9087 }
9188 }
9289}
0 commit comments