diff --git a/RebornCore/src/client/java/reborncore/client/gui/builder/slot/elements/AbstractConfigPopupElement.java b/RebornCore/src/client/java/reborncore/client/gui/builder/slot/elements/AbstractConfigPopupElement.java index eb9734f09..9e6e93316 100644 --- a/RebornCore/src/client/java/reborncore/client/gui/builder/slot/elements/AbstractConfigPopupElement.java +++ b/RebornCore/src/client/java/reborncore/client/gui/builder/slot/elements/AbstractConfigPopupElement.java @@ -33,6 +33,7 @@ import net.minecraft.client.render.Tessellator; import net.minecraft.client.render.VertexConsumerProvider; import net.minecraft.client.render.block.BlockRenderManager; import net.minecraft.client.render.model.BakedModel; +import net.minecraft.client.util.SpriteIdentifier; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.util.math.Direction; import net.minecraft.util.math.RotationAxis; @@ -44,7 +45,7 @@ import reborncore.common.util.MachineFacing; public abstract class AbstractConfigPopupElement extends ElementBase { public boolean filter = false; - public AbstractConfigPopupElement(int x, int y, Sprite sprite) { + public AbstractConfigPopupElement(int x, int y, SpriteIdentifier sprite) { super(x, y, sprite); } diff --git a/RebornCore/src/client/java/reborncore/client/gui/builder/slot/elements/ButtonElement.java b/RebornCore/src/client/java/reborncore/client/gui/builder/slot/elements/ButtonElement.java index 60b4e31be..9a3dc4e27 100644 --- a/RebornCore/src/client/java/reborncore/client/gui/builder/slot/elements/ButtonElement.java +++ b/RebornCore/src/client/java/reborncore/client/gui/builder/slot/elements/ButtonElement.java @@ -28,10 +28,10 @@ import net.minecraft.client.gui.DrawContext; import reborncore.client.gui.builder.GuiBase; public class ButtonElement extends ElementBase { - private final Sprite.Button buttonSprite; + private final GuiSprites.Button buttonSprite; private final Runnable onClicked; - public ButtonElement(int x, int y, Sprite.Button buttonSprite, Runnable onClicked) { + public ButtonElement(int x, int y, GuiSprites.Button buttonSprite, Runnable onClicked) { super(x, y, buttonSprite.normal()); this.buttonSprite = buttonSprite; this.onClicked = onClicked; diff --git a/RebornCore/src/client/java/reborncore/client/gui/builder/slot/elements/CheckBoxElement.java b/RebornCore/src/client/java/reborncore/client/gui/builder/slot/elements/CheckBoxElement.java index 7c64647a0..121973488 100644 --- a/RebornCore/src/client/java/reborncore/client/gui/builder/slot/elements/CheckBoxElement.java +++ b/RebornCore/src/client/java/reborncore/client/gui/builder/slot/elements/CheckBoxElement.java @@ -25,6 +25,7 @@ package reborncore.client.gui.builder.slot.elements; import net.minecraft.client.gui.DrawContext; +import net.minecraft.client.util.SpriteIdentifier; import net.minecraft.text.Text; import reborncore.client.gui.builder.GuiBase; @@ -34,13 +35,13 @@ public class CheckBoxElement extends ElementBase { private final Text label; private final Predicate ticked; private final Runnable onChange; - private final Sprite.CheckBox checkBoxSprite; + private final GuiSprites.CheckBox checkBoxSprite; public CheckBoxElement(Text label, int x, int y, Predicate ticked, Runnable onChange) { - super(x, y, Sprite.LIGHT_CHECK_BOX.normal()); - this.checkBoxSprite = Sprite.LIGHT_CHECK_BOX; + super(x, y, GuiSprites.LIGHT_CHECK_BOX.normal()); + this.checkBoxSprite = GuiSprites.LIGHT_CHECK_BOX; this.label = label; this.ticked = ticked; this.onChange = onChange; @@ -64,12 +65,12 @@ public class CheckBoxElement extends ElementBase { @Override public void draw(DrawContext drawContext, GuiBase gui, int mouseX, int mouseY) { - Sprite sprite = checkBoxSprite.normal(); + SpriteIdentifier sprite = checkBoxSprite.normal(); if (ticked.test(this)) { sprite = checkBoxSprite.ticked(); } drawSprite(drawContext, gui, sprite, getX(), getY() ); - drawText(drawContext, gui, label, getX() + checkBoxSprite.normal().width() + 5, ((getY() + getHeight() / 2) - (gui.getTextRenderer().fontHeight / 2)), 0xFFFFFFFF); + drawText(drawContext, gui, label, getX() + getWidth() + 5, ((getY() + getHeight() / 2) - (gui.getTextRenderer().fontHeight / 2)), 0xFFFFFFFF); } } diff --git a/RebornCore/src/client/java/reborncore/client/gui/builder/slot/elements/ConfigFluidElement.java b/RebornCore/src/client/java/reborncore/client/gui/builder/slot/elements/ConfigFluidElement.java index 86c7146bc..56ad00037 100644 --- a/RebornCore/src/client/java/reborncore/client/gui/builder/slot/elements/ConfigFluidElement.java +++ b/RebornCore/src/client/java/reborncore/client/gui/builder/slot/elements/ConfigFluidElement.java @@ -38,7 +38,7 @@ public class ConfigFluidElement extends ParentElement { FluidConfigPopupElement popupElement; elements.add(popupElement = new FluidConfigPopupElement(x - 22, y - 22, this)); - elements.add(new ButtonElement(x + 37, y - 25, Sprite.EXIT_BUTTON, gui::closeSelectedTab)); + elements.add(new ButtonElement(x + 37, y - 25, GuiSprites.EXIT_BUTTON, gui::closeSelectedTab)); elements.add(new CheckBoxElement(Text.translatable("reborncore.gui.fluidconfig.pullin"), x - 26, y + 42, checkBoxElement -> gui.getMachine().fluidConfiguration.autoInput(), diff --git a/RebornCore/src/client/java/reborncore/client/gui/builder/slot/elements/ConfigSlotElement.java b/RebornCore/src/client/java/reborncore/client/gui/builder/slot/elements/ConfigSlotElement.java index 196a31502..c323afd35 100644 --- a/RebornCore/src/client/java/reborncore/client/gui/builder/slot/elements/ConfigSlotElement.java +++ b/RebornCore/src/client/java/reborncore/client/gui/builder/slot/elements/ConfigSlotElement.java @@ -66,7 +66,7 @@ public class ConfigSlotElement extends ParentElement { elements.add(popupElement = new SlotConfigPopupElement(this.id, x - 22, y - 22, inputEnabled)); - elements.add(new ButtonElement(x + 37, y - 25, Sprite.EXIT_BUTTON, closeConfig)); + elements.add(new ButtonElement(x + 37, y - 25, GuiSprites.EXIT_BUTTON, closeConfig)); if (inputEnabled) { elements.add(new CheckBoxElement(Text.translatable("reborncore.gui.slotconfig.autoinput"), x - 26, y + 42, diff --git a/RebornCore/src/client/java/reborncore/client/gui/builder/slot/elements/ElementBase.java b/RebornCore/src/client/java/reborncore/client/gui/builder/slot/elements/ElementBase.java index f1e7dff6d..5035e4562 100644 --- a/RebornCore/src/client/java/reborncore/client/gui/builder/slot/elements/ElementBase.java +++ b/RebornCore/src/client/java/reborncore/client/gui/builder/slot/elements/ElementBase.java @@ -26,25 +26,23 @@ package reborncore.client.gui.builder.slot.elements; import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.screen.Screen; +import net.minecraft.client.util.SpriteIdentifier; import net.minecraft.text.Text; -import net.minecraft.util.Identifier; import reborncore.client.gui.builder.GuiBase; import reborncore.client.gui.guibuilder.GuiBuilder; public class ElementBase { private final int x; private final int y; - private Sprite sprite; + private SpriteIdentifier sprite; - public static final Identifier MECH_ELEMENTS = new Identifier("reborncore", "textures/gui/elements.png"); - - public ElementBase(int x, int y, Sprite sprite) { + public ElementBase(int x, int y, SpriteIdentifier sprite) { this.sprite = sprite; this.x = x; this.y = y; } - protected void setSprite(Sprite sprite) { + protected void setSprite(SpriteIdentifier sprite) { this.sprite = sprite; } @@ -61,11 +59,11 @@ public class ElementBase { } public int getWidth() { - return sprite.width(); + return sprite.getSprite().getContents().getWidth(); } public int getHeight() { - return sprite.height(); + return sprite.getSprite().getContents().getHeight(); } public boolean onClick(GuiBase gui, double mouseX, double mouseY) { @@ -94,8 +92,8 @@ public class ElementBase { drawContext.drawText(gui.getTextRenderer(), text, x, y, color, false); } - public void drawSprite(DrawContext drawContext, GuiBase gui, Sprite sprite, int x, int y) { - drawContext.drawTexture(sprite.textureLocation(), x + gui.getGuiLeft(), y + gui.getGuiTop(), sprite.x(), sprite.y(), sprite.width(), sprite.height()); + public void drawSprite(DrawContext drawContext, GuiBase gui, SpriteIdentifier sprite, int x, int y) { + drawContext.drawSprite(x + gui.getGuiLeft(), y + gui.getGuiTop(), 0, getWidth(), getHeight(), sprite.getSprite()); } public void drawDefaultBackground(DrawContext drawContext, Screen gui, int x, int y, int width, int height) { diff --git a/RebornCore/src/client/java/reborncore/client/gui/builder/slot/elements/FluidConfigPopupElement.java b/RebornCore/src/client/java/reborncore/client/gui/builder/slot/elements/FluidConfigPopupElement.java index 0b0319d9d..a53d26422 100644 --- a/RebornCore/src/client/java/reborncore/client/gui/builder/slot/elements/FluidConfigPopupElement.java +++ b/RebornCore/src/client/java/reborncore/client/gui/builder/slot/elements/FluidConfigPopupElement.java @@ -38,7 +38,7 @@ public class FluidConfigPopupElement extends AbstractConfigPopupElement { ConfigFluidElement fluidElement; public FluidConfigPopupElement(int x, int y, ConfigFluidElement fluidElement) { - super(x, y, Sprite.SLOT_CONFIG_POPUP); + super(x, y, GuiSprites.SLOT_CONFIG_POPUP); this.fluidElement = fluidElement; } diff --git a/RebornCore/src/client/java/reborncore/client/gui/builder/slot/elements/GuiSpriteAtlasHolder.java b/RebornCore/src/client/java/reborncore/client/gui/builder/slot/elements/GuiSpriteAtlasHolder.java new file mode 100644 index 000000000..017808b22 --- /dev/null +++ b/RebornCore/src/client/java/reborncore/client/gui/builder/slot/elements/GuiSpriteAtlasHolder.java @@ -0,0 +1,47 @@ +/* + * This file is part of RebornCore, licensed under the MIT License (MIT). + * + * Copyright (c) 2023 TeamReborn + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package reborncore.client.gui.builder.slot.elements; + +import net.minecraft.client.texture.Sprite; +import net.minecraft.client.texture.SpriteAtlasHolder; +import net.minecraft.client.texture.TextureManager; +import net.minecraft.util.Identifier; +import org.jetbrains.annotations.Nullable; + +public class GuiSpriteAtlasHolder extends SpriteAtlasHolder { + @Nullable + public static GuiSpriteAtlasHolder INSTANCE; + + public static final Identifier ATLAS_ID = new Identifier("reborncore", "textures/atlas/gui.png"); + + public GuiSpriteAtlasHolder(TextureManager textureManager) { + super(textureManager, ATLAS_ID, new Identifier("reborncore", "gui")); + } + + @Override + public Sprite getSprite(Identifier objectId) { + return super.getSprite(objectId); + } +} diff --git a/RebornCore/src/client/java/reborncore/client/gui/builder/slot/elements/GuiSprites.java b/RebornCore/src/client/java/reborncore/client/gui/builder/slot/elements/GuiSprites.java new file mode 100644 index 000000000..bb2eb559d --- /dev/null +++ b/RebornCore/src/client/java/reborncore/client/gui/builder/slot/elements/GuiSprites.java @@ -0,0 +1,71 @@ +/* + * This file is part of RebornCore, licensed under the MIT License (MIT). + * + * Copyright (c) 2023 TeamReborn + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package reborncore.client.gui.builder.slot.elements; + +import net.minecraft.client.util.SpriteIdentifier; +import net.minecraft.util.Identifier; + +public final class GuiSprites { + public static final SpriteIdentifier SLOT_NORMAL = create("slot_normal"); + public static final SpriteIdentifier CHARGE_SLOT_ICON = create("charge_slot_icon"); + public static final SpriteIdentifier DISCHARGE_SLOT_ICON = create("discharge_slot_icon"); + public static final SpriteIdentifier ENERGY_BAR = create("energy_bar"); + public static final SpriteIdentifier ENERGY_BAR_BACKGROUND = create("energy_bar_background"); + public static final SpriteIdentifier TOP_ENERGY_BAR = create("top_energy_bar"); + public static final SpriteIdentifier TOP_ENERGY_BAR_BACKGROUND = create("top_energy_bar_background"); + public static final SpriteIdentifier LEFT_TAB = create("left_tab"); + public static final SpriteIdentifier LEFT_TAB_SELECTED = create("left_tab_selected"); + public static final SpriteIdentifier CONFIGURE_ICON = create("configure_icon"); + public static final SpriteIdentifier UPGRADE_ICON = create("upgrade_icon"); + public static final SpriteIdentifier ENERGY_ICON = create("energy_icon"); + public static final SpriteIdentifier ENERGY_ICON_EMPTY = create("energy_icon_empty"); + public static final SpriteIdentifier JEI_ICON = create("jei_icon"); + public static final SpriteIdentifier BUTTON_SLOT_NORMAL = create("button_slot_normal"); + public static final SpriteIdentifier FAKE_SLOT = create("fake_slot"); + public static final SpriteIdentifier BUTTON_HOVER_OVERLAY_SLOT_NORMAL = create("button_hover_overlay_slot_normal"); + public static final SpriteIdentifier SLOT_CONFIG_POPUP = create("slot_config_popup"); + + public static final SpriteIdentifier EXIT_BUTTON_NORMAL = create("exit_button_normal"); + public static final SpriteIdentifier EXIT_BUTTON_HOVERED = create("exit_button_hovered"); + public static final Button EXIT_BUTTON = new Button(EXIT_BUTTON_NORMAL, EXIT_BUTTON_HOVERED); + + public static final SpriteIdentifier DARK_CHECK_BOX_NORMAL = create("dark_check_box_normal"); + public static final SpriteIdentifier DARK_CHECK_BOX_TICKED = create("dark_check_box_ticked"); + public static final CheckBox DARK_CHECK_BOX = new CheckBox(DARK_CHECK_BOX_NORMAL, DARK_CHECK_BOX_TICKED); + + public static final SpriteIdentifier LIGHT_CHECK_BOX_NORMAL = create("light_check_box_normal"); + public static final SpriteIdentifier LIGHT_CHECK_BOX_TICKED = create("light_check_box_ticked"); + public static final CheckBox LIGHT_CHECK_BOX = new CheckBox(LIGHT_CHECK_BOX_NORMAL, LIGHT_CHECK_BOX_TICKED); + + private static SpriteIdentifier create(String name) { + return new SpriteIdentifier(GuiSpriteAtlasHolder.ATLAS_ID, new Identifier("reborncore", name)); + } + + record Button(SpriteIdentifier normal, SpriteIdentifier hovered) { + } + + record CheckBox(SpriteIdentifier normal, SpriteIdentifier ticked) { + } +} diff --git a/RebornCore/src/client/java/reborncore/client/gui/builder/slot/elements/ParentElement.java b/RebornCore/src/client/java/reborncore/client/gui/builder/slot/elements/ParentElement.java index b6cadbce8..8e92d33e1 100644 --- a/RebornCore/src/client/java/reborncore/client/gui/builder/slot/elements/ParentElement.java +++ b/RebornCore/src/client/java/reborncore/client/gui/builder/slot/elements/ParentElement.java @@ -26,6 +26,7 @@ package reborncore.client.gui.builder.slot.elements; import com.google.common.collect.Lists; import net.minecraft.client.gui.DrawContext; +import net.minecraft.client.util.SpriteIdentifier; import reborncore.client.gui.builder.GuiBase; import java.util.ArrayList; @@ -34,7 +35,7 @@ import java.util.List; public abstract class ParentElement extends ElementBase { protected final List elements = new ArrayList<>(); - public ParentElement(int x, int y, Sprite sprite) { + public ParentElement(int x, int y, SpriteIdentifier sprite) { super(x, y, sprite); } diff --git a/RebornCore/src/client/java/reborncore/client/gui/builder/slot/elements/SlotConfigPopupElement.java b/RebornCore/src/client/java/reborncore/client/gui/builder/slot/elements/SlotConfigPopupElement.java index 907125e7f..a5ea5f402 100644 --- a/RebornCore/src/client/java/reborncore/client/gui/builder/slot/elements/SlotConfigPopupElement.java +++ b/RebornCore/src/client/java/reborncore/client/gui/builder/slot/elements/SlotConfigPopupElement.java @@ -39,7 +39,7 @@ public class SlotConfigPopupElement extends AbstractConfigPopupElement { private final boolean allowInput; public SlotConfigPopupElement(int slotId, int x, int y, boolean allowInput) { - super(x, y, Sprite.SLOT_CONFIG_POPUP); + super(x, y, GuiSprites.SLOT_CONFIG_POPUP); this.id = slotId; this.allowInput = allowInput; } diff --git a/RebornCore/src/client/java/reborncore/client/gui/builder/slot/elements/SlotType.java b/RebornCore/src/client/java/reborncore/client/gui/builder/slot/elements/SlotType.java index 64eb4ebbc..a4ce4b5d0 100644 --- a/RebornCore/src/client/java/reborncore/client/gui/builder/slot/elements/SlotType.java +++ b/RebornCore/src/client/java/reborncore/client/gui/builder/slot/elements/SlotType.java @@ -24,16 +24,18 @@ package reborncore.client.gui.builder.slot.elements; +import net.minecraft.client.util.SpriteIdentifier; + public enum SlotType { - NORMAL(1, 1, Sprite.SLOT_NORMAL, Sprite.BUTTON_SLOT_NORMAL, Sprite.BUTTON_HOVER_OVERLAY_SLOT_NORMAL); + NORMAL(1, 1, GuiSprites.SLOT_NORMAL, GuiSprites.BUTTON_SLOT_NORMAL, GuiSprites.BUTTON_HOVER_OVERLAY_SLOT_NORMAL); int slotOffsetX; int slotOffsetY; - Sprite sprite; - Sprite buttonSprite; - Sprite buttonHoverOverlay; + SpriteIdentifier sprite; + SpriteIdentifier buttonSprite; + SpriteIdentifier buttonHoverOverlay; - SlotType(int slotOffsetX, int slotOffsetY, Sprite sprite, Sprite buttonSprite, Sprite buttonHoverOverlay) { + SlotType(int slotOffsetX, int slotOffsetY, SpriteIdentifier sprite, SpriteIdentifier buttonSprite, SpriteIdentifier buttonHoverOverlay) { this.slotOffsetX = slotOffsetX; this.slotOffsetY = slotOffsetY; this.sprite = sprite; @@ -41,15 +43,15 @@ public enum SlotType { this.buttonHoverOverlay = buttonHoverOverlay; } - public Sprite getSprite() { + public SpriteIdentifier getSprite() { return sprite; } - public Sprite getButtonSprite() { + public SpriteIdentifier getButtonSprite() { return buttonSprite; } - public Sprite getButtonHoverOverlay() { + public SpriteIdentifier getButtonHoverOverlay() { return buttonHoverOverlay; } } diff --git a/RebornCore/src/client/java/reborncore/client/gui/builder/slot/elements/Sprite.java b/RebornCore/src/client/java/reborncore/client/gui/builder/slot/elements/Sprite.java deleted file mode 100644 index 7d58371f9..000000000 --- a/RebornCore/src/client/java/reborncore/client/gui/builder/slot/elements/Sprite.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * This file is part of RebornCore, licensed under the MIT License (MIT). - * - * Copyright (c) 2021 TeamReborn - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package reborncore.client.gui.builder.slot.elements; - -import net.minecraft.util.Identifier; - -public record Sprite(Identifier textureLocation, int x, int y, int width, int height) { - public static final Sprite EMPTY = new Sprite(ElementBase.MECH_ELEMENTS, 0, 0, 0, 0); - public static final Sprite SLOT_NORMAL = new Sprite(ElementBase.MECH_ELEMENTS, 0, 0, 18, 18); - public static final Sprite CHARGE_SLOT_ICON = new Sprite(ElementBase.MECH_ELEMENTS, 18, 0, 18, 18); - public static final Sprite DISCHARGE_SLOT_ICON = new Sprite(ElementBase.MECH_ELEMENTS, 36, 0, 18, 18); - public static final Sprite ENERGY_BAR = new Sprite(ElementBase.MECH_ELEMENTS, 0, 18, 12, 40); - public static final Sprite ENERGY_BAR_BACKGROUND = new Sprite(ElementBase.MECH_ELEMENTS, 12, 18, 14, 42); - public static final Sprite TOP_ENERGY_BAR = new Sprite(ElementBase.MECH_ELEMENTS, 0, 215, 167, 2); - public static final Sprite TOP_ENERGY_BAR_BACKGROUND = new Sprite(ElementBase.MECH_ELEMENTS, 0, 217, 169, 3); - public static final Sprite LEFT_TAB = new Sprite(ElementBase.MECH_ELEMENTS, 0, 86, 23, 26); - public static final Sprite LEFT_TAB_SELECTED = new Sprite(ElementBase.MECH_ELEMENTS, 0, 60, 29, 26); - public static final Sprite CONFIGURE_ICON = new Sprite(ElementBase.MECH_ELEMENTS, 26, 18, 16, 16); - public static final Sprite UPGRADE_ICON = new Sprite(ElementBase.MECH_ELEMENTS, 26, 34, 16, 16); - public static final Sprite ENERGY_ICON = new Sprite(ElementBase.MECH_ELEMENTS, 46, 19, 9, 13); - public static final Sprite ENERGY_ICON_EMPTY = new Sprite(ElementBase.MECH_ELEMENTS, 62, 19, 9, 13); - public static final Sprite JEI_ICON = new Sprite(ElementBase.MECH_ELEMENTS, 42, 34, 16, 16); - public static final Sprite BUTTON_SLOT_NORMAL = new Sprite(ElementBase.MECH_ELEMENTS, 54, 0, 18, 18); - public static final Sprite FAKE_SLOT = new Sprite(ElementBase.MECH_ELEMENTS, 72, 0, 18, 18); - public static final Sprite BUTTON_HOVER_OVERLAY_SLOT_NORMAL = new Sprite(ElementBase.MECH_ELEMENTS, 90, 0, 18, 18); - public static final Sprite SLOT_CONFIG_POPUP = new Sprite(ElementBase.MECH_ELEMENTS, 29, 60, 62, 62); - public static final Sprite.Button EXIT_BUTTON = new Sprite.Button(new Sprite(ElementBase.MECH_ELEMENTS, 26, 122, 13, 13), new Sprite(ElementBase.MECH_ELEMENTS, 39, 122, 13, 13)); - public static final Sprite.CheckBox DARK_CHECK_BOX = new Sprite.CheckBox(new Sprite(ElementBase.MECH_ELEMENTS, 74, 18, 13, 13), new Sprite(ElementBase.MECH_ELEMENTS, 87, 18, 16, 13)); - public static final Sprite.CheckBox LIGHT_CHECK_BOX = new Sprite.CheckBox(new Sprite(ElementBase.MECH_ELEMENTS, 74, 31, 13, 13), new Sprite(ElementBase.MECH_ELEMENTS, 87, 31, 16, 13)); - - public Sprite { - assert x >= 0 && y >= 0 && width >= 0 && height >= 0; - } - - public record Button(Sprite normal, - Sprite hovered) { - } - - public record CheckBox(Sprite normal, - Sprite ticked) { - } -} diff --git a/RebornCore/src/client/java/reborncore/client/mixin/MixinMinecraftClient.java b/RebornCore/src/client/java/reborncore/client/mixin/MixinMinecraftClient.java new file mode 100644 index 000000000..0537d468b --- /dev/null +++ b/RebornCore/src/client/java/reborncore/client/mixin/MixinMinecraftClient.java @@ -0,0 +1,58 @@ +/* + * This file is part of RebornCore, licensed under the MIT License (MIT). + * + * Copyright (c) 2023 TeamReborn + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package reborncore.client.mixin; + +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.RunArgs; +import net.minecraft.client.texture.TextureManager; +import net.minecraft.resource.ReloadableResourceManagerImpl; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import reborncore.client.gui.builder.slot.elements.GuiSpriteAtlasHolder; + +@Mixin(MinecraftClient.class) +public class MixinMinecraftClient { + @Shadow + @Final + private TextureManager textureManager; + @Shadow + @Final + private ReloadableResourceManagerImpl resourceManager; + + @Inject(method = "", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/texture/PaintingManager;(Lnet/minecraft/client/texture/TextureManager;)V")) + private void init(RunArgs args, CallbackInfo ci) { + GuiSpriteAtlasHolder.INSTANCE = new GuiSpriteAtlasHolder(this.textureManager); + this.resourceManager.registerReloader(GuiSpriteAtlasHolder.INSTANCE ); + } + + @Inject(method = "close", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/texture/PaintingManager;close()V")) + private void close(CallbackInfo ci) { + GuiSpriteAtlasHolder.INSTANCE.close(); + } +} diff --git a/RebornCore/src/client/resources/assets/reborncore/atlases/gui.json b/RebornCore/src/client/resources/assets/reborncore/atlases/gui.json new file mode 100644 index 000000000..d382b3869 --- /dev/null +++ b/RebornCore/src/client/resources/assets/reborncore/atlases/gui.json @@ -0,0 +1,9 @@ +{ + "sources": [ + { + "type": "directory", + "source": "gui/sprites", + "prefix": "" + } + ] +} \ No newline at end of file diff --git a/RebornCore/src/client/resources/reborncore.client.mixins.json b/RebornCore/src/client/resources/reborncore.client.mixins.json index e47a98e7c..125fa557a 100644 --- a/RebornCore/src/client/resources/reborncore.client.mixins.json +++ b/RebornCore/src/client/resources/reborncore.client.mixins.json @@ -5,7 +5,8 @@ "client": [ "MixinDebugRenderer", "MixinGameRenderer", - "MixinKeyBinding" + "MixinKeyBinding", + "MixinMinecraftClient" ], "injectors": { "defaultRequire": 1 diff --git a/RebornCore/src/main/resources/assets/reborncore/textures/gui/elements.png b/RebornCore/src/main/resources/assets/reborncore/textures/gui/elements.png deleted file mode 100644 index 658a48dd7..000000000 Binary files a/RebornCore/src/main/resources/assets/reborncore/textures/gui/elements.png and /dev/null differ diff --git a/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/button_hover_overlay_slot_normal.png b/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/button_hover_overlay_slot_normal.png new file mode 100644 index 000000000..c1efa5975 Binary files /dev/null and b/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/button_hover_overlay_slot_normal.png differ diff --git a/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/button_slot_normal.png b/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/button_slot_normal.png new file mode 100644 index 000000000..55a6f6126 Binary files /dev/null and b/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/button_slot_normal.png differ diff --git a/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/charge_slot_icon.png b/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/charge_slot_icon.png new file mode 100644 index 000000000..649ad2c22 Binary files /dev/null and b/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/charge_slot_icon.png differ diff --git a/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/configure_icon.png b/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/configure_icon.png new file mode 100644 index 000000000..6c63c298d Binary files /dev/null and b/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/configure_icon.png differ diff --git a/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/dark_check_box_normal.png b/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/dark_check_box_normal.png new file mode 100644 index 000000000..368a25722 Binary files /dev/null and b/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/dark_check_box_normal.png differ diff --git a/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/dark_check_box_ticked.png b/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/dark_check_box_ticked.png new file mode 100644 index 000000000..184a16b80 Binary files /dev/null and b/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/dark_check_box_ticked.png differ diff --git a/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/discharge_slot_icon.png b/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/discharge_slot_icon.png new file mode 100644 index 000000000..ffb2a1d25 Binary files /dev/null and b/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/discharge_slot_icon.png differ diff --git a/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/energy_bar.png b/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/energy_bar.png new file mode 100644 index 000000000..fc1cc2391 Binary files /dev/null and b/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/energy_bar.png differ diff --git a/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/energy_bar_background.png b/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/energy_bar_background.png new file mode 100644 index 000000000..40420d73e Binary files /dev/null and b/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/energy_bar_background.png differ diff --git a/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/energy_icon.png b/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/energy_icon.png new file mode 100644 index 000000000..5c23ce7b2 Binary files /dev/null and b/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/energy_icon.png differ diff --git a/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/energy_icon_empty.png b/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/energy_icon_empty.png new file mode 100644 index 000000000..6936878c8 Binary files /dev/null and b/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/energy_icon_empty.png differ diff --git a/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/exit_button_hovered.png b/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/exit_button_hovered.png new file mode 100644 index 000000000..90f626613 Binary files /dev/null and b/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/exit_button_hovered.png differ diff --git a/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/exit_button_normal.png b/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/exit_button_normal.png new file mode 100644 index 000000000..a9fdcebda Binary files /dev/null and b/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/exit_button_normal.png differ diff --git a/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/fake_slot.png b/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/fake_slot.png new file mode 100644 index 000000000..d040b464b Binary files /dev/null and b/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/fake_slot.png differ diff --git a/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/jei_icon.png b/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/jei_icon.png new file mode 100644 index 000000000..1d8534704 Binary files /dev/null and b/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/jei_icon.png differ diff --git a/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/left_tab.png b/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/left_tab.png new file mode 100644 index 000000000..67563def9 Binary files /dev/null and b/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/left_tab.png differ diff --git a/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/left_tab_selected.png b/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/left_tab_selected.png new file mode 100644 index 000000000..75d7d2bea Binary files /dev/null and b/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/left_tab_selected.png differ diff --git a/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/light_check_box_normal.png b/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/light_check_box_normal.png new file mode 100644 index 000000000..8c2e7d256 Binary files /dev/null and b/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/light_check_box_normal.png differ diff --git a/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/light_check_box_ticked.png b/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/light_check_box_ticked.png new file mode 100644 index 000000000..8fea10ae1 Binary files /dev/null and b/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/light_check_box_ticked.png differ diff --git a/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/slot_config_popup.png b/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/slot_config_popup.png new file mode 100644 index 000000000..dbe65a566 Binary files /dev/null and b/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/slot_config_popup.png differ diff --git a/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/slot_normal.png b/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/slot_normal.png new file mode 100644 index 000000000..fc75f2f64 Binary files /dev/null and b/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/slot_normal.png differ diff --git a/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/top_energy_bar.png b/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/top_energy_bar.png new file mode 100644 index 000000000..5ae7af029 Binary files /dev/null and b/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/top_energy_bar.png differ diff --git a/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/top_energy_bar_background.png b/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/top_energy_bar_background.png new file mode 100644 index 000000000..4b605e36e Binary files /dev/null and b/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/top_energy_bar_background.png differ diff --git a/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/upgrade_icon.png b/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/upgrade_icon.png new file mode 100644 index 000000000..8748ebd19 Binary files /dev/null and b/RebornCore/src/main/resources/assets/reborncore/textures/gui/sprites/upgrade_icon.png differ