Skip to content

Commit bd663c6

Browse files
committed
Update to mc26.2-pre.2
1 parent 3b38b94 commit bd663c6

9 files changed

Lines changed: 98 additions & 65 deletions

File tree

changelog.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## 3.3.0-beta.1
4+
5+
- Updated to mc26.2-pre.2
6+
- Temporarily disabled config screen
7+
- Mod versioning scheme now resets `minor` on increment of either `major` or `mc`
8+
39
## 3.0.0
410

511
- Re-enabled config screen

common/src/main/java/dev/terminalmc/effecttimerplus/gui/screen/ConfigScreenProvider.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ public class ConfigScreenProvider {
3535

3636
public static Screen getConfigScreen(Screen parent) {
3737
try {
38-
return YaclScreenProvider.getConfigScreen(parent);
39-
// return new DisabledScreen(parent);
38+
// return YaclScreenProvider.getConfigScreen(parent);
39+
return new DisabledScreen(parent);
4040
} catch (NoClassDefFoundError ignored) {
4141
return new BackupScreen(parent, "installYacl", "https://modrinth.com/project/1eAoo2KR");
4242
}
@@ -69,7 +69,7 @@ public void init() {
6969

7070
Button openLinkButton = Button.builder(
7171
localized("message", "viewModrinth"),
72-
(button) -> Minecraft.getInstance().setScreen(new ConfirmLinkScreen(
72+
(button) -> Minecraft.getInstance().gui.setScreen(new ConfirmLinkScreen(
7373
(open) -> {
7474
if (open)
7575
Util.getPlatform().openUri(modUrl);
@@ -91,7 +91,7 @@ public void init() {
9191

9292
@Override
9393
public void onClose() {
94-
Minecraft.getInstance().setScreen(parent);
94+
Minecraft.getInstance().gui.setScreen(parent);
9595
}
9696
}
9797

@@ -126,7 +126,7 @@ public void init() {
126126

127127
@Override
128128
public void onClose() {
129-
Minecraft.getInstance().setScreen(parent);
129+
Minecraft.getInstance().gui.setScreen(parent);
130130
}
131131
}
132132
}

common/src/main/java/dev/terminalmc/effecttimerplus/gui/screen/YaclScreenProvider.java renamed to common/src/main/java/dev/terminalmc/effecttimerplus/gui/screen/YaclScreenProvider.java.disabled

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
import dev.isxander.yacl3.api.controller.*;
2525
import dev.isxander.yacl3.gui.image.ImageRenderer;
2626
import dev.terminalmc.effecttimerplus.config.Config;
27-
import dev.terminalmc.effecttimerplus.mixin.accessor.GuiAccessor;
27+
import dev.terminalmc.effecttimerplus.mixin.accessor.EffectsInInventoryAccessor;
2828
import dev.terminalmc.effecttimerplus.util.IndicatorUtil;
2929
import net.minecraft.client.Minecraft;
3030
import net.minecraft.client.gui.Gui;

common/src/main/java/dev/terminalmc/effecttimerplus/mixin/MixinGui.java renamed to common/src/main/java/dev/terminalmc/effecttimerplus/mixin/EffectsInInventoryMixin.java

Lines changed: 62 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,9 @@
2323
import com.llamalad7.mixinextras.sugar.Local;
2424
import com.mojang.blaze3d.pipeline.RenderPipeline;
2525
import dev.terminalmc.effecttimerplus.config.Config;
26-
import net.minecraft.client.DeltaTracker;
2726
import net.minecraft.client.Minecraft;
28-
import net.minecraft.client.gui.Gui;
2927
import net.minecraft.client.gui.GuiGraphicsExtractor;
28+
import net.minecraft.client.gui.screens.inventory.EffectsInInventory;
3029
import net.minecraft.resources.Identifier;
3130
import net.minecraft.world.effect.MobEffectInstance;
3231
import org.jetbrains.annotations.Nullable;
@@ -38,17 +37,19 @@
3837
import org.spongepowered.asm.mixin.injection.Inject;
3938
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
4039

40+
import java.util.Collection;
41+
4142
import static dev.terminalmc.effecttimerplus.util.IndicatorUtil.*;
4243

4344
/**
4445
* This file includes derivative work of code from
4546
* <a href="https://github.com/magicus/statuseffecttimer">Status Effect Timer</a>
4647
*/
4748
@Mixin(
48-
value = Gui.class,
49+
value = EffectsInInventory.class,
4950
priority = 2000
5051
)
51-
public abstract class MixinGui {
52+
public abstract class EffectsInInventoryMixin {
5253

5354
@Final
5455
@Shadow
@@ -62,7 +63,16 @@ public abstract class MixinGui {
6263
method = "extractEffects",
6364
at = @At("HEAD")
6465
)
65-
private void scale(GuiGraphicsExtractor graphics, DeltaTracker delta, CallbackInfo ci) {
66+
private void scale(
67+
GuiGraphicsExtractor graphics,
68+
Collection<MobEffectInstance> activeEffects,
69+
int x0,
70+
int yStep,
71+
int mouseX,
72+
int mouseY,
73+
int maxWidth,
74+
CallbackInfo ci
75+
) {
6676
float scale = (float) Config.get().scale;
6777
graphics.pose().pushMatrix();
6878
graphics.pose().translate(graphics.guiWidth() * (1 - scale), 0.0F);
@@ -73,7 +83,16 @@ private void scale(GuiGraphicsExtractor graphics, DeltaTracker delta, CallbackIn
7383
method = "extractEffects",
7484
at = @At("RETURN")
7585
)
76-
private void descale(GuiGraphicsExtractor graphics, DeltaTracker delta, CallbackInfo ci) {
86+
private void descale(
87+
GuiGraphicsExtractor graphics,
88+
Collection<MobEffectInstance> activeEffects,
89+
int x0,
90+
int yStep,
91+
int mouseX,
92+
int mouseY,
93+
int maxWidth,
94+
CallbackInfo ci
95+
) {
7796
graphics.pose().popMatrix();
7897
}
7998

@@ -85,17 +104,24 @@ private void descale(GuiGraphicsExtractor graphics, DeltaTracker delta, Callback
85104
)
86105
)
87106
private void CreateOverlayRunnable(
88-
GuiGraphicsExtractor graphics, RenderPipeline pipeline,
89-
Identifier sprite, int x, int y, int width, int height,
90-
Operation<Void> original, @Local MobEffectInstance effectInstance
107+
GuiGraphicsExtractor instance,
108+
RenderPipeline renderPipeline,
109+
Identifier location,
110+
int x,
111+
int y,
112+
int width,
113+
int height,
114+
Operation<Void> original,
115+
@Local(name = "effect") MobEffectInstance effect
116+
91117
) {
92-
original.call(graphics, pipeline, sprite, x, y, width, height);
118+
original.call(instance, renderPipeline, location, x, y, width, height);
93119

94120
Config options = Config.get();
95121
effectTimerPlus$runnable = () -> {
96122
// Render potency overlay
97-
if (options.potencyEnabled && effectInstance.getAmplifier() > 0) {
98-
String label = getAmplifierAsString(effectInstance.getAmplifier());
123+
if (options.potencyEnabled && effect.getAmplifier() > 0) {
124+
String label = getAmplifierAsString(effect.getAmplifier());
99125
int labelWidth = minecraft.font.width(label);
100126
int posX = x + getTextOffsetX(options.potencyLocation, labelWidth, width);
101127
int posY = y + getTextOffsetY(
@@ -105,37 +131,37 @@ private void CreateOverlayRunnable(
105131
);
106132

107133
float scale = (float) Config.get().potencyScale;
108-
graphics.pose().pushMatrix();
109-
graphics.pose().translate(posX * (1 - scale), posY * (1 - scale));
110-
graphics.pose().translate(
134+
instance.pose().pushMatrix();
135+
instance.pose().translate(posX * (1 - scale), posY * (1 - scale));
136+
instance.pose().translate(
111137
getScaleTranslateX(options.potencyLocation, labelWidth, scale),
112138
getScaleTranslateY(
113139
options.potencyLocation,
114140
minecraft.font.lineHeight,
115141
scale
116142
)
117143
);
118-
graphics.pose().scale(scale, scale);
144+
instance.pose().scale(scale, scale);
119145
if (options.potencyBack) {
120-
graphics.fill(
146+
instance.fill(
121147
posX - 1, posY - 1, posX + labelWidth,
122148
posY + minecraft.font.lineHeight - 1, options.potencyBackColor
123149
);
124150
}
125-
graphics.text(
151+
instance.text(
126152
minecraft.font,
127153
label,
128154
posX,
129155
posY,
130156
options.potencyColor,
131157
options.potencyShadow
132158
);
133-
graphics.pose().popMatrix();
159+
instance.pose().popMatrix();
134160
}
135161
// Render timer overlay
136162
if (options.timerEnabled && (options.timerEnabledAmbient
137-
|| !effectInstance.isAmbient())) {
138-
String label = getDurationAsString(effectInstance.getDuration());
163+
|| !effect.isAmbient())) {
164+
String label = getDurationAsString(effect.getDuration());
139165
int labelWidth = minecraft.font.width(label);
140166
int posX = x + getTextOffsetX(options.timerLocation, labelWidth, width);
141167
int posY = y + getTextOffsetY(
@@ -145,26 +171,26 @@ private void CreateOverlayRunnable(
145171
);
146172

147173
int color = getTimerColor(
148-
effectInstance, options.timerColor,
174+
effect, options.timerColor,
149175
options.timerWarnEnabled, options.timerWarnTime,
150176
options.timerWarnColor, options.timerFlashEnabled
151177
);
152178
float scale = (float) Config.get().timerScale;
153-
graphics.pose().pushMatrix();
154-
graphics.pose().translate(posX * (1 - scale), posY * (1 - scale));
155-
graphics.pose().translate(
179+
instance.pose().pushMatrix();
180+
instance.pose().translate(posX * (1 - scale), posY * (1 - scale));
181+
instance.pose().translate(
156182
getScaleTranslateX(options.timerLocation, labelWidth, scale),
157183
getScaleTranslateY(options.timerLocation, minecraft.font.lineHeight, scale)
158184
);
159-
graphics.pose().scale(scale, scale);
185+
instance.pose().scale(scale, scale);
160186
if (options.timerBack) {
161-
graphics.fill(
187+
instance.fill(
162188
posX - 1, posY - 1, posX + labelWidth,
163189
posY + minecraft.font.lineHeight - 1, options.timerBackColor
164190
);
165191
}
166-
graphics.text(minecraft.font, label, posX, posY, color, options.timerShadow);
167-
graphics.pose().popMatrix();
192+
instance.text(minecraft.font, label, posX, posY, color, options.timerShadow);
193+
instance.pose().popMatrix();
168194
}
169195
};
170196
}
@@ -173,13 +199,18 @@ private void CreateOverlayRunnable(
173199
method = "extractEffects",
174200
at = @At(
175201
value = "INVOKE",
176-
target = "Lnet/minecraft/client/gui/GuiGraphicsExtractor;blitSprite(Lcom/mojang/blaze3d/pipeline/RenderPipeline;Lnet/minecraft/resources/Identifier;IIIII)V",
202+
target = "Lnet/minecraft/client/gui/GuiGraphicsExtractor;blitSprite(Lcom/mojang/blaze3d/pipeline/RenderPipeline;Lnet/minecraft/resources/Identifier;IIII)V",
177203
shift = At.Shift.AFTER
178204
)
179205
)
180206
private void AddOverlayRunnable(
181207
GuiGraphicsExtractor graphics,
182-
DeltaTracker deltaTracker,
208+
Collection<MobEffectInstance> activeEffects,
209+
int x0,
210+
int yStep,
211+
int mouseX,
212+
int mouseY,
213+
int maxWidth,
183214
CallbackInfo ci
184215
) {
185216
if (effectTimerPlus$runnable != null) {

common/src/main/java/dev/terminalmc/effecttimerplus/mixin/accessor/GuiAccessor.java renamed to common/src/main/java/dev/terminalmc/effecttimerplus/mixin/accessor/EffectsInInventoryAccessor.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@
1717

1818
package dev.terminalmc.effecttimerplus.mixin.accessor;
1919

20-
import net.minecraft.client.gui.Gui;
20+
import net.minecraft.client.gui.screens.inventory.EffectsInInventory;
2121
import net.minecraft.resources.Identifier;
2222
import org.spongepowered.asm.mixin.Mixin;
2323
import org.spongepowered.asm.mixin.gen.Accessor;
2424

25-
@Mixin(Gui.class)
26-
public interface GuiAccessor {
25+
@Mixin(EffectsInInventory.class)
26+
public interface EffectsInInventoryAccessor {
2727

2828
@Accessor("EFFECT_BACKGROUND_SPRITE")
2929
static Identifier etp$getEffectBackgroundSprite() {

common/src/main/java/dev/terminalmc/effecttimerplus/util/IndicatorUtil.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
package dev.terminalmc.effecttimerplus.util;
1919

20-
import net.minecraft.client.resources.language.I18n;
20+
import net.minecraft.locale.Language;
2121
import net.minecraft.world.effect.MobEffectInstance;
2222

2323
public class IndicatorUtil {
@@ -56,11 +56,7 @@ public static String getAmplifierAsString(int amplifier) {
5656
int value = amplifier + 1;
5757
if (value > 1) {
5858
String key = String.format("enchantment.level.%d", value);
59-
if (I18n.exists(key)) {
60-
return I18n.get(key);
61-
} else {
62-
return String.valueOf(value);
63-
}
59+
return Language.getInstance().getOrDefault(key, String.valueOf(value));
6460
}
6561
return "";
6662
}

common/src/main/resources/effecttimerplus.mixins.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
"mixins": [
1212
],
1313
"client": [
14-
"accessor.GuiAccessor",
15-
"MixinGui"
14+
"accessor.EffectsInInventoryAccessor",
15+
"EffectsInInventoryMixin"
1616
],
1717
"server": [
1818
],

0 commit comments

Comments
 (0)