Skip to content

Commit

Permalink
Spotless
Browse files Browse the repository at this point in the history
  • Loading branch information
qwer523 committed Jun 10, 2024
1 parent 2895a56 commit 4f66bc7
Show file tree
Hide file tree
Showing 52 changed files with 1,126 additions and 705 deletions.
4 changes: 3 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ plugins {
alias libs.plugins.architectury.loom
alias libs.plugins.machete // automatic jar compressing on build
alias libs.plugins.shadow
alias libs.plugins.spotless
}

apply plugin: "dev.architectury.loom"
Expand Down Expand Up @@ -36,6 +37,7 @@ apply from: "$rootDir/gradle/scripts/dependencies.gradle"
apply from: "$rootDir/gradle/scripts/resources.gradle"
apply from: "$rootDir/gradle/scripts/jars.gradle"
apply from: "$rootDir/gradle/scripts/publishing.gradle"
apply from: "$rootDir/gradle/scripts/spotless.gradle"

tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
Expand All @@ -44,4 +46,4 @@ tasks.withType(JavaCompile) {
machete {
// disable machete locally for faster builds
enabled = false
}
}
2 changes: 1 addition & 1 deletion gradle/scripts/architectury_loom.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,4 @@ loom {
}
}
}
}
}
2 changes: 1 addition & 1 deletion gradle/scripts/capabilities.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ configurations {
// capability("io.github.llamalad7:mixinextras-forge:${this.forge.versions.mixinextras.get()}")
// }
// }
}
}
2 changes: 1 addition & 1 deletion gradle/scripts/jars.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ remapSlimJar {

tasks.remapJar.dependsOn('remapSlimJar')

archivesBaseName = "${project.name}-${libs.versions.minecraft.get()}"
archivesBaseName = "${project.name}-${libs.versions.minecraft.get()}"
2 changes: 1 addition & 1 deletion gradle/scripts/repositories.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ repositories {
maven { url = "https://maven.jamieswhiteshirt.com/libs-release" } // Reach Entity Attributes
maven { url 'https://jitpack.io' } // Mixin Extras, Fabric ASM
maven { url = "https://server.cjsah.net:1002/maven/" }
}
}
2 changes: 1 addition & 1 deletion gradle/scripts/resources.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ processResources {
filesMatching("META-INF/mods.toml") {
expand properties
}
}
}
24 changes: 24 additions & 0 deletions gradle/scripts/spotless.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
spotless {
encoding 'UTF-8'
format 'misc', {
target '.gitignore', '*.gradle', 'gradle/scripts/*.gradle'

trimTrailingWhitespace()
indentWithSpaces(4)
endWithNewline()
}
java {
target 'src/*/java/**/*.java'

palantirJavaFormat().style("GOOGLE")
indentWithTabs(2)
indentWithSpaces(4)

// Must be after Google Format, see https://github.com/diffplug/spotless/issues/1407
importOrderFile("$rootDir/spotless/spotless.importorder")
removeUnusedImports()

cleanthat()
formatAnnotations()
}
}
4 changes: 4 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ dependencyResolutionManagement {
def ldLibVersion = "1.0.25.j"
def mixinextrasVersion = "0.3.2"
def monomorphismLibVersion = "1.1.0-build.23"
def spotlessVersion = "7.0.0.BETA1"

forge {
version("forgeShortVersion", forgeVersion)
Expand Down Expand Up @@ -102,6 +103,9 @@ dependencyResolutionManagement {

def machete = version("machete", macheteVersion)
plugin("machete", "io.github.p03w.machete").versionRef(machete)

def spotless = version("spotless", spotlessVersion)
plugin("spotless", "com.diffplug.spotless").versionRef(spotless)
}
}
}
Expand Down
11 changes: 11 additions & 0 deletions spotless/spotless.importorder
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#Organize Import Order
#Sat May 27 02:13:47 CDT 2023
0=com.epimorphismmc.gregiceng
1=com.epimorphismmc
1=com.gregtechceu
1=com.lowdragmc
1=net
2=
3=java
4=javax
5=\#
7 changes: 4 additions & 3 deletions src/main/java/com/epimorphismmc/gregiceng/GEGTAddon.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package com.epimorphismmc.gregiceng;

import com.epimorphismmc.gregiceng.common.data.GERecipes;

import com.epimorphismmc.monomorphism.MOGTAddon;

import com.gregtechceu.gtceu.api.addon.GTAddon;

import net.minecraft.data.recipes.FinishedRecipe;

import java.util.function.Consumer;
Expand All @@ -14,9 +17,7 @@ public GEGTAddon() {
}

@Override
public void initializeAddon() {

}
public void initializeAddon() {}

@Override
public void addRecipes(Consumer<FinishedRecipe> provider) {
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/com/epimorphismmc/gregiceng/GregicEng.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,20 @@
import com.epimorphismmc.gregiceng.common.CommonProxy;
import com.epimorphismmc.gregiceng.config.GEConfigHolder;
import com.epimorphismmc.gregiceng.data.lang.GELangHandler;

import com.epimorphismmc.monomorphism.MOMod;
import com.epimorphismmc.monomorphism.datagen.MOProviderTypes;
import com.epimorphismmc.monomorphism.registry.registrate.MORegistrate;

import com.gregtechceu.gtceu.utils.FormattingUtil;

import com.lowdragmc.lowdraglib.networking.INetworking;

import net.minecraft.resources.ResourceLocation;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.fml.common.Mod;

import org.slf4j.Logger;

@Mod(GregicEng.MODID)
Expand Down Expand Up @@ -78,5 +83,4 @@ protected CommonProxy createServerProxy() {
public void addDataGenerator(MORegistrate registrate) {
registrate.addDataGenerator(MOProviderTypes.MO_LANG, GELangHandler::init);
}

}
3 changes: 1 addition & 2 deletions src/main/java/com/epimorphismmc/gregiceng/api/GEValues.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
package com.epimorphismmc.gregiceng.api;

public class GEValues {
}
public class GEValues {}
Original file line number Diff line number Diff line change
@@ -1,23 +1,34 @@
package com.epimorphismmc.gregiceng.api.gui;

import com.epimorphismmc.gregiceng.GregicEng;

import com.lowdragmc.lowdraglib.gui.texture.ResourceBorderTexture;
import com.lowdragmc.lowdraglib.gui.texture.ResourceTexture;

public class GEGuiTextures {
public static final ResourceTexture SMALL_ARROW_OVERLAY = createTexture("overlay/small_arrow_overlay.png");
public static final ResourceTexture SMALL_ARROW_OVERLAY =
createTexture("overlay/small_arrow_overlay.png");

public static final ResourceTexture REFUND_OVERLAY = createTexture("overlay/refund_overlay.png");
public static final ResourceTexture PATTERN_OVERLAY = createTexture("overlay/pattern_overlay.png");
public static final ResourceTexture PATTERN_OVERLAY =
createTexture("overlay/pattern_overlay.png");

public static final ResourceTexture BUTTON_AUTOMATIC_RETURN = createTexture("widget/button_automatic_return.png");
public static final ResourceTexture BUTTON_AUTO_PULL_ME = createTexture("widget/button_auto_pull_me.png");
public static final ResourceTexture BUTTON_AUTOMATIC_RETURN =
createTexture("widget/button_automatic_return.png");
public static final ResourceTexture BUTTON_AUTO_PULL_ME =
createTexture("widget/button_auto_pull_me.png");

private static ResourceTexture createTexture(String imageLocation) {
return new ResourceTexture("%s:textures/gui/%s".formatted(GregicEng.MODID, imageLocation));
}

private static ResourceBorderTexture createBorderTexture(String imageLocation, int imageWidth, int imageHeight, int cornerWidth, int cornerHeight) {
return new ResourceBorderTexture("%s:textures/gui/%s".formatted(GregicEng.MODID, imageLocation), imageWidth, imageHeight, cornerWidth, cornerHeight);
private static ResourceBorderTexture createBorderTexture(
String imageLocation, int imageWidth, int imageHeight, int cornerWidth, int cornerHeight) {
return new ResourceBorderTexture(
"%s:textures/gui/%s".formatted(GregicEng.MODID, imageLocation),
imageWidth,
imageHeight,
cornerWidth,
cornerHeight);
}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
package com.epimorphismmc.gregiceng.api.gui.wight;

import appeng.api.stacks.AEKey;
import com.epimorphismmc.gregiceng.api.misc.IConfigurableAESlot;

import com.lowdragmc.lowdraglib.gui.widget.Widget;
import com.lowdragmc.lowdraglib.utils.Position;
import com.lowdragmc.lowdraglib.utils.Size;
import lombok.Setter;

import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.network.chat.Component;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;

import appeng.api.stacks.AEKey;
import lombok.Setter;
import org.jetbrains.annotations.Nullable;

import java.util.List;
Expand All @@ -18,6 +21,7 @@
public abstract class AESlotWidget<T extends AEKey> extends Widget {
@Setter
protected BiConsumer<AESlotWidget<T>, List<Component>> onAddedTooltips;

protected IConfigurableAESlot<T> aeSlot;
protected T key;
protected long amount;
Expand All @@ -43,7 +47,7 @@ public void writeInitialData(FriendlyByteBuf buffer) {
super.writeInitialData(buffer);
this.key = aeSlot.getConfig();
this.amount = aeSlot.getAmount();
if (key != null && amount > 0){
if (key != null && amount > 0) {
buffer.writeBoolean(true);
key.writeToPacket(buffer);
buffer.writeVarLong(amount);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
package com.epimorphismmc.gregiceng.api.gui.wight;

import appeng.api.stacks.AEKey;
import com.epimorphismmc.gregiceng.api.misc.IConfigurableAESlotList;

import com.lowdragmc.lowdraglib.gui.ingredient.IGhostIngredientTarget;
import com.lowdragmc.lowdraglib.gui.ingredient.Target;
import com.lowdragmc.lowdraglib.gui.widget.Widget;
import com.lowdragmc.lowdraglib.utils.Position;
import com.lowdragmc.lowdraglib.utils.Size;
import com.mojang.blaze3d.systems.RenderSystem;

import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.network.chat.Component;
import net.minecraft.world.item.ItemStack;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;

import appeng.api.stacks.AEKey;
import com.mojang.blaze3d.systems.RenderSystem;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

Expand All @@ -24,9 +27,10 @@

import static com.lowdragmc.lowdraglib.gui.util.DrawerHelper.drawSolidRect;

public abstract class ConfigSlotWidget<T extends AEKey> extends Widget implements IGhostIngredientTarget {
protected final static int REMOVE_ID = 1000;
protected final static int UPDATE_ID = 1001;
public abstract class ConfigSlotWidget<T extends AEKey> extends Widget
implements IGhostIngredientTarget {
protected static final int REMOVE_ID = 1000;
protected static final int UPDATE_ID = 1001;
protected static final int BLOCKED_OVERLAY_COLOR = 0x80404040;
protected static final int SELECTION_OVERLAY_COLOR = -0x7f000001;
protected final int index;
Expand All @@ -35,32 +39,36 @@ public abstract class ConfigSlotWidget<T extends AEKey> extends Widget implement
protected T latestConfig;
protected BooleanSupplier isBlocked = () -> false;

public ConfigSlotWidget(IConfigurableAESlotList<T> slotList, int index, Position pos, Predicate<T> validator) {
public ConfigSlotWidget(
IConfigurableAESlotList<T> slotList, int index, Position pos, Predicate<T> validator) {
super(pos, new Size(18, 18));
this.slotList = slotList;
this.index = index;
this.validator = validator;
}

public ConfigSlotWidget(IConfigurableAESlotList<T> slotList, int index, int x, int y, Predicate<T> validator) {
public ConfigSlotWidget(
IConfigurableAESlotList<T> slotList, int index, int x, int y, Predicate<T> validator) {
this(slotList, index, new Position(x, y), validator);
}

@OnlyIn(Dist.CLIENT)
@Override
public void drawInForeground(@NotNull GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) {
public void drawInForeground(
@NotNull GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) {
if (isMouseOverElement(mouseX, mouseY)
&& getHoverElement(mouseX, mouseY) == this
&& gui != null
&& gui.getModularUIGui() != null) {
&& getHoverElement(mouseX, mouseY) == this
&& gui != null
&& gui.getModularUIGui() != null) {
drawTooltipTexts(mouseX, mouseY);
}
}

@OnlyIn(Dist.CLIENT)
@Override
protected void drawTooltipTexts(int mouseX, int mouseY) {
gui.getModularUIGui().setHoverTooltip(getHoverTexts(new ArrayList<>()), ItemStack.EMPTY, null, null);
gui.getModularUIGui()
.setHoverTooltip(getHoverTexts(new ArrayList<>()), ItemStack.EMPTY, null, null);
}

public ConfigSlotWidget<T> setIsBlocked(BooleanSupplier isBlocked) {
Expand Down Expand Up @@ -91,7 +99,8 @@ protected List<Component> getHoverTexts(List<Component> hoverTexts) {
}

@OnlyIn(Dist.CLIENT)
protected static void drawBlockedOverlay(GuiGraphics graphics, int x, int y, int width, int height) {
protected static void drawBlockedOverlay(
GuiGraphics graphics, int x, int y, int width, int height) {
RenderSystem.disableDepthTest();
RenderSystem.colorMask(true, true, true, false);
drawSolidRect(graphics, x, y, width, height, BLOCKED_OVERLAY_COLOR);
Expand All @@ -101,7 +110,8 @@ protected static void drawBlockedOverlay(GuiGraphics graphics, int x, int y, int
}

@OnlyIn(Dist.CLIENT)
protected static void drawSelectionOverlay(GuiGraphics graphics, int x, int y, int width, int height) {
protected static void drawSelectionOverlay(
GuiGraphics graphics, int x, int y, int width, int height) {
RenderSystem.disableDepthTest();
RenderSystem.colorMask(true, true, true, false);
drawSolidRect(graphics, x, y, width, height, SELECTION_OVERLAY_COLOR);
Expand Down
Loading

0 comments on commit 4f66bc7

Please sign in to comment.