aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.editorconfig1
-rw-r--r--GuiTest/src/main/java/io/github/cottonmc/test/ImplementedInventory.java377
-rw-r--r--GuiTest/src/main/java/io/github/cottonmc/test/client/WHudTest.java1
-rw-r--r--build.gradle11
-rw-r--r--checkstyle.suppressions.xml8
-rw-r--r--checkstyle.xml10
-rw-r--r--javadoc/build.gradle4
7 files changed, 218 insertions, 194 deletions
diff --git a/.editorconfig b/.editorconfig
index 73c5d15..c3db1ed 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -8,6 +8,7 @@ insert_final_newline = true
[*.java]
ij_java_imports_layout = com.mojang.**,net.fabricmc.**,net.minecraft.**,|,*,|,javax.**,java.**,|,$*
+ij_java_layout_static_imports_separately = false
ij_java_class_count_to_use_import_on_demand = 1000
# This seems to be needed so that IDEA properly uses tabs in json files.
diff --git a/GuiTest/src/main/java/io/github/cottonmc/test/ImplementedInventory.java b/GuiTest/src/main/java/io/github/cottonmc/test/ImplementedInventory.java
index d8ba3f3..a1d3911 100644
--- a/GuiTest/src/main/java/io/github/cottonmc/test/ImplementedInventory.java
+++ b/GuiTest/src/main/java/io/github/cottonmc/test/ImplementedInventory.java
@@ -17,196 +17,197 @@ import java.util.List;
* Use {@link Inventories#readNbt(net.minecraft.nbt.NbtCompound, DefaultedList)} and {@link Inventories#writeNbt(net.minecraft.nbt.NbtCompound, DefaultedList)}
* on {@linkplain #getItems() the item list}.
*
- * License: <a href="https://creativecommons.org/publicdomain/zero/1.0/">CC0</a>
+ * <p>License: <a href="https://creativecommons.org/publicdomain/zero/1.0/">CC0</a>
+ *
* @author Juuz
*/
@FunctionalInterface
public interface ImplementedInventory extends SidedInventory {
- /**
- * Gets the item list of this inventory.
- * Must return the same instance every time it's called.
- *
- * @return the item list
- */
- DefaultedList<ItemStack> getItems();
-
- // Creation
-
- /**
- * Creates an inventory from the item list.
- *
- * @param items the item list
- * @return a new inventory
- */
- static ImplementedInventory of(DefaultedList<ItemStack> items) {
- return () -> items;
- }
-
- /**
- * Creates a new inventory with the size.
- *
- * @param size the inventory size
- * @return a new inventory
- */
- static ImplementedInventory ofSize(int size) {
- return of(DefaultedList.ofSize(size, ItemStack.EMPTY));
- }
-
- // SidedInventory
-
- /**
- * Gets the available slots to automation on the side.
- *
- * <p>The default implementation returns an array of all slots.
- *
- * @param side the side
- * @return the available slots
- */
- @Override
- default int[] getAvailableSlots(Direction side) {
- int[] result = new int[getItems().size()];
- for (int i = 0; i < result.length; i++) {
- result[i] = i;
- }
-
- return result;
- }
-
- /**
- * Returns true if the stack can be inserted in the slot at the side.
- *
- * <p>The default implementation returns true.
- *
- * @param slot the slot
- * @param stack the stack
- * @param side the side
- * @return true if the stack can be inserted
- */
- @Override
- default boolean canInsert(int slot, ItemStack stack, Direction side) {
- return true;
- }
-
- /**
- * Returns true if the stack can be extracted from the slot at the side.
- *
- * <p>The default implementation returns true.
- *
- * @param slot the slot
- * @param stack the stack
- * @param side the side
- * @return true if the stack can be extracted
- */
- @Override
- default boolean canExtract(int slot, ItemStack stack, Direction side) {
- return true;
- }
-
- // Inventory
-
- /**
- * Returns the inventory size.
- *
- * <p>The default implementation returns the size of {@link #getItems()}.
- *
- * @return the inventory size
- */
- @Override
- default int size() {
- return getItems().size();
- }
-
- /**
- * @return true if this inventory has only empty stacks, false otherwise
- */
- @Override
- default boolean isEmpty() {
- for (int i = 0; i < size(); i++) {
- ItemStack stack = getStack(i);
- if (!stack.isEmpty()) {
- return false;
- }
- }
-
- return true;
- }
-
- /**
- * Gets the item in the slot.
- *
- * @param slot the slot
- * @return the item in the slot
- */
- @Override
- default ItemStack getStack(int slot) {
- return getItems().get(slot);
- }
-
- /**
- * Takes a stack of the size from the slot.
- *
- * <p>(default implementation) If there are less items in the slot than what are requested,
- * takes all items in that slot.
- *
- * @param slot the slot
- * @param count the item count
- * @return a stack
- */
- @Override
- default ItemStack removeStack(int slot, int count) {
- ItemStack result = Inventories.splitStack(getItems(), slot, count);
- if (!result.isEmpty()) {
- markDirty();
- }
-
- return result;
- }
-
- /**
- * Removes the current stack in the {@code slot} and returns it.
- *
- * <p>The default implementation uses {@link Inventories#removeStack(List, int)}
- *
- * @param slot the slot
- * @return the removed stack
- */
- @Override
- default ItemStack removeStack(int slot) {
- return Inventories.removeStack(getItems(), slot);
- }
-
- /**
- * Replaces the current stack in the {@code slot} with the provided stack.
- *
- * <p>If the stack is too big for this inventory ({@link Inventory#getMaxCountPerStack()} ()}),
- * it gets resized to this inventory's maximum amount.
- *
- * @param slot the slot
- * @param stack the stack
- */
- @Override
- default void setStack(int slot, ItemStack stack) {
- getItems().set(slot, stack);
- if (stack.getCount() > getMaxCountPerStack()) {
- stack.setCount(getMaxCountPerStack());
- }
- }
-
- /**
- * Clears {@linkplain #getItems() the item list}}.
- */
- @Override
- default void clear() {
- getItems().clear();
- }
-
- @Override
- default void markDirty() {
- // Override if you want behavior.
- }
-
- @Override
- default boolean canPlayerUse(PlayerEntity player) {
- return true;
- }
+ /**
+ * Gets the item list of this inventory.
+ * Must return the same instance every time it's called.
+ *
+ * @return the item list
+ */
+ DefaultedList<ItemStack> getItems();
+
+ // Creation
+
+ /**
+ * Creates an inventory from the item list.
+ *
+ * @param items the item list
+ * @return a new inventory
+ */
+ static ImplementedInventory of(DefaultedList<ItemStack> items) {
+ return () -> items;
+ }
+
+ /**
+ * Creates a new inventory with the size.
+ *
+ * @param size the inventory size
+ * @return a new inventory
+ */
+ static ImplementedInventory ofSize(int size) {
+ return of(DefaultedList.ofSize(size, ItemStack.EMPTY));
+ }
+
+ // SidedInventory
+
+ /**
+ * Gets the available slots to automation on the side.
+ *
+ * <p>The default implementation returns an array of all slots.
+ *
+ * @param side the side
+ * @return the available slots
+ */
+ @Override
+ default int[] getAvailableSlots(Direction side) {
+ int[] result = new int[getItems().size()];
+ for (int i = 0; i < result.length; i++) {
+ result[i] = i;
+ }
+
+ return result;
+ }
+
+ /**
+ * Returns true if the stack can be inserted in the slot at the side.
+ *
+ * <p>The default implementation returns true.
+ *
+ * @param slot the slot
+ * @param stack the stack
+ * @param side the side
+ * @return true if the stack can be inserted
+ */
+ @Override
+ default boolean canInsert(int slot, ItemStack stack, Direction side) {
+ return true;
+ }
+
+ /**
+ * Returns true if the stack can be extracted from the slot at the side.
+ *
+ * <p>The default implementation returns true.
+ *
+ * @param slot the slot
+ * @param stack the stack
+ * @param side the side
+ * @return true if the stack can be extracted
+ */
+ @Override
+ default boolean canExtract(int slot, ItemStack stack, Direction side) {
+ return true;
+ }
+
+ // Inventory
+
+ /**
+ * Returns the inventory size.
+ *
+ * <p>The default implementation returns the size of {@link #getItems()}.
+ *
+ * @return the inventory size
+ */
+ @Override
+ default int size() {
+ return getItems().size();
+ }
+
+ /**
+ * @return true if this inventory has only empty stacks, false otherwise
+ */
+ @Override
+ default boolean isEmpty() {
+ for (int i = 0; i < size(); i++) {
+ ItemStack stack = getStack(i);
+ if (!stack.isEmpty()) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ /**
+ * Gets the item in the slot.
+ *
+ * @param slot the slot
+ * @return the item in the slot
+ */
+ @Override
+ default ItemStack getStack(int slot) {
+ return getItems().get(slot);
+ }
+
+ /**
+ * Takes a stack of the size from the slot.
+ *
+ * <p>(default implementation) If there are less items in the slot than what are requested,
+ * takes all items in that slot.
+ *
+ * @param slot the slot
+ * @param count the item count
+ * @return a stack
+ */
+ @Override
+ default ItemStack removeStack(int slot, int count) {
+ ItemStack result = Inventories.splitStack(getItems(), slot, count);
+ if (!result.isEmpty()) {
+ markDirty();
+ }
+
+ return result;
+ }
+
+ /**
+ * Removes the current stack in the {@code slot} and returns it.
+ *
+ * <p>The default implementation uses {@link Inventories#removeStack(List, int)}
+ *
+ * @param slot the slot
+ * @return the removed stack
+ */
+ @Override
+ default ItemStack removeStack(int slot) {
+ return Inventories.removeStack(getItems(), slot);
+ }
+
+ /**
+ * Replaces the current stack in the {@code slot} with the provided stack.
+ *
+ * <p>If the stack is too big for this inventory ({@link Inventory#getMaxCountPerStack()} ()}),
+ * it gets resized to this inventory's maximum amount.
+ *
+ * @param slot the slot
+ * @param stack the stack
+ */
+ @Override
+ default void setStack(int slot, ItemStack stack) {
+ getItems().set(slot, stack);
+ if (stack.getCount() > getMaxCountPerStack()) {
+ stack.setCount(getMaxCountPerStack());
+ }
+ }
+
+ /**
+ * Clears {@linkplain #getItems() the item list}}.
+ */
+ @Override
+ default void clear() {
+ getItems().clear();
+ }
+
+ @Override
+ default void markDirty() {
+ // Override if you want behavior.
+ }
+
+ @Override
+ default boolean canPlayerUse(PlayerEntity player) {
+ return true;
+ }
}
diff --git a/GuiTest/src/main/java/io/github/cottonmc/test/client/WHudTest.java b/GuiTest/src/main/java/io/github/cottonmc/test/client/WHudTest.java
index 41d566d..98f4d0f 100644
--- a/GuiTest/src/main/java/io/github/cottonmc/test/client/WHudTest.java
+++ b/GuiTest/src/main/java/io/github/cottonmc/test/client/WHudTest.java
@@ -2,7 +2,6 @@ package io.github.cottonmc.test.client;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
-
import net.minecraft.client.util.math.MatrixStack;
import io.github.cottonmc.cotton.gui.client.ScreenDrawing;
diff --git a/build.gradle b/build.gradle
index 7e1585d..38d2974 100644
--- a/build.gradle
+++ b/build.gradle
@@ -107,9 +107,14 @@ jar {
from "CREDITS.txt", "LICENSE"
}
-checkstyle {
- configFile = file('checkstyle.xml')
- toolVersion = '10.9.2'
+allprojects {
+ apply plugin: 'checkstyle'
+
+ checkstyle {
+ configFile = rootProject.file('checkstyle.xml')
+ configProperties = [suppressions: rootProject.file('checkstyle.suppressions.xml').absolutePath]
+ toolVersion = '10.9.2'
+ }
}
evaluationDependsOn(':javadoc')
diff --git a/checkstyle.suppressions.xml b/checkstyle.suppressions.xml
new file mode 100644
index 0000000..d002048
--- /dev/null
+++ b/checkstyle.suppressions.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0"?>
+<!DOCTYPE suppressions PUBLIC
+ "-//Checkstyle//DTD SuppressionFilter Configuration 1.2//EN"
+ "https://checkstyle.org/dtds/suppressions_1_2.dtd">
+<suppressions>
+ <suppress checks="JavadocPackage"
+ files="io[\\/]github[\\/]cottonmc[\\/](test|cotton[\\/]gui[\\/]jd)"/>
+</suppressions>
diff --git a/checkstyle.xml b/checkstyle.xml
index ba8120f..6d56d5d 100644
--- a/checkstyle.xml
+++ b/checkstyle.xml
@@ -1,5 +1,6 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!DOCTYPE module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.2//EN" "http://www.puppycrawl.com/dtds/configuration_1_2.dtd">
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE module PUBLIC "-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
+ "https://checkstyle.org/dtds/configuration_1_3.dtd">
<module name="Checker">
<property name="localeLanguage" value="en"/>
<property name="tabWidth" value="4"/>
@@ -36,6 +37,7 @@
<property name="illegalPkgs" value="sun, java.awt, javax.swing, javafx"/>
</module>
<module name="ImportOrder">
+ <property name="option" value="bottom"/>
<property name="groups" value="/(com.mojang|net.fabricmc|net.minecraft)\..+/,*,/javax?\..+/"/>
<property name="separated" value="true"/>
<property name="useContainerOrderingForStatic" value="true"/>
@@ -43,4 +45,8 @@
<module name="RedundantImport"/>
<module name="UnusedImports"/>
</module>
+
+ <module name="SuppressionFilter">
+ <property name="file" value="${suppressions}"/>
+ </module>
</module>
diff --git a/javadoc/build.gradle b/javadoc/build.gradle
index bde068f..d263b57 100644
--- a/javadoc/build.gradle
+++ b/javadoc/build.gradle
@@ -1,3 +1,7 @@
plugins {
id 'java'
}
+
+repositories {
+ mavenCentral()
+}