Skip to content

Commit

Permalink
Neoforge
Browse files Browse the repository at this point in the history
  • Loading branch information
Mari023 committed Oct 27, 2023
1 parent db43205 commit 37965cb
Show file tree
Hide file tree
Showing 51 changed files with 444 additions and 739 deletions.
9 changes: 3 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
# This workflow will build a Java project with Gradle
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle

name: build master
name: build forge
on:
push:
branches: [ "master" ]
pull_request:
branches:
- '*'
branches: [ "forge/master" ]

jobs:
build:
Expand Down Expand Up @@ -38,7 +35,7 @@ jobs:
path: ~/.gradle/wrapper
key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
- name: Build with Gradle
run: ./gradlew remapJar
run: ./gradlew build
env:
HASH: $(git rev-parse --short "$GITHUB_SHA")
- name: Upload a Build Artifact
Expand Down
24 changes: 12 additions & 12 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,26 @@ jobs:
run: chmod +x gradlew

- name: Build with Gradle
run: ./gradlew remapJar
run: ./gradlew build
env:
TAG: ${{ github.event.release.tag_name }}

- name: Upload a fabric build
- name: Upload a forge build
uses: actions/upload-artifact@v3
with:
path: build/libs/**.jar
name: fabric
name: forge
retention-days: 2

publish_fabric:
publish_forge:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v3

- uses: actions/download-artifact@v3
with:
name: fabric
name: forge
path: download

- uses: Kir-Antipov/[email protected]
Expand All @@ -55,20 +55,20 @@ jobs:

changelog-file: CHANGELOG.md
github-token: ${{ secrets.GITHUB_TOKEN }}
loaders: fabric
loaders: |
forge
neoforge
game-versions: 1.20.1
curseforge-dependencies: |
cloth-config | depends
fabric-api | depends
applied-energistics-2 | depends
roughly-enough-items | suggests
trinkets | suggests
architectury-api | depends
curios | depends
modrinth-dependencies: |
cloth-config | depends
fabric-api | depends
ae2 | depends
roughly-enough-items | suggests
trinkets | suggests
architectury-api | depends
curios | depends
java: 17
version: ${{ env.version_name }}
name: ${{ env.version_name }}
Expand Down
95 changes: 59 additions & 36 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import net.minecraftforge.gradle.common.util.RunConfig

buildscript {
repositories {
mavenCentral()
Expand All @@ -8,10 +10,10 @@ buildscript {
}

plugins {
id("fabric-loom") version "1.3-SNAPSHOT"
id("net.neoforged.gradle") version "[6.0.18,6.2)"
id("org.spongepowered.mixin") version "0.7+"
id("com.diffplug.spotless") version "6.21.0"
id("maven-publish")
id("io.github.juuxel.loom-vineflower") version "1.11.0"
java
idea
}
Expand All @@ -34,6 +36,8 @@ val jeiMinecraftVersion: String by project
val jeiVersion: String by project
val reiVersion: String by project
val emiVersion: String by project
val forgeVersion: String by project
val curiosVersion: String by project

version = "$modVersion-SNAPSHOT"

Expand All @@ -51,51 +55,35 @@ if (tag != "") {
}

dependencies {
minecraft("com.mojang:minecraft:${minecraftVersion}")
mappings(loom.layered {
officialMojangMappings()
parchment("org.parchmentmc.data:parchment-${parchmentMinecraftVersion}:${parchmentVersion}@zip")
})

modImplementation("net.fabricmc:fabric-loader:${fabricLoaderVersion}")
modApi("net.fabricmc.fabric-api:fabric-api:${fabricApiVersion}")
modCompileOnly("dev.emi:trinkets:${trinketsVersion}") { isTransitive = false }
//modRuntimeOnly("dev.emi:trinkets:${trinketsVersion}")
modCompileOnly("dev.onyxstudios.cardinal-components-api:cardinal-components-base:${ccaVersion}")
modRuntimeOnly("me.shedaniel.cloth:cloth-config-${modloader}:${clothVersion}")
modCompileOnly("com.terraformersmc:modmenu:${modMenuVersion}")
modCompileOnly("dev.architectury:architectury-${modloader}:${architecturyVersion}")
modImplementation("appeng:appliedenergistics2-${modloader}:${ae2Version}") {
add("minecraft", "net.neoforged:forge:${minecraftVersion}-${forgeVersion}")

implementation(fg.deobf("top.theillusivec4.curios:curios-forge:${curiosVersion}"))
implementation(fg.deobf("me.shedaniel.cloth:cloth-config-${modloader}:${clothVersion}"))
implementation(fg.deobf("dev.architectury:architectury-${modloader}:${architecturyVersion}"))
implementation(fg.deobf("appeng:appliedenergistics2-${modloader}:${ae2Version}") as ExternalModuleDependency) {
exclude(group = "mezz.jei")
exclude(group = "me.shedaniel")
exclude(group = "net.fabricmc.fabric-api")
}

modCompileOnly("me.shedaniel:RoughlyEnoughItems-${modloader}:${reiVersion}") {
exclude(group = "net.fabricmc.fabric-api")
}
modCompileOnly("mezz.jei:jei-${jeiMinecraftVersion}-${modloader}:${jeiVersion}") {
exclude(group = "mezz.jei")
}
compileOnly(fg.deobf("me.shedaniel:RoughlyEnoughItems-${modloader}:${reiVersion}"))
compileOnly(fg.deobf("mezz.jei:jei-${jeiMinecraftVersion}-${modloader}:${jeiVersion}"))

when (runtimeItemlistMod) {
"rei" -> modRuntimeOnly("me.shedaniel:RoughlyEnoughItems-${modloader}:${reiVersion}") {
exclude(group = "net.fabricmc.fabric-api")
}
"rei" -> runtimeOnly(fg.deobf("me.shedaniel:RoughlyEnoughItems-${modloader}:${reiVersion}"))

"jei" -> modRuntimeOnly("mezz.jei:jei-${jeiMinecraftVersion}-${modloader}:${jeiVersion}") {
exclude(group = "mezz.jei")
}
"jei" -> runtimeOnly(fg.deobf("mezz.jei:jei-${jeiMinecraftVersion}-${modloader}:${jeiVersion}"))

"emi" -> {
modRuntimeOnly("dev.emi:emi-${modloader}:${emiVersion}+${minecraftVersion}")
modRuntimeOnly("mezz.jei:jei-${jeiMinecraftVersion}-${modloader}:${jeiVersion}") {
exclude(group = "mezz.jei")
}
runtimeOnly(fg.deobf("dev.emi:emi-${modloader}:${emiVersion}+${minecraftVersion}"))
runtimeOnly(fg.deobf("mezz.jei:jei-${jeiMinecraftVersion}-${modloader}:${jeiVersion}"))
}
}

annotationProcessor("org.spongepowered:mixin:0.8.4:processor")
implementation("com.google.code.findbugs:jsr305:3.0.2")

//testing
//runtimeOnly(fg.deobf("maven.modrinth:aeinfinitybooster:1.20.1-1.0.0+20"))
}

repositories {
Expand Down Expand Up @@ -149,6 +137,12 @@ repositories {
includeGroup("top.theillusivec4.curios")
}
}
maven {
url = uri("https://repo.spongepowered.org/maven")
content {
includeGroup("org.spongepowered")
}
}
maven {
url = uri("https://api.modrinth.com/maven")
content {
Expand All @@ -157,17 +151,46 @@ repositories {
}
}

minecraft {
mappings("official", minecraftVersion)
runs {
val config = Action<RunConfig> {
properties(mapOf(
"fml.earlyprogresswindow" to "false",
"forge.logging.console.level" to "debug",
"mixin.env.remapRefMap" to "true",
"mixin.env.refMapRemappingFile" to "${projectDir}/build/createSrgToMcp/output.srg"
))
workingDirectory = project.file("run").canonicalPath
source(sourceSets["main"])
}

create("client", config)
create("server", config)
}
}

mixin {
add(sourceSets.main.get(), "ae2wtlib.mixins.refmap.json")
config("ae2wtlib.mixins.json")
}

java {
withSourcesJar()
}

tasks {
jar {
finalizedBy("remapJar")
finalizedBy("reobfJar")
manifest {
attributes(mapOf(
"MixinConfigs" to "ae2wtlib.mixins.json"
))
}
}

processResources {
val resourceTargets = "fabric.mod.json"
val resourceTargets = "META-INF/mods.toml"

val replaceProperties = mapOf(
"version" to version as String,
Expand Down
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ archivesBaseName=AE2WTLib
# Dependencies
# check this on https://modmuss50.me/fabric.html
fabricApiVersion=0.88.1+1.20.1
forgeVersion=1.18.2-40.0.32
modloader=fabric
forgeVersion=47.1.54
modloader=forge

ae2Version=15.0.12
trinketsVersion=3.7.1
#Trinkets dependency
ccaVersion=5.2.1
curiosVersion=1.18.2-5.0.6.3
curiosVersion=5.2.0-beta.3+1.20.1
reiVersion=12.0.652
clothVersion=11.1.106
modMenuVersion=7.1.0
Expand Down
3 changes: 2 additions & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
pluginManagement {
repositories {
gradlePluginPortal()
maven("https://maven.fabricmc.net/")
maven("https://server.bbkr.space/artifactory/libs-release/")
maven("https://maven.neoforged.net/releases")
maven("https://repo.spongepowered.org/maven")
}
}

Expand Down
14 changes: 8 additions & 6 deletions src/main/java/de/mari_023/ae2wtlib/AE2WTLibCreativeTab.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package de.mari_023.ae2wtlib;

import java.util.ArrayList;
import java.util.List;
import java.util.ArrayDeque;
import java.util.Collection;

import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroup;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
Expand All @@ -12,14 +13,15 @@
import appeng.items.tools.powered.WirelessTerminalItem;

public class AE2WTLibCreativeTab {
private static final List<ItemStack> items = new ArrayList<>();
private static final Collection<ItemStack> items = new ArrayDeque<>();

public static CreativeModeTab init() {
return FabricItemGroup.builder()
public static void init(Registry<CreativeModeTab> registry) {
var tab = CreativeModeTab.builder()
.title(TextConstants.CREATIVE_TAB)
.icon(() -> new ItemStack(AE2wtlib.UNIVERSAL_TERMINAL))
.displayItems(AE2WTLibCreativeTab::buildDisplayItems)
.build();
Registry.register(registry, new ResourceLocation(AE2wtlib.MOD_NAME, "main"), tab);
}

public static void add(Item item) {
Expand Down
39 changes: 10 additions & 29 deletions src/main/java/de/mari_023/ae2wtlib/AE2wtlib.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
package de.mari_023.ae2wtlib;

import net.fabricmc.api.EnvType;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.world.item.Item;

import de.mari_023.ae2wtlib.curio.CurioHelper;
import de.mari_023.ae2wtlib.hotkeys.MagnetHotkeyAction;
import de.mari_023.ae2wtlib.hotkeys.RestockHotkeyAction;
import de.mari_023.ae2wtlib.networking.ServerNetworkManager;
import de.mari_023.ae2wtlib.networking.c2s.CycleTerminalPacket;
import de.mari_023.ae2wtlib.terminal.IUniversalWirelessTerminalItem;
import de.mari_023.ae2wtlib.trinket.TrinketsHelper;
import de.mari_023.ae2wtlib.wat.ItemWAT;
import de.mari_023.ae2wtlib.wat.WATMenu;
import de.mari_023.ae2wtlib.wat.WATMenuHost;
Expand Down Expand Up @@ -47,8 +45,6 @@ public class AE2wtlib {
public static Item MAGNET_CARD;

public static void onAe2Initialized() {
createItems();

WUTHandler.addTerminal("crafting",
((IUniversalWirelessTerminalItem) AEItems.WIRELESS_CRAFTING_TERMINAL.asItem())::tryOpen,
WCTMenuHost::new, WCTMenu.TYPE,
Expand All @@ -60,20 +56,15 @@ public static void onAe2Initialized() {
WUTHandler.addTerminal("pattern_access", PATTERN_ACCESS_TERMINAL::tryOpen, WATMenuHost::new, WATMenu.TYPE,
PATTERN_ACCESS_TERMINAL);

registerMenus();

Platform.registerRecipe(UpgradeSerializer.NAME, Upgrade.serializer = new UpgradeSerializer());
Platform.registerRecipe(CombineSerializer.NAME, Combine.serializer = new CombineSerializer());

ServerNetworkManager.registerServerBoundPacket(CycleTerminalPacket.NAME, CycleTerminalPacket::new);
HotkeyActions.register(new RestockHotkeyAction(), "ae2wtlib_restock");
HotkeyActions.register(new MagnetHotkeyAction(), "ae2wtlib_magnet");

SearchInventoryEvent.EVENT.register(TrinketsHelper::addAllTrinkets);

notifyAddons("");// common
if (FabricLoader.getInstance().getEnvironmentType().equals(EnvType.SERVER))
notifyAddons(":server");
SearchInventoryEvent.EVENT.register(CurioHelper::addAllCurios);
// we need something to call addon terminals here

UpgradeHelper.addUpgrades();
TestPlots.addPlotClass(AE2WTLibTestPlots.class);
Expand All @@ -93,35 +84,25 @@ public static void createItems() {
Platform.registerItem("wireless_pattern_access_terminal", PATTERN_ACCESS_TERMINAL);
Platform.registerItem("wireless_universal_terminal", UNIVERSAL_TERMINAL);

GridLinkables.register(PATTERN_ENCODING_TERMINAL, WirelessTerminalItem.LINKABLE_HANDLER);
GridLinkables.register(PATTERN_ACCESS_TERMINAL, WirelessTerminalItem.LINKABLE_HANDLER);
GridLinkables.register(UNIVERSAL_TERMINAL, WirelessTerminalItem.LINKABLE_HANDLER);
}

static void addToCreativeTab() {
AE2WTLibCreativeTab.addTerminal(AEItems.WIRELESS_CRAFTING_TERMINAL.asItem());
AE2WTLibCreativeTab.addTerminal(PATTERN_ENCODING_TERMINAL);
AE2WTLibCreativeTab.addTerminal(PATTERN_ACCESS_TERMINAL);
AE2WTLibCreativeTab.addTerminal(UNIVERSAL_TERMINAL);
AE2WTLibCreativeTab.add(QUANTUM_BRIDGE_CARD);
AE2WTLibCreativeTab.add(MAGNET_CARD);
Platform.registerCreativeTab(AE2WTLibCreativeTab.init());

Platform.registerTrinket(AEItems.WIRELESS_CRAFTING_TERMINAL.asItem());
Platform.registerTrinket(UNIVERSAL_TERMINAL);

GridLinkables.register(PATTERN_ENCODING_TERMINAL, WirelessTerminalItem.LINKABLE_HANDLER);
GridLinkables.register(PATTERN_ACCESS_TERMINAL, WirelessTerminalItem.LINKABLE_HANDLER);
GridLinkables.register(UNIVERSAL_TERMINAL, WirelessTerminalItem.LINKABLE_HANDLER);
}

private static void registerMenus() {
static void registerMenus() {
Platform.registerMenuType(WCTMenu.ID, WCTMenu.TYPE);
Platform.registerMenuType(WATMenu.ID, WATMenu.TYPE);
Platform.registerMenuType(WETMenu.ID, WETMenu.TYPE);
Platform.registerMenuType(MagnetMenu.ID, MagnetMenu.TYPE);
Platform.registerMenuType(TrashMenu.ID, TrashMenu.TYPE);
}

public static void notifyAddons(String type) {
var entrypoints = FabricLoader.getInstance().getEntrypointContainers(MOD_NAME + type,
IWTLibAddonEntrypoint.class);
for (var entrypoint : entrypoints) {
entrypoint.getEntrypoint().onWTLibInitialized();
}
}
}
Loading

0 comments on commit 37965cb

Please sign in to comment.