From b149c0f4f5d74b7a990d6db5a0c8ae28d53e69b0 Mon Sep 17 00:00:00 2001 From: Ruben Taelman Date: Sat, 15 Jun 2024 16:09:21 +0200 Subject: [PATCH] Update to NeoForge 1.20.4 --- .github/workflows/ci.yml | 2 + .gitignore | 2 + build.gradle | 160 ++++++++---------- gradle.properties | 11 +- settings.gradle | 6 +- .../integratedscripting/Capabilities.java | 14 ++ .../integratedscripting/GeneralConfig.java | 2 +- .../IntegratedScripting.java | 44 +++-- .../integratedscripting/RegistryEntries.java | 22 +-- .../api/language/ILanguageHandler.java | 4 +- .../block/BlockScriptingDrive.java | 9 + .../BlockEntityScriptingDrive.java | 34 +++- .../BlockEntityScriptingDriveConfig.java | 9 +- ...criptingNetworkCapabilityConstructors.java | 11 +- .../network/ScriptingNetworkConfig.java | 27 --- .../gui/component/input/WidgetTextArea.java | 10 +- .../ContainerScreenTerminalScripting.java | 6 +- .../evaluate/ScriptVariableFacadeHandler.java | 12 ++ .../core/item/ScriptVariableFacade.java | 6 +- .../language/LanguageHandlerRegistry.java | 6 +- .../language/TypeScriptTypingsGenerator.java | 4 +- .../core/network/ScriptingNetworkHelpers.java | 10 +- .../container/ContainerScriptingDrive.java | 4 +- .../ContainerScriptingDriveConfig.java | 4 +- .../container/ContainerTerminalScripting.java | 8 +- .../ContainerTerminalScriptingConfig.java | 4 +- .../item/ItemScriptingDisk.java | 4 +- ...erminalScriptingCreateNewScriptPacket.java | 11 +- .../TerminalScriptingDeleteScriptPacket.java | 11 +- ...TerminalScriptingModifiedScriptPacket.java | 11 +- .../part/PartTypeTerminalScripting.java | 4 +- .../proxy/CommonProxy.java | 6 +- src/main/resources/META-INF/mods.toml | 18 +- .../advancements/basics/mendesite.json | 10 +- .../advancements/basics/scripting_disk.json | 10 +- .../advancements/basics/scripting_drive.json | 10 +- .../advancements/functions/filter_chest.json | 4 +- .../advancements/terminal/display.json | 2 +- .../recipes/drying_basin/mendesite.json | 12 +- .../mechanical_drying_basin/mendesite.json | 12 +- 40 files changed, 284 insertions(+), 272 deletions(-) create mode 100644 src/main/java/org/cyclops/integratedscripting/Capabilities.java delete mode 100644 src/main/java/org/cyclops/integratedscripting/capability/network/ScriptingNetworkConfig.java diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e7c48a11..024329af 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -49,6 +49,8 @@ jobs: SIGN_STOREPASS: ${{ secrets.SIGN_STOREPASS }} MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }} MAVEN_KEY: ${{ secrets.MAVEN_KEY }} + GITHUB_USER: ${{ github.actor }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: 'Test' env: COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }} diff --git a/.gitignore b/.gitignore index 2f1e37b2..b50deb84 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ doc/info.txt /build /run +/runs # Ignore project specific files .classpath @@ -17,6 +18,7 @@ repo/* *.iws out/* keystore.jks +.idea # Ignore mac-specific file(s) .DS_Store diff --git a/build.gradle b/build.gradle index a6ac36dd..3232eae0 100644 --- a/build.gradle +++ b/build.gradle @@ -1,18 +1,17 @@ plugins { - id 'net.minecraftforge.gradle' version '[6.0,6.2)' - id 'com.matthewprenger.cursegradle' version '1.4.0' + id 'net.neoforged.gradle.userdev' version '7.0.97' + id 'net.darkhax.curseforgegradle' version '1.0.8' id 'com.github.kt3k.coveralls' version '2.12.0' id 'com.diffplug.spotless' version '5.14.3' id 'com.github.johnrengelman.shadow' version '8.1.1' id 'com.modrinth.minotaur' version '2.+' } -apply plugin: 'net.minecraftforge.gradle' apply plugin: 'idea' apply plugin: 'maven-publish' apply plugin: 'jacoco' -import net.minecraftforge.gradle.common.tasks.SignJar +import net.neoforged.gradle.common.tasks.PotentiallySignJar // Determine build number String build_number = "DEV" // this will be referenced as simply build_number from now on. @@ -29,7 +28,10 @@ logger.lifecycle "BUILDING VERSION: " + build_number // Set mod details version = project.mod_version group = "org.cyclops.integratedscripting" -archivesBaseName = "IntegratedScripting" +archivesBaseName = "IntegratedScripting-${project.minecraft_version}-neoforge" +base { + archivesName = archivesBaseName +} // Set Java details java.toolchain.languageVersion = JavaLanguageVersion.of(17) @@ -50,6 +52,7 @@ sourceSets { main test } +sourceSets.main.resources { srcDir 'src/generated/resources' } configurations { modLib @@ -69,33 +72,33 @@ repositories { name "Cyclops Repo" url "https://maven.pkg.github.com/CyclopsMC/packages" credentials { - username = project.findProperty("gpr.user") ?: System.getenv("MAVEN_USERNAME") - password = project.findProperty("gpr.key") ?: System.getenv("MAVEN_KEY") + username = project.findProperty("gpr.user") ?: System.getenv("MAVEN_USERNAME") ?: System.getenv("GITHUB_USER") + password = project.findProperty("gpr.key") ?: System.getenv("MAVEN_KEY") ?: System.getenv("GITHUB_TOKEN") } } } dependencies { - minecraft "net.minecraftforge:forge:${project.minecraft_version}-${project.forge_version}" + implementation "net.neoforged:neoforge:${project.neoforge_version}" // Add something like 'cyclopscore_version_local=0.1.0-DEV' to your secrets.properties if you want to use a custom local CyclopsCore version. if(secrets.cyclopscore_version_local) { - implementation "org.cyclops.cyclopscore:cyclopscore:${project.minecraft_version}-${secrets.cyclopscore_version_local}:deobf" + implementation "org.cyclops.cyclopscore:cyclopscore-${project.minecraft_version}-neoforge:${secrets.cyclopscore_version_local}:deobf" } else { - implementation "org.cyclops.cyclopscore:cyclopscore:${project.minecraft_version}-${project.cyclopscore_version}:deobf" + implementation "org.cyclops.cyclopscore:cyclopscore-${project.minecraft_version}-neoforge:${project.cyclopscore_version}:deobf" } // Add something like 'integrateddynamics_version_local=0.1.0-DEV' to your secrets.properties if you want to use a custom local Integrated Tunnels Compat version. if(secrets.integrateddynamics_version_local) { - implementation "org.cyclops.integrateddynamics:integrateddynamics:${secrets.integrateddynamics_version_local}:deobf" + implementation "org.cyclops.integrateddynamics:integrateddynamics-${project.minecraft_version}-neoforge:${secrets.integrateddynamics_version_local}:deobf" } else { - implementation "org.cyclops.integrateddynamics:integrateddynamics:${project.integrateddynamics_version}:deobf" + implementation "org.cyclops.integrateddynamics:integrateddynamics-${project.minecraft_version}-neoforge:${project.integrateddynamics_version}:deobf" } if(secrets.commoncapabilities_version_local) { - implementation "org.cyclops.commoncapabilities:commoncapabilities:${secrets.commoncapabilities_version_local}:deobf" + implementation "org.cyclops.commoncapabilities:commoncapabilities-${project.minecraft_version}-neoforge:${secrets.commoncapabilities_version_local}:deobf" } else { - implementation fg.deobf("org.cyclops.commoncapabilities:commoncapabilities:${project.commoncapabilities_version}") { // https://dl.bintray.com/cyclopsmc/dev/org/cyclops/commoncapabilities/CommonCapabilities/ + implementation("org.cyclops.commoncapabilities:commoncapabilities-${project.minecraft_version}-neoforge:${project.commoncapabilities_version}") { // https://dl.bintray.com/cyclopsmc/dev/org/cyclops/commoncapabilities/CommonCapabilities/ transitive = false } } @@ -123,60 +126,40 @@ dependencies { testImplementation "org.mockito:mockito-core:1.+" } -minecraft { - mappings channel: "official", version: "${project.minecraft_version}" - - runs { - client { - workingDirectory project.file('run') - //property 'forge.logging.markers', 'REGISTRIES,REGISTRYDUMP' - property 'forge.logging.console.level', 'debug' - mods { - integratedscripting { - source sourceSets.main - } - } +runs { + configureEach { + systemProperty 'forge.logging.markers', 'REGISTRIES' + systemProperty 'forge.logging.console.level', 'debug' + systemProperty 'forge.logging.console.level', 'debug' + modSource project.sourceSets.main - lazyToken('minecraft_classpath') { - configurations.modLib.copyRecursive().resolve().collect { it.absolutePath }.join(File.pathSeparator) - } + dependencies { + runtime project.configurations.modLib } + } + + client { + systemProperty 'forge.enabledGameTestNamespaces', project.mod_id + } - server { - workingDirectory project.file('run') - property 'forge.logging.console.level', 'debug' - mods { - integratedscripting { - source sourceSets.main - } - } - - lazyToken('minecraft_classpath') { - configurations.modLib.copyRecursive().resolve().collect { it.absolutePath }.join(File.pathSeparator) - } - } + server { + systemProperty 'forge.enabledGameTestNamespaces', project.mod_id + programArgument '--nogui' + } - data { - workingDirectory project.file('run') - property 'forge.logging.console.level', 'debug' - args '--mod', 'integratedscripting', '--all', '--output', file('src/generated/resources/') - mods { - integratedscripting { - source sourceSets.main - } - } + gameTestServer { + systemProperty 'forge.enabledGameTestNamespaces', project.mod_id + } - lazyToken('minecraft_classpath') { - configurations.modLib.copyRecursive().resolve().collect { it.absolutePath }.join(File.pathSeparator) - } - } + data { + programArguments.addAll '--mod', project.mod_id, '--all', '--output', file('src/generated/resources/').getAbsolutePath(), '--existing', file('src/main/resources/').getAbsolutePath() } } if (build_number.equals("RELEASE")) - version = "${project.minecraft_version}-${project.mod_version}" + version = "${project.mod_version}" else - version = "${project.minecraft_version}-${project.mod_version}-${build_number}" + version = "${project.mod_version}-${build_number}" jar { archiveClassifier.set('slim') @@ -193,7 +176,9 @@ jar { } } -task signJar(type: SignJar, dependsOn: jar) { +task signJar(type: PotentiallySignJar, dependsOn: jar) { + dependsOn(tasks.jar) + onlyIf { System.getenv().SIGN_KEYSTORE } @@ -202,10 +187,9 @@ task signJar(type: SignJar, dependsOn: jar) { alias = System.getenv().SIGN_ALIAS storePass = System.getenv().SIGN_STOREPASS keyPass = System.getenv().SIGN_KEYPASS - inputFile = jar.archivePath - outputFile = jar.archivePath + input = jar.archivePath + output = jar.archivePath } -build.dependsOn signJar task deobfJar(type: Jar) { from sourceSets.main.output @@ -243,12 +227,10 @@ shadowJar { relocate 'org.graalvm', 'org.cyclops.integratedscripting.vendors.org.graalvm' relocate 'com.oracle', 'org.cyclops.integratedscripting.vendors.com.oracle' relocate 'com.ibm', 'org.cyclops.integratedscripting.vendors.com.ibm' - finalizedBy 'reobfShadowJar' } - assemble.dependsOn shadowJar -reobf { - shadowJar {} // Reobfuscate the shadowed JAR +jar { + shadowJar {} } artifacts { @@ -258,33 +240,29 @@ artifacts { archives javadocJar } -curseforge { - if(project.hasProperty("curseforge_key")) { - apiKey = project.curseforge_key - } else if((System.getenv().TRAVIS || System.getenv().GITHUB_ACTIONS) && System.getenv().CURSEFORGE_KEY_SECRET) { - apiKey = System.getenv().CURSEFORGE_KEY_SECRET - } +task publishCurseForge(type: net.darkhax.curseforgegradle.TaskPublishCurseForge) { + dependsOn(tasks.jar) - project { - id = "889785" // my project url is http://minecraft.curseforge.com/mc-mods/889785/ - releaseType = project.project.release_type - addGameVersion project.minecraft_version - mainArtifact(shadowJar) { - relations { - requiredDependency 'cyclops-core' - requiredDependency 'integrated-dynamics' - } - } + if(secrets.hasProperty("curseforge_key") && secrets.hasProperty("changelog")) { + apiToken = secrets.curseforge_key + } else if(System.getenv().GITHUB_ACTIONS && System.getenv().CURSEFORGE_KEY_SECRET) { + apiToken = System.getenv().CURSEFORGE_KEY_SECRET + } else { + apiToken = "DUMMY" + } - changelog = "" - if (new File("resources/changelog/${project.version}.txt").exists()) { - changelog = new File("resources/changelog/${project.version}.txt").text - } + def projectId = "889785" // my project url is http://minecraft.curseforge.com/mc-mods/889785/ - addArtifact deobfJar - addArtifact sourcesJar - addArtifact javadocJar + def mainFile = upload(projectId, jar) + mainFile.changelogType = "text" + if (new File("resources/changelog/${project.version}.txt").exists()) { + mainFile.changelog = file("resources/changelog/${project.version}.txt") } + mainFile.addGameVersion(project.minecraft_version) + mainFile.addModLoader("NeoForge") + + mainFile.addRequirement('cyclops-core') + mainFile.addRequirement('integrated-dynamics') } modrinth { @@ -375,3 +353,7 @@ tasks.register('updateGitHooks', Copy) { into './.git/hooks' } compileJava.dependsOn updateGitHooks + +tasks.withType(JavaCompile).configureEach { + options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation +} diff --git a/gradle.properties b/gradle.properties index d5d3507c..fa47faba 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,12 +1,13 @@ +mod_id=integratedscripting mod_version=1.0.1 -minecraft_version=1.20.1 -forge_version=47.0.1 -cyclopscore_version=1.19.0-405 -integrateddynamics_version=1.20.1-1.21.0-699 +minecraft_version=1.20.4 +neoforge_version=20.4.160-beta +cyclopscore_version=1.19.0-423 +integrateddynamics_version=1.21.2-740 release_type=release fingerprint=bd0353b3e8a2810d60dd584e256e364bc3bedd44 -commoncapabilities_version=1.20.1-2.9.0-98 +commoncapabilities_version=2.9.1-116 # Workaround for Spotless bug # https://github.com/diffplug/spotless/issues/834 diff --git a/settings.gradle b/settings.gradle index a30364e8..b359a59d 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,10 +1,8 @@ pluginManagement { repositories { + mavenLocal() gradlePluginPortal() - maven { - name = 'MinecraftForge' - url = 'https://maven.minecraftforge.net/' - } + maven { url = 'https://maven.neoforged.net/releases' } } } diff --git a/src/main/java/org/cyclops/integratedscripting/Capabilities.java b/src/main/java/org/cyclops/integratedscripting/Capabilities.java new file mode 100644 index 00000000..054854dd --- /dev/null +++ b/src/main/java/org/cyclops/integratedscripting/Capabilities.java @@ -0,0 +1,14 @@ +package org.cyclops.integratedscripting; + +import net.minecraft.resources.ResourceLocation; +import org.cyclops.integrateddynamics.api.network.NetworkCapability; +import org.cyclops.integratedscripting.api.network.IScriptingNetwork; + +/** + * @author rubensworks + */ +public class Capabilities { + public static final class ScriptingNetwork { + public static final NetworkCapability NETWORK = NetworkCapability.create(new ResourceLocation(Reference.MOD_ID, "scripting_network"), IScriptingNetwork.class); + } +} diff --git a/src/main/java/org/cyclops/integratedscripting/GeneralConfig.java b/src/main/java/org/cyclops/integratedscripting/GeneralConfig.java index 9ea79abf..7d77b2ee 100644 --- a/src/main/java/org/cyclops/integratedscripting/GeneralConfig.java +++ b/src/main/java/org/cyclops/integratedscripting/GeneralConfig.java @@ -1,6 +1,6 @@ package org.cyclops.integratedscripting; -import net.minecraftforge.fml.config.ModConfig; +import net.neoforged.fml.config.ModConfig; import org.cyclops.cyclopscore.config.ConfigurableProperty; import org.cyclops.cyclopscore.config.extendedconfig.DummyConfig; import org.cyclops.cyclopscore.tracking.Versions; diff --git a/src/main/java/org/cyclops/integratedscripting/IntegratedScripting.java b/src/main/java/org/cyclops/integratedscripting/IntegratedScripting.java index e15f850e..8dad24a1 100644 --- a/src/main/java/org/cyclops/integratedscripting/IntegratedScripting.java +++ b/src/main/java/org/cyclops/integratedscripting/IntegratedScripting.java @@ -4,18 +4,18 @@ import net.minecraft.commands.CommandSourceStack; import net.minecraft.world.item.CreativeModeTab; import net.minecraft.world.item.ItemStack; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.event.TickEvent; -import net.minecraftforge.event.server.ServerStartedEvent; -import net.minecraftforge.event.server.ServerStoppingEvent; -import net.minecraftforge.eventbus.api.SubscribeEvent; -import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; -import net.minecraftforge.fml.event.lifecycle.FMLLoadCompleteEvent; -import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; -import net.minecraftforge.registries.NewRegistryEvent; +import net.neoforged.api.distmarker.Dist; +import net.neoforged.api.distmarker.OnlyIn; +import net.neoforged.bus.api.IEventBus; +import net.neoforged.bus.api.SubscribeEvent; +import net.neoforged.fml.common.Mod; +import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent; +import net.neoforged.fml.event.lifecycle.FMLLoadCompleteEvent; +import net.neoforged.neoforge.common.NeoForge; +import net.neoforged.neoforge.event.TickEvent; +import net.neoforged.neoforge.event.server.ServerStartedEvent; +import net.neoforged.neoforge.event.server.ServerStoppingEvent; +import net.neoforged.neoforge.registries.NewRegistryEvent; import org.apache.logging.log4j.Level; import org.cyclops.cyclopscore.config.ConfigHandler; import org.cyclops.cyclopscore.helper.MinecraftHelpers; @@ -32,7 +32,6 @@ import org.cyclops.integratedscripting.block.BlockScriptingDriveConfig; import org.cyclops.integratedscripting.blockentity.BlockEntityScriptingDriveConfig; import org.cyclops.integratedscripting.capability.ScriptingNetworkCapabilityConstructors; -import org.cyclops.integratedscripting.capability.network.ScriptingNetworkConfig; import org.cyclops.integratedscripting.command.CommandTestScript; import org.cyclops.integratedscripting.core.client.model.ScriptingVariableModelProviders; import org.cyclops.integratedscripting.core.evaluate.ScriptVariableFacadeHandler; @@ -60,16 +59,17 @@ public class IntegratedScripting extends ModBaseVersionable public ScriptingData scriptingData; - public IntegratedScripting() { - super(Reference.MOD_ID, (instance) -> _instance = instance); + public IntegratedScripting(IEventBus modEventBus) { + super(Reference.MOD_ID, (instance) -> _instance = instance, modEventBus); getRegistryManager().addRegistry(IValueTranslatorRegistry.class, ValueTranslatorRegistry.getInstance()); getRegistryManager().addRegistry(ILanguageHandlerRegistry.class, LanguageHandlerRegistry.getInstance()); - FMLJavaModLoadingContext.get().getModEventBus().addListener(this::onRegistriesCreate); - FMLJavaModLoadingContext.get().getModEventBus().addListener(this::afterSetup); - MinecraftForge.EVENT_BUS.addListener(this::onServerStarting); - MinecraftForge.EVENT_BUS.addListener(this::onServerTick); + modEventBus.addListener(this::onRegistriesCreate); + modEventBus.addListener(this::afterSetup); + modEventBus.register(new ScriptingNetworkCapabilityConstructors()); + NeoForge.EVENT_BUS.addListener(this::onServerStarting); + NeoForge.EVENT_BUS.addListener(this::onServerTick); } public void onRegistriesCreate(NewRegistryEvent event) { @@ -99,15 +99,13 @@ protected LiteralArgumentBuilder constructBaseCommand() { protected void setup(FMLCommonSetupEvent event) { super.setup(event); - MinecraftForge.EVENT_BUS.register(new ScriptingNetworkCapabilityConstructors()); - ValueTranslators.load(); LanguageHandlers.load(); } @SubscribeEvent public void onServerStarted(ServerStartedEvent event) { - MinecraftForge.EVENT_BUS.register(this.scriptingData = new ScriptingData(event.getServer().getWorldPath(ScriptingData.LEVEL_RESOURCE))); + this.scriptingData = new ScriptingData(event.getServer().getWorldPath(ScriptingData.LEVEL_RESOURCE)); } @Override @@ -149,8 +147,6 @@ protected CreativeModeTab.Builder constructDefaultCreativeModeTab(CreativeModeTa protected void onConfigsRegister(ConfigHandler configHandler) { super.onConfigsRegister(configHandler); - configHandler.addConfigurable(new ScriptingNetworkConfig()); - configHandler.addConfigurable(new ItemScriptingDiskConfig()); configHandler.addConfigurable(new BlockScriptingDriveConfig()); diff --git a/src/main/java/org/cyclops/integratedscripting/RegistryEntries.java b/src/main/java/org/cyclops/integratedscripting/RegistryEntries.java index 5c18cbd6..45ae970c 100644 --- a/src/main/java/org/cyclops/integratedscripting/RegistryEntries.java +++ b/src/main/java/org/cyclops/integratedscripting/RegistryEntries.java @@ -1,10 +1,12 @@ package org.cyclops.integratedscripting; +import net.minecraft.core.registries.Registries; +import net.minecraft.resources.ResourceLocation; import net.minecraft.world.inventory.MenuType; import net.minecraft.world.item.Item; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.entity.BlockEntityType; -import net.minecraftforge.registries.ObjectHolder; +import net.neoforged.neoforge.registries.DeferredHolder; import org.cyclops.integrateddynamics.blockentity.BlockEntityVariablestore; import org.cyclops.integratedscripting.inventory.container.ContainerScriptingDrive; import org.cyclops.integratedscripting.inventory.container.ContainerTerminalScripting; @@ -14,19 +16,13 @@ * @author rubensworks */ public class RegistryEntries { - @ObjectHolder(registryName = "item", value = "integratedscripting:scripting_disk") - public static final Item ITEM_SCRIPTING_DISK = null; + public static final DeferredHolder ITEM_SCRIPTING_DISK = DeferredHolder.create(Registries.ITEM, new ResourceLocation("integratedscripting:scripting_disk")); - @ObjectHolder(registryName = "block", value = "integratedscripting:scripting_drive") - public static final Block BLOCK_SCRIPTING_DRIVE = null; - @ObjectHolder(registryName = "block", value = "integratedscripting:part_terminal_scripting") - public static final Block BLOCK_PART_TERMINAL_SCRIPTING = null; + public static final DeferredHolder BLOCK_SCRIPTING_DRIVE = DeferredHolder.create(Registries.BLOCK, new ResourceLocation("integratedscripting:scripting_drive")); + public static final DeferredHolder BLOCK_PART_TERMINAL_SCRIPTING = DeferredHolder.create(Registries.BLOCK, new ResourceLocation("integratedscripting:part_terminal_scripting")); - @ObjectHolder(registryName = "block_entity_type", value = "integratedscripting:scripting_drive") - public static final BlockEntityType BLOCK_ENTITY_SCRIPTING_DRIVE = null; + public static final DeferredHolder, BlockEntityType> BLOCK_ENTITY_SCRIPTING_DRIVE = DeferredHolder.create(Registries.BLOCK_ENTITY_TYPE, new ResourceLocation("integratedscripting:scripting_drive")); - @ObjectHolder(registryName = "menu", value = "integratedscripting:scripting_drive") - public static final MenuType CONTAINER_SCRIPTING_DRIVE = null; - @ObjectHolder(registryName = "menu", value = "integratedscripting:part_terminal_scripting") - public static final MenuType CONTAINER_TERMINAL_SCRIPTING = null; + public static final DeferredHolder, MenuType> CONTAINER_SCRIPTING_DRIVE = DeferredHolder.create(Registries.MENU, new ResourceLocation("integratedscripting:scripting_drive")); + public static final DeferredHolder, MenuType> CONTAINER_TERMINAL_SCRIPTING = DeferredHolder.create(Registries.MENU, new ResourceLocation("integratedscripting:part_terminal_scripting")); } diff --git a/src/main/java/org/cyclops/integratedscripting/api/language/ILanguageHandler.java b/src/main/java/org/cyclops/integratedscripting/api/language/ILanguageHandler.java index 3f5acf97..55962bb2 100644 --- a/src/main/java/org/cyclops/integratedscripting/api/language/ILanguageHandler.java +++ b/src/main/java/org/cyclops/integratedscripting/api/language/ILanguageHandler.java @@ -1,8 +1,8 @@ package org.cyclops.integratedscripting.api.language; import net.minecraft.network.chat.Style; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; +import net.neoforged.api.distmarker.Dist; +import net.neoforged.api.distmarker.OnlyIn; import org.apache.commons.lang3.tuple.Pair; import org.cyclops.cyclopscore.client.gui.image.IImage; import org.cyclops.integrateddynamics.api.evaluate.EvaluationException; diff --git a/src/main/java/org/cyclops/integratedscripting/block/BlockScriptingDrive.java b/src/main/java/org/cyclops/integratedscripting/block/BlockScriptingDrive.java index 26fb8f01..c3621244 100644 --- a/src/main/java/org/cyclops/integratedscripting/block/BlockScriptingDrive.java +++ b/src/main/java/org/cyclops/integratedscripting/block/BlockScriptingDrive.java @@ -1,8 +1,10 @@ package org.cyclops.integratedscripting.block; +import com.mojang.serialization.MapCodec; import net.minecraft.core.Direction; import net.minecraft.world.item.context.BlockPlaceContext; import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.BaseEntityBlock; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntityTicker; @@ -23,6 +25,8 @@ */ public class BlockScriptingDrive extends BlockWithEntityGuiCabled { + public static final MapCodec CODEC = simpleCodec(BlockScriptingDrive::new); + public static final DirectionProperty FACING = BlockStateProperties.HORIZONTAL_FACING; public BlockScriptingDrive(Properties properties) { @@ -32,6 +36,11 @@ public BlockScriptingDrive(Properties properties) { .setValue(FACING, Direction.NORTH)); } + @Override + protected MapCodec codec() { + return CODEC; + } + @Override @Nullable public BlockEntityTicker getTicker(Level level, BlockState blockState, BlockEntityType blockEntityType) { diff --git a/src/main/java/org/cyclops/integratedscripting/blockentity/BlockEntityScriptingDrive.java b/src/main/java/org/cyclops/integratedscripting/blockentity/BlockEntityScriptingDrive.java index 38930117..127d2bec 100644 --- a/src/main/java/org/cyclops/integratedscripting/blockentity/BlockEntityScriptingDrive.java +++ b/src/main/java/org/cyclops/integratedscripting/blockentity/BlockEntityScriptingDrive.java @@ -9,21 +9,22 @@ import net.minecraft.world.inventory.AbstractContainerMenu; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.state.BlockState; -import net.minecraftforge.common.capabilities.ForgeCapabilities; -import net.minecraftforge.common.util.LazyOptional; +import net.neoforged.neoforge.capabilities.RegisterCapabilitiesEvent; import org.cyclops.cyclopscore.datastructure.DimPos; import org.cyclops.cyclopscore.inventory.SimpleInventory; import org.cyclops.cyclopscore.persist.IDirtyMarkListener; +import org.cyclops.integrateddynamics.Capabilities; import org.cyclops.integrateddynamics.api.network.INetworkElement; -import org.cyclops.integrateddynamics.capability.networkelementprovider.NetworkElementProviderConfig; +import org.cyclops.integrateddynamics.api.network.INetworkElementProvider; import org.cyclops.integrateddynamics.capability.networkelementprovider.NetworkElementProviderSingleton; import org.cyclops.integrateddynamics.core.blockentity.BlockEntityCableConnectableInventory; import org.cyclops.integratedscripting.RegistryEntries; +import org.cyclops.integratedscripting.core.network.ScriptingDriveNetworkElement; import org.cyclops.integratedscripting.core.network.ScriptingNetworkHelpers; import org.cyclops.integratedscripting.inventory.container.ContainerScriptingDrive; import org.cyclops.integratedscripting.item.ItemScriptingDisk; -import org.cyclops.integratedscripting.core.network.ScriptingDriveNetworkElement; import javax.annotation.Nullable; @@ -42,16 +43,33 @@ public class BlockEntityScriptingDrive extends BlockEntityCableConnectableInvent private int exposedDiskId = -1; public BlockEntityScriptingDrive(BlockPos blockPos, BlockState blockState) { - super(RegistryEntries.BLOCK_ENTITY_SCRIPTING_DRIVE, blockPos, blockState, BlockEntityScriptingDrive.INVENTORY_SIZE, 1); + super(RegistryEntries.BLOCK_ENTITY_SCRIPTING_DRIVE.get(), blockPos, blockState, BlockEntityScriptingDrive.INVENTORY_SIZE, 1); getInventory().addDirtyMarkListener(this); + } - addCapabilityInternal(ForgeCapabilities.ITEM_HANDLER, LazyOptional.of(() -> getInventory().getItemHandler())); - addCapabilityInternal(NetworkElementProviderConfig.CAPABILITY, LazyOptional.of(() -> new NetworkElementProviderSingleton() { + public static void registerScriptingDriveCapabilities(RegisterCapabilitiesEvent event, BlockEntityType blockEntityType) { + BlockEntityCableConnectableInventory.registerCableConnectableInventoryCapabilities(event, blockEntityType); + + event.registerBlockEntity( + net.neoforged.neoforge.capabilities.Capabilities.ItemHandler.BLOCK, + blockEntityType, + (blockEntity, context) -> blockEntity.getInventory().getItemHandler() + ); + event.registerBlockEntity( + Capabilities.NetworkElementProvider.BLOCK, + blockEntityType, + (blockEntity, context) -> blockEntity.getNetworkElementProvider() + ); + } + + @Override + public INetworkElementProvider getNetworkElementProvider() { + return new NetworkElementProviderSingleton() { @Override public INetworkElement createNetworkElement(Level world, BlockPos blockPos) { return new ScriptingDriveNetworkElement(DimPos.of(world, blockPos), () -> getExposedDiskId()); } - })); + }; } @Override diff --git a/src/main/java/org/cyclops/integratedscripting/blockentity/BlockEntityScriptingDriveConfig.java b/src/main/java/org/cyclops/integratedscripting/blockentity/BlockEntityScriptingDriveConfig.java index e89e6ffc..ea377fe7 100644 --- a/src/main/java/org/cyclops/integratedscripting/blockentity/BlockEntityScriptingDriveConfig.java +++ b/src/main/java/org/cyclops/integratedscripting/blockentity/BlockEntityScriptingDriveConfig.java @@ -2,7 +2,9 @@ import com.google.common.collect.Sets; import net.minecraft.world.level.block.entity.BlockEntityType; +import net.neoforged.neoforge.capabilities.RegisterCapabilitiesEvent; import org.cyclops.cyclopscore.config.extendedconfig.BlockEntityConfig; +import org.cyclops.integrateddynamics.IntegratedDynamics; import org.cyclops.integratedscripting.IntegratedScripting; import org.cyclops.integratedscripting.RegistryEntries; @@ -18,8 +20,13 @@ public BlockEntityScriptingDriveConfig() { IntegratedScripting._instance, "scripting_drive", (eConfig) -> new BlockEntityType<>(BlockEntityScriptingDrive::new, - Sets.newHashSet(RegistryEntries.BLOCK_SCRIPTING_DRIVE), null) + Sets.newHashSet(RegistryEntries.BLOCK_SCRIPTING_DRIVE.get()), null) ); + IntegratedDynamics._instance.getModEventBus().addListener(this::registerCapability); + } + + protected void registerCapability(RegisterCapabilitiesEvent event) { + BlockEntityScriptingDrive.registerScriptingDriveCapabilities(event, getInstance()); } } diff --git a/src/main/java/org/cyclops/integratedscripting/capability/ScriptingNetworkCapabilityConstructors.java b/src/main/java/org/cyclops/integratedscripting/capability/ScriptingNetworkCapabilityConstructors.java index 9d472540..7b4eb068 100644 --- a/src/main/java/org/cyclops/integratedscripting/capability/ScriptingNetworkCapabilityConstructors.java +++ b/src/main/java/org/cyclops/integratedscripting/capability/ScriptingNetworkCapabilityConstructors.java @@ -1,11 +1,9 @@ package org.cyclops.integratedscripting.capability; -import net.minecraft.resources.ResourceLocation; -import net.minecraftforge.eventbus.api.SubscribeEvent; +import net.neoforged.bus.api.SubscribeEvent; import org.cyclops.cyclopscore.modcompat.capabilities.DefaultCapabilityProvider; import org.cyclops.integrateddynamics.api.network.AttachCapabilitiesEventNetwork; -import org.cyclops.integratedscripting.Reference; -import org.cyclops.integratedscripting.capability.network.ScriptingNetworkConfig; +import org.cyclops.integratedscripting.Capabilities; import org.cyclops.integratedscripting.core.network.ScriptingNetwork; /** @@ -16,10 +14,7 @@ public class ScriptingNetworkCapabilityConstructors { @SubscribeEvent public void onNetworkLoad(AttachCapabilitiesEventNetwork event) { ScriptingNetwork scriptingNetwork = new ScriptingNetwork(); - event.addCapability( - new ResourceLocation(Reference.MOD_ID, "scripting_network"), - new DefaultCapabilityProvider<>(() -> ScriptingNetworkConfig.CAPABILITY, scriptingNetwork) - ); + event.register(Capabilities.ScriptingNetwork.NETWORK, new DefaultCapabilityProvider<>(scriptingNetwork)); } } diff --git a/src/main/java/org/cyclops/integratedscripting/capability/network/ScriptingNetworkConfig.java b/src/main/java/org/cyclops/integratedscripting/capability/network/ScriptingNetworkConfig.java deleted file mode 100644 index 0beec057..00000000 --- a/src/main/java/org/cyclops/integratedscripting/capability/network/ScriptingNetworkConfig.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.cyclops.integratedscripting.capability.network; - -import net.minecraftforge.common.capabilities.Capability; -import net.minecraftforge.common.capabilities.CapabilityManager; -import net.minecraftforge.common.capabilities.CapabilityToken; -import org.cyclops.cyclopscore.config.extendedconfig.CapabilityConfig; -import org.cyclops.integratedscripting.IntegratedScripting; -import org.cyclops.integratedscripting.api.network.IScriptingNetwork; - -/** - * Config for the item network capability. - * @author rubensworks - * - */ -public class ScriptingNetworkConfig extends CapabilityConfig { - - public static Capability CAPABILITY = CapabilityManager.get(new CapabilityToken<>(){}); - - public ScriptingNetworkConfig() { - super( - IntegratedScripting._instance, - "scriptingNetwork", - IScriptingNetwork.class - ); - } - -} diff --git a/src/main/java/org/cyclops/integratedscripting/client/gui/component/input/WidgetTextArea.java b/src/main/java/org/cyclops/integratedscripting/client/gui/component/input/WidgetTextArea.java index d4828cbf..fd8f3ff5 100644 --- a/src/main/java/org/cyclops/integratedscripting/client/gui/component/input/WidgetTextArea.java +++ b/src/main/java/org/cyclops/integratedscripting/client/gui/component/input/WidgetTextArea.java @@ -27,8 +27,8 @@ import net.minecraft.network.chat.Component; import net.minecraft.network.chat.MutableComponent; import net.minecraft.network.chat.Style; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; +import net.neoforged.api.distmarker.Dist; +import net.neoforged.api.distmarker.OnlyIn; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.mutable.MutableBoolean; import org.apache.commons.lang3.mutable.MutableInt; @@ -53,7 +53,7 @@ * * {@link #tick()} * * {@link #mouseClicked(double, double, int)} * * {@link #mouseDragged(double, double, int, double, double)} - * * {@link #mouseScrolled(double, double, double)} + * * {@link #mouseScrolled(double, double, double, double)} * * {@link #keyPressed(int, int, int)} * * {@link #charTyped(char, int)} * @@ -277,10 +277,10 @@ private void selectWord(int p_98142_) { } @Override - public boolean mouseScrolled(double mouseX, double mouseY, double scroll) { + public boolean mouseScrolled(double mouseX, double mouseY, double mouseZ, double scroll) { if (this.scrollBar != null && mouseX >= this.getX() && mouseX < this.getX() + this.width && mouseY >= this.getY() && mouseY < this.getY() + this.height - && this.scrollBar.mouseScrolled(mouseX, mouseY, scroll)) { + && this.scrollBar.mouseScrolled(mouseX, mouseY, mouseZ, scroll)) { return true; } return false; diff --git a/src/main/java/org/cyclops/integratedscripting/client/gui/container/ContainerScreenTerminalScripting.java b/src/main/java/org/cyclops/integratedscripting/client/gui/container/ContainerScreenTerminalScripting.java index 37c5867b..a5b3d147 100644 --- a/src/main/java/org/cyclops/integratedscripting/client/gui/container/ContainerScreenTerminalScripting.java +++ b/src/main/java/org/cyclops/integratedscripting/client/gui/container/ContainerScreenTerminalScripting.java @@ -486,11 +486,11 @@ private void removeScript(Path path) { } @Override - public boolean mouseScrolled(double mouseX, double mouseY, double scroll) { - if (textArea.mouseScrolled(mouseX, mouseY, scroll)) { + public boolean mouseScrolled(double mouseX, double mouseY, double mouseZ, double scroll) { + if (textArea.mouseScrolled(mouseX, mouseY, mouseZ, scroll)) { return true; } - return super.mouseScrolled(mouseX, mouseY, scroll); + return super.mouseScrolled(mouseX, mouseY, mouseZ, scroll); } @Override diff --git a/src/main/java/org/cyclops/integratedscripting/core/evaluate/ScriptVariableFacadeHandler.java b/src/main/java/org/cyclops/integratedscripting/core/evaluate/ScriptVariableFacadeHandler.java index 75c2707c..0ca61c6d 100644 --- a/src/main/java/org/cyclops/integratedscripting/core/evaluate/ScriptVariableFacadeHandler.java +++ b/src/main/java/org/cyclops/integratedscripting/core/evaluate/ScriptVariableFacadeHandler.java @@ -3,7 +3,9 @@ import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.Tag; import net.minecraft.resources.ResourceLocation; +import org.cyclops.integrateddynamics.api.evaluate.variable.IVariable; import org.cyclops.integrateddynamics.api.evaluate.variable.ValueDeseralizationContext; +import org.cyclops.integrateddynamics.api.item.IVariableFacade; import org.cyclops.integrateddynamics.api.item.IVariableFacadeHandler; import org.cyclops.integratedscripting.Reference; import org.cyclops.integratedscripting.api.item.IScriptVariableFacade; @@ -54,4 +56,14 @@ public void setVariableFacade(CompoundTag tag, IScriptVariableFacade variableFac tag.putString("path", variableFacade.getPath().toString()); tag.putString("member", variableFacade.getMember()); } + + @Override + public boolean isInstance(IVariableFacade variableFacade) { + return variableFacade instanceof IScriptVariableFacade; + } + + @Override + public boolean isInstance(IVariable variable) { + return variable instanceof ScriptVariable; + } } diff --git a/src/main/java/org/cyclops/integratedscripting/core/item/ScriptVariableFacade.java b/src/main/java/org/cyclops/integratedscripting/core/item/ScriptVariableFacade.java index a0602721..2980dc06 100644 --- a/src/main/java/org/cyclops/integratedscripting/core/item/ScriptVariableFacade.java +++ b/src/main/java/org/cyclops/integratedscripting/core/item/ScriptVariableFacade.java @@ -6,9 +6,9 @@ import net.minecraft.network.chat.Component; import net.minecraft.util.RandomSource; import net.minecraft.world.level.Level; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.client.model.data.ModelData; +import net.neoforged.api.distmarker.Dist; +import net.neoforged.api.distmarker.OnlyIn; +import net.neoforged.neoforge.client.model.data.ModelData; import org.cyclops.integrateddynamics.api.client.model.IVariableModelBaked; import org.cyclops.integrateddynamics.api.evaluate.EvaluationException; import org.cyclops.integrateddynamics.api.evaluate.variable.IValue; diff --git a/src/main/java/org/cyclops/integratedscripting/core/language/LanguageHandlerRegistry.java b/src/main/java/org/cyclops/integratedscripting/core/language/LanguageHandlerRegistry.java index ed19f567..b8d609fd 100644 --- a/src/main/java/org/cyclops/integratedscripting/core/language/LanguageHandlerRegistry.java +++ b/src/main/java/org/cyclops/integratedscripting/core/language/LanguageHandlerRegistry.java @@ -1,8 +1,8 @@ package org.cyclops.integratedscripting.core.language; import com.google.common.collect.Maps; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.event.server.ServerStartedEvent; +import net.neoforged.neoforge.common.NeoForge; +import net.neoforged.neoforge.event.server.ServerStartedEvent; import org.cyclops.integratedscripting.api.language.ILanguageHandler; import org.cyclops.integratedscripting.api.language.ILanguageHandlerRegistry; import org.cyclops.integratedscripting.evaluate.ScriptHelpers; @@ -21,7 +21,7 @@ public class LanguageHandlerRegistry implements ILanguageHandlerRegistry { private final Map extensionToHandlerMap = Maps.newHashMap(); private LanguageHandlerRegistry() { - MinecraftForge.EVENT_BUS.addListener(this::onServerStarted); + NeoForge.EVENT_BUS.addListener(this::onServerStarted); } /** diff --git a/src/main/java/org/cyclops/integratedscripting/core/language/TypeScriptTypingsGenerator.java b/src/main/java/org/cyclops/integratedscripting/core/language/TypeScriptTypingsGenerator.java index f071227e..95aa9b29 100644 --- a/src/main/java/org/cyclops/integratedscripting/core/language/TypeScriptTypingsGenerator.java +++ b/src/main/java/org/cyclops/integratedscripting/core/language/TypeScriptTypingsGenerator.java @@ -1,8 +1,8 @@ package org.cyclops.integratedscripting.core.language; import net.minecraft.client.resources.language.I18n; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.fml.DistExecutor; +import net.neoforged.api.distmarker.Dist; +import net.neoforged.fml.DistExecutor; import org.cyclops.cyclopscore.helper.L10NHelpers; import org.cyclops.integrateddynamics.api.evaluate.operator.IOperator; import org.cyclops.integrateddynamics.api.evaluate.variable.IValueType; diff --git a/src/main/java/org/cyclops/integratedscripting/core/network/ScriptingNetworkHelpers.java b/src/main/java/org/cyclops/integratedscripting/core/network/ScriptingNetworkHelpers.java index e7158b2d..a013402b 100644 --- a/src/main/java/org/cyclops/integratedscripting/core/network/ScriptingNetworkHelpers.java +++ b/src/main/java/org/cyclops/integratedscripting/core/network/ScriptingNetworkHelpers.java @@ -1,13 +1,13 @@ package org.cyclops.integratedscripting.core.network; -import net.minecraftforge.common.util.LazyOptional; import org.cyclops.integrateddynamics.api.network.INetwork; +import org.cyclops.integratedscripting.Capabilities; import org.cyclops.integratedscripting.IntegratedScripting; import org.cyclops.integratedscripting.api.network.IScriptingData; import org.cyclops.integratedscripting.api.network.IScriptingNetwork; -import org.cyclops.integratedscripting.capability.network.ScriptingNetworkConfig; import javax.annotation.Nullable; +import java.util.Optional; /** * @author rubensworks @@ -27,11 +27,11 @@ public static IScriptingData getScriptingData() { * @param network The network. * @return The optional scripting network. */ - public static LazyOptional getScriptingNetwork(@Nullable INetwork network) { + public static Optional getScriptingNetwork(@Nullable INetwork network) { if (network == null) { - return LazyOptional.empty(); + return Optional.empty(); } - return network.getCapability(ScriptingNetworkConfig.CAPABILITY); + return network.getCapability(Capabilities.ScriptingNetwork.NETWORK); } } diff --git a/src/main/java/org/cyclops/integratedscripting/inventory/container/ContainerScriptingDrive.java b/src/main/java/org/cyclops/integratedscripting/inventory/container/ContainerScriptingDrive.java index f4864e86..ba280bb2 100644 --- a/src/main/java/org/cyclops/integratedscripting/inventory/container/ContainerScriptingDrive.java +++ b/src/main/java/org/cyclops/integratedscripting/inventory/container/ContainerScriptingDrive.java @@ -20,7 +20,7 @@ public ContainerScriptingDrive(int id, Inventory playerInventory) { } public ContainerScriptingDrive(int id, Inventory playerInventory, Container inventory) { - super(RegistryEntries.CONTAINER_SCRIPTING_DRIVE, id, playerInventory, inventory); + super(RegistryEntries.CONTAINER_SCRIPTING_DRIVE.get(), id, playerInventory, inventory); addInventory(inventory, 0, offsetX + 80, offsetY + 16, BlockEntityScriptingDrive.ROWS, BlockEntityScriptingDrive.COLS); addPlayerInventory(playerInventory, offsetX + 8, offsetY + 11 + BlockEntityScriptingDrive.ROWS * 18 + 17); } @@ -30,6 +30,6 @@ public Slot createNewSlot(Container inventory, int index, int row, int column) { if(inventory instanceof Inventory) { return super.createNewSlot(inventory, index, row, column); } - return new SlotSingleItem(inventory, index, row, column, RegistryEntries.ITEM_SCRIPTING_DISK); + return new SlotSingleItem(inventory, index, row, column, RegistryEntries.ITEM_SCRIPTING_DISK.get()); } } diff --git a/src/main/java/org/cyclops/integratedscripting/inventory/container/ContainerScriptingDriveConfig.java b/src/main/java/org/cyclops/integratedscripting/inventory/container/ContainerScriptingDriveConfig.java index a74797a5..4ed58957 100644 --- a/src/main/java/org/cyclops/integratedscripting/inventory/container/ContainerScriptingDriveConfig.java +++ b/src/main/java/org/cyclops/integratedscripting/inventory/container/ContainerScriptingDriveConfig.java @@ -5,8 +5,8 @@ import net.minecraft.client.gui.screens.inventory.MenuAccess; import net.minecraft.world.flag.FeatureFlags; import net.minecraft.world.inventory.MenuType; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; +import net.neoforged.api.distmarker.Dist; +import net.neoforged.api.distmarker.OnlyIn; import org.cyclops.cyclopscore.client.gui.ScreenFactorySafe; import org.cyclops.cyclopscore.config.extendedconfig.GuiConfig; import org.cyclops.integratedscripting.IntegratedScripting; diff --git a/src/main/java/org/cyclops/integratedscripting/inventory/container/ContainerTerminalScripting.java b/src/main/java/org/cyclops/integratedscripting/inventory/container/ContainerTerminalScripting.java index 40f2a7cc..ed7cbf75 100644 --- a/src/main/java/org/cyclops/integratedscripting/inventory/container/ContainerTerminalScripting.java +++ b/src/main/java/org/cyclops/integratedscripting/inventory/container/ContainerTerminalScripting.java @@ -82,7 +82,7 @@ public ContainerTerminalScripting(int id, Inventory playerInventory, FriendlyByt public ContainerTerminalScripting(int id, Inventory playerInventory, PartTarget target, Optional partContainer, PartTypeTerminalScripting partType, InitData initData) { - super(RegistryEntries.CONTAINER_TERMINAL_SCRIPTING, id, playerInventory, new SimpleInventory(1, 1)); + super(RegistryEntries.CONTAINER_TERMINAL_SCRIPTING.get(), id, playerInventory, new SimpleInventory(1, 1)); ((SimpleInventory) getContainerInventory()).addDirtyMarkListener(this); addSlot(new SlotVariable(getContainerInventory(), 0, 232, 137)); @@ -93,8 +93,8 @@ public ContainerTerminalScripting(int id, Inventory playerInventory, this.partContainer = partContainer; this.world = player.getCommandSenderWorld(); - this.network = NetworkHelpers.getNetwork(getTarget().getCenter()).resolve(); - this.scriptingNetwork = this.network.flatMap(network -> ScriptingNetworkHelpers.getScriptingNetwork(network).resolve()); + this.network = NetworkHelpers.getNetwork(getTarget().getCenter()); + this.scriptingNetwork = this.network.flatMap(ScriptingNetworkHelpers::getScriptingNetwork); this.clientScriptsDirty = Sets.newHashSet(); this.availableDisks = initData.getAvailableDisks(); @@ -370,7 +370,7 @@ public IScriptVariableFacade create(boolean generateId) { public IScriptVariableFacade create(int id) { return new ScriptVariableFacade(id, disk, path, member); } - }, getLevel(), player, RegistryEntries.BLOCK_PART_TERMINAL_SCRIPTING.defaultBlockState()); + }, getLevel(), player, RegistryEntries.BLOCK_PART_TERMINAL_SCRIPTING.get().defaultBlockState()); } @Override diff --git a/src/main/java/org/cyclops/integratedscripting/inventory/container/ContainerTerminalScriptingConfig.java b/src/main/java/org/cyclops/integratedscripting/inventory/container/ContainerTerminalScriptingConfig.java index ec9428a3..687e8f3c 100644 --- a/src/main/java/org/cyclops/integratedscripting/inventory/container/ContainerTerminalScriptingConfig.java +++ b/src/main/java/org/cyclops/integratedscripting/inventory/container/ContainerTerminalScriptingConfig.java @@ -4,8 +4,8 @@ import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.gui.screens.inventory.MenuAccess; import net.minecraft.world.flag.FeatureFlags; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; +import net.neoforged.api.distmarker.Dist; +import net.neoforged.api.distmarker.OnlyIn; import org.cyclops.cyclopscore.client.gui.ScreenFactorySafe; import org.cyclops.cyclopscore.config.extendedconfig.GuiConfig; import org.cyclops.cyclopscore.inventory.container.ContainerTypeData; diff --git a/src/main/java/org/cyclops/integratedscripting/item/ItemScriptingDisk.java b/src/main/java/org/cyclops/integratedscripting/item/ItemScriptingDisk.java index ffb3b1d2..a07fc9a9 100644 --- a/src/main/java/org/cyclops/integratedscripting/item/ItemScriptingDisk.java +++ b/src/main/java/org/cyclops/integratedscripting/item/ItemScriptingDisk.java @@ -9,8 +9,8 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.TooltipFlag; import net.minecraft.world.level.Level; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; +import net.neoforged.api.distmarker.Dist; +import net.neoforged.api.distmarker.OnlyIn; import org.cyclops.integrateddynamics.IntegratedDynamics; import org.cyclops.integratedscripting.Reference; diff --git a/src/main/java/org/cyclops/integratedscripting/network/packet/TerminalScriptingCreateNewScriptPacket.java b/src/main/java/org/cyclops/integratedscripting/network/packet/TerminalScriptingCreateNewScriptPacket.java index 13f5a64b..2ae0ed0e 100644 --- a/src/main/java/org/cyclops/integratedscripting/network/packet/TerminalScriptingCreateNewScriptPacket.java +++ b/src/main/java/org/cyclops/integratedscripting/network/packet/TerminalScriptingCreateNewScriptPacket.java @@ -1,12 +1,14 @@ package org.cyclops.integratedscripting.network.packet; +import net.minecraft.resources.ResourceLocation; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.player.Player; import net.minecraft.world.level.Level; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; +import net.neoforged.api.distmarker.Dist; +import net.neoforged.api.distmarker.OnlyIn; import org.cyclops.cyclopscore.network.CodecField; import org.cyclops.cyclopscore.network.PacketCodec; +import org.cyclops.integratedscripting.Reference; import org.cyclops.integratedscripting.inventory.container.ContainerTerminalScripting; @@ -17,14 +19,17 @@ */ public class TerminalScriptingCreateNewScriptPacket extends PacketCodec { + public static final ResourceLocation ID = new ResourceLocation(Reference.MOD_ID, "terminal_scripting_create_new_script"); + @CodecField private int disk; public TerminalScriptingCreateNewScriptPacket() { - + super(ID); } public TerminalScriptingCreateNewScriptPacket(int disk) { + super(ID); this.disk = disk; } diff --git a/src/main/java/org/cyclops/integratedscripting/network/packet/TerminalScriptingDeleteScriptPacket.java b/src/main/java/org/cyclops/integratedscripting/network/packet/TerminalScriptingDeleteScriptPacket.java index 521a46b5..da4e6a6c 100644 --- a/src/main/java/org/cyclops/integratedscripting/network/packet/TerminalScriptingDeleteScriptPacket.java +++ b/src/main/java/org/cyclops/integratedscripting/network/packet/TerminalScriptingDeleteScriptPacket.java @@ -1,12 +1,14 @@ package org.cyclops.integratedscripting.network.packet; +import net.minecraft.resources.ResourceLocation; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.player.Player; import net.minecraft.world.level.Level; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; +import net.neoforged.api.distmarker.Dist; +import net.neoforged.api.distmarker.OnlyIn; import org.cyclops.cyclopscore.network.CodecField; import org.cyclops.cyclopscore.network.PacketCodec; +import org.cyclops.integratedscripting.Reference; import org.cyclops.integratedscripting.inventory.container.ContainerTerminalScripting; import java.nio.file.Path; @@ -19,16 +21,19 @@ */ public class TerminalScriptingDeleteScriptPacket extends PacketCodec { + public static final ResourceLocation ID = new ResourceLocation(Reference.MOD_ID, "terminal_scripting_delete_script"); + @CodecField private int disk; @CodecField private String path; public TerminalScriptingDeleteScriptPacket() { - + super(ID); } public TerminalScriptingDeleteScriptPacket(int disk, Path path) { + super(ID); this.disk = disk; this.path = path.toString(); } diff --git a/src/main/java/org/cyclops/integratedscripting/network/packet/TerminalScriptingModifiedScriptPacket.java b/src/main/java/org/cyclops/integratedscripting/network/packet/TerminalScriptingModifiedScriptPacket.java index 4ec1ae4e..0aae7206 100644 --- a/src/main/java/org/cyclops/integratedscripting/network/packet/TerminalScriptingModifiedScriptPacket.java +++ b/src/main/java/org/cyclops/integratedscripting/network/packet/TerminalScriptingModifiedScriptPacket.java @@ -1,12 +1,14 @@ package org.cyclops.integratedscripting.network.packet; +import net.minecraft.resources.ResourceLocation; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.player.Player; import net.minecraft.world.level.Level; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; +import net.neoforged.api.distmarker.Dist; +import net.neoforged.api.distmarker.OnlyIn; import org.cyclops.cyclopscore.network.CodecField; import org.cyclops.cyclopscore.network.PacketCodec; +import org.cyclops.integratedscripting.Reference; import org.cyclops.integratedscripting.inventory.container.ContainerTerminalScripting; import java.nio.file.Path; @@ -20,6 +22,8 @@ */ public class TerminalScriptingModifiedScriptPacket extends PacketCodec { + public static final ResourceLocation ID = new ResourceLocation(Reference.MOD_ID, "terminal_scripting_modified_script"); + @CodecField private int disk; @CodecField @@ -28,10 +32,11 @@ public class TerminalScriptingModifiedScriptPacket extends PacketCodec { private List script; public TerminalScriptingModifiedScriptPacket() { - + super(ID); } public TerminalScriptingModifiedScriptPacket(int disk, Path path, String script) { + super(ID); this.disk = disk; this.path = path.toString(); this.script = Arrays.stream(script.split("\n")).toList(); diff --git a/src/main/java/org/cyclops/integratedscripting/part/PartTypeTerminalScripting.java b/src/main/java/org/cyclops/integratedscripting/part/PartTypeTerminalScripting.java index 9291a29a..058a575a 100644 --- a/src/main/java/org/cyclops/integratedscripting/part/PartTypeTerminalScripting.java +++ b/src/main/java/org/cyclops/integratedscripting/part/PartTypeTerminalScripting.java @@ -115,8 +115,8 @@ public void writeExtraGuiData(FriendlyByteBuf packetBuffer, PartPos pos, ServerP } protected ContainerTerminalScripting.InitData createContainerInitData(PartPos pos) { - Optional network = NetworkHelpers.getNetwork(pos).resolve(); - Optional scriptingNetwork = network.flatMap(net -> ScriptingNetworkHelpers.getScriptingNetwork(net).resolve()); + Optional network = NetworkHelpers.getNetwork(pos); + Optional scriptingNetwork = network.flatMap(ScriptingNetworkHelpers::getScriptingNetwork); IntArrayList availableDisks = scriptingNetwork .map(net -> net.getDisks().stream().sorted().collect(Collectors.toList())) .map(IntArrayList::new) diff --git a/src/main/java/org/cyclops/integratedscripting/proxy/CommonProxy.java b/src/main/java/org/cyclops/integratedscripting/proxy/CommonProxy.java index da022fa6..b422a3b8 100644 --- a/src/main/java/org/cyclops/integratedscripting/proxy/CommonProxy.java +++ b/src/main/java/org/cyclops/integratedscripting/proxy/CommonProxy.java @@ -24,8 +24,8 @@ public ModBase getMod() { public void registerPacketHandlers(PacketHandler packetHandler) { super.registerPacketHandlers(packetHandler); - packetHandler.register(TerminalScriptingModifiedScriptPacket.class); - packetHandler.register(TerminalScriptingCreateNewScriptPacket.class); - packetHandler.register(TerminalScriptingDeleteScriptPacket.class); + packetHandler.register(TerminalScriptingModifiedScriptPacket.ID, TerminalScriptingModifiedScriptPacket::new); + packetHandler.register(TerminalScriptingCreateNewScriptPacket.ID, TerminalScriptingCreateNewScriptPacket::new); + packetHandler.register(TerminalScriptingDeleteScriptPacket.ID, TerminalScriptingDeleteScriptPacket::new); } } diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index 77903274..af1409cd 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -1,5 +1,5 @@ modLoader="javafml" -loaderVersion="[47,)" +loaderVersion="[2,)" issueTrackerURL="https://github.com/CyclopsMC/IntegratedScripting/issues" displayURL="https://www.curseforge.com/minecraft/mc-mods/integrated-scripting" license="MIT" @@ -15,31 +15,31 @@ Create scripts for handling operations in Integrated Dynamics. ''' [[dependencies.integratedscripting]] modId="cyclopscore" - mandatory=true + type="required" versionRange="[1.19.0,)" ordering="NONE" side="BOTH" [[dependencies.integratedscripting]] modId="commoncapabilities" - mandatory=true + type="required" versionRange="[2.9.0,)" ordering="NONE" side="BOTH" [[dependencies.integratedscripting]] modId="integrateddynamics" - mandatory=true + type="required" versionRange="[1.21.0,)" ordering="NONE" side="BOTH" [[dependencies.integratedscripting]] - modId="forge" - mandatory=true - versionRange="[47.0.1,)" + modId="neoforge" + type="required" + versionRange="[20.4,)" ordering="NONE" side="BOTH" [[dependencies.integratedscripting]] modId="minecraft" - mandatory=true - versionRange="[1.20.1,]" + type="required" + versionRange="[1.20.4,]" ordering="NONE" side="BOTH" diff --git a/src/main/resources/data/integratedscripting/advancements/basics/mendesite.json b/src/main/resources/data/integratedscripting/advancements/basics/mendesite.json index b1d8a4ae..2d5f7ca4 100644 --- a/src/main/resources/data/integratedscripting/advancements/basics/mendesite.json +++ b/src/main/resources/data/integratedscripting/advancements/basics/mendesite.json @@ -15,13 +15,9 @@ "criteria_0": { "trigger": "minecraft:inventory_changed", "conditions": { - "items": [ - { - "items": [ - "integratedscripting:mendesite" - ] - } - ] + "item": { + "item": "integratedscripting:mendesite" + } } } } diff --git a/src/main/resources/data/integratedscripting/advancements/basics/scripting_disk.json b/src/main/resources/data/integratedscripting/advancements/basics/scripting_disk.json index b4c0754c..58fc2c3b 100644 --- a/src/main/resources/data/integratedscripting/advancements/basics/scripting_disk.json +++ b/src/main/resources/data/integratedscripting/advancements/basics/scripting_disk.json @@ -15,13 +15,9 @@ "criteria_0": { "trigger": "cyclopscore:item_crafted", "conditions": { - "items": [ - { - "items": [ - "integratedscripting:scripting_disk" - ] - } - ] + "item": { + "item": "integratedscripting:scripting_disk" + } } } } diff --git a/src/main/resources/data/integratedscripting/advancements/basics/scripting_drive.json b/src/main/resources/data/integratedscripting/advancements/basics/scripting_drive.json index 8eec899e..ec9191a4 100644 --- a/src/main/resources/data/integratedscripting/advancements/basics/scripting_drive.json +++ b/src/main/resources/data/integratedscripting/advancements/basics/scripting_drive.json @@ -15,13 +15,9 @@ "criteria_0": { "trigger": "cyclopscore:item_crafted", "conditions": { - "items": [ - { - "items": [ - "integratedscripting:scripting_drive" - ] - } - ] + "item": { + "item": "integratedscripting:scripting_drive" + } } } } diff --git a/src/main/resources/data/integratedscripting/advancements/functions/filter_chest.json b/src/main/resources/data/integratedscripting/advancements/functions/filter_chest.json index e8a45c3a..01324fdc 100644 --- a/src/main/resources/data/integratedscripting/advancements/functions/filter_chest.json +++ b/src/main/resources/data/integratedscripting/advancements/functions/filter_chest.json @@ -17,14 +17,14 @@ "conditions": { "parttype": "integrateddynamics:display_panel", "variable": { - "type": "integrateddynamics:operator", + "type": "operator", "operator": "integrateddynamics:operator_filter", "input": { "0": { "type": "integratedscripting:script" }, "1": { - "type": "integrateddynamics:aspect", + "type": "aspect", "aspect": "integrateddynamics:read_list_inventory_itemstacks" } } diff --git a/src/main/resources/data/integratedscripting/advancements/terminal/display.json b/src/main/resources/data/integratedscripting/advancements/terminal/display.json index 8c9f693d..f2b1aee0 100644 --- a/src/main/resources/data/integratedscripting/advancements/terminal/display.json +++ b/src/main/resources/data/integratedscripting/advancements/terminal/display.json @@ -15,7 +15,7 @@ "criteria_0": { "trigger": "integrateddynamics:part_variable_driven", "conditions": { - "parttype": "integrateddynamics:display_panel", + "part_type": "integrateddynamics:display_panel", "variable": { "type": "integratedscripting:script" } diff --git a/src/main/resources/data/integratedscripting/recipes/drying_basin/mendesite.json b/src/main/resources/data/integratedscripting/recipes/drying_basin/mendesite.json index 2ef7d48c..5991a4a2 100644 --- a/src/main/resources/data/integratedscripting/recipes/drying_basin/mendesite.json +++ b/src/main/resources/data/integratedscripting/recipes/drying_basin/mendesite.json @@ -1,12 +1,14 @@ { "type": "integrateddynamics:drying_basin", - "item": "minecraft:andesite", - "fluid": { - "fluid": "integrateddynamics:menril_resin", - "amount": 1000 + "input_item": { + "item": "minecraft:andesite" + }, + "input_fluid": { + "FluidName": "integrateddynamics:menril_resin", + "Amount": 1000 }, "duration": 300, - "result": { + "output_item": { "item": "integratedscripting:mendesite" } } \ No newline at end of file diff --git a/src/main/resources/data/integratedscripting/recipes/mechanical_drying_basin/mendesite.json b/src/main/resources/data/integratedscripting/recipes/mechanical_drying_basin/mendesite.json index 220ae00f..189aa614 100644 --- a/src/main/resources/data/integratedscripting/recipes/mechanical_drying_basin/mendesite.json +++ b/src/main/resources/data/integratedscripting/recipes/mechanical_drying_basin/mendesite.json @@ -1,12 +1,14 @@ { "type": "integrateddynamics:mechanical_drying_basin", - "item": "minecraft:andesite", - "fluid": { - "fluid": "integrateddynamics:menril_resin", - "amount": 1000 + "input_item": { + "item": "minecraft:andesite" + }, + "input_fluid": { + "FluidName": "integrateddynamics:menril_resin", + "Amount": 1000 }, "duration": 15, - "result": { + "output_item": { "item": "integratedscripting:mendesite" } } \ No newline at end of file