diff --git a/src/main/java/vazkii/quark/base/client/config/widget/QButton.java b/src/main/java/vazkii/quark/base/client/config/QButton.java similarity index 94% rename from src/main/java/vazkii/quark/base/client/config/widget/QButton.java rename to src/main/java/vazkii/quark/base/client/config/QButton.java index db8f1cbdbd..a7647ce543 100644 --- a/src/main/java/vazkii/quark/base/client/config/widget/QButton.java +++ b/src/main/java/vazkii/quark/base/client/config/QButton.java @@ -1,4 +1,4 @@ -package vazkii.quark.base.client.config.widget; +package vazkii.quark.base.client.config; import java.awt.*; import java.io.File; @@ -19,8 +19,7 @@ import net.minecraft.client.resources.language.I18n; import net.minecraft.network.chat.Component; import vazkii.quark.base.QuarkClient; -import vazkii.quark.base.client.config.screen.QuarkConfigHomeScreen; -import vazkii.quark.base.client.handler.TopLayerTooltipHandler; +import vazkii.zeta.client.TopLayerTooltipHandler; import vazkii.quark.base.handler.ContributorRewardHandler; import vazkii.quark.base.handler.GeneralConfig; import vazkii.quark.base.handler.MiscUtil; @@ -144,7 +143,7 @@ public void renderButton(@Nonnull PoseStack mstack, int mouseX, int mouseY, floa boolean hovered = mouseX >= x && mouseY >= y && mouseX < (x + width) && mouseY < (y + height); if(hovered) - TopLayerTooltipHandler.setTooltip(List.of(I18n.get("quark.gui.celebration." + celebrating.name)), mouseX, mouseY); + QuarkClient.ZETA_CLIENT.topLayerTooltipHandler.setTooltip(List.of(I18n.get("quark.gui.celebration." + celebrating.name)), mouseX, mouseY); } int u = 256 - iconIndex * w; diff --git a/src/main/java/vazkii/quark/base/client/config/QButtonHandler.java b/src/main/java/vazkii/quark/base/client/config/QButtonHandler.java index 325863bea8..a0ac544fcf 100644 --- a/src/main/java/vazkii/quark/base/client/config/QButtonHandler.java +++ b/src/main/java/vazkii/quark/base/client/config/QButtonHandler.java @@ -12,7 +12,6 @@ import net.minecraft.client.resources.language.I18n; import net.minecraftforge.client.event.ScreenEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; -import vazkii.quark.base.client.config.widget.QButton; import vazkii.quark.base.handler.GeneralConfig; public class QButtonHandler { diff --git a/src/main/java/vazkii/quark/base/client/config/screen/QuarkConfigHomeScreen.java b/src/main/java/vazkii/quark/base/client/config/QuarkConfigHomeScreen.java similarity index 97% rename from src/main/java/vazkii/quark/base/client/config/screen/QuarkConfigHomeScreen.java rename to src/main/java/vazkii/quark/base/client/config/QuarkConfigHomeScreen.java index c081175e67..50c49801b5 100644 --- a/src/main/java/vazkii/quark/base/client/config/screen/QuarkConfigHomeScreen.java +++ b/src/main/java/vazkii/quark/base/client/config/QuarkConfigHomeScreen.java @@ -1,4 +1,4 @@ -package vazkii.quark.base.client.config.screen; +package vazkii.quark.base.client.config; import java.util.Iterator; import java.util.List; @@ -16,7 +16,6 @@ import net.minecraft.resources.ResourceLocation; import vazkii.quark.base.Quark; import vazkii.quark.base.QuarkClient; -import vazkii.quark.base.client.config.widget.SocialButton; import vazkii.quark.base.handler.ContributorRewardHandler; import vazkii.quark.base.handler.GeneralConfig; import vazkii.zeta.client.config.screen.ZetaConfigHomeScreen; diff --git a/src/main/java/vazkii/quark/base/client/config/widget/SocialButton.java b/src/main/java/vazkii/quark/base/client/config/SocialButton.java similarity index 87% rename from src/main/java/vazkii/quark/base/client/config/widget/SocialButton.java rename to src/main/java/vazkii/quark/base/client/config/SocialButton.java index e332ddb63c..48e4b3d182 100644 --- a/src/main/java/vazkii/quark/base/client/config/widget/SocialButton.java +++ b/src/main/java/vazkii/quark/base/client/config/SocialButton.java @@ -1,4 +1,4 @@ -package vazkii.quark.base.client.config.widget; +package vazkii.quark.base.client.config; import java.util.List; @@ -12,7 +12,8 @@ import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import vazkii.quark.base.Quark; -import vazkii.quark.base.client.handler.TopLayerTooltipHandler; +import vazkii.quark.base.QuarkClient; +import vazkii.zeta.client.TopLayerTooltipHandler; public class SocialButton extends Button { @@ -49,7 +50,7 @@ public void renderButton(@Nonnull PoseStack mstack, int mouseX, int mouseY, floa blit(mstack, x, y, u, v, 20, 20, 128, 64); if(isHovered) - TopLayerTooltipHandler.setTooltip(List.of(text.getString()), mouseX, mouseY); + QuarkClient.ZETA_CLIENT.topLayerTooltipHandler.setTooltip(List.of(text.getString()), mouseX, mouseY); } @Override diff --git a/src/main/java/vazkii/quark/base/client/handler/TopLayerTooltipHandler.java b/src/main/java/vazkii/quark/base/client/handler/TopLayerTooltipHandler.java deleted file mode 100644 index 1d92f471ee..0000000000 --- a/src/main/java/vazkii/quark/base/client/handler/TopLayerTooltipHandler.java +++ /dev/null @@ -1,38 +0,0 @@ -package vazkii.quark.base.client.handler; - -import java.util.List; -import java.util.Optional; -import java.util.stream.Collectors; - -import com.mojang.blaze3d.vertex.PoseStack; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.screens.Screen; -import net.minecraft.network.chat.Component; -import net.minecraft.world.item.ItemStack; -import net.minecraftforge.event.TickEvent.Phase; -import net.minecraftforge.event.TickEvent.RenderTickEvent; -import net.minecraftforge.eventbus.api.SubscribeEvent; - -public class TopLayerTooltipHandler { - - private static List tooltip; - private static int tooltipX, tooltipY; - - @SubscribeEvent - public static void renderTick(RenderTickEvent event) { - if(event.phase == Phase.END && tooltip != null) { - Minecraft mc = Minecraft.getInstance(); - Screen screen = Minecraft.getInstance().screen; - screen.renderTooltip(new PoseStack(), tooltip, Optional.empty(), tooltipX, tooltipY, mc.font, ItemStack.EMPTY); - tooltip = null; - } - } - - public static void setTooltip(List tooltip, int tooltipX, int tooltipY) { - TopLayerTooltipHandler.tooltip = tooltip.stream().map(Component::literal).collect(Collectors.toList()); - TopLayerTooltipHandler.tooltipX = tooltipX; - TopLayerTooltipHandler.tooltipY = tooltipY; - } - -} diff --git a/src/main/java/vazkii/quark/base/proxy/ClientProxy.java b/src/main/java/vazkii/quark/base/proxy/ClientProxy.java index 05ce8c4884..1723ac2b0c 100644 --- a/src/main/java/vazkii/quark/base/proxy/ClientProxy.java +++ b/src/main/java/vazkii/quark/base/proxy/ClientProxy.java @@ -19,12 +19,12 @@ import vazkii.quark.base.Quark; import vazkii.quark.base.QuarkClient; import vazkii.quark.base.client.config.QButtonHandler; -import vazkii.quark.base.client.config.screen.QuarkConfigHomeScreen; +import vazkii.quark.base.client.config.QuarkConfigHomeScreen; import vazkii.quark.base.client.handler.InventoryButtonHandler; import vazkii.quark.base.client.handler.ModelHandler; import vazkii.quark.base.client.handler.NetworkProfilingHandler; import vazkii.quark.base.client.handler.RequiredModTooltipHandler; -import vazkii.quark.base.client.handler.TopLayerTooltipHandler; +import vazkii.zeta.client.TopLayerTooltipHandler; import vazkii.quark.base.handler.ContributorRewardHandler; import vazkii.quark.base.handler.DyeHandler; import vazkii.quark.base.handler.MiscUtil; diff --git a/src/main/java/vazkii/quark/content/client/module/MicrocraftingHelperModule.java b/src/main/java/vazkii/quark/content/client/module/MicrocraftingHelperModule.java index 6be1895123..b6c3eb86bc 100644 --- a/src/main/java/vazkii/quark/content/client/module/MicrocraftingHelperModule.java +++ b/src/main/java/vazkii/quark/content/client/module/MicrocraftingHelperModule.java @@ -36,7 +36,8 @@ import net.minecraftforge.client.event.ScreenEvent.MouseButtonPressed; import net.minecraftforge.event.TickEvent.ClientTickEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; -import vazkii.quark.base.client.handler.TopLayerTooltipHandler; +import vazkii.quark.base.QuarkClient; +import vazkii.zeta.client.TopLayerTooltipHandler; import vazkii.quark.base.handler.MiscUtil; import vazkii.quark.base.module.LoadModule; import vazkii.zeta.module.ZetaModule; @@ -165,7 +166,7 @@ public void onDrawGui(ContainerScreenEvent.Render.Background event) { if(pair != null) { GhostIngredient ingr = pair.getRight(); if(ingr != null) - TopLayerTooltipHandler.setTooltip(Lists.newArrayList(I18n.get("quark.misc.rightclick_to_craft")), event.getMouseX(), event.getMouseY() - 15); + QuarkClient.ZETA_CLIENT.topLayerTooltipHandler.setTooltip(Lists.newArrayList(I18n.get("quark.misc.rightclick_to_craft")), event.getMouseX(), event.getMouseY() - 15); } } } diff --git a/src/main/java/vazkii/quark/content/management/client/screen/widgets/MiniInventoryButton.java b/src/main/java/vazkii/quark/content/management/client/screen/widgets/MiniInventoryButton.java index 4a20df835c..faa38374b2 100644 --- a/src/main/java/vazkii/quark/content/management/client/screen/widgets/MiniInventoryButton.java +++ b/src/main/java/vazkii/quark/content/management/client/screen/widgets/MiniInventoryButton.java @@ -18,7 +18,8 @@ import net.minecraft.client.resources.language.I18n; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.MutableComponent; -import vazkii.quark.base.client.handler.TopLayerTooltipHandler; +import vazkii.quark.base.QuarkClient; +import vazkii.zeta.client.TopLayerTooltipHandler; import vazkii.quark.base.handler.MiscUtil; public class MiniInventoryButton extends Button { @@ -73,7 +74,7 @@ public void renderButton(@Nonnull PoseStack matrix, int mouseX, int mouseY, floa blit(matrix, x, y, u, v, width, height); if(isHovered) - TopLayerTooltipHandler.setTooltip(getTooltip(), mouseX, mouseY); + QuarkClient.ZETA_CLIENT.topLayerTooltipHandler.setTooltip(getTooltip(), mouseX, mouseY); } @Nonnull diff --git a/src/main/java/vazkii/quark/content/tools/module/EndermoshMusicDiscModule.java b/src/main/java/vazkii/quark/content/tools/module/EndermoshMusicDiscModule.java index 217d30db33..a0e7deaaf0 100644 --- a/src/main/java/vazkii/quark/content/tools/module/EndermoshMusicDiscModule.java +++ b/src/main/java/vazkii/quark/content/tools/module/EndermoshMusicDiscModule.java @@ -15,7 +15,7 @@ import vazkii.zeta.event.ZRegister; import vazkii.zeta.event.bus.LoadEvent; import vazkii.zeta.event.bus.PlayEvent; -import vazkii.zeta.client.event.ZEndClientTickEvent; +import vazkii.zeta.client.event.ZEndClientTick; import vazkii.zeta.module.ZetaLoadModule; import vazkii.zeta.module.ZetaModule; @@ -58,7 +58,7 @@ public static class Client extends EndermoshMusicDiscModule { private SimpleSoundInstance sound; @PlayEvent - public void tick(ZEndClientTickEvent event) { + public void tick(ZEndClientTick event) { if(playEndermoshDuringEnderdragonFight) { boolean wasFightingDragon = isFightingDragon; diff --git a/src/main/java/vazkii/zeta/client/TopLayerTooltipHandler.java b/src/main/java/vazkii/zeta/client/TopLayerTooltipHandler.java new file mode 100644 index 0000000000..3698b1a850 --- /dev/null +++ b/src/main/java/vazkii/zeta/client/TopLayerTooltipHandler.java @@ -0,0 +1,40 @@ +package vazkii.zeta.client; + +import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; + +import com.mojang.blaze3d.vertex.PoseStack; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.screens.Screen; +import net.minecraft.network.chat.Component; +import net.minecraft.world.item.ItemStack; +import vazkii.zeta.client.event.ZEndRenderTick; +import vazkii.zeta.event.bus.PlayEvent; + +public class TopLayerTooltipHandler { + + private List tooltip; + private int tooltipX, tooltipY; + + @PlayEvent + public void endRenderTick(ZEndRenderTick event) { + if(tooltip != null) { + Minecraft mc = Minecraft.getInstance(); + Screen screen = Minecraft.getInstance().screen; + + //TODO: I think this is a Forge extension + screen.renderTooltip(new PoseStack(), tooltip, Optional.empty(), tooltipX, tooltipY, mc.font, ItemStack.EMPTY); + + tooltip = null; + } + } + + public void setTooltip(List tooltip, int x, int y) { + this.tooltip = tooltip.stream().map(Component::literal).collect(Collectors.toList()); + this.tooltipX = x; + this.tooltipY = y; + } + +} diff --git a/src/main/java/vazkii/zeta/client/ZetaClient.java b/src/main/java/vazkii/zeta/client/ZetaClient.java index 6d297cba41..58edd9560f 100644 --- a/src/main/java/vazkii/zeta/client/ZetaClient.java +++ b/src/main/java/vazkii/zeta/client/ZetaClient.java @@ -1,5 +1,6 @@ package vazkii.zeta.client; +import net.minecraft.resources.ResourceLocation; import vazkii.zeta.Zeta; import vazkii.zeta.client.config.ClientConfigManager; import vazkii.zeta.event.bus.IZetaLoadEvent; @@ -15,14 +16,20 @@ public ZetaClient(Zeta zeta) { //this.ticker = new ClientTicker(); this.ticker = zeta.ticker_SHOULD_NOT_BE_HERE; //TODO, move ClientTicker into actual client code this.clientConfigManager = new ClientConfigManager(); + this.topLayerTooltipHandler = new TopLayerTooltipHandler(); + + playBus.subscribe(topLayerTooltipHandler); } public final Zeta zeta; protected final ZetaEventBus loadBus; protected final ZetaEventBus playBus; + public ResourceLocation generalIcons = new ResourceLocation("zeta", "textures/gui/general_icons.png"); + public final ClientTicker ticker; public final ClientConfigManager clientConfigManager; + public final TopLayerTooltipHandler topLayerTooltipHandler; public abstract void start(); } diff --git a/src/main/java/vazkii/zeta/client/config/definition/BooleanClientDefinition.java b/src/main/java/vazkii/zeta/client/config/definition/BooleanClientDefinition.java index 92d1cdd967..b241b55bcd 100644 --- a/src/main/java/vazkii/zeta/client/config/definition/BooleanClientDefinition.java +++ b/src/main/java/vazkii/zeta/client/config/definition/BooleanClientDefinition.java @@ -4,7 +4,7 @@ import net.minecraft.client.gui.components.AbstractWidget; import net.minecraft.client.gui.screens.Screen; -import vazkii.quark.base.client.config.widget.CheckboxButton; +import vazkii.zeta.client.config.widget.CheckboxButton; import vazkii.zeta.client.ZetaClient; import vazkii.zeta.config.ChangeSet; import vazkii.zeta.config.ValueDefinition; @@ -17,6 +17,6 @@ public String getSubtitle(ChangeSet changes, ValueDefinition def) { @Override public void addWidgets(ZetaClient zc, Screen parent, ChangeSet changes, ValueDefinition def, Consumer widgets) { - widgets.accept(new CheckboxButton(230, 3, changes, def)); + widgets.accept(new CheckboxButton(zc, 230, 3, changes, def)); } } diff --git a/src/main/java/vazkii/zeta/client/config/definition/ConvulsionMatrixClientDefinition.java b/src/main/java/vazkii/zeta/client/config/definition/ConvulsionMatrixClientDefinition.java index 41dd8a8db5..a941d458c1 100644 --- a/src/main/java/vazkii/zeta/client/config/definition/ConvulsionMatrixClientDefinition.java +++ b/src/main/java/vazkii/zeta/client/config/definition/ConvulsionMatrixClientDefinition.java @@ -21,7 +21,7 @@ import net.minecraft.world.item.Items; import net.minecraftforge.client.gui.widget.ForgeSlider; import vazkii.zeta.client.config.screen.AbstractSectionInputScreen; -import vazkii.quark.base.client.config.widget.PencilButton; +import vazkii.zeta.client.config.widget.PencilButton; import vazkii.quark.base.module.config.type.inputtable.ConvulsionMatrixConfig; import vazkii.zeta.client.ZetaClient; import vazkii.zeta.config.ChangeSet; @@ -62,7 +62,7 @@ public String getSubtitle(ChangeSet changes, SectionDefinition def) { @Override public void addWidgets(ZetaClient zc, Screen parent, ChangeSet changes, SectionDefinition def, Consumer widgets) { Screen newScreen = new ConvulsionMatrixInputScreen(zc, parent, changes, def); - widgets.accept(new PencilButton(230, 3, b1 -> Minecraft.getInstance().setScreen(newScreen))); + widgets.accept(new PencilButton(zc, 230, 3, b1 -> Minecraft.getInstance().setScreen(newScreen))); } class ConvulsionMatrixInputScreen extends AbstractSectionInputScreen { diff --git a/src/main/java/vazkii/zeta/client/config/definition/DoubleClientDefinition.java b/src/main/java/vazkii/zeta/client/config/definition/DoubleClientDefinition.java index 15653d71d3..55e959cb9c 100644 --- a/src/main/java/vazkii/zeta/client/config/definition/DoubleClientDefinition.java +++ b/src/main/java/vazkii/zeta/client/config/definition/DoubleClientDefinition.java @@ -7,7 +7,7 @@ import net.minecraft.client.gui.screens.Screen; import org.jetbrains.annotations.Nullable; import vazkii.zeta.client.config.screen.AbstractEditBoxInputScreen; -import vazkii.quark.base.client.config.widget.PencilButton; +import vazkii.zeta.client.config.widget.PencilButton; import vazkii.zeta.client.ZetaClient; import vazkii.zeta.config.ChangeSet; import vazkii.zeta.config.ValueDefinition; @@ -35,6 +35,6 @@ protected int maxStringLength() { } } }; - widgets.accept(new PencilButton(230, 3, b -> Minecraft.getInstance().setScreen(newScreen))); + widgets.accept(new PencilButton(zc, 230, 3, b -> Minecraft.getInstance().setScreen(newScreen))); } } diff --git a/src/main/java/vazkii/zeta/client/config/definition/IntegerClientDefinition.java b/src/main/java/vazkii/zeta/client/config/definition/IntegerClientDefinition.java index 99f53094e7..296ddcd1b6 100644 --- a/src/main/java/vazkii/zeta/client/config/definition/IntegerClientDefinition.java +++ b/src/main/java/vazkii/zeta/client/config/definition/IntegerClientDefinition.java @@ -7,7 +7,7 @@ import net.minecraft.client.gui.screens.Screen; import org.jetbrains.annotations.Nullable; import vazkii.zeta.client.config.screen.AbstractEditBoxInputScreen; -import vazkii.quark.base.client.config.widget.PencilButton; +import vazkii.zeta.client.config.widget.PencilButton; import vazkii.zeta.client.ZetaClient; import vazkii.zeta.config.ChangeSet; import vazkii.zeta.config.ValueDefinition; @@ -30,6 +30,6 @@ public void addWidgets(ZetaClient zc, Screen parent, ChangeSet changes, ValueDef } } }; - widgets.accept(new PencilButton(230, 3, b -> Minecraft.getInstance().setScreen(newScreen))); + widgets.accept(new PencilButton(zc, 230, 3, b -> Minecraft.getInstance().setScreen(newScreen))); } } diff --git a/src/main/java/vazkii/zeta/client/config/definition/RGBClientDefinition.java b/src/main/java/vazkii/zeta/client/config/definition/RGBClientDefinition.java index 7e61815f05..01a4b5f5a5 100644 --- a/src/main/java/vazkii/zeta/client/config/definition/RGBClientDefinition.java +++ b/src/main/java/vazkii/zeta/client/config/definition/RGBClientDefinition.java @@ -14,7 +14,7 @@ import net.minecraftforge.client.gui.widget.ForgeSlider; import org.jetbrains.annotations.Nullable; import vazkii.zeta.client.config.screen.AbstractSectionInputScreen; -import vazkii.quark.base.client.config.widget.PencilButton; +import vazkii.zeta.client.config.widget.PencilButton; import vazkii.quark.base.module.config.type.inputtable.RGBAColorConfig; import vazkii.zeta.client.ZetaClient; import vazkii.zeta.config.ChangeSet; @@ -55,7 +55,7 @@ public String getSubtitle(ChangeSet changes, SectionDefinition def) { @Override public void addWidgets(ZetaClient zc, Screen parent, ChangeSet changes, SectionDefinition def, Consumer widgets) { Screen newScreen = new RGBInputScreen(zc, parent, changes, def); - widgets.accept(new PencilButton(230, 3, b1 -> Minecraft.getInstance().setScreen(newScreen))); + widgets.accept(new PencilButton(zc, 230, 3, b1 -> Minecraft.getInstance().setScreen(newScreen))); } class RGBInputScreen extends AbstractSectionInputScreen { diff --git a/src/main/java/vazkii/zeta/client/config/definition/SectionClientDefinition.java b/src/main/java/vazkii/zeta/client/config/definition/SectionClientDefinition.java index f309fe774f..2c56dec64f 100644 --- a/src/main/java/vazkii/zeta/client/config/definition/SectionClientDefinition.java +++ b/src/main/java/vazkii/zeta/client/config/definition/SectionClientDefinition.java @@ -7,7 +7,7 @@ import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.resources.language.I18n; import vazkii.zeta.client.config.screen.SectionScreen; -import vazkii.quark.base.client.config.widget.PencilButton; +import vazkii.zeta.client.config.widget.PencilButton; import vazkii.zeta.client.ZetaClient; import vazkii.zeta.config.ChangeSet; import vazkii.zeta.config.SectionDefinition; @@ -22,6 +22,6 @@ public String getSubtitle(ChangeSet changes, SectionDefinition def) { @Override public void addWidgets(ZetaClient zc, Screen parent, ChangeSet changes, SectionDefinition def, Consumer widgets) { - widgets.accept(new PencilButton(230, 3, b -> Minecraft.getInstance().setScreen(new SectionScreen(zc, parent, changes, def)))); + widgets.accept(new PencilButton(zc, 230, 3, b -> Minecraft.getInstance().setScreen(new SectionScreen(zc, parent, changes, def)))); } } diff --git a/src/main/java/vazkii/zeta/client/config/definition/StringClientDefinition.java b/src/main/java/vazkii/zeta/client/config/definition/StringClientDefinition.java index 1e6591483c..4a74e14112 100644 --- a/src/main/java/vazkii/zeta/client/config/definition/StringClientDefinition.java +++ b/src/main/java/vazkii/zeta/client/config/definition/StringClientDefinition.java @@ -7,7 +7,7 @@ import net.minecraft.client.gui.screens.Screen; import org.jetbrains.annotations.Nullable; import vazkii.zeta.client.config.screen.AbstractEditBoxInputScreen; -import vazkii.quark.base.client.config.widget.PencilButton; +import vazkii.zeta.client.config.widget.PencilButton; import vazkii.zeta.client.ZetaClient; import vazkii.zeta.config.ChangeSet; import vazkii.zeta.config.ValueDefinition; @@ -26,6 +26,6 @@ public void addWidgets(ZetaClient zc, Screen parent, ChangeSet changes, ValueDef return string; } }; - widgets.accept(new PencilButton(230, 3, b -> Minecraft.getInstance().setScreen(newScreen))); + widgets.accept(new PencilButton(zc, 230, 3, b -> Minecraft.getInstance().setScreen(newScreen))); } } diff --git a/src/main/java/vazkii/zeta/client/config/definition/StringListClientDefinition.java b/src/main/java/vazkii/zeta/client/config/definition/StringListClientDefinition.java index d4b5ff8ce5..771de40c9c 100644 --- a/src/main/java/vazkii/zeta/client/config/definition/StringListClientDefinition.java +++ b/src/main/java/vazkii/zeta/client/config/definition/StringListClientDefinition.java @@ -7,7 +7,7 @@ import net.minecraft.client.gui.components.AbstractWidget; import net.minecraft.client.gui.screens.Screen; import vazkii.zeta.client.config.screen.StringListInputScreen; -import vazkii.quark.base.client.config.widget.PencilButton; +import vazkii.zeta.client.config.widget.PencilButton; import vazkii.zeta.client.ZetaClient; import vazkii.zeta.config.ChangeSet; import vazkii.zeta.config.ValueDefinition; @@ -33,6 +33,6 @@ public String getSubtitle(ChangeSet changes, ValueDefinition> def) @Override public void addWidgets(ZetaClient zc, Screen parent, ChangeSet changes, ValueDefinition> def, Consumer widgets) { Screen newScreen = new StringListInputScreen(zc, parent, changes, def); - widgets.accept(new PencilButton(230, 3, b -> Minecraft.getInstance().setScreen(newScreen))); + widgets.accept(new PencilButton(zc, 230, 3, b -> Minecraft.getInstance().setScreen(newScreen))); } } diff --git a/src/main/java/vazkii/zeta/client/config/screen/SectionScreen.java b/src/main/java/vazkii/zeta/client/config/screen/SectionScreen.java index 41e9270bdf..ea0ff579c7 100644 --- a/src/main/java/vazkii/zeta/client/config/screen/SectionScreen.java +++ b/src/main/java/vazkii/zeta/client/config/screen/SectionScreen.java @@ -16,7 +16,7 @@ import org.jetbrains.annotations.NotNull; import vazkii.zeta.client.config.widget.DefaultDiscardDone; import vazkii.zeta.client.config.widget.ScrollableWidgetList; -import vazkii.quark.base.client.handler.TopLayerTooltipHandler; +import vazkii.zeta.client.TopLayerTooltipHandler; import vazkii.zeta.client.ZetaClient; import vazkii.zeta.config.ChangeSet; import vazkii.zeta.config.Definition; @@ -163,7 +163,7 @@ public void render(@NotNull PoseStack mstack, int index, int rowTop, int rowLeft name += (ChatFormatting.AQUA + " (?)"); if(mouseX >= hoverLeft && mouseX < hoverRight && mouseY >= top && mouseY < (top + 10)) - TopLayerTooltipHandler.setTooltip(tooltip, mouseX, mouseY); + zc.topLayerTooltipHandler.setTooltip(tooltip, mouseX, mouseY); } minecraft.font.drawShadow(mstack, name, left, top, 0xFFFFFF); diff --git a/src/main/java/vazkii/zeta/client/config/screen/ZetaConfigHomeScreen.java b/src/main/java/vazkii/zeta/client/config/screen/ZetaConfigHomeScreen.java index f2d8bff8d2..7eb6caad4b 100644 --- a/src/main/java/vazkii/zeta/client/config/screen/ZetaConfigHomeScreen.java +++ b/src/main/java/vazkii/zeta/client/config/screen/ZetaConfigHomeScreen.java @@ -15,8 +15,8 @@ import net.minecraft.network.chat.Component; import net.minecraft.network.chat.MutableComponent; import org.apache.commons.lang3.text.WordUtils; -import vazkii.quark.base.client.config.widget.CheckboxButton; -import vazkii.quark.base.client.config.widget.IconButton; +import vazkii.zeta.client.config.widget.CheckboxButton; +import vazkii.zeta.client.config.widget.CategoryButton; import vazkii.zeta.client.ZetaClient; import vazkii.zeta.config.ChangeSet; import vazkii.zeta.config.SectionDefinition; @@ -61,9 +61,9 @@ protected void init() { SectionDefinition categorySection = z.weirdConfigSingleton.getCategorySection(category); bWidth -= 20; //room for the checkbox - Button mainButton = addRenderableWidget(new IconButton(x, y, bWidth, 20, componentFor(categorySection), category.icon.get(), + Button mainButton = addRenderableWidget(new CategoryButton(zc, x, y, bWidth, 20, componentFor(categorySection), category.icon.get(), b -> Minecraft.getInstance().setScreen(new SectionScreen(zc, this, changeSet, categorySection)))); - Button checkButton = addRenderableWidget(new CheckboxButton(x + bWidth, y, changeSet, categoryEnabled)); + Button checkButton = addRenderableWidget(new CheckboxButton(zc, x + bWidth, y, changeSet, categoryEnabled)); boolean active = category.modsLoaded(z); mainButton.active = active; diff --git a/src/main/java/vazkii/quark/base/client/config/widget/IconButton.java b/src/main/java/vazkii/zeta/client/config/widget/CategoryButton.java similarity index 71% rename from src/main/java/vazkii/quark/base/client/config/widget/IconButton.java rename to src/main/java/vazkii/zeta/client/config/widget/CategoryButton.java index ef28eaebed..0fe05b9cfc 100644 --- a/src/main/java/vazkii/quark/base/client/config/widget/IconButton.java +++ b/src/main/java/vazkii/zeta/client/config/widget/CategoryButton.java @@ -1,4 +1,4 @@ -package vazkii.quark.base.client.config.widget; +package vazkii.zeta.client.config.widget; import java.util.List; @@ -10,15 +10,17 @@ import net.minecraft.client.resources.language.I18n; import net.minecraft.network.chat.Component; import net.minecraft.world.item.ItemStack; -import vazkii.quark.base.client.handler.TopLayerTooltipHandler; +import vazkii.zeta.client.ZetaClient; -public class IconButton extends Button { +public class CategoryButton extends Button { + private final ZetaClient zc; private final ItemStack icon; private final Component text; - public IconButton(int x, int y, int w, int h, Component text, ItemStack icon, OnPress onClick) { + public CategoryButton(ZetaClient zc, int x, int y, int w, int h, Component text, ItemStack icon, OnPress onClick) { super(x, y, w, h, Component.literal(""), onClick); + this.zc = zc; this.icon = icon; this.text = text; } @@ -28,7 +30,7 @@ public void render(@Nonnull PoseStack mstack, int mouseX, int mouseY, float part super.render(mstack, mouseX, mouseY, partialTicks); if(!active && mouseX >= x && mouseY >= y && mouseX < (x + width) && mouseY < (y + height)) - TopLayerTooltipHandler.setTooltip(List.of(I18n.get("quark.gui.config.missingaddon")), mouseX, mouseY); + zc.topLayerTooltipHandler.setTooltip(List.of(I18n.get("quark.gui.config.missingaddon")), mouseX, mouseY); Minecraft mc = Minecraft.getInstance(); mc.getItemRenderer().renderGuiItem(icon, x + 5, y + 2); diff --git a/src/main/java/vazkii/quark/base/client/config/widget/CheckboxButton.java b/src/main/java/vazkii/zeta/client/config/widget/CheckboxButton.java similarity index 65% rename from src/main/java/vazkii/quark/base/client/config/widget/CheckboxButton.java rename to src/main/java/vazkii/zeta/client/config/widget/CheckboxButton.java index 795a0317d1..8daae9007d 100644 --- a/src/main/java/vazkii/quark/base/client/config/widget/CheckboxButton.java +++ b/src/main/java/vazkii/zeta/client/config/widget/CheckboxButton.java @@ -1,4 +1,4 @@ -package vazkii.quark.base.client.config.widget; +package vazkii.zeta.client.config.widget; import javax.annotation.Nonnull; @@ -7,21 +7,30 @@ import net.minecraft.client.gui.components.Button; import net.minecraft.client.renderer.GameRenderer; import net.minecraft.network.chat.Component; -import vazkii.quark.base.handler.MiscUtil; +import net.minecraft.resources.ResourceLocation; +import vazkii.zeta.client.ZetaClient; import vazkii.zeta.config.ChangeSet; import vazkii.zeta.config.ValueDefinition; public class CheckboxButton extends Button { + //checked: u0 v0 to u16 v16 + //unchecked: u16 v0 to u32 v16 + private final ResourceLocation iconsTexture; private final ValueDefinition value; private final ChangeSet changes; - public CheckboxButton(int x, int y, ChangeSet changes, ValueDefinition value) { + public CheckboxButton(ResourceLocation iconsTexture, int x, int y, ChangeSet changes, ValueDefinition value) { super(x, y, 20, 20, Component.literal(""), CheckboxButton::toggle); + this.iconsTexture = iconsTexture; this.value = value; this.changes = changes; } + public CheckboxButton(ZetaClient zc, int x, int y, ChangeSet changes, ValueDefinition value) { + this(zc.generalIcons, x, y, changes, value); + } + private static void toggle(Button press) { if(press instanceof CheckboxButton checkbox) { checkbox.changes.toggle(checkbox.value); @@ -34,10 +43,10 @@ public void renderButton(@Nonnull PoseStack mstack, int mouseX, int mouseY, floa RenderSystem.setShader(GameRenderer::getPositionTexShader); RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); - RenderSystem.setShaderTexture(0, MiscUtil.GENERAL_ICONS); + RenderSystem.setShaderTexture(0, iconsTexture); boolean enabled = changes.get(value) && active; int u = enabled ? 0 : 16; - int v = 93; + int v = 0; blit(mstack, x + 2, y + 1, u, v, 15, 15); } diff --git a/src/main/java/vazkii/quark/base/client/config/widget/PencilButton.java b/src/main/java/vazkii/zeta/client/config/widget/PencilButton.java similarity index 59% rename from src/main/java/vazkii/quark/base/client/config/widget/PencilButton.java rename to src/main/java/vazkii/zeta/client/config/widget/PencilButton.java index 4ca7bab7aa..9cbff02ff6 100644 --- a/src/main/java/vazkii/quark/base/client/config/widget/PencilButton.java +++ b/src/main/java/vazkii/zeta/client/config/widget/PencilButton.java @@ -1,4 +1,4 @@ -package vazkii.quark.base.client.config.widget; +package vazkii.zeta.client.config.widget; import javax.annotation.Nonnull; @@ -7,12 +7,21 @@ import net.minecraft.client.gui.components.Button; import net.minecraft.client.renderer.GameRenderer; import net.minecraft.network.chat.Component; -import vazkii.quark.base.handler.MiscUtil; +import net.minecraft.resources.ResourceLocation; +import vazkii.zeta.client.ZetaClient; public class PencilButton extends Button { - public PencilButton(int x, int y, OnPress pressable) { + //pencil: u32 v0 to u48 v16 + private final ResourceLocation iconsTexture; + + public PencilButton(ResourceLocation iconsTexture, int x, int y, OnPress pressable) { super(x, y, 20, 20, Component.literal(""), pressable); + this.iconsTexture = iconsTexture; + } + + public PencilButton(ZetaClient zc, int x, int y, OnPress pressable) { + this(zc.generalIcons, x, y, pressable); } @Override @@ -21,10 +30,10 @@ public void renderButton(@Nonnull PoseStack mstack, int mouseX, int mouseY, floa RenderSystem.setShader(GameRenderer::getPositionTexShader); RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); - RenderSystem.setShaderTexture(0, MiscUtil.GENERAL_ICONS); + RenderSystem.setShaderTexture(0, iconsTexture); int u = 32; - int v = 93; + int v = 0; blit(mstack, x + 2, y + 1, u, v, 16, 16); } diff --git a/src/main/java/vazkii/zeta/client/event/ZEndClientTickEvent.java b/src/main/java/vazkii/zeta/client/event/ZEndClientTick.java similarity index 54% rename from src/main/java/vazkii/zeta/client/event/ZEndClientTickEvent.java rename to src/main/java/vazkii/zeta/client/event/ZEndClientTick.java index a037148b3e..49773ab712 100644 --- a/src/main/java/vazkii/zeta/client/event/ZEndClientTickEvent.java +++ b/src/main/java/vazkii/zeta/client/event/ZEndClientTick.java @@ -3,5 +3,5 @@ import vazkii.zeta.event.bus.FiredAs; import vazkii.zeta.event.bus.IZetaPlayEvent; -@FiredAs(ZEndClientTickEvent.class) -public class ZEndClientTickEvent implements IZetaPlayEvent { } +@FiredAs(ZEndClientTick.class) +public class ZEndClientTick implements IZetaPlayEvent { } diff --git a/src/main/java/vazkii/zeta/client/event/ZEndRenderTick.java b/src/main/java/vazkii/zeta/client/event/ZEndRenderTick.java new file mode 100644 index 0000000000..3694e34f52 --- /dev/null +++ b/src/main/java/vazkii/zeta/client/event/ZEndRenderTick.java @@ -0,0 +1,7 @@ +package vazkii.zeta.client.event; + +import vazkii.zeta.event.bus.FiredAs; +import vazkii.zeta.event.bus.IZetaPlayEvent; + +@FiredAs(ZEndRenderTick.class) +public class ZEndRenderTick implements IZetaPlayEvent { } diff --git a/src/main/java/vazkii/zetaimplforge/client/ForgeZetaClient.java b/src/main/java/vazkii/zetaimplforge/client/ForgeZetaClient.java index 42af9c4bd8..9de527802e 100644 --- a/src/main/java/vazkii/zetaimplforge/client/ForgeZetaClient.java +++ b/src/main/java/vazkii/zetaimplforge/client/ForgeZetaClient.java @@ -17,7 +17,8 @@ import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import vazkii.zeta.Zeta; import vazkii.zeta.client.ZetaClient; -import vazkii.zeta.client.event.ZEndClientTickEvent; +import vazkii.zeta.client.event.ZEndClientTick; +import vazkii.zeta.client.event.ZEndRenderTick; import vazkii.zeta.client.event.ZFirstClientTick; import vazkii.zeta.client.event.ZRegisterReloadListeners; import vazkii.zetaimplforge.event.client.ForgeZAddBlockColorHandlers; @@ -103,11 +104,14 @@ public void registerClientTooltipComponentFactories(RegisterClientTooltipCompone loadBus.fire(new ForgeZTooltipComponents(event)); } + //TODO: move ticker stuff out of forge event handlers, subscribe to them from zeta public void renderTick(TickEvent.RenderTickEvent e) { if(e.phase == TickEvent.Phase.START) ticker.startRenderTick(e.renderTickTime); - else + else { + playBus.fire(new ZEndRenderTick()); ticker.endRenderTick(); + } } boolean clientTicked = false; @@ -120,7 +124,7 @@ public void clientTick(TickEvent.ClientTickEvent event) { clientTicked = true; } - playBus.fire(new ZEndClientTickEvent()); + playBus.fire(new ZEndClientTick()); } } diff --git a/src/main/resources/assets/zeta/textures/gui/general_icons.png b/src/main/resources/assets/zeta/textures/gui/general_icons.png new file mode 100644 index 0000000000..72d4734169 Binary files /dev/null and b/src/main/resources/assets/zeta/textures/gui/general_icons.png differ