diff --git a/src/main/java/codechicken/lib/colour/Colour.java b/src/main/java/codechicken/lib/colour/Colour.java index fa94af40..61b22b05 100644 --- a/src/main/java/codechicken/lib/colour/Colour.java +++ b/src/main/java/codechicken/lib/colour/Colour.java @@ -134,75 +134,75 @@ public Colour set(float[] floats) { return set(floats[0], floats[1], floats[2], floats[3]); } - public Colour r(float r) { + public Colour rF(float r) { this.r = (byte) (255F * r); return this; } - public Colour g(float g) { + public Colour gF(float g) { this.g = (byte) (255F * g); return this; } - public Colour b(float b) { + public Colour bF(float b) { this.b = (byte) (255F * b); return this; } - public Colour a(float a) { + public Colour aF(float a) { this.a = (byte) (255F * a); return this; } - public Colour r(int r) { + public Colour rF(int r) { this.r = (byte) r; return this; } - public Colour g(int g) { + public Colour gF(int g) { this.g = (byte) g; return this; } - public Colour b(int b) { + public Colour bF(int b) { this.b = (byte) b; return this; } - public Colour a(int a) { + public Colour aF(int a) { this.a = (byte) a; return this; } - public float r() { + public float rF() { return r / 255F; } - public float g() { + public float gF() { return g / 255F; } - public float b() { + public float bF() { return b / 255F; } - public float a() { + public float aF() { return a / 255F; } - public float rI() { + public int r() { return r & 0xFF; } - public float gI() { + public int g() { return g & 0xFF; } - public float bI() { + public int b() { return b & 0xFF; } - public float aI() { + public int a() { return a & 0xFF; } diff --git a/src/main/java/codechicken/lib/gui/modular/ModularGui.java b/src/main/java/codechicken/lib/gui/modular/ModularGui.java index 6fcb4e6f..b0a9d527 100644 --- a/src/main/java/codechicken/lib/gui/modular/ModularGui.java +++ b/src/main/java/codechicken/lib/gui/modular/ModularGui.java @@ -9,6 +9,7 @@ import net.covers1624.quack.collection.FastStream; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Font; +import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.network.chat.Component; @@ -204,7 +205,7 @@ public boolean vanillaSlotRendering() { /** * Create a new {@link GuiRender} for the current render call. * - * @param buffers BufferSource can be retried from {@link net.minecraft.client.gui.GuiGraphics} + * @param buffers BufferSource can be retried from {@link GuiGraphics} * @return A new {@link GuiRender} for the current render call. */ public GuiRender createRender(MultiBufferSource.BufferSource buffers) { diff --git a/src/main/java/codechicken/lib/gui/modular/ModularGuiContainer.java b/src/main/java/codechicken/lib/gui/modular/ModularGuiContainer.java index a770f997..0063b6a6 100644 --- a/src/main/java/codechicken/lib/gui/modular/ModularGuiContainer.java +++ b/src/main/java/codechicken/lib/gui/modular/ModularGuiContainer.java @@ -141,13 +141,12 @@ protected void containerTick() { } @Override - public void onClose() { - super.onClose(); + public void removed() { + super.removed(); modularGui.onGuiClose(); } //=== Input Pass-though ===// - //TODO, We probably dont need to call super for most of these, If anyone tries adding vanilla components to these guis its probably going to break. @Override public void mouseMoved(double mouseX, double mouseY) { diff --git a/src/main/java/codechicken/lib/gui/modular/ModularGuiScreen.java b/src/main/java/codechicken/lib/gui/modular/ModularGuiScreen.java index 100f876e..10fd1060 100644 --- a/src/main/java/codechicken/lib/gui/modular/ModularGuiScreen.java +++ b/src/main/java/codechicken/lib/gui/modular/ModularGuiScreen.java @@ -78,13 +78,11 @@ public void tick() { } @Override - public void onClose() { - super.onClose(); + public void removed() { modularGui.onGuiClose(); } //=== Input Pass-though ===// - //TODO, We probably dont need to call super for most of these, If anyone tries adding vanilla components to these guis its probably going to break. @Override public void mouseMoved(double mouseX, double mouseY) { diff --git a/src/main/java/codechicken/lib/gui/modular/elements/GuiColourPicker.java b/src/main/java/codechicken/lib/gui/modular/elements/GuiColourPicker.java index 96f1a117..c4550bae 100644 --- a/src/main/java/codechicken/lib/gui/modular/elements/GuiColourPicker.java +++ b/src/main/java/codechicken/lib/gui/modular/elements/GuiColourPicker.java @@ -65,7 +65,7 @@ public static GuiColourPicker create(GuiParent> guiParent, ColourState colourS slider = makeSlider(background, 0xFFFFFFFF, picker.sliderStateAlpha()) .constrain(TOP, relative(slider.get(BOTTOM), 1)); } else { - colourState.set(colourState.getColour().a(0)); + colourState.set(colourState.getColour().aF(0)); } ColourPreview preview = new ColourPreview(background, () -> hasAlpha ? colourState.get() : (colourState.get() | 0xFF000000)) @@ -200,19 +200,19 @@ public ColourState getState() { } public SliderState sliderStateAlpha() { - return SliderState.forSlider(() -> (double) colourState.getColour().a(), e -> colourState.set(colourState.getColour().a(e.floatValue())), () -> -1D / (Screen.hasShiftDown() ? 16 : 64)); + return SliderState.forSlider(() -> (double) colourState.getColour().aF(), e -> colourState.set(colourState.getColour().aF(e.floatValue())), () -> -1D / (Screen.hasShiftDown() ? 16 : 64)); } public SliderState sliderStateRed() { - return SliderState.forSlider(() -> (double) colourState.getColour().r(), e -> colourState.set(colourState.getColour().r(e.floatValue())), () -> -1D / (Screen.hasShiftDown() ? 16 : 64)); + return SliderState.forSlider(() -> (double) colourState.getColour().rF(), e -> colourState.set(colourState.getColour().rF(e.floatValue())), () -> -1D / (Screen.hasShiftDown() ? 16 : 64)); } public SliderState sliderStateGreen() { - return SliderState.forSlider(() -> (double) colourState.getColour().g(), e -> colourState.set(colourState.getColour().g(e.floatValue())), () -> -1D / (Screen.hasShiftDown() ? 16 : 64)); + return SliderState.forSlider(() -> (double) colourState.getColour().gF(), e -> colourState.set(colourState.getColour().gF(e.floatValue())), () -> -1D / (Screen.hasShiftDown() ? 16 : 64)); } public SliderState sliderStateBlue() { - return SliderState.forSlider(() -> (double) colourState.getColour().b(), e -> colourState.set(colourState.getColour().b(e.floatValue())), () -> -1D / (Screen.hasShiftDown() ? 16 : 64)); + return SliderState.forSlider(() -> (double) colourState.getColour().bF(), e -> colourState.set(colourState.getColour().bF(e.floatValue())), () -> -1D / (Screen.hasShiftDown() ? 16 : 64)); } public TextState getTextState() { @@ -225,32 +225,8 @@ public GuiButton getOkButton() { /** * If cancel button is disabled, ok button will automatically resize. - * */ + */ public GuiButton getCancelButton() { return cancelButton; } -} - - - - - - - - - - - - - - - - - - - - - - - - +} \ No newline at end of file diff --git a/src/main/java/codechicken/lib/gui/modular/elements/GuiDVD.java b/src/main/java/codechicken/lib/gui/modular/elements/GuiDVD.java index fb174d15..a3195c62 100644 --- a/src/main/java/codechicken/lib/gui/modular/elements/GuiDVD.java +++ b/src/main/java/codechicken/lib/gui/modular/elements/GuiDVD.java @@ -93,7 +93,5 @@ public void render(GuiRender render, double mouseX, double mouseY, float partial velocity.y = velocity.y > 0 ? MathHelper.clip(velocity.y, 0.4, 0.6) : MathHelper.clip(velocity.y, -0.4, -0.6); velocity.normalize(); } - -// if (bounces == 2) } } diff --git a/src/main/java/codechicken/lib/gui/modular/elements/GuiElement.java b/src/main/java/codechicken/lib/gui/modular/elements/GuiElement.java index 5f5d6db8..8942e51f 100644 --- a/src/main/java/codechicken/lib/gui/modular/elements/GuiElement.java +++ b/src/main/java/codechicken/lib/gui/modular/elements/GuiElement.java @@ -11,6 +11,7 @@ import net.covers1624.quack.util.SneakyUtils; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Font; +import net.minecraft.client.gui.GuiGraphics; import net.minecraft.network.chat.Component; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -33,7 +34,7 @@ * This is then used to properly layer elements and child elements when they are rendered. *
@@ -229,14 +230,6 @@ public boolean blockMouseEvents() {
return isMouseOver() && isOpaque();
}
- /**
- * @return True if the cursor is within the bounds of this element.
- */
- @Deprecated(forRemoval = true) //use #isMouseOver()
- public boolean isMouseOver(double mouseX, double mouseY) {
- return isMouseOver;//GuiRender.isInRect(xMin(), yMin(), xSize(), ySize(), mouseX, mouseY) && !blockMouseOver(this, mouseX, mouseY);
- }
-
/**
* @return True if the cursor is within the bounds of this element, and there is no opaque element above this one obstructing the cursor.
*/
@@ -265,14 +258,6 @@ public int hoverTime() {
return hoverTime;
}
- /**
- * Note, Due to this using hoverTime, there may be a 1 tick delay in the updating of this value.
- */
- @Deprecated(forRemoval = true) //use #isMouseOver()
- public boolean hovered() {
- return hoverTime > 0;
- }
-
@Override
public String toString() {
return getClass().getSimpleName() + "{" +
diff --git a/src/main/java/codechicken/lib/gui/modular/lib/GuiProvider.java b/src/main/java/codechicken/lib/gui/modular/lib/GuiProvider.java
index fe7c8fa2..32dbcbb5 100644
--- a/src/main/java/codechicken/lib/gui/modular/lib/GuiProvider.java
+++ b/src/main/java/codechicken/lib/gui/modular/lib/GuiProvider.java
@@ -2,10 +2,11 @@
import codechicken.lib.gui.modular.ModularGui;
import codechicken.lib.gui.modular.elements.GuiElement;
+import codechicken.lib.gui.modular.lib.container.ContainerGuiProvider;
/**
* This interface is used to build modular gui Screens.
- * For modular gui container screens use {@link codechicken.lib.gui.modular.lib.container.ContainerGuiProvider}
+ * For modular gui container screens use {@link ContainerGuiProvider}
*
* Created by brandon3055 on 19/08/2023
*/
diff --git a/src/main/java/codechicken/lib/gui/modular/lib/ScissorHandler.java b/src/main/java/codechicken/lib/gui/modular/lib/ScissorHandler.java
index e84e17f2..06952dec 100644
--- a/src/main/java/codechicken/lib/gui/modular/lib/ScissorHandler.java
+++ b/src/main/java/codechicken/lib/gui/modular/lib/ScissorHandler.java
@@ -30,7 +30,7 @@ public void pushGuiScissor(double x, double y, double width, double height) {
public void pushScissor(int x, int y, int width, int height) {
int xMax = x + width;
int yMax = y + height;
- stack.addLast(new ScissorState(x, y, xMax, yMax, stack.peekLast()).apply());
+ stack.addLast(ScissorState.createState(x, y, xMax, yMax, stack.peekLast()).apply());
}
public void popScissor() {
@@ -46,36 +46,30 @@ public void popScissor() {
}
}
- private static class ScissorState {
- private int x;
- private int y;
- private int xMax;
- private int yMax;
+ private record ScissorState(int x, int y, int xMax, int yMax) {
- private ScissorState(int x, int y, int xMax, int yMax, ScissorState prevState) {
+ private ScissorState apply() {
+ RenderSystem.enableScissor(x, y, xMax - x, yMax - y);
+ return this;
+ }
+
+ private static ScissorState createState(int newX, int newY, int newXMax, int newYMax, ScissorState prevState) {
if (prevState != null) {
- this.x = Math.max(prevState.x, x);
- this.y = Math.max(prevState.y, y);
- this.xMax = Math.min(prevState.xMax, xMax);
- this.yMax = Math.min(prevState.yMax, yMax);
+ int x = Math.max(prevState.x, newX);
+ int y = Math.max(prevState.y, newY);
+ int xMax = Math.min(prevState.xMax, newXMax);
+ int yMax = Math.min(prevState.yMax, newYMax);
Minecraft mc = Minecraft.getInstance();
- if (this.x < 0) this.x = 0;
- if (this.y < 0) this.y = 0;
- if (this.xMax > mc.getWindow().getScreenWidth()) this.xMax = mc.getWindow().getScreenWidth();
- if (this.yMax > mc.getWindow().getScreenHeight()) this.yMax = mc.getWindow().getScreenHeight();
- if (this.xMax < this.x) this.xMax = this.x;
- if (this.yMax < this.y) this.yMax = this.y;
+ if (x < 0) x = 0;
+ if (y < 0) y = 0;
+ if (xMax > mc.getWindow().getScreenWidth()) xMax = mc.getWindow().getScreenWidth();
+ if (yMax > mc.getWindow().getScreenHeight()) yMax = mc.getWindow().getScreenHeight();
+ if (xMax < x) xMax = x;
+ if (yMax < y) yMax = y;
+ return new ScissorState(x, y, xMax, yMax);
} else {
- this.x = x;
- this.y = y;
- this.xMax = xMax;
- this.yMax = yMax;
+ return new ScissorState(newX, newY, newXMax, newYMax);
}
}
-
- private ScissorState apply() {
- RenderSystem.enableScissor(x, y, xMax - x, yMax - y);
- return this;
- }
}
}
diff --git a/src/main/java/codechicken/lib/gui/modular/lib/container/ContainerGuiProvider.java b/src/main/java/codechicken/lib/gui/modular/lib/container/ContainerGuiProvider.java
index b8c105cc..92282ee8 100644
--- a/src/main/java/codechicken/lib/gui/modular/lib/container/ContainerGuiProvider.java
+++ b/src/main/java/codechicken/lib/gui/modular/lib/container/ContainerGuiProvider.java
@@ -1,6 +1,7 @@
package codechicken.lib.gui.modular.lib.container;
import codechicken.lib.gui.modular.ModularGui;
+import codechicken.lib.gui.modular.ModularGuiContainer;
import codechicken.lib.gui.modular.lib.GuiProvider;
import net.minecraft.client.gui.screens.inventory.MenuAccess;
import net.minecraft.world.inventory.AbstractContainerMenu;
@@ -26,7 +27,7 @@ public final void buildGui(ModularGui gui) {
* The given menu accessor should always be the parent screen unless your using some custom modular gui implementation.
*
* @param gui The modular gui instance.
- * @param screenAccess The screen access (This will be a gui class that extends {@link codechicken.lib.gui.modular.ModularGuiContainer}
+ * @param screenAccess The screen access (This will be a gui class that extends {@link ModularGuiContainer}
*/
public abstract void buildGui(ModularGui gui, ContainerScreenAccess