Skip to content

Commit

Permalink
Port to 1.21 and changed forge to neoforge
Browse files Browse the repository at this point in the history
  • Loading branch information
Uraneptus committed Jul 31, 2024
1 parent d49800f commit 754e0f7
Show file tree
Hide file tree
Showing 16 changed files with 189 additions and 185 deletions.
6 changes: 3 additions & 3 deletions Fabric/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'fabric-loom' version '0.13.9'
id 'fabric-loom' version '1.7.2'
}

version = "${mc_version}-${build_number}-FABRIC"
Expand Down Expand Up @@ -31,8 +31,8 @@ dependencies {
minecraft "com.mojang:minecraft:${mc_version}"
mappings loom.officialMojangMappings()

modImplementation "net.fabricmc:fabric-loader:0.14.21"
modImplementation "net.fabricmc.fabric-api:fabric-api:0.83.0+1.20"
modImplementation "net.fabricmc:fabric-loader:0.16.0"
modImplementation "net.fabricmc.fabric-api:fabric-api:0.100.8+1.21"

compileOnly project(":Xplat")

Expand Down
9 changes: 5 additions & 4 deletions Fabric/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"authors": [
"Vazkii",
"williewillus",
"Alwinfy"
"Alwinfy",
"Uraneptus"
],
"contact": {
"irc": "ircs://irc.esper.net:6697/vazkii",
Expand All @@ -31,8 +32,8 @@
"accessWidener": "neat.accesswidener",

"depends": {
"fabricloader": ">=0.14.14",
"fabric": ">=0.76",
"minecraft": ">=1.19.4"
"fabricloader": ">=0.16.0",
"fabric": ">=0.100",
"minecraft": ">=1.21"
}
}
86 changes: 0 additions & 86 deletions Forge/build.gradle

This file was deleted.

26 changes: 0 additions & 26 deletions Forge/src/main/java/vazkii/neat/NeatForgeInitializer.java

This file was deleted.

66 changes: 66 additions & 0 deletions NeoForge/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
plugins {
id 'java-library'
id 'idea'
id 'net.neoforged.gradle.userdev'
id 'eclipse'
}

version = "${project.mc_version}-${project.build_number}-NEOFORGE"

def accesstransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
if (accesstransformer.exists()) {
minecraft.accessTransformers.file accesstransformer
}

runs {
configureEach {
workingDirectory project.file('../run')
systemProperty 'forge.logging.console.level', 'debug'
modSource project.sourceSets.main
}

client {
}

server {
programArgument '--nogui'
}
}

dependencies {
implementation "net.neoforged:neoforge:${neoforge_version}"
implementation project(":Xplat")
}

compileJava {
source(project(":Xplat").sourceSets.main.allSource)
options.compilerArgs << "-Xlint:all,-classfile,-processing,-deprecation,-serial" << "-Werror"
}

sourcesJar {
from project(":Xplat").sourceSets.main.allJava
}

processResources {
from project(":Xplat").sourceSets.main.resources
inputs.property "version", project.version

filesMatching("META-INF/neoforge.mods.toml") {
expand "version": project.version
}
}

jar {
manifest {
attributes([
"Specification-Title": "${project.mod_id}",
"Specification-Vendor": "vazkii",
"Specification-Version": "1", // We are version 1 of ourselves
"Implementation-Title": "${project.mod_id}",
"Implementation-Version": "${project.version}",
"Implementation-Vendor" :"vazkii",
])
}
}

defaultTasks 'clean', 'build'
Original file line number Diff line number Diff line change
@@ -1,47 +1,48 @@
package vazkii.neat;

import net.minecraftforge.common.ForgeConfigSpec;
import net.minecraftforge.common.ForgeConfigSpec.ConfigValue;
import net.minecraftforge.fml.ModLoadingContext;
import net.minecraftforge.fml.config.ModConfig;

import net.neoforged.fml.ModContainer;
import net.neoforged.fml.ModLoadingContext;
import net.neoforged.fml.config.ModConfig;
import net.neoforged.neoforge.common.ModConfigSpec;
import org.apache.commons.lang3.tuple.Pair;

import java.util.List;

public class NeatForgeConfig {
public static void init() {
Pair<ForgeNeatConfig, ForgeConfigSpec> specPair = new ForgeConfigSpec.Builder().configure(ForgeNeatConfig::new);
public static void init(ModContainer container) {
Pair<ForgeNeatConfig, ModConfigSpec> specPair = new ModConfigSpec.Builder().configure(ForgeNeatConfig::new);
NeatConfig.instance = specPair.getLeft();
ModLoadingContext.get().registerConfig(ModConfig.Type.CLIENT, specPair.getRight());
container.registerConfig(ModConfig.Type.CLIENT, specPair.getRight());
//TODO consider using the build-in config ui of neoforge
}

private static class ForgeNeatConfig implements NeatConfig.ConfigAccess {
private final ConfigValue<Integer> maxDistance;
private final ConfigValue<Boolean> renderInF1;
private final ConfigValue<Double> heightAbove;
private final ConfigValue<Boolean> drawBackground;
private final ConfigValue<Integer> backgroundPadding;
private final ConfigValue<Integer> backgroundHeight;
private final ConfigValue<Integer> barHeight;
private final ConfigValue<Integer> plateSize;
private final ConfigValue<Integer> plateSizeBoss;
private final ConfigValue<Boolean> showAttributes;
private final ConfigValue<Boolean> showArmor;
private final ConfigValue<Boolean> groupArmor;
private final ConfigValue<Boolean> colorByType;
private final ConfigValue<Integer> hpTextHeight;
private final ConfigValue<Boolean> showMaxHP;
private final ConfigValue<Boolean> showCurrentHP;
private final ConfigValue<Boolean> showPercentage;
private final ConfigValue<Boolean> showOnPlayers;
private final ConfigValue<Boolean> showOnBosses;
private final ConfigValue<Boolean> showOnlyFocused;
private final ConfigValue<Boolean> showFullHealth;
private final ConfigValue<Boolean> enableDebugInfo;
private final ConfigValue<List<? extends String>> blacklist;

public ForgeNeatConfig(ForgeConfigSpec.Builder builder) {
private final ModConfigSpec.ConfigValue<Integer> maxDistance;
private final ModConfigSpec.ConfigValue<Boolean> renderInF1;
private final ModConfigSpec.ConfigValue<Double> heightAbove;
private final ModConfigSpec.ConfigValue<Boolean> drawBackground;
private final ModConfigSpec.ConfigValue<Integer> backgroundPadding;
private final ModConfigSpec.ConfigValue<Integer> backgroundHeight;
private final ModConfigSpec.ConfigValue<Integer> barHeight;
private final ModConfigSpec.ConfigValue<Integer> plateSize;
private final ModConfigSpec.ConfigValue<Integer> plateSizeBoss;
private final ModConfigSpec.ConfigValue<Boolean> showAttributes;
private final ModConfigSpec.ConfigValue<Boolean> showArmor;
private final ModConfigSpec.ConfigValue<Boolean> groupArmor;
private final ModConfigSpec.ConfigValue<Boolean> colorByType;
private final ModConfigSpec.ConfigValue<Integer> hpTextHeight;
private final ModConfigSpec.ConfigValue<Boolean> showMaxHP;
private final ModConfigSpec.ConfigValue<Boolean> showCurrentHP;
private final ModConfigSpec.ConfigValue<Boolean> showPercentage;
private final ModConfigSpec.ConfigValue<Boolean> showOnPlayers;
private final ModConfigSpec.ConfigValue<Boolean> showOnBosses;
private final ModConfigSpec.ConfigValue<Boolean> showOnlyFocused;
private final ModConfigSpec.ConfigValue<Boolean> showFullHealth;
private final ModConfigSpec.ConfigValue<Boolean> enableDebugInfo;
private final ModConfigSpec.ConfigValue<List<? extends String>> blacklist;

public ForgeNeatConfig(ModConfigSpec.Builder builder) {
builder.push("general");

maxDistance = builder.define("Max Distance", 24);
Expand Down
27 changes: 27 additions & 0 deletions NeoForge/src/main/java/vazkii/neat/NeatForgeInitializer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package vazkii.neat;

import net.neoforged.bus.api.IEventBus;
import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.fml.ModContainer;
import net.neoforged.fml.ModLoadingContext;
import net.neoforged.neoforge.client.event.RegisterKeyMappingsEvent;
import net.neoforged.api.distmarker.Dist;
import net.neoforged.fml.common.EventBusSubscriber;
import net.neoforged.fml.common.Mod;

@Mod(NeatConfig.MOD_ID)
public class NeatForgeInitializer {

public NeatForgeInitializer(IEventBus bus, ModContainer modContainer) {
//ModLoadingContext.get().registerExtensionPoint(IExtensionPoint.DisplayTest.class, () -> new IExtensionPoint.DisplayTest(() -> NetworkConstants.IGNORESERVERONLY, (incoming, isNetwork) -> true));
NeatForgeConfig.init(modContainer);
}

@EventBusSubscriber(modid = NeatConfig.MOD_ID, bus = EventBusSubscriber.Bus.MOD, value = Dist.CLIENT)
public static class ClientEventHandler {
@SubscribeEvent
public static void registerKey(RegisterKeyMappingsEvent event) {
event.register(ToggleKeybind.KEY);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
modLoader="javafml"
loaderVersion="[45,)"
loaderVersion="[4,)"
issueTrackerURL="https://github.com/VazkiiMods/Neat"
license="MIT AND CC-BY-NC-SA-3.0" # Code is MIT, assets are CC

[[mods]]
modId="neat"
displayName="Neat"
version="${version}"
authors="Vazkii"
authors="Vazkii, Uraneptus"
description="Minimalistic Functional Unit Plates for the modern Minecrafter"

[[dependencies.neat]]
modId="forge"
mandatory=true
versionRange="[45.0.40,)"
modId="neoforge"
type="required"
versionRange="[21.0.143,)"

[[mixins]]
config="neat.mixins.json"
Loading

0 comments on commit 754e0f7

Please sign in to comment.