diff options
8 files changed, 60 insertions, 27 deletions
diff --git a/gradle.properties b/gradle.properties index 632492a..2586ca0 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,15 +3,15 @@ org.gradle.jvmargs=-Xmx1G # Fabric Properties # check these on https://fabricmc.net/use - minecraft_version=1.15.1 - yarn_mappings=1.15.1+build.37 - loader_version=0.7.4+build.177 + minecraft_version=1.15.2 + yarn_mappings=1.15.2+build.2 + loader_version=0.7.5+build.178 # Mod Properties - mod_version = 1.4.0 + mod_version = 1.5.0 maven_group = io.github.cottonmc archives_base_name = LibGui # Dependencies - fabric_version=0.4.28+build.288-1.15 + fabric_version=0.4.29+build.290-1.15 jankson_version=2.0.1+j1.2.0 diff --git a/src/main/java/io/github/cottonmc/cotton/gui/CottonCraftingController.java b/src/main/java/io/github/cottonmc/cotton/gui/CottonCraftingController.java index f3a23c6..54038ec 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/CottonCraftingController.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/CottonCraftingController.java @@ -99,8 +99,8 @@ public class CottonCraftingController extends CraftingContainer<Inventory> imple return ItemStack.EMPTY; } - if (slotNumber>=this.slotList.size()) return ItemStack.EMPTY; - Slot slot = this.slotList.get(slotNumber); + if (slotNumber>=this.slots.size()) return ItemStack.EMPTY; + Slot slot = this.slots.get(slotNumber); if (slot == null || !slot.canTakeItems(player)) { return ItemStack.EMPTY; } @@ -179,7 +179,7 @@ public class CottonCraftingController extends CraftingContainer<Inventory> imple private boolean insertItem(ItemStack toInsert, Inventory inventory, boolean walkBackwards) { //Make a unified list of slots *only from this inventory* ArrayList<Slot> inventorySlots = new ArrayList<>(); - for(Slot slot : slotList) { + for(Slot slot : slots) { if (slot.inventory==inventory) inventorySlots.add(slot); } if (inventorySlots.isEmpty()) return false; @@ -229,7 +229,7 @@ public class CottonCraftingController extends CraftingContainer<Inventory> imple boolean swapToStorage = true; boolean inserted = false; - for(Slot slot : slotList) { + for(Slot slot : slots) { if (slot.inventory==inventory && slot instanceof ValidatedSlot) { int index = ((ValidatedSlot)slot).getInventoryIndex(); if (PlayerInventory.isValidHotbarIndex(index)) { diff --git a/src/main/java/io/github/cottonmc/cotton/gui/client/BackgroundPainter.java b/src/main/java/io/github/cottonmc/cotton/gui/client/BackgroundPainter.java index 18325c3..65cf95f 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/client/BackgroundPainter.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/client/BackgroundPainter.java @@ -5,6 +5,10 @@ import io.github.cottonmc.cotton.gui.widget.WWidget; import net.minecraft.util.Identifier; import net.minecraft.util.math.MathHelper; +/** + * Background painters are used to paint the background of a widget. + * The background painter instance of a widget can be changed to customize the look of a widget. + */ public interface BackgroundPainter { /** * Paint the specified panel to the screen. @@ -13,13 +17,20 @@ public interface BackgroundPainter { * @param panel The panel being painted */ public void paintBackground(int left, int top, WWidget panel); - - - + + + /** + * The {@code VANILLA} background painter draws a vanilla-like gui panel using {@link ScreenDrawing#drawGuiPanel(int, int, int, int)}. + * + * <p>This background painter applies a padding of 8 pixels to all sides around the widget. + */ public static BackgroundPainter VANILLA = (left, top, panel) -> { ScreenDrawing.drawGuiPanel(left-8, top-8, panel.getWidth()+16, panel.getHeight()+16); }; + /** + * The {@code SLOT} background painter draws item slots or slot-like widgets. + */ public static BackgroundPainter SLOT = (left, top, panel) -> { if (!(panel instanceof WItemSlot)) { ScreenDrawing.drawBeveledPanel(left-1, top-1, panel.getWidth()+2, panel.getHeight()+2, 0xB8000000, 0x4C000000, 0xB8FFFFFF); @@ -42,13 +53,27 @@ public interface BackgroundPainter { } } }; - + + /** + * Creates a colorful gui panel painter. This painter paints the panel using the specified color. + * + * @param panelColor the panel background color + * @return a colorful gui panel painter + * @see ScreenDrawing#drawGuiPanel(int, int, int, int, int) + */ public static BackgroundPainter createColorful(int panelColor) { return (left, top, panel) -> { ScreenDrawing.drawGuiPanel(left-8, top-8, panel.getWidth()+16, panel.getHeight()+16, panelColor); }; } - + + /** + * Creates a colorful gui panel painter that has a custom contrast between the shadows and highlights. + * + * @param panelColor the panel background color + * @param contrast the contrast between the shadows and highlights + * @return a colorful gui panel painter + */ public static BackgroundPainter createColorful(int panelColor, float contrast) { return (left, top, panel) -> { int shadowColor = ScreenDrawing.multiplyColor(panelColor, 1.0f - contrast); @@ -59,7 +84,9 @@ public interface BackgroundPainter { } /** - * Utility method to call {@link NinePatch#NinePatch(Identifier)}. + * Creates a new nine-patch background painter. + * + * <p>This method is equivalent to {@code new NinePatch(texture)}. * * @param texture the background painter texture * @return a new nine-patch background painter @@ -69,8 +96,9 @@ public interface BackgroundPainter { } /** - * Utility method to call {@link NinePatch#NinePatch(Identifier)} - * and set the padding of the nine-patch painter. + * Creates a new nine-patch background painter with a custom padding. + * + * <p>This method is equivalent to {@code new NinePatch(texture).setPadding(padding)}. * * @param texture the background painter texture * @param padding the padding of the painter @@ -100,7 +128,7 @@ public interface BackgroundPainter { * * <p>Nine-patch textures are separated into nine sections: four corners, four edges and a center part. * The edges and the center are either tiled or stretched, depending on the {@linkplain BackgroundPainter.NinePatch.Mode mode}, - * to fill the area between the corners. + * to fill the area between the corners. The default mode is {@link BackgroundPainter.NinePatch.Mode#TILING}. * * <p>{@code NinePatch} painters have a customizable padding that can be applied. * For example, a GUI panel for a container block might have a padding of 8 pixels, like {@link BackgroundPainter#VANILLA}. @@ -215,11 +243,17 @@ public interface BackgroundPainter { return this; } + /** + * Sets the {@linkplain Mode mode} of this painter to {@link Mode#STRETCHING}. + */ public NinePatch stretch() { this.mode = Mode.STRETCHING; return this; } + /** + * Sets the {@linkplain Mode mode} of this painter to {@link Mode#TILING}. + */ public NinePatch tile() { this.mode = Mode.TILING; return this; @@ -288,12 +322,12 @@ public interface BackgroundPainter { public enum Mode { /** * The texture is stretched to fill the edges and the center. - * This is the default mode. */ STRETCHING, /** * The texture is tiled to fill the edges and the center. + * This is the default mode. */ TILING; } diff --git a/src/main/java/io/github/cottonmc/cotton/gui/client/CottonInventoryScreen.java b/src/main/java/io/github/cottonmc/cotton/gui/client/CottonInventoryScreen.java index ed494dc..56818d7 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/client/CottonInventoryScreen.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/client/CottonInventoryScreen.java @@ -7,12 +7,12 @@ import io.github.cottonmc.cotton.gui.CottonCraftingController; import io.github.cottonmc.cotton.gui.widget.WPanel; import io.github.cottonmc.cotton.gui.widget.WWidget; import net.minecraft.client.MinecraftClient; -import net.minecraft.client.gui.screen.ingame.AbstractContainerScreen; +import net.minecraft.client.gui.screen.ingame.ContainerScreen; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.text.LiteralText; import net.minecraft.text.Text; -public class CottonInventoryScreen<T extends CottonCraftingController> extends AbstractContainerScreen<T> implements TextHoverRendererScreen { +public class CottonInventoryScreen<T extends CottonCraftingController> extends ContainerScreen<T> implements TextHoverRendererScreen { protected CottonCraftingController description; public static final int PADDING = 8; protected WWidget lastResponder = null; diff --git a/src/main/java/io/github/cottonmc/cotton/gui/client/ScreenDrawing.java b/src/main/java/io/github/cottonmc/cotton/gui/client/ScreenDrawing.java index 26cff28..6caadcd 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/client/ScreenDrawing.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/client/ScreenDrawing.java @@ -13,6 +13,9 @@ import net.minecraft.client.render.Tessellator; import net.minecraft.client.render.VertexFormats; import net.minecraft.util.Identifier; +/** + * {@code ScreenDrawing} contains utility methods for drawing contents on a screen. + */ public class ScreenDrawing { private ScreenDrawing() {} diff --git a/src/main/java/io/github/cottonmc/cotton/gui/client/modmenu/WKirbSprite.java b/src/main/java/io/github/cottonmc/cotton/gui/client/modmenu/WKirbSprite.java index 1428c1b..52df46c 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/client/modmenu/WKirbSprite.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/client/modmenu/WKirbSprite.java @@ -27,10 +27,6 @@ public class WKirbSprite extends WWidget { private int frameTime = 300; private long lastFrame; - /** - * Create a new sprite with a single image. - * @param image The location of the image to display. - */ public WKirbSprite() { state = (LibGuiClient.config.darkMode) ? State.ASLEEP : State.AWAKE; } diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/WBar.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WBar.java index 0311a73..3b634b4 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/widget/WBar.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/WBar.java @@ -154,7 +154,6 @@ public class WBar extends WWidget { * Creates a WBar that has a constant maximum-value instead of getting the maximum from a field. * @param bg the background image to use for the bar * @param bar the foreground image that represents the filled bar - * @param properties the PropertyDelegate to pull bar values from * @param field the field index for bar values * @param maxValue the constant maximum value for the bar * @param dir the direction the bar should grow towards diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/WWidget.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WWidget.java index 062c560..a1957af 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/widget/WWidget.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/WWidget.java @@ -80,6 +80,8 @@ public class WWidget { /** * Notifies this widget that the mouse has been moved while pressed and inside its bounds. * + * <p>The default implementation calls {@link #onMouseDrag(int, int, int)} for backwards compatibility. + * * @param x The X coordinate of the event, in widget-space (0 is the left edge of this widget) * @param y The Y coordinate of the event, in widget-space (0 is the top edge of this widget) * @param button The mouse button that was used. Button numbering is consistent with LWJGL Mouse (0=left, 1=right, 2=mousewheel click) @@ -87,7 +89,6 @@ public class WWidget { * @param deltaY The amount of dragging on the Y axis * * @since 1.5.0 - * @implSpec The default implementation calls {@link #onMouseDrag(int, int, int)}. */ public void onMouseDrag(int x, int y, int button, double deltaX, double deltaY) { onMouseDrag(x, y, button); |