Move some gui elements to sprites
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<CheckBoxElement> ticked;
|
||||
private final Runnable onChange;
|
||||
private final Sprite.CheckBox checkBoxSprite;
|
||||
private final GuiSprites.CheckBox checkBoxSprite;
|
||||
|
||||
public CheckBoxElement(Text label, int x, int y,
|
||||
Predicate<CheckBoxElement> 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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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(),
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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) {
|
||||
}
|
||||
}
|
|
@ -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<ElementBase> elements = new ArrayList<>();
|
||||
|
||||
public ParentElement(int x, int y, Sprite sprite) {
|
||||
public ParentElement(int x, int y, SpriteIdentifier sprite) {
|
||||
super(x, y, sprite);
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
}
|
||||
}
|
|
@ -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 = "<init>", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/texture/PaintingManager;<init>(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();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"sources": [
|
||||
{
|
||||
"type": "directory",
|
||||
"source": "gui/sprites",
|
||||
"prefix": ""
|
||||
}
|
||||
]
|
||||
}
|
|
@ -5,7 +5,8 @@
|
|||
"client": [
|
||||
"MixinDebugRenderer",
|
||||
"MixinGameRenderer",
|
||||
"MixinKeyBinding"
|
||||
"MixinKeyBinding",
|
||||
"MixinMinecraftClient"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
|
|
Before Width: | Height: | Size: 12 KiB |
After Width: | Height: | Size: 116 B |
After Width: | Height: | Size: 99 B |
After Width: | Height: | Size: 281 B |
After Width: | Height: | Size: 397 B |
After Width: | Height: | Size: 101 B |
After Width: | Height: | Size: 169 B |
After Width: | Height: | Size: 294 B |
After Width: | Height: | Size: 845 B |
After Width: | Height: | Size: 113 B |
After Width: | Height: | Size: 219 B |
After Width: | Height: | Size: 237 B |
After Width: | Height: | Size: 155 B |
After Width: | Height: | Size: 135 B |
After Width: | Height: | Size: 103 B |
After Width: | Height: | Size: 383 B |
After Width: | Height: | Size: 139 B |
After Width: | Height: | Size: 144 B |
After Width: | Height: | Size: 100 B |
After Width: | Height: | Size: 166 B |
After Width: | Height: | Size: 350 B |
After Width: | Height: | Size: 100 B |
After Width: | Height: | Size: 749 B |
After Width: | Height: | Size: 483 B |
After Width: | Height: | Size: 436 B |