Skip to content

Commit

Permalink
Add Spotless (#4)
Browse files Browse the repository at this point in the history
* Add Spotless

Copied from Frontiers-PackForge/CosmicCore#34

Shoutout omergunr100

* Run spotless

* Update README.md

* Add MOOC to Readme
  • Loading branch information
JuiceyBeans authored Mar 1, 2025
1 parent d02faf3 commit 1147082
Show file tree
Hide file tree
Showing 8 changed files with 494 additions and 23 deletions.
37 changes: 32 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,38 @@
# GregTech Addon Template
Template for GregTech Modern addons on 1.20.1
## Template for GregTech Modern addons on 1.20.1

Original template by screret, updated by JuiceyBeans
Original template by [screret](https://github.com/screret), updated by [JuiceyBeans](https://github.com/JuiceyBeans)

Repositories you can use for additional reference:
<hr>

## How do I make an addon for GregTech Modern?
Well for one, you WILL need to know Java to make an addon. There's no getting around this. A good starting point would be [MOOC](https://java-programming.mooc.fi/) or [W3Schools](https://www.w3schools.com/java/
)

Unfortunately, there isn't any official documentation so far for making GregTech Modern addons. There are a couple of mods you can look at to reference though!

Repositories for other addons:

- [CosmicCore](https://github.com/Frontiers-PackForge/CosmicCore)
- [Gregicality Rocketry](https://github.com/Argent-Matter/gcyr/)
- [Gregtech: Extended Chemistry Extended](https://github.com/jmoiron/Gregtech-Extended-Chemistry)
- [Juiceycality](https://github.com/JuiceyBeans/Juiceycality)
- [Juiceycality](https://github.com/JuiceyBeans/Juiceycality)
- [Gregicality Rocketry](https://github.com/Argent-Matter/gcyr/)

Additionally, you may be able to find help on the [GregTech CEu Discord](https://discord.gg/bWSWuYvURP)!

<hr>

## This template comes packaged with [Spotless](https://github.com/diffplug/spotless)!

### 1. What is Spotless?
- Spotless keeps your code neatly formatted. It's essentially a grammar check for your code!
### 2. Can I choose not to use Spotless?
- Yes! Spotless is completely optional and will not affect your project by default
### 3. How do I run Spotless?
- You can run Spotless anytime by:
- Running the `spotlessApply` task from the Gradle tab in IntelliJ
- Installing the [Spotless Gradle plugin for IntelliJ](https://plugins.jetbrains.com/plugin/18321-spotless-gradle)
- Typing in `gradlew.bat :spotlessApply` if you're on Windows
- Typing in `bash gradlew :spotlessApply` if you're on Linux
### 4. So how do I check if Spotless has been applied to my code?
- Running `spotlessApply` will format all files for you automatically! If you want GitHub to check each commit for if Spotless has been run, you can add [this](https://github.com/Frontiers-PackForge/CosmicCore/blob/main-1.20.1-forge/.github/workflows/spotless.yml) and [this](https://github.com/Frontiers-PackForge/CosmicCore/blob/main-1.20.1-forge/.github/actions/build_setup/action.yml) to your project
4 changes: 4 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ plugins {
id "maven-publish"
id 'net.minecraftforge.gradle' version '[6.0,6.2)'
id 'org.parchmentmc.librarian.forgegradle' version '1.+'
id 'com.diffplug.spotless' version '7.0.2'
}

def generatedResources = file("src/generated")
Expand Down Expand Up @@ -101,6 +102,9 @@ minecraft {
}
}


apply from: "$rootDir/gradle/scripts/spotless.gradle"

dependencies {
minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}"

Expand Down
26 changes: 26 additions & 0 deletions gradle/scripts/spotless.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Spotless auto-formatter
// See https://github.com/diffplug/spotless/tree/main/plugin-gradle
// Can be locally toggled via spotless:off/spotless:on comments
spotless {
encoding 'UTF-8'

format 'misc', {
target '.gitignore'

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

def orderFile = file("$rootDir/spotless/spotless.importorder")
def formatFile = file("$rootDir/spotless/spotless.eclipseformat.xml")

toggleOffOn()
importOrderFile(orderFile)
removeUnusedImports('cleanthat-javaparser-unnecessaryimport')
endWithNewline()
eclipse('4.31').configFile(formatFile)
}
}
1 change: 1 addition & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ pluginManagement {
// when using additional gradle plugins like shadow,
// add their repositories to this list!
repositories {
gradlePluginPortal() // Needed for spotless
maven { url = 'https://maven.minecraftforge.net/' }
maven { url = 'https://maven.parchmentmc.org' }
}
Expand Down
400 changes: 400 additions & 0 deletions spotless/spotless.eclipseformat.xml

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions spotless/spotless.importorder
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
0=com.example
1=com.gregtechceu
2=com.lowdragmc
3=net
4=
5=java
6=javax
7=\#
30 changes: 16 additions & 14 deletions src/main/java/com/example/examplemod/ExampleGTAddon.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@
import com.gregtechceu.gtceu.api.addon.GTAddon;
import com.gregtechceu.gtceu.api.addon.IGTAddon;
import com.gregtechceu.gtceu.api.registry.registrate.GTRegistrate;

import net.minecraft.data.recipes.FinishedRecipe;

import java.util.function.Consumer;

@SuppressWarnings("unused")
@GTAddon
public class ExampleGTAddon implements IGTAddon {

@Override
public GTRegistrate getRegistrate() {
return ExampleMod.EXAMPLE_REGISTRATE;
}

@Override
public void initializeAddon() {

}
public void initializeAddon() {}

@Override
public String addonModId() {
Expand All @@ -27,23 +27,25 @@ public String addonModId() {

@Override
public void registerTagPrefixes() {
//CustomTagPrefixes.init();
// CustomTagPrefixes.init();
}

@Override
public void addRecipes(Consumer<FinishedRecipe> provider) {
//CustomRecipes.init(provider);
// CustomRecipes.init(provider);
}

// If you have custom ingredient types, uncomment this & change to match your capability.
// KubeJS WILL REMOVE YOUR RECIPES IF THESE ARE NOT REGISTERED.
/*
public static final ContentJS<Double> PRESSURE_IN = new ContentJS<>(NumberComponent.ANY_DOUBLE, GregitasRecipeCapabilities.PRESSURE, false);
public static final ContentJS<Double> PRESSURE_OUT = new ContentJS<>(NumberComponent.ANY_DOUBLE, GregitasRecipeCapabilities.PRESSURE, true);
@Override
public void registerRecipeKeys(KJSRecipeKeyEvent event) {
event.registerKey(CustomRecipeCapabilities.PRESSURE, Pair.of(PRESSURE_IN, PRESSURE_OUT));
}
*/
* public static final ContentJS<Double> PRESSURE_IN = new ContentJS<>(NumberComponent.ANY_DOUBLE,
* GregitasRecipeCapabilities.PRESSURE, false);
* public static final ContentJS<Double> PRESSURE_OUT = new ContentJS<>(NumberComponent.ANY_DOUBLE,
* GregitasRecipeCapabilities.PRESSURE, true);
*
* @Override
* public void registerRecipeKeys(KJSRecipeKeyEvent event) {
* event.registerKey(CustomRecipeCapabilities.PRESSURE, Pair.of(PRESSURE_IN, PRESSURE_OUT));
* }
*/
}
11 changes: 7 additions & 4 deletions src/main/java/com/example/examplemod/ExampleMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.gregtechceu.gtceu.api.machine.MachineDefinition;
import com.gregtechceu.gtceu.api.recipe.GTRecipeType;
import com.gregtechceu.gtceu.api.registry.registrate.GTRegistrate;

import net.minecraft.client.Minecraft;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.Items;
Expand All @@ -16,11 +17,13 @@
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

@Mod(ExampleMod.MOD_ID)
public class ExampleMod {

public static final String MOD_ID = "examplemod";
public static final Logger LOGGER = LogManager.getLogger();
public static GTRegistrate EXAMPLE_REGISTRATE = GTRegistrate.create(ExampleMod.MOD_ID);
Expand Down Expand Up @@ -61,19 +64,19 @@ private void addMaterialRegistries(MaterialRegistryEvent event) {

// As well as this.
private void addMaterials(MaterialEvent event) {
//CustomMaterials.init();
// CustomMaterials.init();
}

// This is optional, though.
private void modifyMaterials(PostMaterialEvent event) {
//CustomMaterials.modify();
// CustomMaterials.modify();
}

private void registerRecipeTypes(GTCEuAPI.RegisterEvent<ResourceLocation, GTRecipeType> event) {
//CustomRecipeTypes.init();
// CustomRecipeTypes.init();
}

private void registerMachines(GTCEuAPI.RegisterEvent<ResourceLocation, MachineDefinition> event) {
//CustomMachines.init();
// CustomMachines.init();
}
}

0 comments on commit 1147082

Please sign in to comment.