From 73f89f6604bf598f655e270ebf8b5047339e0b31 Mon Sep 17 00:00:00 2001 From: enjarai Date: Tue, 2 Apr 2024 14:36:22 +0200 Subject: [PATCH] The NeoForge 1.20.4! Got dam! --- CHANGELOG.md | 4 ++- build.gradle | 12 +++---- .../impl/key/InputContextImpl.java | 3 +- .../mixin/client/key/KeyBindingAccessor.java | 12 +++++++ .../resources/do_a_barrel_roll.accesswidener | 2 -- .../resources/do_a_barrel_roll.mixins.json | 1 + fabric/src/main/resources/fabric.mod.json | 3 +- gradle.properties | 8 ++--- neoforge/build.gradle | 7 ++-- ...rePublicTransportationInThisModLoader.java | 25 --------------- ...ublicTransportationInThisModLoaderMod.java | 32 +++++++++++++++++++ .../resources/META-INF/accesstransformer.cfg | 1 - .../src/main/resources/META-INF/mods.toml | 2 +- 13 files changed, 66 insertions(+), 46 deletions(-) create mode 100644 common/src/main/java/nl/enjarai/doabarrelroll/mixin/client/key/KeyBindingAccessor.java create mode 100644 neoforge/src/main/java/nl/enjarai/doabarrelroll/WhyIsTherePublicTransportationInThisModLoaderMod.java diff --git a/CHANGELOG.md b/CHANGELOG.md index edc724da..eb4b85e2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1 +1,3 @@ -- Fixed an issue with hud rendering on Forge introduced in a recent update. (#127) +- Fixed Controlify 2.0 compatibility. +- Updated Forge version to NeoForge 1.20.4. + - LexForge will not be supported from now on. diff --git a/build.gradle b/build.gradle index 632b424e..d3434d21 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,6 @@ plugins { id 'dev.architectury.loom' version '1.5-SNAPSHOT' apply(false) -// id 'me.fallenbreath.yamlang' version '1.3.1' apply(false) + id 'me.fallenbreath.yamlang' version '1.3.1' apply(false) id "me.modmuss50.mod-publish-plugin" version "0.4.4" apply(false) id 'maven-publish' } @@ -10,7 +10,7 @@ version = "${mod_version}+${minecraft_version}" subprojects { apply plugin: 'java' apply plugin: 'dev.architectury.loom' -// apply plugin: 'me.fallenbreath.yamlang' + apply plugin: 'me.fallenbreath.yamlang' apply plugin: "me.modmuss50.mod-publish-plugin" apply plugin: 'maven-publish' @@ -131,8 +131,8 @@ subprojects { enabled = false } -// yamlang { -// targetSourceSets = [sourceSets.main] -// inputDir = "assets/${mod_id}/lang" -// } + yamlang { + targetSourceSets = [sourceSets.main] + inputDir = "assets/${mod_id}/lang" + } } diff --git a/common/src/main/java/nl/enjarai/doabarrelroll/impl/key/InputContextImpl.java b/common/src/main/java/nl/enjarai/doabarrelroll/impl/key/InputContextImpl.java index 6a0a7a60..a37899fc 100644 --- a/common/src/main/java/nl/enjarai/doabarrelroll/impl/key/InputContextImpl.java +++ b/common/src/main/java/nl/enjarai/doabarrelroll/impl/key/InputContextImpl.java @@ -5,6 +5,7 @@ import net.minecraft.client.util.InputUtil; import net.minecraft.util.Identifier; import nl.enjarai.doabarrelroll.api.key.InputContext; +import nl.enjarai.doabarrelroll.mixin.client.key.KeyBindingAccessor; import nl.enjarai.doabarrelroll.util.key.ContextualKeyBinding; import java.util.HashMap; @@ -81,7 +82,7 @@ public KeyBinding getKeyBinding(InputUtil.Key key) { public void updateKeysByCode() { bindingsByKey.clear(); for (KeyBinding keyBinding : keyBindings) { - bindingsByKey.put(keyBinding.boundKey, keyBinding); + bindingsByKey.put(((KeyBindingAccessor) keyBinding).getBoundKey(), keyBinding); } } } diff --git a/common/src/main/java/nl/enjarai/doabarrelroll/mixin/client/key/KeyBindingAccessor.java b/common/src/main/java/nl/enjarai/doabarrelroll/mixin/client/key/KeyBindingAccessor.java new file mode 100644 index 00000000..df6471bf --- /dev/null +++ b/common/src/main/java/nl/enjarai/doabarrelroll/mixin/client/key/KeyBindingAccessor.java @@ -0,0 +1,12 @@ +package nl.enjarai.doabarrelroll.mixin.client.key; + +import net.minecraft.client.option.KeyBinding; +import net.minecraft.client.util.InputUtil; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +@Mixin(KeyBinding.class) +public interface KeyBindingAccessor { + @Accessor + public InputUtil.Key getBoundKey(); +} diff --git a/common/src/main/resources/do_a_barrel_roll.accesswidener b/common/src/main/resources/do_a_barrel_roll.accesswidener index 5c86bfd7..9ab21739 100644 --- a/common/src/main/resources/do_a_barrel_roll.accesswidener +++ b/common/src/main/resources/do_a_barrel_roll.accesswidener @@ -1,3 +1 @@ accessWidener v2 named - -accessible field net/minecraft/client/option/KeyBinding boundKey Lnet/minecraft/client/util/InputUtil$Key; \ No newline at end of file diff --git a/common/src/main/resources/do_a_barrel_roll.mixins.json b/common/src/main/resources/do_a_barrel_roll.mixins.json index fdafbce5..3eb41f0e 100644 --- a/common/src/main/resources/do_a_barrel_roll.mixins.json +++ b/common/src/main/resources/do_a_barrel_roll.mixins.json @@ -17,6 +17,7 @@ "client.InGameHudMixin", "client.LivingEntityMixin", "client.PlayerEntityMixin", + "client.key.KeyBindingAccessor", "client.key.KeyBindingEntryMixin", "client.key.KeyBindingMixin", "client.roll.CameraMixin", diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json index 04d82e54..e3471b98 100644 --- a/fabric/src/main/resources/fabric.mod.json +++ b/fabric/src/main/resources/fabric.mod.json @@ -58,7 +58,8 @@ "cicada": ">=0.6.0 <1.0.0" }, "breaks": { - "optifabric": "*" + "optifabric": "*", + "controlify": "<2.0.0-" }, "custom": { diff --git a/gradle.properties b/gradle.properties index 953f338d..7736f5af 100644 --- a/gradle.properties +++ b/gradle.properties @@ -15,11 +15,11 @@ publish_target_max=1.20.4 # Forge # The Forge version must agree with the Minecraft version to get a valid artifact -forge_version=20.4.73-beta +forge_version=20.4.218 # The Forge version range can use any version of Forge as bounds or match the loader version range -forge_version_range=[20.4.73-beta,) +forge_version_range=[20.4.218,) # The loader version range can only use the major version of Forge/FML as bounds -loader_version_range=[20.4,) +loader_version_range=[1,) # The Minecraft version range can use any release version of Minecraft as bounds. # Snapshots, pre-releases, and release candidates are not guaranteed to sort properly # as they do not follow standard versioning conventions. @@ -43,7 +43,7 @@ mod_description=Microsoft flight simulator for Minecraft elytras. mod_license=GPL-3.0 mod_url=https://enjarai.dev/ mod_github=enjarai/do-a-barrel-roll -git_branch=arch/1.20 +git_branch=arch/1.20.4 mod_modrinth=6FtRfnLg mod_curseforge=663658 mod_issue_tracker_url=https://github.com/enjarai/do-a-barrel-roll/issues diff --git a/neoforge/build.gradle b/neoforge/build.gradle index b04ff9c3..f905f4bd 100644 --- a/neoforge/build.gradle +++ b/neoforge/build.gradle @@ -75,11 +75,10 @@ publishing { publishMods { file = remapJar.archiveFile - displayName = "${property('mod_version')} for Forge ${property('minecraft_version')}" - version = "${project.version}-forge" + displayName = "${property('mod_version')} for NeoForge ${property('minecraft_version')}" + version = "${project.version}-neoforge" changelog = getRootProject().file("CHANGELOG.md").text type = STABLE - modLoaders.add("forge") modLoaders.add("neoforge") def min = property('publish_target_min') @@ -123,7 +122,7 @@ publishMods { accessToken = providers.gradleProperty('enjaraiGithubToken').get() commitish = property('git_branch') - tagName = "${project.version}-forge" + tagName = "${project.version}-neoforge" } } } diff --git a/neoforge/src/main/java/nl/enjarai/doabarrelroll/WhyIsTherePublicTransportationInThisModLoader.java b/neoforge/src/main/java/nl/enjarai/doabarrelroll/WhyIsTherePublicTransportationInThisModLoader.java index ce6f4f60..c698978e 100644 --- a/neoforge/src/main/java/nl/enjarai/doabarrelroll/WhyIsTherePublicTransportationInThisModLoader.java +++ b/neoforge/src/main/java/nl/enjarai/doabarrelroll/WhyIsTherePublicTransportationInThisModLoader.java @@ -1,18 +1,13 @@ package nl.enjarai.doabarrelroll; import net.minecraft.server.network.ServerPlayerEntity; -import net.minecraft.util.Identifier; import net.neoforged.bus.api.SubscribeEvent; import net.neoforged.fml.common.Mod; import net.neoforged.neoforge.event.TickEvent; import net.neoforged.neoforge.event.entity.player.PlayerEvent; -import net.neoforged.neoforge.network.event.RegisterPayloadHandlerEvent; -import net.neoforged.neoforge.network.registration.IPayloadRegistrar; import net.neoforged.neoforge.server.permission.events.PermissionGatherEvent; import net.neoforged.neoforge.server.permission.nodes.PermissionNode; -import java.util.Objects; - @Mod.EventBusSubscriber public class WhyIsTherePublicTransportationInThisModLoader { @SubscribeEvent @@ -33,24 +28,4 @@ public static void serverTick(TickEvent.ServerTickEvent event) { EventCallbacks.serverTick(event.getServer()); } } - - @SubscribeEvent - public static void register(final RegisterPayloadHandlerEvent event) { - final IPayloadRegistrar registrar = event.registrar(DoABarrelRoll.MODID); - registerChannel(registrar, DoABarrelRoll.HANDSHAKE_CHANNEL); - registerChannel(registrar, DoABarrelRoll.ROLL_CHANNEL); - } - - private static void registerChannel(IPayloadRegistrar registrar, Identifier id) { - registrar.play(id, buf -> new SillyPayload(buf, id), (payload, ctx) -> { - if (ctx.flow().getReceptionSide().isServer()) { - DoABarrelRollForge.SERVER_LISTENERS.get(id).forEach( - listener -> listener.accept(((ServerPlayerEntity) ctx.player().orElseThrow()).networkHandler, payload.buf(), - replyBuf -> ctx.replyHandler().send(new SillyPayload(replyBuf, id)))); - } else { - DoABarrelRollForge.CLIENT_LISTENERS.get(id).forEach( - listener -> listener.accept(payload.buf(), replyBuf -> ctx.replyHandler().send(new SillyPayload(replyBuf, id)))); - } - }); - } } diff --git a/neoforge/src/main/java/nl/enjarai/doabarrelroll/WhyIsTherePublicTransportationInThisModLoaderMod.java b/neoforge/src/main/java/nl/enjarai/doabarrelroll/WhyIsTherePublicTransportationInThisModLoaderMod.java new file mode 100644 index 00000000..1a15f964 --- /dev/null +++ b/neoforge/src/main/java/nl/enjarai/doabarrelroll/WhyIsTherePublicTransportationInThisModLoaderMod.java @@ -0,0 +1,32 @@ +package nl.enjarai.doabarrelroll; + +import net.minecraft.server.network.ServerPlayerEntity; +import net.minecraft.util.Identifier; +import net.neoforged.bus.api.SubscribeEvent; +import net.neoforged.fml.common.Mod; +import net.neoforged.neoforge.client.event.RegisterKeyMappingsEvent; +import net.neoforged.neoforge.network.event.RegisterPayloadHandlerEvent; +import net.neoforged.neoforge.network.registration.IPayloadRegistrar; + +@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD) +public class WhyIsTherePublicTransportationInThisModLoaderMod { + @SubscribeEvent + public static void register(RegisterPayloadHandlerEvent event) { + final IPayloadRegistrar registrar = event.registrar(DoABarrelRoll.MODID); + registerChannel(registrar, DoABarrelRoll.HANDSHAKE_CHANNEL); + registerChannel(registrar, DoABarrelRoll.ROLL_CHANNEL); + } + + private static void registerChannel(IPayloadRegistrar registrar, Identifier id) { + registrar.play(id, buf -> new SillyPayload(buf, id), (payload, ctx) -> { + if (ctx.flow().getReceptionSide().isServer()) { + DoABarrelRollForge.SERVER_LISTENERS.get(id).forEach( + listener -> listener.accept(((ServerPlayerEntity) ctx.player().orElseThrow()).networkHandler, payload.buf(), + replyBuf -> ctx.replyHandler().send(new SillyPayload(replyBuf, id)))); + } else { + DoABarrelRollForge.CLIENT_LISTENERS.get(id).forEach( + listener -> listener.accept(payload.buf(), replyBuf -> ctx.replyHandler().send(new SillyPayload(replyBuf, id)))); + } + }); + } +} diff --git a/neoforge/src/main/resources/META-INF/accesstransformer.cfg b/neoforge/src/main/resources/META-INF/accesstransformer.cfg index bd83e56d..e69de29b 100644 --- a/neoforge/src/main/resources/META-INF/accesstransformer.cfg +++ b/neoforge/src/main/resources/META-INF/accesstransformer.cfg @@ -1 +0,0 @@ -public net.minecraft.client.option.KeyBinding boundKey \ No newline at end of file diff --git a/neoforge/src/main/resources/META-INF/mods.toml b/neoforge/src/main/resources/META-INF/mods.toml index b6d60a1f..e543a470 100644 --- a/neoforge/src/main/resources/META-INF/mods.toml +++ b/neoforge/src/main/resources/META-INF/mods.toml @@ -49,7 +49,7 @@ file="META-INF/accesstransformer.cfg" description='''${mod_description}''' [[dependencies.'${mod_id}']] #optional # the modid of the dependency - modId = "forge" #mandatory + modId = "neoforge" #mandatory # Does this dependency have to exist - if not, ordering below must be specified type = "required" #mandatory # The version range of the dependency