generated from jaredlll08/MultiLoader-Template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
61 changed files
with
1,549 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# This workflow will build a package using Gradle | ||
|
||
name: Check Builds For Errors | ||
|
||
on: [ pull_request, push ] | ||
|
||
jobs: | ||
build: | ||
continue-on-error: true | ||
strategy: | ||
matrix: | ||
# Use these Java versions | ||
java: [ 17 ] | ||
# and run on both Linux and Windows | ||
os: [ ubuntu-20.04, windows-latest ] | ||
runs-on: ${{ matrix.os }} | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Validate gradle wrapper | ||
uses: gradle/wrapper-validation-action@v1 | ||
|
||
- name: Set up JDK ${{ matrix.java }} | ||
uses: actions/setup-java@v3 | ||
with: | ||
distribution: adopt | ||
java-version: ${{ matrix.java }} | ||
|
||
- name: Make gradle wrapper executable | ||
if: ${{ runner.os != 'Windows' }} | ||
run: chmod +x ./gradlew | ||
|
||
- name: Build Fabric | ||
run: ./gradlew :Fabric:build | ||
- name: Capture Fabric build artifacts | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: Artifacts | ||
path: Fabric/build/libs/ | ||
|
||
- name: Build Forge | ||
run: ./gradlew :Forge:build | ||
- name: Capture Forge build artifacts | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: Artifacts | ||
path: Forge/build/libs/ | ||
|
||
- name: Build Quilt | ||
run: ./gradlew :Quilt:build | ||
- name: Capture Quilt build artifacts | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: Artifacts | ||
path: Forge/build/libs/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
plugins { | ||
id 'java' | ||
} | ||
|
||
group = 'de.griefed' | ||
version = '0.0.1' | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
implementation 'com.fasterxml.jackson.core:jackson-databind:2.15.3' | ||
testImplementation platform('org.junit:junit-bom:5.9.1') | ||
testImplementation 'org.junit.jupiter:junit-jupiter' | ||
} | ||
|
||
test { | ||
useJUnitPlatform() | ||
} | ||
|
Empty file.
46 changes: 46 additions & 0 deletions
46
buildSrc/src/main/java/de/griefed/generation/BlockAndItemCodeGenerator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package de.griefed.generation; | ||
|
||
import com.fasterxml.jackson.core.json.JsonReadFeature; | ||
import com.fasterxml.jackson.databind.DeserializationFeature; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import de.griefed.generation.blocks.BlockDefinitionParser; | ||
import org.gradle.api.Plugin; | ||
import org.gradle.api.Project; | ||
|
||
import java.io.File; | ||
import java.io.FileInputStream; | ||
import java.io.IOException; | ||
import java.util.Properties; | ||
|
||
/** | ||
* Generates Forge, Fabric and Quilt block-implementations from block-definitions in a JSON-file.<br> | ||
* See <code>definitions/blocks.json</code><br> | ||
* Take note that textures for blocks must be present in <code>definitions/blocks</code> and the name of the textures | ||
* must match the ID of the block. | ||
*/ | ||
public class BlockAndItemCodeGenerator implements Plugin<Project> { | ||
private final ObjectMapper objectMapper = new ObjectMapper() | ||
.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES) | ||
.enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY) | ||
.enable(JsonReadFeature.ALLOW_UNESCAPED_CONTROL_CHARS.mappedFeature()); | ||
|
||
public void apply(Project project) { | ||
project.getTasks().register("blockAndItemCodeGen", task -> task.doLast(s -> System.out.println("Hello from plugin " + this.getClass().getName()))); | ||
try { | ||
Properties gradleProperties = new Properties(); | ||
gradleProperties.load(new FileInputStream(new File(project.getRootDir(),"gradle.properties"))); | ||
String modName = gradleProperties.getProperty("mod_name"); | ||
BlockDefinitionParser parser = new BlockDefinitionParser(project, objectMapper); | ||
|
||
CommonGeneration common = new CommonGeneration(project.findProject("common"), modName, parser, objectMapper); | ||
FabricGeneration fabric = new FabricGeneration(project.findProject("fabric"), modName, parser, objectMapper); | ||
ForgeGeneration forge = new ForgeGeneration(project.findProject("forge"), modName, parser, objectMapper); | ||
|
||
common.run(); | ||
fabric.run(); | ||
forge.run(); | ||
} catch (IOException e) { | ||
throw new RuntimeException("Error generating block and item code.", e); | ||
} | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
buildSrc/src/main/java/de/griefed/generation/CodeGeneration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package de.griefed.generation; | ||
|
||
import java.io.IOException; | ||
|
||
public interface CodeGeneration { | ||
|
||
void run() throws IOException; | ||
|
||
/** | ||
* Create the ModBlocks-class inside the <code>your.group.modid.block</code>-package. | ||
* Depending on the modloader, the template from which this class is generated differs. | ||
* The functionality stays the same: The generated class allows for registering all custom blocks defined in | ||
* the <code>definitions/blocks.json</code>-file.<br> | ||
* <b>Do not manually edit the generated file!</b> | ||
* @throws IOException when the file could not be created or edited. | ||
*/ | ||
void createModBlocksClass() throws IOException; | ||
|
||
/** | ||
* Create the ModItems-class inside the <code>your.group.modid.item</code>-package. | ||
* Depending on the modloader, the template from which this class is generated differs. | ||
* The functionality stays the same: The generated class allows for registering all custom items defined in | ||
* the <code>definitions/items.json</code>-file, as well as all items for any blocks defined in the | ||
* <code>definitions/blocks.json</code>-file. | ||
* @throws IOException when the file could not be created or edited. | ||
*/ | ||
void createModItemsClass() throws IOException; | ||
|
||
/** | ||
* Create the modloader main-class housing the registration events, making sure that all blocks and items | ||
* actually get registered. The class gets created inside the <code>your.group.modid</code>-package. | ||
* @throws IOException when the file could not be created or edited. | ||
*/ | ||
void createModloaderClass() throws IOException; | ||
|
||
/** | ||
* Update the <code>ModBlocks</code>-class to register all defined blocks. | ||
* @throws IOException when the file could not be created or edited. | ||
*/ | ||
void updateModBlocksClass() throws IOException; | ||
|
||
/** | ||
* Update the <code>ModItems</code>-class to register all defined blocks and items. | ||
* @throws IOException when the file could not be created or edited. | ||
*/ | ||
void updateModItemsClass() throws IOException; | ||
|
||
/** | ||
* Updates the modloaders main-class, more specifically the area inside said class which is reserved for updates | ||
* by this method. The generated code will ensure that all mods registered in the ModBlocks-class will get added | ||
* to the game by the respective modloader. | ||
* @throws IOException when the file could not be created or edited. | ||
*/ | ||
void updateModloaderMain() throws IOException; | ||
|
||
} |
19 changes: 19 additions & 0 deletions
19
buildSrc/src/main/java/de/griefed/generation/CommonGeneration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package de.griefed.generation; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import de.griefed.generation.blocks.BlockDefinitionParser; | ||
import org.gradle.api.Project; | ||
|
||
import java.io.IOException; | ||
|
||
public class CommonGeneration extends ModloaderGeneration { | ||
protected CommonGeneration(Project project, String modName, BlockDefinitionParser parser, ObjectMapper objectMapper) { | ||
super(project, modName, parser, objectMapper); | ||
} | ||
|
||
public void run() throws IOException { | ||
updateTranslations(); | ||
createBlockFiles(); | ||
createItemFiles(); | ||
} | ||
} |
Oops, something went wrong.