Skip to content

Commit d9a1d22

Browse files
committed
merge 1.20.3 changes
2 parents b8e8d7c + c40a0d2 commit d9a1d22

File tree

3 files changed

+22
-9
lines changed

3 files changed

+22
-9
lines changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ org.gradle.jvmargs=-Xmx1G
99
loader_version=0.15.10
1010

1111
# Mod Properties
12-
mod_version = 0.1.8
12+
mod_version = 0.1.9
1313
maven_group = io.wispforest
1414
archives_base_name = lavender
1515

src/main/java/io/wispforest/lavender/client/AssociatedEntryTooltipComponent.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@
55
import io.wispforest.owo.ui.container.Containers;
66
import io.wispforest.owo.ui.container.FlowLayout;
77
import io.wispforest.owo.ui.core.*;
8+
import io.wispforest.owo.ui.util.Delta;
9+
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
810
import net.minecraft.client.font.TextRenderer;
911
import net.minecraft.client.gui.DrawContext;
12+
import net.minecraft.client.gui.screen.Screen;
1013
import net.minecraft.client.gui.tooltip.TooltipComponent;
1114
import net.minecraft.item.ItemStack;
1215
import net.minecraft.text.Text;
@@ -17,6 +20,7 @@
1720

1821
public class AssociatedEntryTooltipComponent implements TooltipComponent {
1922

23+
public static float entryTriggerProgress = 0f;
2024
public static @Nullable WeakReference<ItemStack> tooltipStack = null;
2125

2226
private final FlowLayout layout;
@@ -61,4 +65,11 @@ public int getHeight() {
6165
public int getWidth(TextRenderer textRenderer) {
6266
return this.layout.width();
6367
}
68+
69+
static {
70+
ClientTickEvents.END_CLIENT_TICK.register(client -> {
71+
if (Screen.hasAltDown()) return;
72+
entryTriggerProgress += Delta.compute(entryTriggerProgress, 0f, .125f);
73+
});
74+
}
6475
}

src/main/java/io/wispforest/lavender/mixin/DrawContextMixin.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package io.wispforest.lavender.mixin;
22

3+
import com.llamalad7.mixinextras.sugar.Local;
4+
import com.llamalad7.mixinextras.sugar.ref.LocalRef;
35
import io.wispforest.lavender.book.LavenderBookItem;
46
import io.wispforest.lavender.book.BookLoader;
57
import io.wispforest.lavender.client.AssociatedEntryTooltipComponent;
@@ -12,21 +14,20 @@
1214
import net.minecraft.client.gui.tooltip.TooltipComponent;
1315
import net.minecraft.client.gui.tooltip.TooltipPositioner;
1416
import org.spongepowered.asm.mixin.Mixin;
15-
import org.spongepowered.asm.mixin.Unique;
1617
import org.spongepowered.asm.mixin.injection.At;
1718
import org.spongepowered.asm.mixin.injection.Inject;
1819
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
1920

21+
import java.util.ArrayList;
2022
import java.util.List;
2123

24+
import static io.wispforest.lavender.client.AssociatedEntryTooltipComponent.entryTriggerProgress;
25+
2226
@Mixin(DrawContext.class)
2327
public class DrawContextMixin {
2428

25-
@Unique
26-
private static float entryTriggerProgress = 0f;
27-
2829
@Inject(method = "drawTooltip(Lnet/minecraft/client/font/TextRenderer;Ljava/util/List;IILnet/minecraft/client/gui/tooltip/TooltipPositioner;)V", at = @At("HEAD"))
29-
private void injectTooltipComponents(TextRenderer textRenderer, List<TooltipComponent> components, int x, int y, TooltipPositioner positioner, CallbackInfo ci) {
30+
private void injectTooltipComponents(TextRenderer textRenderer, List<TooltipComponent> components, int x, int y, TooltipPositioner positioner, CallbackInfo ci, @Local(argsOnly = true) LocalRef<List<TooltipComponent>> componentsRef) {
3031
var client = MinecraftClient.getInstance();
3132

3233
if (AssociatedEntryTooltipComponent.tooltipStack != null && AssociatedEntryTooltipComponent.tooltipStack.get() != null) {
@@ -51,8 +52,11 @@ private void injectTooltipComponents(TextRenderer textRenderer, List<TooltipComp
5152

5253
if (bookIndex == -1) return;
5354

55+
components = new ArrayList<>(components);
5456
components.add(new AssociatedEntryTooltipComponent(LavenderBookItem.itemOf(book), associatedEntry, entryTriggerProgress));
55-
entryTriggerProgress += Delta.compute(entryTriggerProgress, Screen.hasAltDown() ? 1.35f : 0f, client.getLastFrameDuration() * .125);
57+
componentsRef.set(components);
58+
59+
entryTriggerProgress += Delta.compute(entryTriggerProgress, Screen.hasAltDown() ? 1.35f : 0f, client.getLastFrameDuration() * .125f);
5660

5761
if (entryTriggerProgress >= .95) {
5862
LavenderBookScreen.pushEntry(book, associatedEntry);
@@ -68,7 +72,5 @@ private void injectTooltipComponents(TextRenderer textRenderer, List<TooltipComp
6872
return;
6973
}
7074
}
71-
72-
entryTriggerProgress += Delta.compute(entryTriggerProgress, 0f, client.getLastFrameDuration() * .125);
7375
}
7476
}

0 commit comments

Comments
 (0)