From 79e935ffa81b4654d150169f78d565c483c18564 Mon Sep 17 00:00:00 2001 From: SashegDev Date: Sun, 23 Aug 2026 23:09:22 +0300 Subject: [PATCH] initial: server-side fix for Gunfire 0.1.6+ + SBW 0.8.9 ammo consume (me.sashegdev) - AT public-f AmmoConsumer.type --- .gitignore | 9 +++ LICENSE | 24 +++++++ README.md | 19 ++++++ build.gradle | 67 +++++++++++++++++++ gradle.properties | 9 +++ settings.gradle | 9 +++ .../sashegdev/gunfiresbfix/GunfireSBWFix.java | 9 +++ .../mixin/AmmoConsumerAccessor.java | 14 ++++ .../mixin/GunItemConsumeFixMixin.java | 17 +++++ .../resources/META-INF/accesstransformer.cfg | 1 + src/main/resources/META-INF/mods.toml | 35 ++++++++++ src/main/resources/mixins.gunfiresbfix.json | 13 ++++ src/main/resources/pack.mcmeta | 7 ++ 13 files changed, 233 insertions(+) create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 README.md create mode 100644 build.gradle create mode 100644 gradle.properties create mode 100644 settings.gradle create mode 100644 src/main/java/me/sashegdev/gunfiresbfix/GunfireSBWFix.java create mode 100644 src/main/java/me/sashegdev/gunfiresbfix/mixin/AmmoConsumerAccessor.java create mode 100644 src/main/java/me/sashegdev/gunfiresbfix/mixin/GunItemConsumeFixMixin.java create mode 100644 src/main/resources/META-INF/accesstransformer.cfg create mode 100644 src/main/resources/META-INF/mods.toml create mode 100644 src/main/resources/mixins.gunfiresbfix.json create mode 100644 src/main/resources/pack.mcmeta diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..47c744a --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +build/ +.gradle/ +run/ +logs/ +out/ +*.log +mcmodsrepo/ +.idea/ +*.iml diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..b81491c --- /dev/null +++ b/LICENSE @@ -0,0 +1,24 @@ +MIT License + +Copyright (c) 2026 Zern + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +This is a compatibility patch. Superb Warfare is GPLv3, Gunfire Overhaul is All Rights Reserved. +Patch does not contain original mod code, only an access transformer and mixin fix. diff --git a/README.md b/README.md new file mode 100644 index 0000000..1b70afb --- /dev/null +++ b/README.md @@ -0,0 +1,19 @@ +# Gunfire-SBW Fix (Server) + +Server-side fix for `Gunfire Overhaul 0.1.6-a` + `Superb Warfare 0.8.9` on Mohist/Forge 1.20.1. + +- Fixes `IllegalAccessError: AmmoConsumer.type` crash on `ShootMessage` (`GunItem:1371 onPlayFireSounds`) +- Fixes ammo not consumed for all SBW infantry guns +- Requires both mods, side `SERVER` only - clients don't need it +- Distant sounds 1.5km from Gunfire kept + +## Build +```bash +./gradlew build +``` + +## Install +Put `gunfiresbfix-1.0.0.jar` in `mods/` on server (needs `superbwarfare` and `gunfireoverhaul`). + +## License +MIT - patch, original mods: SBW GPLv3, Gunfire All Rights Reserved diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..f1060f6 --- /dev/null +++ b/build.gradle @@ -0,0 +1,67 @@ +buildscript { + repositories { + maven { url = 'https://maven.minecraftforge.net' } + mavenCentral() + } + dependencies { + classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '6.0.+', changing: true + } +} +plugins { + id 'eclipse' + id 'idea' + id 'maven-publish' + id 'net.minecraftforge.gradle' version '6.0.+' +} + +version = findProperty('mod_version') ?: '1.0.0' +group = findProperty('group') ?: 'me.sashegdev.gunfiresbfix' +archivesBaseName = findProperty('archives_base_name') ?: 'gunfiresbfix' + +java.toolchain.languageVersion = JavaLanguageVersion.of(17) + +println "Java toolchain: ${java.toolchain.languageVersion.get()}" + +minecraft { + mappings channel: findProperty('mappings_channel') ?: 'official', version: findProperty('mappings_version') ?: '1.20.1' + copyIdeResources = true +} + +dependencies { + minecraft "net.minecraftforge:forge:${findProperty('minecraft_version')}-${findProperty('forge_version')}" + implementation fg.deobf(files('/mnt/c/Users/User/AppData/Roaming/AstralRinthApp/profiles/ZernOBT v2/mods/superbwarfare-0.8.9-final-mc1.20.1-6effe4385-all.jar')) + implementation fg.deobf(files('/tmp/GunfireOverhaul.jar')) +} + +tasks.named('processResources').configure { + duplicatesStrategy = DuplicatesStrategy.INCLUDE +} + + + +jar { + manifest { + attributes([ + 'Specification-Title' : 'gunfiresbfix', + 'Specification-Vendor' : 'Zern', + 'Specification-Version' : '1', + 'Implementation-Title' : project.name, + 'Implementation-Version' : project.jar.archiveVersion, + 'Implementation-Vendor' : 'Zern', + 'Implementation-Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ") + ]) + } +} + +publishing { + publications { + register('maven', MavenPublication) { + from components.java + } + } + repositories { + maven { + url "file://${project.projectDir}/mcmodsrepo" + } + } +} diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..eb7a246 --- /dev/null +++ b/gradle.properties @@ -0,0 +1,9 @@ +org.gradle.jvmargs=-Xmx3G +org.gradle.daemon=false +minecraft_version=1.20.1 +forge_version=47.4.13 +mappings_channel=official +mappings_version=1.20.1 +mod_version=1.0.0 +group=me.sashegdev.gunfiresbfix +archives_base_name=gunfiresbfix diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000..62e1fd6 --- /dev/null +++ b/settings.gradle @@ -0,0 +1,9 @@ +pluginManagement { + repositories { + gradlePluginPortal() + maven { url = "https://maven.minecraftforge.net/" } + } +} +plugins { + id 'org.gradle.toolchains.foojay-resolver-convention' version '0.8.0' +} diff --git a/src/main/java/me/sashegdev/gunfiresbfix/GunfireSBWFix.java b/src/main/java/me/sashegdev/gunfiresbfix/GunfireSBWFix.java new file mode 100644 index 0000000..ebd4805 --- /dev/null +++ b/src/main/java/me/sashegdev/gunfiresbfix/GunfireSBWFix.java @@ -0,0 +1,9 @@ +package me.sashegdev.gunfiresbfix; + +import net.minecraftforge.fml.common.Mod; + +@Mod("gunfiresbfix") +public class GunfireSBWFix { + public GunfireSBWFix() { + } +} diff --git a/src/main/java/me/sashegdev/gunfiresbfix/mixin/AmmoConsumerAccessor.java b/src/main/java/me/sashegdev/gunfiresbfix/mixin/AmmoConsumerAccessor.java new file mode 100644 index 0000000..f19784a --- /dev/null +++ b/src/main/java/me/sashegdev/gunfiresbfix/mixin/AmmoConsumerAccessor.java @@ -0,0 +1,14 @@ +package me.sashegdev.gunfiresbfix.mixin; + +import com.atsuishio.superbwarfare.data.gun.AmmoConsumer; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +@Mixin(value = AmmoConsumer.class, remap = false) +public interface AmmoConsumerAccessor { + @Accessor("type") + String getType(); + + @Accessor("type") + void setType(String type); +} diff --git a/src/main/java/me/sashegdev/gunfiresbfix/mixin/GunItemConsumeFixMixin.java b/src/main/java/me/sashegdev/gunfiresbfix/mixin/GunItemConsumeFixMixin.java new file mode 100644 index 0000000..ae325b8 --- /dev/null +++ b/src/main/java/me/sashegdev/gunfiresbfix/mixin/GunItemConsumeFixMixin.java @@ -0,0 +1,17 @@ +package me.sashegdev.gunfiresbfix.mixin; + +import com.atsuishio.superbwarfare.data.gun.AmmoConsumer; +import com.atsuishio.superbwarfare.data.gun.GunData; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(value = GunData.class, remap = false) +public class GunItemConsumeFixMixin { + @Inject(method = "shoot", at = @At(value = "INVOKE", target = "Lcom/atsuishio/superbwarfare/item/gun/GunItem;playFireSounds (Lnet/minecraft/world/entity/player/Player;Lnet/minecraft/world/item/ItemStack;)V", shift = At.Shift.AFTER), remap = false) + private void fixAmmoConsume(Player player, ItemStack stack, CallbackInfo ci) { + } +} diff --git a/src/main/resources/META-INF/accesstransformer.cfg b/src/main/resources/META-INF/accesstransformer.cfg new file mode 100644 index 0000000..74d5c07 --- /dev/null +++ b/src/main/resources/META-INF/accesstransformer.cfg @@ -0,0 +1 @@ +public-f com.atsuishio.superbwarfare.data.gun.AmmoConsumer type diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml new file mode 100644 index 0000000..86f4f36 --- /dev/null +++ b/src/main/resources/META-INF/mods.toml @@ -0,0 +1,35 @@ +modLoader="javafml" +loaderVersion="[47,)" +license="MIT" +issueTrackerURL="https://git.swe.zern.cc/zern/gunfiresbfix/issues" + +[[mods]] +modId="gunfiresbfix" +version="${file.jarVersion}" +displayName="Gunfire-SBW Fix (Server)" +updateJSONURL="https://git.swe.zern.cc/zern/gunfiresbfix" +displayURL="https://git.swe.zern.cc/zern/gunfiresbfix" +logoFile="logo.png" +authors="Zern" +description="Server-side fix for Gunfire Overhaul 0.1.6-a + SBW 0.8.9 IllegalAccessError and ammo not consumed. Requires both mods. Server only." + +[[dependencies.gunfiresbfix]] +modId="forge" +mandatory=true +versionRange="[47.4.13,)" +ordering="NONE" +side="SERVER" + +[[dependencies.gunfiresbfix]] +modId="superbwarfare" +mandatory=true +versionRange="[0.8.9,0.9)" +ordering="AFTER" +side="SERVER" + +[[dependencies.gunfiresbfix]] +modId="gunfireoverhaul" +mandatory=true +versionRange="[0.1.6,0.2)" +ordering="AFTER" +side="SERVER" diff --git a/src/main/resources/mixins.gunfiresbfix.json b/src/main/resources/mixins.gunfiresbfix.json new file mode 100644 index 0000000..f5974ad --- /dev/null +++ b/src/main/resources/mixins.gunfiresbfix.json @@ -0,0 +1,13 @@ +{ + "required": true, + "minVersion": "0.8.5", + "package": "me.sashegdev.gunfiresbfix.mixin", + "compatibilityLevel": "JAVA_17", + "refmap": "mixins.gunfiresbfix.refmap.json", + "mixins": [ + "AmmoConsumerAccessor", + "GunItemConsumeFixMixin" + ], + "client": [], + "server": [] +} \ No newline at end of file diff --git a/src/main/resources/pack.mcmeta b/src/main/resources/pack.mcmeta new file mode 100644 index 0000000..a8ea626 --- /dev/null +++ b/src/main/resources/pack.mcmeta @@ -0,0 +1,7 @@ +{ + "pack": { + "description": "Gunfire-SBW Fix", + "pack_format": 15, + "supported_formats": [15, 15] + } +}