Skip to content

Commit

Permalink
Port to 1.20.3 neo
Browse files Browse the repository at this point in the history
  • Loading branch information
manmaed committed Dec 6, 2023
1 parent cc914c9 commit dd79b6e
Show file tree
Hide file tree
Showing 24 changed files with 432 additions and 514 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build & Release For Minecraft 1.20.2 - Forge
name: Build & Release For Minecraft 1.20.3 - Neo

on:
push:
Expand Down
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ build
# other
eclipse
run
runs
run-data

# Files from Forge MDK
forge*changelog.txt
repo
129 changes: 30 additions & 99 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,142 +1,73 @@
plugins {
id 'java-library'
id 'eclipse'
id 'idea'
id 'maven-publish'
id 'net.minecraftforge.gradle' version '[6.0,6.2)'
id 'net.neoforged.gradle.userdev' version '7.0.57'
id "me.modmuss50.mod-publish-plugin" version "0.3.5"
}

def ENV = System.getenv()
version = "${ENV.GITHUB_RUN_NUMBER}" ? "${mod_version}.${ENV.GITHUB_RUN_NUMBER}" : "${mod_version}.nobuildnumber"
group = project.maven_group

repositories {
mavenLocal()
maven {
url "https://maven.curse.tools"
}
}
def ENV = System.getenv()
version = "${ENV.GITHUB_RUN_NUMBER}" ? "${mod_version}.${ENV.GITHUB_RUN_NUMBER}" : "${mod_version}.nobuildnumber"
group = project.maven_group

base {
archivesBaseName = project.archives_base_name + "-forge"
archivesName = project.archives_base_name + "-neo"
}

// Mojang ships Java 17 to end users in 1.18+, so your mod should target Java 17.
java.toolchain.languageVersion = JavaLanguageVersion.of(17)

println "Java: ${System.getProperty 'java.version'}, JVM: ${System.getProperty 'java.vm.version'} (${System.getProperty 'java.vendor'}), Arch: ${System.getProperty 'os.arch'}"
minecraft {
mappings channel: "${minecraft_mappings}", version: "${minecraft_version}"
copyIdeResources = true
runs {
client {
workingDirectory project.file('run')
property 'forge.logging.markers', 'REGISTRIES'
property 'forge.logging.console.level', 'debug'
property 'forge.enabledGameTestNamespaces', 'antiblocksrechiseled'
property 'mixin.env.remapRefMap', 'true'
property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg"
mods {
antiblocksrechiseled {
source sourceSets.main
}
}
}
runs {
configureEach {
systemProperty 'forge.logging.markers', 'REGISTRIES'
systemProperty 'forge.logging.console.level', 'debug'
modSource project.sourceSets.main
}

server {
workingDirectory project.file('run')
property 'forge.logging.markers', 'REGISTRIES'
property 'forge.logging.console.level', 'debug'
property 'forge.enabledGameTestNamespaces', 'antiblocksrechiseled'
property 'mixin.env.remapRefMap', 'true'
property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg"
mods {
antiblocksrechiseled {
source sourceSets.main
}
}
}
client {
systemProperty 'forge.enabledGameTestNamespaces', project.archives_base_name
}

gameTestServer {
workingDirectory project.file('run')
property 'forge.logging.markers', 'REGISTRIES'
property 'forge.logging.console.level', 'debug'
property 'forge.enabledGameTestNamespaces', 'antiblocksrechiseled'
mods {
antiblocksrechiseled {
source sourceSets.main
}
}
}
server {
systemProperty 'forge.enabledGameTestNamespaces', project.archives_base_name
programArgument '--nogui'
}

data {
workingDirectory project.file('run')
property 'forge.logging.markers', 'REGISTRIES'
property 'forge.logging.console.level', 'debug'
args '--mod', 'antiblocksrechiseled', '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/')
mods {
antiblocksrechiseled {
source sourceSets.main
}
}
}
data {
programArguments.addAll '--mod', project.archives_base_name, '--all', '--output', file('src/generated/resources/').getAbsolutePath(), '--existing', file('src/main/resources/').getAbsolutePath()
}
}

sourceSets.main.resources { srcDir 'src/generated/resources' }

repositories {
sourceSets.main.resources {
srcDir 'src/generated/resources'
}

dependencies {
minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}"
//implementation fg.deobf("curse.maven:ctm-${ctm_id}:${ctm_file_id}")
}

jar {
manifest {
attributes([
"Specification-Title" : "antiblocksrechiseled",
"Specification-Vendor" : "manmaed",
"Specification-Version" : "1", // We are version 1 of ourselves
"Implementation-Title" : project.name,
"Implementation-Version" : project.jar.archiveVersion,
"Implementation-Vendor" : "manmaed",
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
])
}
}

jar.finalizedBy('reobfJar')

publishing {
publications {
mavenJava(MavenPublication) {
artifact jar
}
}
repositories {
maven {
url "file://${project.projectDir}/mcmodsrepo"
}
}
implementation "net.neoforged:neoforge:${neo_version}"
}

publishMods {
dryRun = providers.environmentVariable("CURSE_DEPLOY").getOrNull() == null
file = jar.archiveFile
modLoaders.add("forge")
modLoaders.add("neoforge")
type = BETA
changelog = "changeme"
displayName = "${mod_name} v${mod_version} - Forge - ${minecraft_version}"
displayName = "${mod_name} v${mod_version} - NeoForge - ${minecraft_version}"
curseforge {
accessToken = providers.environmentVariable("CURSE_DEPLOY")
projectId = project.curseforge_id
minecraftVersions.add("Java 17")
minecraftVersions.add("${minecraft_version}")
optional {
slug = 'ctm'
}
}
}

tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation
}
}
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=false

# Forge Stuff
# Neo Stuff
minecraft_version=1.20.2
forge_version=48.0.1
neo_version=20.2.86
minecraft_mappings=official

# Mod Properties
Expand All @@ -14,7 +14,7 @@ minecraft_mappings=official

# Mod Stuff
mod_name=antiblocksrechiseled
mod_version=0.5
mod_version=0.6

#CurseForge Stuff
curseforge_id=715567
Expand Down
12 changes: 8 additions & 4 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand All @@ -80,10 +80,10 @@ do
esac
done

APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

APP_NAME="Gradle"
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
Expand Down Expand Up @@ -143,12 +143,16 @@ fi
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down
4 changes: 4 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
pluginManagement {
repositories {
mavenLocal()
gradlePluginPortal()
maven { url = 'https://maven.creeperhost.net/' }
}
}
plugins {
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.5.0'
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,38 @@
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegistryObject;
import net.neoforged.bus.api.IEventBus;
import net.neoforged.fml.common.Mod;
import net.neoforged.neoforge.registries.DeferredHolder;
import net.neoforged.neoforge.registries.DeferredRegister;

import java.util.Arrays;
import java.util.List;

@Mod(AntiBlocksReChiseled.MOD_ID)
public class AntiBlocksReChiseled {

public static final String MOD_ID = "antiblocksrechiseled";
public static final DeferredRegister<CreativeModeTab> CREATIVE_MODE_TABS = DeferredRegister.create(Registries.CREATIVE_MODE_TAB, MOD_ID);
public static final RegistryObject<CreativeModeTab> ABRC_TAB = CREATIVE_MODE_TABS.register(MOD_ID, () -> CreativeModeTab.builder()
public static final DeferredHolder<CreativeModeTab, CreativeModeTab> ABRC_TAB = CREATIVE_MODE_TABS.register(MOD_ID, () -> CreativeModeTab.builder()
.icon(() -> new ItemStack(ABRCBrightColors.BRIGHT_WHITE_BORDER.get()))
.title(Component.translatable("itemGroup." + MOD_ID ))
.displayItems((parameters, output) -> {
for (Item item: ForgeRegistries.ITEMS.getValues()) {
if (item.getCreatorModId(item.getDefaultInstance()).equals(MOD_ID)) {
output.accept(item);
}
List<DeferredRegister<Item>> myItems = Arrays.asList(
ABRCWoolColors.ITEMS,
ABRCBrightColors.ITEMS,
ABRCSlabs.ITEMS,
ABRCStairs.ITEMS,
ABRCButtons.ITEMS,
ABRCPressurePlates.ITEMS
);
for (DeferredRegister<Item> register : myItems) {
register.getEntries().forEach(entry -> output.accept(entry.get()));
}
})
.build());

public AntiBlocksReChiseled() {
IEventBus event = FMLJavaModLoadingContext.get().getModEventBus();
public AntiBlocksReChiseled(IEventBus event) {
ABRCWoolColors.BLOCKS.register(event);
ABRCBrightColors.BLOCKS.register(event);
ABRCSlabs.BLOCKS.register(event);
Expand All @@ -44,27 +50,6 @@ public AntiBlocksReChiseled() {
ABRCStairs.ITEMS.register(event);
ABRCButtons.ITEMS.register(event);
ABRCPressurePlates.ITEMS.register(event);
/*ABRCTests.BLOCKS.register(event);
ABRCTests.ITEMS.register(event);*/
CREATIVE_MODE_TABS.register(event);

/*event.addListener(this::createTab);*/
}

/*public void createTab(BuildCreativeModeTabContentsEvent event) {
event.getTabKey()
event.registerCreativeModeTab(new ResourceLocation(MOD_ID, "creative_tab"), builder -> builder
.icon(() -> new ItemStack(ABRCBrightColors.BRIGHT_WHITE_BORDER.get()))
.title(Component.translatable("itemGroup." + MOD_ID))
.displayItems((features, output, hasPrems) -> {
for (Item item : ForgeRegistries.ITEMS.getValues()) {
if (item.getCreatorModId(item.getDefaultInstance()).equals(MOD_ID)) {
//LogHelper.warn("This item is form this mod" + item.toString());
output.accept(item);
}
}
})
);
}*/

}
Loading

0 comments on commit dd79b6e

Please sign in to comment.