diff options
author | Anthony Hilyard <anthony.hilyard@gmail.com> | 2021-10-30 10:25:30 -0700 |
---|---|---|
committer | Anthony Hilyard <anthony.hilyard@gmail.com> | 2021-10-30 10:25:30 -0700 |
commit | 95f63bb1d6ba39a01a7124626c051130640d39c4 (patch) | |
tree | a8052c993577c99a11b8541493a0331b84711ccc /src/main/java/com/anthonyhilyard/iceberg/events | |
parent | ac69a23dacfe35f7f24b8d3d86acd67133992ad0 (diff) | |
download | Iceberg-95f63bb1d6ba39a01a7124626c051130640d39c4.tar.gz Iceberg-95f63bb1d6ba39a01a7124626c051130640d39c4.tar.bz2 Iceberg-95f63bb1d6ba39a01a7124626c051130640d39c4.zip |
Added rendertick event, added color results for color event.
Diffstat (limited to 'src/main/java/com/anthonyhilyard/iceberg/events')
-rw-r--r-- | src/main/java/com/anthonyhilyard/iceberg/events/RenderTickEvents.java | 23 | ||||
-rw-r--r-- | src/main/java/com/anthonyhilyard/iceberg/events/RenderTooltipEvents.java | 8 |
2 files changed, 29 insertions, 2 deletions
diff --git a/src/main/java/com/anthonyhilyard/iceberg/events/RenderTickEvents.java b/src/main/java/com/anthonyhilyard/iceberg/events/RenderTickEvents.java new file mode 100644 index 0000000..dc3a91a --- /dev/null +++ b/src/main/java/com/anthonyhilyard/iceberg/events/RenderTickEvents.java @@ -0,0 +1,23 @@ +package com.anthonyhilyard.iceberg.events; + +import net.fabricmc.fabric.api.event.Event; +import net.fabricmc.fabric.api.event.EventFactory; + +public class RenderTickEvents +{ + public RenderTickEvents() { } + + public static final Event<RenderTickEvents.Start> START = EventFactory.createArrayBacked(RenderTickEvents.Start.class, + callbacks -> (timer) -> { + for (RenderTickEvents.Start callback : callbacks) + { + callback.onStart(timer); + } + }); + + @FunctionalInterface + public interface Start + { + void onStart(float timer); + } +} diff --git a/src/main/java/com/anthonyhilyard/iceberg/events/RenderTooltipEvents.java b/src/main/java/com/anthonyhilyard/iceberg/events/RenderTooltipEvents.java index 1ef654d..7dd58b7 100644 --- a/src/main/java/com/anthonyhilyard/iceberg/events/RenderTooltipEvents.java +++ b/src/main/java/com/anthonyhilyard/iceberg/events/RenderTooltipEvents.java @@ -31,10 +31,12 @@ public final class RenderTooltipEvents public static final Event<RenderTooltipEvents.Color> COLOR = EventFactory.createArrayBacked(RenderTooltipEvents.Color.class, callbacks -> (stack, components, poseStack, x, y, font, background, borderStart, borderEnd, comparison) -> { + ColorResult result = new ColorResult(background, borderStart, borderEnd); for (RenderTooltipEvents.Color callback : callbacks) { - callback.onColor(stack, components, poseStack, x, y, font, background, borderStart, borderEnd, comparison); + result = callback.onColor(stack, components, poseStack, x, y, font, result.background, result.borderStart, result.borderEnd, comparison); } + return result; }); public static final Event<RenderTooltipEvents.Post> POST = EventFactory.createArrayBacked(RenderTooltipEvents.Post.class, @@ -54,7 +56,7 @@ public final class RenderTooltipEvents @FunctionalInterface public interface Color { - void onColor(ItemStack stack, List<ClientTooltipComponent> components, PoseStack poseStack, int x, int y, Font font, int background, int borderStart, int borderEnd, boolean comparison); + ColorResult onColor(ItemStack stack, List<ClientTooltipComponent> components, PoseStack poseStack, int x, int y, Font font, int background, int borderStart, int borderEnd, boolean comparison); } @FunctionalInterface @@ -62,4 +64,6 @@ public final class RenderTooltipEvents { void onPost(ItemStack stack, List<ClientTooltipComponent> components, PoseStack poseStack, int x, int y, Font font, int width, int height, boolean comparison); } + + public record ColorResult(int background, int borderStart, int borderEnd) {} } |