diff options
author | Juuxel <6596629+Juuxel@users.noreply.github.com> | 2020-10-24 14:20:09 +0300 |
---|---|---|
committer | Juuxel <6596629+Juuxel@users.noreply.github.com> | 2020-10-24 14:20:09 +0300 |
commit | d28de77017fc810cd253021470bc7de6f9a96f12 (patch) | |
tree | 76ac08b8a0999009cdf9c84e63662b6368464f3f /src/main/java | |
parent | 6d564aa54cbbda7f3cbc8225f8561e8518009de2 (diff) | |
download | LibGui-d28de77017fc810cd253021470bc7de6f9a96f12.tar.gz LibGui-d28de77017fc810cd253021470bc7de6f9a96f12.tar.bz2 LibGui-d28de77017fc810cd253021470bc7de6f9a96f12.zip |
Add checkstyle to check code format
Diffstat (limited to 'src/main/java')
23 files changed, 243 insertions, 230 deletions
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/ValidatedSlot.java b/src/main/java/io/github/cottonmc/cotton/gui/ValidatedSlot.java index 69acc85..aa6ae36 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/ValidatedSlot.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/ValidatedSlot.java @@ -1,13 +1,14 @@ package io.github.cottonmc.cotton.gui; -import com.google.common.collect.HashMultimap; -import com.google.common.collect.Multimap; -import io.github.cottonmc.cotton.gui.widget.WItemSlot; -import io.github.cottonmc.cotton.gui.impl.access.SlotAccessor; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.inventory.Inventory; import net.minecraft.item.ItemStack; import net.minecraft.screen.slot.Slot; + +import com.google.common.collect.HashMultimap; +import com.google.common.collect.Multimap; +import io.github.cottonmc.cotton.gui.impl.access.SlotAccessor; +import io.github.cottonmc.cotton.gui.widget.WItemSlot; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; 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 e3a61a8..6ae53d0 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 @@ -1,6 +1,5 @@ package io.github.cottonmc.cotton.gui.client; -import io.github.cottonmc.cotton.gui.SyncedGuiDescription; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.screen.ingame.HandledScreen; import net.minecraft.client.render.DiffuseLighting; @@ -9,10 +8,11 @@ import net.minecraft.entity.player.PlayerEntity; import net.minecraft.text.LiteralText; import net.minecraft.text.Style; import net.minecraft.text.Text; -import org.lwjgl.glfw.GLFW; +import io.github.cottonmc.cotton.gui.SyncedGuiDescription; import io.github.cottonmc.cotton.gui.widget.WPanel; import io.github.cottonmc.cotton.gui.widget.WWidget; +import org.lwjgl.glfw.GLFW; import org.lwjgl.opengl.GL11; /** diff --git a/src/main/java/io/github/cottonmc/cotton/gui/client/LibGuiClient.java b/src/main/java/io/github/cottonmc/cotton/gui/client/LibGuiClient.java index 386f5ad..a5fbb2d 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/client/LibGuiClient.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/client/LibGuiClient.java @@ -1,13 +1,14 @@ package io.github.cottonmc.cotton.gui.client; -import blue.endless.jankson.Jankson; -import blue.endless.jankson.JsonElement; -import blue.endless.jankson.JsonObject; -import io.github.cottonmc.jankson.JanksonFactory; import net.fabricmc.api.ClientModInitializer; import net.fabricmc.fabric.api.resource.ResourceManagerHelper; import net.fabricmc.loader.api.FabricLoader; import net.minecraft.resource.ResourceType; + +import blue.endless.jankson.Jankson; +import blue.endless.jankson.JsonElement; +import blue.endless.jankson.JsonObject; +import io.github.cottonmc.jankson.JanksonFactory; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; diff --git a/src/main/java/io/github/cottonmc/cotton/gui/client/NinePatch.java b/src/main/java/io/github/cottonmc/cotton/gui/client/NinePatch.java index c74e2aa..9057739 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/client/NinePatch.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/client/NinePatch.java @@ -56,199 +56,199 @@ import java.util.Properties; */ @Environment(EnvType.CLIENT) public class NinePatch implements BackgroundPainter { - private final Identifier texture; - private final int cornerSize; - private final float cornerUv; - private int topPadding = 0; - private int leftPadding = 0; - private int bottomPadding = 0; - private int rightPadding = 0; - private Mode mode = null; - - /** - * Creates a nine-patch background painter with 4 px corners and a 0.25 corner UV. - * - * @param texture the texture ID - */ - public NinePatch(Identifier texture) { - this(texture, 4, 0.25f); - } - - /** - * Creates a nine-patch background painter. - * - * @param texture the texture ID - * @param cornerSize the size of the corners on the screen - * @param cornerUv the fraction of the corners from the whole texture - */ - public NinePatch(Identifier texture, int cornerSize, float cornerUv) { - this.texture = texture; - this.cornerSize = cornerSize; - this.cornerUv = cornerUv; - } - - public int getTopPadding() { - return topPadding; - } - - public NinePatch setTopPadding(int topPadding) { - this.topPadding = topPadding; - return this; - } - - public int getLeftPadding() { - return leftPadding; - } - - public NinePatch setLeftPadding(int leftPadding) { - this.leftPadding = leftPadding; - return this; - } - - public int getBottomPadding() { - return bottomPadding; - } - - public NinePatch setBottomPadding(int bottomPadding) { - this.bottomPadding = bottomPadding; - return this; - } - - public int getRightPadding() { - return rightPadding; - } - - public NinePatch setRightPadding(int rightPadding) { - this.rightPadding = rightPadding; - return this; - } - - public NinePatch setPadding(int padding) { - this.topPadding = this.leftPadding = this.bottomPadding = this.rightPadding = padding; - return this; - } - - public NinePatch setPadding(int vertical, int horizontal) { - this.topPadding = this.bottomPadding = vertical; - this.leftPadding = this.rightPadding = horizontal; - return this; - } - - public NinePatch setPadding(int topPadding, int leftPadding, int bottomPadding, int rightPadding) { - this.topPadding = topPadding; - this.leftPadding = leftPadding; - this.bottomPadding = bottomPadding; - this.rightPadding = rightPadding; - - return this; - } - - public Identifier getTexture() { - return texture; - } - - public int getCornerSize() { - return cornerSize; - } - - @Nullable - public Mode getMode() { - return mode; - } - - /** - * Sets the {@linkplain Mode mode} of this painter to the specified mode. - * <p>If the {@code mode} is not null, it will override the one specified in the texture metadata. - * A null mode uses the texture metadata. - */ - public NinePatch setMode(@Nullable Mode mode) { - this.mode = mode; - return this; - } - - @Override - public void paintBackground(int left, int top, WWidget panel) { - int width = panel.getWidth() + leftPadding + rightPadding; - int height = panel.getHeight() + topPadding + bottomPadding; - left = left - leftPadding; - top = top - topPadding; - int x1 = left + cornerSize; - int x2 = left + width - cornerSize; - int y1 = top + cornerSize; - int y2 = top + height - cornerSize; - float uv1 = cornerUv; - float uv2 = 1.0f - cornerUv; - Mode mode = this.mode != null ? this.mode : MetadataLoader.INSTANCE.getProperties(texture).getMode(); - - ScreenDrawing.texturedRect(left, top, cornerSize, cornerSize, texture, 0, 0, uv1, uv1, 0xFF_FFFFFF); - ScreenDrawing.texturedRect(x2, top, cornerSize, cornerSize, texture, uv2, 0, 1, uv1, 0xFF_FFFFFF); - ScreenDrawing.texturedRect(left, y2, cornerSize, cornerSize, texture, 0, uv2, uv1, 1, 0xFF_FFFFFF); - ScreenDrawing.texturedRect(x2, y2, cornerSize, cornerSize, texture, uv2, uv2, 1, 1, 0xFF_FFFFFF); - - if (mode == Mode.TILING) { - int tileSize = (int) (cornerSize / cornerUv - 2 * cornerSize); - int widthLeft = width - 2 * cornerSize; - int heightLeft = height - 2 * cornerSize; - int tileCountX = MathHelper.ceil((float) widthLeft / tileSize); - int tileCountY = MathHelper.ceil((float) heightLeft / tileSize); - for (int i = 0; i < tileCountX; i++) { - float px = 1 / 16f; - int tileWidth = Math.min(widthLeft, tileSize); - float uo = (tileSize - tileWidth) * px; // Used to remove unnecessary pixels on the X axis - - ScreenDrawing.texturedRect(x1 + i * tileSize, top, tileWidth, cornerSize, texture, uv1, 0, uv2 - uo, uv1, 0xFF_FFFFFF); - ScreenDrawing.texturedRect(x1 + i * tileSize, y2, tileWidth, cornerSize, texture, uv1, uv2, uv2 - uo, 1, 0xFF_FFFFFF); - - // Reset the height left each time the Y is looped - heightLeft = height - 2 * cornerSize; - - for (int j = 0; j < tileCountY; j++) { - int tileHeight = Math.min(heightLeft, tileSize); - float vo = (tileSize - tileHeight) * px; // Used to remove unnecessary pixels on the Y axis - - ScreenDrawing.texturedRect(left, y1 + j * tileSize, cornerSize, tileHeight, texture, 0, uv1, uv1, uv2 - vo, 0xFF_FFFFFF); - ScreenDrawing.texturedRect(x2, y1 + j * tileSize, cornerSize, tileHeight, texture, uv2, uv1, 1, uv2 - vo, 0xFF_FFFFFF); - - ScreenDrawing.texturedRect(x1 + i * tileSize, y1 + j * tileSize, tileWidth, tileHeight, texture, uv1, uv1, uv2 - uo, uv2 - vo, 0xFF_FFFFFF); - heightLeft -= tileSize; - } - widthLeft -= tileSize; - } - } else { - ScreenDrawing.texturedRect(x1, top, width - 2 * cornerSize, cornerSize, texture, uv1, 0, uv2, uv1, 0xFF_FFFFFF); - ScreenDrawing.texturedRect(left, y1, cornerSize, height - 2 * cornerSize, texture, 0, uv1, uv1, uv2, 0xFF_FFFFFF); - ScreenDrawing.texturedRect(x1, y2, width - 2 * cornerSize, cornerSize, texture, uv1, uv2, uv2, 1, 0xFF_FFFFFF); - ScreenDrawing.texturedRect(x2, y1, cornerSize, height - 2 * cornerSize, texture, uv2, uv1, 1, uv2, 0xFF_FFFFFF); - - ScreenDrawing.texturedRect(x1, y1, width - 2 * cornerSize, height - 2 * cornerSize, texture, uv1, uv1, uv2, uv2, 0xFF_FFFFFF); - } - } - - /** - * The mode of a nine-patch painter defines how it fills the area between the corners. - */ - 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. - */ - TILING; - - @Nullable - static Mode fromString(String str) { - if (str == null) return null; - - if (str.equalsIgnoreCase("stretching")) return STRETCHING; - if (str.equalsIgnoreCase("tiling")) return TILING; - - return null; - } - } + private final Identifier texture; + private final int cornerSize; + private final float cornerUv; + private int topPadding = 0; + private int leftPadding = 0; + private int bottomPadding = 0; + private int rightPadding = 0; + private Mode mode = null; + + /** + * Creates a nine-patch background painter with 4 px corners and a 0.25 corner UV. + * + * @param texture the texture ID + */ + public NinePatch(Identifier texture) { + this(texture, 4, 0.25f); + } + + /** + * Creates a nine-patch background painter. + * + * @param texture the texture ID + * @param cornerSize the size of the corners on the screen + * @param cornerUv the fraction of the corners from the whole texture + */ + public NinePatch(Identifier texture, int cornerSize, float cornerUv) { + this.texture = texture; + this.cornerSize = cornerSize; + this.cornerUv = cornerUv; + } + + public int getTopPadding() { + return topPadding; + } + + public NinePatch setTopPadding(int topPadding) { + this.topPadding = topPadding; + return this; + } + + public int getLeftPadding() { + return leftPadding; + } + + public NinePatch setLeftPadding(int leftPadding) { + this.leftPadding = leftPadding; + return this; + } + + public int getBottomPadding() { + return bottomPadding; + } + + public NinePatch setBottomPadding(int bottomPadding) { + this.bottomPadding = bottomPadding; + return this; + } + + public int getRightPadding() { + return rightPadding; + } + + public NinePatch setRightPadding(int rightPadding) { + this.rightPadding = rightPadding; + return this; + } + + public NinePatch setPadding(int padding) { + this.topPadding = this.leftPadding = this.bottomPadding = this.rightPadding = padding; + return this; + } + + public NinePatch setPadding(int vertical, int horizontal) { + this.topPadding = this.bottomPadding = vertical; + this.leftPadding = this.rightPadding = horizontal; + return this; + } + + public NinePatch setPadding(int topPadding, int leftPadding, int bottomPadding, int rightPadding) { + this.topPadding = topPadding; + this.leftPadding = leftPadding; + this.bottomPadding = bottomPadding; + this.rightPadding = rightPadding; + + return this; + } + + public Identifier getTexture() { + return texture; + } + + public int getCornerSize() { + return cornerSize; + } + + @Nullable + public Mode getMode() { + return mode; + } + + /** + * Sets the {@linkplain Mode mode} of this painter to the specified mode. + * <p>If the {@code mode} is not null, it will override the one specified in the texture metadata. + * A null mode uses the texture metadata. + */ + public NinePatch setMode(@Nullable Mode mode) { + this.mode = mode; + return this; + } + + @Override + public void paintBackground(int left, int top, WWidget panel) { + int width = panel.getWidth() + leftPadding + rightPadding; + int height = panel.getHeight() + topPadding + bottomPadding; + left = left - leftPadding; + top = top - topPadding; + int x1 = left + cornerSize; + int x2 = left + width - cornerSize; + int y1 = top + cornerSize; + int y2 = top + height - cornerSize; + float uv1 = cornerUv; + float uv2 = 1.0f - cornerUv; + Mode mode = this.mode != null ? this.mode : MetadataLoader.INSTANCE.getProperties(texture).getMode(); + + ScreenDrawing.texturedRect(left, top, cornerSize, cornerSize, texture, 0, 0, uv1, uv1, 0xFF_FFFFFF); + ScreenDrawing.texturedRect(x2, top, cornerSize, cornerSize, texture, uv2, 0, 1, uv1, 0xFF_FFFFFF); + ScreenDrawing.texturedRect(left, y2, cornerSize, cornerSize, texture, 0, uv2, uv1, 1, 0xFF_FFFFFF); + ScreenDrawing.texturedRect(x2, y2, cornerSize, cornerSize, texture, uv2, uv2, 1, 1, 0xFF_FFFFFF); + + if (mode == Mode.TILING) { + int tileSize = (int) (cornerSize / cornerUv - 2 * cornerSize); + int widthLeft = width - 2 * cornerSize; + int heightLeft = height - 2 * cornerSize; + int tileCountX = MathHelper.ceil((float) widthLeft / tileSize); + int tileCountY = MathHelper.ceil((float) heightLeft / tileSize); + for (int i = 0; i < tileCountX; i++) { + float px = 1 / 16f; + int tileWidth = Math.min(widthLeft, tileSize); + float uo = (tileSize - tileWidth) * px; // Used to remove unnecessary pixels on the X axis + + ScreenDrawing.texturedRect(x1 + i * tileSize, top, tileWidth, cornerSize, texture, uv1, 0, uv2 - uo, uv1, 0xFF_FFFFFF); + ScreenDrawing.texturedRect(x1 + i * tileSize, y2, tileWidth, cornerSize, texture, uv1, uv2, uv2 - uo, 1, 0xFF_FFFFFF); + + // Reset the height left each time the Y is looped + heightLeft = height - 2 * cornerSize; + + for (int j = 0; j < tileCountY; j++) { + int tileHeight = Math.min(heightLeft, tileSize); + float vo = (tileSize - tileHeight) * px; // Used to remove unnecessary pixels on the Y axis + + ScreenDrawing.texturedRect(left, y1 + j * tileSize, cornerSize, tileHeight, texture, 0, uv1, uv1, uv2 - vo, 0xFF_FFFFFF); + ScreenDrawing.texturedRect(x2, y1 + j * tileSize, cornerSize, tileHeight, texture, uv2, uv1, 1, uv2 - vo, 0xFF_FFFFFF); + + ScreenDrawing.texturedRect(x1 + i * tileSize, y1 + j * tileSize, tileWidth, tileHeight, texture, uv1, uv1, uv2 - uo, uv2 - vo, 0xFF_FFFFFF); + heightLeft -= tileSize; + } + widthLeft -= tileSize; + } + } else { + ScreenDrawing.texturedRect(x1, top, width - 2 * cornerSize, cornerSize, texture, uv1, 0, uv2, uv1, 0xFF_FFFFFF); + ScreenDrawing.texturedRect(left, y1, cornerSize, height - 2 * cornerSize, texture, 0, uv1, uv1, uv2, 0xFF_FFFFFF); + ScreenDrawing.texturedRect(x1, y2, width - 2 * cornerSize, cornerSize, texture, uv1, uv2, uv2, 1, 0xFF_FFFFFF); + ScreenDrawing.texturedRect(x2, y1, cornerSize, height - 2 * cornerSize, texture, uv2, uv1, 1, uv2, 0xFF_FFFFFF); + + ScreenDrawing.texturedRect(x1, y1, width - 2 * cornerSize, height - 2 * cornerSize, texture, uv1, uv1, uv2, uv2, 0xFF_FFFFFF); + } + } + + /** + * The mode of a nine-patch painter defines how it fills the area between the corners. + */ + 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. + */ + TILING; + + @Nullable + static Mode fromString(String str) { + if (str == null) return null; + + if (str.equalsIgnoreCase("stretching")) return STRETCHING; + if (str.equalsIgnoreCase("tiling")) return TILING; + + return null; + } + } public static class TextureProperties { public static final TextureProperties DEFAULT = new TextureProperties(Mode.STRETCHING); diff --git a/src/main/java/io/github/cottonmc/cotton/gui/client/Scissors.java b/src/main/java/io/github/cottonmc/cotton/gui/client/Scissors.java index 4998a05..e7c7e72 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/client/Scissors.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/client/Scissors.java @@ -3,6 +3,7 @@ package io.github.cottonmc.cotton.gui.client; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.client.MinecraftClient; + import org.lwjgl.opengl.GL11; import java.util.ArrayDeque; 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 f382911..f31a046 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 @@ -2,7 +2,6 @@ package io.github.cottonmc.cotton.gui.client; import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.systems.RenderSystem; -import io.github.cottonmc.cotton.gui.widget.data.Texture; import net.minecraft.client.MinecraftClient; import net.minecraft.client.render.BufferBuilder; import net.minecraft.client.render.Tessellator; @@ -10,9 +9,10 @@ import net.minecraft.client.render.VertexFormats; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.text.OrderedText; import net.minecraft.util.Identifier; -import org.lwjgl.opengl.GL11; import io.github.cottonmc.cotton.gui.widget.data.HorizontalAlignment; +import io.github.cottonmc.cotton.gui.widget.data.Texture; +import org.lwjgl.opengl.GL11; /** * {@code ScreenDrawing} contains utility methods for drawing contents on a screen. diff --git a/src/main/java/io/github/cottonmc/cotton/gui/client/modmenu/ModMenuSupport.java b/src/main/java/io/github/cottonmc/cotton/gui/client/modmenu/ModMenuSupport.java index 29ea6bf..e7c7ece 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/client/modmenu/ModMenuSupport.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/client/modmenu/ModMenuSupport.java @@ -1,12 +1,11 @@ package io.github.cottonmc.cotton.gui.client.modmenu; - -import io.github.prospector.modmenu.api.ConfigScreenFactory; -import io.github.prospector.modmenu.api.ModMenuApi; import net.minecraft.text.TranslatableText; import io.github.cottonmc.cotton.gui.client.CottonClientScreen; import io.github.cottonmc.cotton.gui.client.LibGuiClient; +import io.github.prospector.modmenu.api.ConfigScreenFactory; +import io.github.prospector.modmenu.api.ModMenuApi; public class ModMenuSupport implements ModMenuApi { diff --git a/src/main/java/io/github/cottonmc/cotton/gui/impl/access/SlotAccessor.java b/src/main/java/io/github/cottonmc/cotton/gui/impl/access/SlotAccessor.java index 954b4a8..4b4644c 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/impl/access/SlotAccessor.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/impl/access/SlotAccessor.java @@ -1,6 +1,7 @@ package io.github.cottonmc.cotton.gui.impl.access; import net.minecraft.screen.slot.Slot; + import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; diff --git a/src/main/java/io/github/cottonmc/cotton/gui/impl/access/package-info.java b/src/main/java/io/github/cottonmc/cotton/gui/impl/access/package-info.java new file mode 100644 index 0000000..8f391fd --- /dev/null +++ b/src/main/java/io/github/cottonmc/cotton/gui/impl/access/package-info.java @@ -0,0 +1,4 @@ +/** + * Internal implementation classes. + */ +package io.github.cottonmc.cotton.gui.impl.access; diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/WAbstractSlider.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WAbstractSlider.java index 3b9179d..6c422bc 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/widget/WAbstractSlider.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/WAbstractSlider.java @@ -65,8 +65,7 @@ public abstract class WAbstractSlider extends WWidget { @Nullable private IntConsumer draggingFinishedListener = null; protected WAbstractSlider(int min, int max, Axis axis) { - if (max <= min) - throw new IllegalArgumentException("Minimum value must be smaller than the maximum!"); + if (max <= min) throw new IllegalArgumentException("Minimum value must be smaller than the maximum!"); this.min = min; this.max = max; 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 826950c..13cf16b 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 @@ -245,4 +245,4 @@ public class WBar extends WWidget { DOWN, LEFT; } -}
\ No newline at end of file +} diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/WButton.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WButton.java index 6bf65ff..65dde6f 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/widget/WButton.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/WButton.java @@ -77,8 +77,11 @@ public class WButton extends WWidget { public void paint(MatrixStack matrices, int x, int y, int mouseX, int mouseY) { boolean hovered = (mouseX>=0 && mouseY>=0 && mouseX<getWidth() && mouseY<getHeight()); int state = 1; //1=regular. 2=hovered. 0=disabled. - if (!enabled) state = 0; - else if (hovered || isFocused()) state = 2; + if (!enabled) { + state = 0; + } else if (hovered || isFocused()) { + state = 2; + } float px = 1/256f; float buttonLeft = 0 * px; diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/WCardPanel.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WCardPanel.java index dc899ab..3d1da6a 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/widget/WCardPanel.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/WCardPanel.java @@ -1,9 +1,10 @@ package io.github.cottonmc.cotton.gui.widget; -import io.github.cottonmc.cotton.gui.GuiDescription; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; +import io.github.cottonmc.cotton.gui.GuiDescription; + import java.util.ArrayList; import java.util.List; import java.util.NoSuchElementException; diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/WClippedPanel.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WClippedPanel.java index 9a93c7a..6daf600 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/widget/WClippedPanel.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/WClippedPanel.java @@ -1,10 +1,11 @@ package io.github.cottonmc.cotton.gui.widget; -import io.github.cottonmc.cotton.gui.client.Scissors; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.client.util.math.MatrixStack; +import io.github.cottonmc.cotton.gui.client.Scissors; + /** * A panel that is clipped to only render widgets inside its bounds. */ diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/WGridPanel.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WGridPanel.java index 3082389..69aa036 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/widget/WGridPanel.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/WGridPanel.java @@ -62,4 +62,4 @@ public class WGridPanel extends WPanel { expandToFit(w); } -}
\ No newline at end of file +} diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/WItem.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WItem.java index 1269afe..21abe8b 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/widget/WItem.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/WItem.java @@ -1,10 +1,8 @@ package io.github.cottonmc.cotton.gui.widget; -import com.google.common.collect.ImmutableList; import com.mojang.blaze3d.systems.RenderSystem; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; -import net.fabricmc.loader.api.FabricLoader; import net.minecraft.client.MinecraftClient; import net.minecraft.client.render.item.ItemRenderer; import net.minecraft.client.util.math.MatrixStack; @@ -13,6 +11,8 @@ import net.minecraft.item.ItemConvertible; import net.minecraft.item.ItemStack; import net.minecraft.tag.Tag; +import com.google.common.collect.ImmutableList; + import java.util.Collections; import java.util.List; import java.util.Objects; diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/WLabel.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WLabel.java index b3ab678..0bdf81a 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/widget/WLabel.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/WLabel.java @@ -272,4 +272,4 @@ public class WLabel extends WWidget { this.verticalAlignment = align; return this; } -}
\ No newline at end of file +} diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/WPlainPanel.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WPlainPanel.java index aba2da5..d658d1f 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/widget/WPlainPanel.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/WPlainPanel.java @@ -46,4 +46,4 @@ public class WPlainPanel extends WPanel { expandToFit(w); //valid = false; } -}
\ No newline at end of file +} diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/WScrollBar.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WScrollBar.java index 233a90a..8687c52 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/widget/WScrollBar.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/WScrollBar.java @@ -1,12 +1,13 @@ package io.github.cottonmc.cotton.gui.widget; -import io.github.cottonmc.cotton.gui.client.LibGuiClient; -import io.github.cottonmc.cotton.gui.client.ScreenDrawing; -import io.github.cottonmc.cotton.gui.widget.data.Axis; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.client.util.math.MatrixStack; +import io.github.cottonmc.cotton.gui.client.LibGuiClient; +import io.github.cottonmc.cotton.gui.client.ScreenDrawing; +import io.github.cottonmc.cotton.gui.widget.data.Axis; + public class WScrollBar extends WWidget { protected Axis axis = Axis.HORIZONTAL; protected int value; diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/WSprite.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WSprite.java index 9e6f038..632ca6c 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/widget/WSprite.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/WSprite.java @@ -1,12 +1,12 @@ package io.github.cottonmc.cotton.gui.widget; -import io.github.cottonmc.cotton.gui.widget.data.Texture; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.util.Identifier; import io.github.cottonmc.cotton.gui.client.ScreenDrawing; +import io.github.cottonmc.cotton.gui.widget.data.Texture; public class WSprite extends WWidget { protected int currentFrame= 0; diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/WTiledSprite.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WTiledSprite.java index 2b7f3ca..5750636 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/widget/WTiledSprite.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/WTiledSprite.java @@ -1,11 +1,12 @@ package io.github.cottonmc.cotton.gui.widget; -import io.github.cottonmc.cotton.gui.client.ScreenDrawing; -import io.github.cottonmc.cotton.gui.widget.data.Texture; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.util.Identifier; +import io.github.cottonmc.cotton.gui.client.ScreenDrawing; +import io.github.cottonmc.cotton.gui.widget.data.Texture; + /** * A sprite whose texture will be tiled. * 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 42dd6ac..cd3c31b 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 @@ -354,8 +354,7 @@ public class WWidget { TooltipBuilder builder = new TooltipBuilder(); addTooltip(builder); - if (builder.size() == 0) - return; + if (builder.size() == 0) return; Screen screen = MinecraftClient.getInstance().currentScreen; screen.renderOrderedTooltip(matrices, builder.lines, tX+x, tY+y); diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/icon/TextureIcon.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/icon/TextureIcon.java index 1d7dcc9..18cf4c3 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/widget/icon/TextureIcon.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/icon/TextureIcon.java @@ -1,12 +1,13 @@ package io.github.cottonmc.cotton.gui.widget.icon; -import io.github.cottonmc.cotton.gui.client.ScreenDrawing; -import io.github.cottonmc.cotton.gui.widget.data.Texture; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.util.Identifier; +import io.github.cottonmc.cotton.gui.client.ScreenDrawing; +import io.github.cottonmc.cotton.gui.widget.data.Texture; + /** * An icon that draws a texture. * |