├── example ├── README.md ├── tacz │ ├── README.md │ ├── server_scripts │ │ ├── shooter.js │ │ ├── custom_index.js │ │ └── custom_data.js │ ├── startup_scripts │ │ ├── custom_index.js │ │ ├── custom_data.js │ │ └── custom_recipe.js │ └── client_scripts │ │ └── client.js └── player_revive │ ├── README.md │ ├── server_scripts │ └── disable_shooting_when_bleeding.js │ └── client_scripts │ └── disable_shooting_when_bleeding.js ├── forge ├── gradle.properties ├── src │ └── main │ │ ├── resources │ │ ├── kubejs.plugins.txt │ │ ├── pack.mcmeta │ │ ├── META-INF │ │ │ └── mods.toml │ │ └── taczjs.mixins.json │ │ └── java │ │ └── dev │ │ └── aika │ │ └── taczjs │ │ └── forge │ │ ├── events │ │ ├── crafting │ │ │ ├── legacy │ │ │ │ ├── RecipeLoadEndEvent.java │ │ │ │ ├── RecipeLoadBeginEvent.java │ │ │ │ └── RecipeLoadEvent.java │ │ │ └── AbstractRecipeEvent.java │ │ ├── AbstractAssetLoadEvent.java │ │ ├── client │ │ │ ├── ClientGunIndexLoadEvent.java │ │ │ ├── LocalPlayerMeleeEvent.java │ │ │ ├── LocalPlayerReloadEvent.java │ │ │ ├── LocalPlayerShootEvent.java │ │ │ ├── LocalPlayerAimEvent.java │ │ │ └── AbstractClientGunEvent.java │ │ ├── shooter │ │ │ ├── LivingEntityAimEvent.java │ │ │ ├── LivingEntityMeleeEvent.java │ │ │ ├── LivingEntityShootEvent.java │ │ │ ├── LivingEntityReloadEvent.java │ │ │ └── AbstractShooterEvent.java │ │ ├── index │ │ │ ├── GunIndexLoadEvent.java │ │ │ ├── AmmoIndexLoadEvent.java │ │ │ └── AttachmentIndexLoadEvent.java │ │ ├── asset │ │ │ ├── GunDataLoadEvent.java │ │ │ ├── AttachmentDataLoadEvent.java │ │ │ └── AttachmentTagsLoadEvent.java │ │ ├── ModClientEvents.java │ │ ├── ModStartupEvents.java │ │ ├── AbstractIndexLoadEvent.java │ │ └── ModServerEvents.java │ │ ├── interfaces │ │ └── client │ │ │ └── IClientGun.java │ │ ├── TaCZJSForge.java │ │ ├── TaCZJSPlugin.java │ │ ├── mixin │ │ ├── client │ │ │ ├── ClientGunIndexMixin.java │ │ │ ├── InteractKeyTextOverlayMixin.java │ │ │ ├── ClientPreventGunClickMixin.java │ │ │ ├── ClientIndexManagerMixin.java │ │ │ ├── LocalPlayerMeleeMixin.java │ │ │ ├── LocalPlayerAimMixin.java │ │ │ ├── LocalPlayerShootMixin.java │ │ │ ├── LocalPlayerReloadMixin.java │ │ │ ├── ReloadableResourceManagerMixin.java │ │ │ ├── AmmoItemBuilderMixin.java │ │ │ ├── GunItemBuilderMixin.java │ │ │ └── AttachmentItemBuilderMixin.java │ │ ├── shooter │ │ │ ├── LivingEntityAimMixin.java │ │ │ ├── LivingEntityMeleeMixin.java │ │ │ ├── LivingEntityReloadMixin.java │ │ │ └── LivingEntityShootMixin.java │ │ ├── resource │ │ │ └── manager │ │ │ │ └── CommonDataManagerMixin.java │ │ └── crafting │ │ │ └── RecipeManagerMixin.java │ │ ├── TaCZJSHelper.java │ │ └── TaCZJSUtils.java └── build.gradle ├── .github ├── FUNDING.yml └── workflows │ └── publish.yml ├── assets ├── icon.png └── icon-128x128.png ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .gitattributes ├── .idea └── dictionaries │ └── project.xml ├── settings.gradle ├── common ├── src │ └── main │ │ └── java │ │ └── dev │ │ └── aika │ │ └── taczjs │ │ └── TaCZJS.java └── build.gradle ├── gradle.properties ├── CHANGELOG.md ├── types ├── TaCZJSUtils.d.ts ├── TaCZClientEvents.d.ts ├── TaCZStartupEvents.d.ts └── TaCZServerEvents.d.ts ├── .gitignore ├── README.md ├── gradlew.bat ├── gradlew └── LICENSE /example/README.md: -------------------------------------------------------------------------------- 1 | # TaCZ JS Examples 2 | -------------------------------------------------------------------------------- /forge/gradle.properties: -------------------------------------------------------------------------------- 1 | loom.platform=forge 2 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | custom: [ "https://afdian.com/a/gizmo" ] -------------------------------------------------------------------------------- /forge/src/main/resources/kubejs.plugins.txt: -------------------------------------------------------------------------------- 1 | dev.aika.taczjs.forge.TaCZJSPlugin -------------------------------------------------------------------------------- /assets/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gizmo-ds/taczjs-mod/1.20.1/assets/icon.png -------------------------------------------------------------------------------- /assets/icon-128x128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gizmo-ds/taczjs-mod/1.20.1/assets/icon-128x128.png -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gizmo-ds/taczjs-mod/1.20.1/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /forge/src/main/resources/pack.mcmeta: -------------------------------------------------------------------------------- 1 | { 2 | "pack": { 3 | "description": "taczjs resources", 4 | "pack_format": 15 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /example/tacz/README.md: -------------------------------------------------------------------------------- 1 | # TaCZ JS 例子 2 | 3 | 本目录演示了 TaCZ JS 修改默认枪包的例子. 4 | 5 | 你可以将目录复制到 `.minecraft/kubejs` 目录下. 6 | 7 | 这个目录中所有文件使用 [CC0 1.0](https://creativecommons.org/publicdomain/zero/1.0/) 授权, 你可以随意使用它们. 8 | -------------------------------------------------------------------------------- /forge/src/main/java/dev/aika/taczjs/forge/events/crafting/legacy/RecipeLoadEndEvent.java: -------------------------------------------------------------------------------- 1 | package dev.aika.taczjs.forge.events.crafting.legacy; 2 | 3 | public class RecipeLoadEndEvent extends RecipeLoadBeginEvent { 4 | } 5 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # 2 | # https://help.github.com/articles/dealing-with-line-endings/ 3 | # 4 | # Linux start script should use lf 5 | /gradlew text eol=lf 6 | 7 | # These are Windows script files and should use crlf 8 | *.bat text eol=crlf -------------------------------------------------------------------------------- /.idea/dictionaries/project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | johnrengelman 5 | llamalad 6 | tacz 7 | 8 | 9 | -------------------------------------------------------------------------------- /forge/src/main/java/dev/aika/taczjs/forge/interfaces/client/IClientGun.java: -------------------------------------------------------------------------------- 1 | package dev.aika.taczjs.forge.interfaces.client; 2 | 3 | @SuppressWarnings("unused") 4 | public interface IClientGun { 5 | boolean isVanillaInteract(); 6 | 7 | void setVanillaInteract(boolean isVanillaInteract); 8 | } 9 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip 4 | networkTimeout=10000 5 | validateDistributionUrl=true 6 | zipStoreBase=GRADLE_USER_HOME 7 | zipStorePath=wrapper/dists 8 | -------------------------------------------------------------------------------- /example/tacz/server_scripts/shooter.js: -------------------------------------------------------------------------------- 1 | // 实体使用武器进行瞄准的事件 2 | TaCZServerEvents.entityAim(event => { 3 | const shooter = event.getShooter() 4 | const gunId = event.getGunId().toString(); 5 | // 如果实体使用 RPG-7火箭筒 进行瞄准, 杀死实体 6 | if (gunId === "tacz:rpg7") { 7 | shooter.kill() 8 | } 9 | }) 10 | -------------------------------------------------------------------------------- /forge/src/main/java/dev/aika/taczjs/forge/TaCZJSForge.java: -------------------------------------------------------------------------------- 1 | package dev.aika.taczjs.forge; 2 | 3 | import dev.aika.taczjs.TaCZJS; 4 | import net.minecraftforge.fml.common.Mod; 5 | 6 | @Mod(TaCZJS.MOD_ID) 7 | public final class TaCZJSForge { 8 | public TaCZJSForge() { 9 | TaCZJS.init(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | repositories { 3 | maven { url "https://maven.fabricmc.net/" } 4 | maven { url "https://maven.architectury.dev/" } 5 | maven { url "https://files.minecraftforge.net/maven/" } 6 | gradlePluginPortal() 7 | } 8 | } 9 | 10 | rootProject.name = 'taczjs' 11 | 12 | include 'common' 13 | include 'forge' 14 | -------------------------------------------------------------------------------- /example/player_revive/README.md: -------------------------------------------------------------------------------- 1 | # Disable shooting when bleeding 2 | 3 | 一个结合 [PlayerRevive](https://modrinth.com/mod/playerrevive) 使用的例子, 禁止玩家在倒地后进行射击和近战。 4 | 5 | 你只需要将 `server_scripts/disable_shooting_when_bleeding.js` 和 `client_scripts/disable_shooting_when_bleeding.js` 复制到 6 | `.minecraft/kubejs` 目录下即可。 7 | 8 | 这个目录中所有文件使用 [CC0 1.0](https://creativecommons.org/publicdomain/zero/1.0/) 授权, 你可以随意使用它们. 9 | -------------------------------------------------------------------------------- /common/src/main/java/dev/aika/taczjs/TaCZJS.java: -------------------------------------------------------------------------------- 1 | package dev.aika.taczjs; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | 6 | public final class TaCZJS { 7 | public static final String MOD_ID = "taczjs"; 8 | public static final String MOD_NAME = "TaCZ JS"; 9 | public static final Logger LOGGER = LoggerFactory.getLogger(MOD_NAME); 10 | 11 | public static void init() { 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /common/build.gradle: -------------------------------------------------------------------------------- 1 | architectury { 2 | common rootProject.enabled_platforms.split(',') 3 | } 4 | 5 | dependencies { 6 | // We depend on Fabric Loader here to use the Fabric @Environment annotations, 7 | // which get remapped to the correct annotations on each platform. 8 | // Do NOT use other classes from Fabric Loader. 9 | modImplementation "net.fabricmc:fabric-loader:$rootProject.fabric_loader_version" 10 | } 11 | -------------------------------------------------------------------------------- /forge/src/main/java/dev/aika/taczjs/forge/events/AbstractAssetLoadEvent.java: -------------------------------------------------------------------------------- 1 | package dev.aika.taczjs.forge.events; 2 | 3 | import com.google.gson.JsonElement; 4 | import net.minecraft.resources.ResourceLocation; 5 | 6 | @SuppressWarnings("unused") 7 | public abstract class AbstractAssetLoadEvent extends AbstractIndexLoadEvent { 8 | public AbstractAssetLoadEvent(ResourceLocation id, JsonElement json) { 9 | super(id, json); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /forge/src/main/java/dev/aika/taczjs/forge/events/client/ClientGunIndexLoadEvent.java: -------------------------------------------------------------------------------- 1 | package dev.aika.taczjs.forge.events.client; 2 | 3 | import net.minecraft.resources.ResourceLocation; 4 | import net.minecraftforge.api.distmarker.Dist; 5 | import net.minecraftforge.api.distmarker.OnlyIn; 6 | 7 | @SuppressWarnings("unused") 8 | @OnlyIn(Dist.CLIENT) 9 | public class ClientGunIndexLoadEvent extends AbstractClientGunEvent { 10 | public ClientGunIndexLoadEvent(ResourceLocation gunId) { 11 | super(gunId); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /forge/src/main/java/dev/aika/taczjs/forge/events/shooter/LivingEntityAimEvent.java: -------------------------------------------------------------------------------- 1 | package dev.aika.taczjs.forge.events.shooter; 2 | 3 | import net.minecraft.world.entity.LivingEntity; 4 | import net.minecraft.world.item.ItemStack; 5 | 6 | @SuppressWarnings("unused") 7 | public class LivingEntityAimEvent extends AbstractShooterEvent { 8 | public LivingEntityAimEvent(LivingEntity entity, ItemStack gunItem) { 9 | super(entity, gunItem); 10 | } 11 | 12 | public void cancelAim() { 13 | setCancelled(); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /forge/src/main/java/dev/aika/taczjs/forge/events/shooter/LivingEntityMeleeEvent.java: -------------------------------------------------------------------------------- 1 | package dev.aika.taczjs.forge.events.shooter; 2 | 3 | import net.minecraft.world.entity.LivingEntity; 4 | import net.minecraft.world.item.ItemStack; 5 | 6 | @SuppressWarnings("unused") 7 | public class LivingEntityMeleeEvent extends AbstractShooterEvent { 8 | public LivingEntityMeleeEvent(LivingEntity entity, ItemStack gunItem) { 9 | super(entity, gunItem); 10 | } 11 | 12 | public void cancelMelee() { 13 | setCancelled(); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /forge/src/main/java/dev/aika/taczjs/forge/events/shooter/LivingEntityShootEvent.java: -------------------------------------------------------------------------------- 1 | package dev.aika.taczjs.forge.events.shooter; 2 | 3 | import net.minecraft.world.entity.LivingEntity; 4 | import net.minecraft.world.item.ItemStack; 5 | 6 | @SuppressWarnings("unused") 7 | public class LivingEntityShootEvent extends AbstractShooterEvent { 8 | public LivingEntityShootEvent(LivingEntity entity, ItemStack gunItem) { 9 | super(entity, gunItem); 10 | } 11 | 12 | public void cancelShoot() { 13 | setCancelled(); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /forge/src/main/java/dev/aika/taczjs/forge/events/shooter/LivingEntityReloadEvent.java: -------------------------------------------------------------------------------- 1 | package dev.aika.taczjs.forge.events.shooter; 2 | 3 | import net.minecraft.world.entity.LivingEntity; 4 | import net.minecraft.world.item.ItemStack; 5 | 6 | @SuppressWarnings("unused") 7 | public class LivingEntityReloadEvent extends AbstractShooterEvent { 8 | public LivingEntityReloadEvent(LivingEntity entity, ItemStack gunItem) { 9 | super(entity, gunItem); 10 | } 11 | 12 | public void cancelReload() { 13 | setCancelled(); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /forge/src/main/java/dev/aika/taczjs/forge/events/client/LocalPlayerMeleeEvent.java: -------------------------------------------------------------------------------- 1 | package dev.aika.taczjs.forge.events.client; 2 | 3 | import net.minecraft.resources.ResourceLocation; 4 | import net.minecraftforge.api.distmarker.Dist; 5 | import net.minecraftforge.api.distmarker.OnlyIn; 6 | 7 | @SuppressWarnings("unused") 8 | @OnlyIn(Dist.CLIENT) 9 | public class LocalPlayerMeleeEvent extends AbstractClientGunEvent { 10 | public LocalPlayerMeleeEvent(ResourceLocation gunId) { 11 | super(gunId); 12 | } 13 | 14 | public void cancelMelee() { 15 | setCancelled(); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /forge/src/main/java/dev/aika/taczjs/forge/events/client/LocalPlayerReloadEvent.java: -------------------------------------------------------------------------------- 1 | package dev.aika.taczjs.forge.events.client; 2 | 3 | import net.minecraft.resources.ResourceLocation; 4 | import net.minecraftforge.api.distmarker.Dist; 5 | import net.minecraftforge.api.distmarker.OnlyIn; 6 | 7 | @SuppressWarnings("unused") 8 | @OnlyIn(Dist.CLIENT) 9 | public class LocalPlayerReloadEvent extends AbstractClientGunEvent { 10 | public LocalPlayerReloadEvent(ResourceLocation gunId) { 11 | super(gunId); 12 | } 13 | 14 | public void cancelReload() { 15 | setCancelled(); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /forge/src/main/java/dev/aika/taczjs/forge/events/client/LocalPlayerShootEvent.java: -------------------------------------------------------------------------------- 1 | package dev.aika.taczjs.forge.events.client; 2 | 3 | import net.minecraft.resources.ResourceLocation; 4 | import net.minecraftforge.api.distmarker.Dist; 5 | import net.minecraftforge.api.distmarker.OnlyIn; 6 | 7 | @SuppressWarnings("unused") 8 | @OnlyIn(Dist.CLIENT) 9 | public class LocalPlayerShootEvent extends AbstractClientGunEvent { 10 | public LocalPlayerShootEvent(ResourceLocation gunId) { 11 | super(gunId); 12 | } 13 | 14 | public void cancelShoot() { 15 | setCancelled(); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # suppress inspection "SpellCheckingInspection" for whole file 2 | # Done to increase the memory available to Gradle. 3 | org.gradle.jvmargs=-Xmx2G 4 | org.gradle.parallel=true 5 | # Mod properties 6 | mod_version=1.3.7 7 | maven_group=dev.aika 8 | archives_name=taczjs 9 | enabled_platforms=forge 10 | # Minecraft properties 11 | minecraft_version=1.20.1 12 | parchment_version=2023.09.03 13 | # Dependencies 14 | fabric_loader_version=0.16.7 15 | forge_version=1.20.1-47.3.11 16 | kubejs_version=2001.6.5-build.20 17 | tacz_forge_version=7278003-sources-7280838 18 | # Dev dependencies 19 | jei_version=15.0.0.12 20 | -------------------------------------------------------------------------------- /example/player_revive/server_scripts/disable_shooting_when_bleeding.js: -------------------------------------------------------------------------------- 1 | const $PlayerReviveServer = Java.tryLoadClass( 2 | "team.creative.playerrevive.server.PlayerReviveServer" 3 | ); 4 | 5 | function isBleeding(player) { 6 | return $PlayerReviveServer.getBleeding(player).isBleeding(); 7 | } 8 | 9 | TaCZServerEvents.entityShoot((event) => { 10 | // 倒地后禁止射击 11 | if (isBleeding(event.getShooter())) { 12 | return event.cancelShoot(); 13 | } 14 | }); 15 | 16 | TaCZServerEvents.entityMelee((event) => { 17 | // 倒地后禁用枪械近战 18 | if (isBleeding(event.getShooter())) { 19 | return event.cancelMelee(); 20 | } 21 | }); 22 | -------------------------------------------------------------------------------- /example/player_revive/client_scripts/disable_shooting_when_bleeding.js: -------------------------------------------------------------------------------- 1 | const $PlayerReviveServer = Java.tryLoadClass( 2 | "team.creative.playerrevive.server.PlayerReviveServer" 3 | ); 4 | 5 | function isBleeding(player) { 6 | return $PlayerReviveServer.getBleeding(player).isBleeding(); 7 | } 8 | 9 | TaCZClientEvents.playerShoot((event) => { 10 | // 倒地后禁止射击 11 | if (isBleeding(event.getGunOperator())) { 12 | return event.cancelShoot(); 13 | } 14 | }); 15 | 16 | TaCZClientEvents.playerMelee((event) => { 17 | // 倒地后禁用枪械近战 18 | if (isBleeding(event.getGunOperator())) { 19 | return event.cancelMelee(); 20 | } 21 | }); 22 | -------------------------------------------------------------------------------- /forge/src/main/java/dev/aika/taczjs/forge/events/index/GunIndexLoadEvent.java: -------------------------------------------------------------------------------- 1 | package dev.aika.taczjs.forge.events.index; 2 | 3 | import com.google.gson.JsonElement; 4 | import dev.aika.taczjs.forge.events.AbstractIndexLoadEvent; 5 | import net.minecraft.resources.ResourceLocation; 6 | import net.minecraft.util.GsonHelper; 7 | 8 | @SuppressWarnings("unused") 9 | public class GunIndexLoadEvent extends AbstractIndexLoadEvent { 10 | public GunIndexLoadEvent(ResourceLocation id, JsonElement json) { 11 | super(id, json); 12 | } 13 | 14 | public Object getPOJO() { 15 | return GsonHelper.parse(this.getJson(), true); 16 | } 17 | 18 | public void removeGun() { 19 | this.setRemove(true); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /forge/src/main/java/dev/aika/taczjs/forge/events/index/AmmoIndexLoadEvent.java: -------------------------------------------------------------------------------- 1 | package dev.aika.taczjs.forge.events.index; 2 | 3 | import com.google.gson.JsonElement; 4 | import dev.aika.taczjs.forge.events.AbstractIndexLoadEvent; 5 | import net.minecraft.resources.ResourceLocation; 6 | import net.minecraft.util.GsonHelper; 7 | 8 | @SuppressWarnings("unused") 9 | public class AmmoIndexLoadEvent extends AbstractIndexLoadEvent { 10 | public AmmoIndexLoadEvent(ResourceLocation id, JsonElement json) { 11 | super(id, json); 12 | } 13 | 14 | public Object getPOJO() { 15 | return GsonHelper.parse(this.getJson(), true); 16 | } 17 | 18 | public void removeAmmo() { 19 | this.setRemove(true); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /forge/src/main/java/dev/aika/taczjs/forge/events/client/LocalPlayerAimEvent.java: -------------------------------------------------------------------------------- 1 | package dev.aika.taczjs.forge.events.client; 2 | 3 | import net.minecraft.resources.ResourceLocation; 4 | import net.minecraftforge.api.distmarker.Dist; 5 | import net.minecraftforge.api.distmarker.OnlyIn; 6 | 7 | @SuppressWarnings("unused") 8 | @OnlyIn(Dist.CLIENT) 9 | public class LocalPlayerAimEvent extends AbstractClientGunEvent { 10 | private final boolean isAim; 11 | 12 | public LocalPlayerAimEvent(boolean isAim, ResourceLocation gunId) { 13 | super(gunId); 14 | this.isAim = isAim; 15 | } 16 | 17 | public boolean isAim() { 18 | return isAim; 19 | } 20 | 21 | public void cancelAim() { 22 | setCancelled(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /forge/src/main/java/dev/aika/taczjs/forge/events/index/AttachmentIndexLoadEvent.java: -------------------------------------------------------------------------------- 1 | package dev.aika.taczjs.forge.events.index; 2 | 3 | import com.google.gson.JsonElement; 4 | import dev.aika.taczjs.forge.events.AbstractIndexLoadEvent; 5 | import net.minecraft.resources.ResourceLocation; 6 | import net.minecraft.util.GsonHelper; 7 | 8 | @SuppressWarnings("unused") 9 | public class AttachmentIndexLoadEvent extends AbstractIndexLoadEvent { 10 | public AttachmentIndexLoadEvent(ResourceLocation id, JsonElement json) { 11 | super(id, json); 12 | } 13 | 14 | public Object getPOJO() { 15 | return GsonHelper.parse(this.getJson(), true); 16 | } 17 | 18 | public void removeAttachment() { 19 | this.setRemove(true); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /forge/src/main/java/dev/aika/taczjs/forge/TaCZJSPlugin.java: -------------------------------------------------------------------------------- 1 | package dev.aika.taczjs.forge; 2 | 3 | import dev.aika.taczjs.forge.events.ModClientEvents; 4 | import dev.aika.taczjs.forge.events.ModServerEvents; 5 | import dev.aika.taczjs.forge.events.ModStartupEvents; 6 | import dev.latvian.mods.kubejs.KubeJSPlugin; 7 | import dev.latvian.mods.kubejs.script.BindingsEvent; 8 | 9 | @SuppressWarnings("unused") 10 | public class TaCZJSPlugin extends KubeJSPlugin { 11 | @Override 12 | public void registerEvents() { 13 | ModStartupEvents.GROUP.register(); 14 | ModClientEvents.GROUP.register(); 15 | ModServerEvents.GROUP.register(); 16 | } 17 | 18 | @Override 19 | public void registerBindings(BindingsEvent event) { 20 | event.add("TaCZJSUtils", TaCZJSUtils.class); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /forge/src/main/java/dev/aika/taczjs/forge/events/asset/GunDataLoadEvent.java: -------------------------------------------------------------------------------- 1 | package dev.aika.taczjs.forge.events.asset; 2 | 3 | import com.google.gson.JsonElement; 4 | import com.tacz.guns.resource.CommonAssetsManager; 5 | import com.tacz.guns.resource.pojo.data.gun.GunData; 6 | import dev.aika.taczjs.forge.events.AbstractAssetLoadEvent; 7 | import net.minecraft.resources.ResourceLocation; 8 | 9 | @SuppressWarnings("unused") 10 | public class GunDataLoadEvent extends AbstractAssetLoadEvent { 11 | public GunDataLoadEvent(ResourceLocation id, JsonElement json) { 12 | super(id, json); 13 | } 14 | 15 | public GunData getGunData() { 16 | return CommonAssetsManager.GSON.fromJson(this.getJson(), GunData.class); 17 | } 18 | 19 | public void removeGunData() { 20 | this.setRemove(true); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## v1.3.7+mc1.20.1 - 2025-12-02 4 | 5 | - Added TaCZ 1.1.7 support 6 | 7 | ## v1.2.2+mc1.20.1 - 2024-11-14 8 | 9 | ### Added 10 | 11 | - TaCZStartupEvents: Added a `getStdJson` method to AbstractLoadEvent, enabling the retrieval of JavaScript-compatible 12 | standard JSON. The `getJson` method remains available for non-standard JSON formats. 13 | 14 | ### Changed 15 | 16 | - Build Process: Updated to use a compressed icon for output, reducing file size and optimizing resource usage. 17 | 18 | ## v1.2.1+mc1.20.1 - 2024-11-11 19 | 20 | ### Added 21 | 22 | - Added `TaCZJSUtils.openRefitScreen` and `TaCZJSUtils.mainHandHoldGun` functions. 23 | 24 | ### Fixed 25 | 26 | - Prevented a crash when attempting to retrieve an icon for a non-existent 27 | item. [#2](https://github.com/gizmo-ds/taczjs-mod/issues/2) 28 | -------------------------------------------------------------------------------- /forge/src/main/java/dev/aika/taczjs/forge/events/asset/AttachmentDataLoadEvent.java: -------------------------------------------------------------------------------- 1 | package dev.aika.taczjs.forge.events.asset; 2 | 3 | import com.google.gson.JsonElement; 4 | import com.tacz.guns.resource.CommonAssetsManager; 5 | import com.tacz.guns.resource.pojo.data.attachment.AttachmentData; 6 | import dev.aika.taczjs.forge.events.AbstractAssetLoadEvent; 7 | import net.minecraft.resources.ResourceLocation; 8 | 9 | @SuppressWarnings("unused") 10 | public class AttachmentDataLoadEvent extends AbstractAssetLoadEvent { 11 | public AttachmentDataLoadEvent(ResourceLocation id, JsonElement json) { 12 | super(id, json); 13 | } 14 | 15 | public AttachmentData getAttachmentData() { 16 | return CommonAssetsManager.GSON.fromJson(this.getJson(), AttachmentData.class); 17 | } 18 | 19 | public void removeAttachmentData() { 20 | this.setRemove(true); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /forge/src/main/java/dev/aika/taczjs/forge/events/ModClientEvents.java: -------------------------------------------------------------------------------- 1 | package dev.aika.taczjs.forge.events; 2 | 3 | import dev.aika.taczjs.forge.events.client.*; 4 | import dev.latvian.mods.kubejs.event.EventGroup; 5 | import dev.latvian.mods.kubejs.event.EventHandler; 6 | 7 | public interface ModClientEvents { 8 | EventGroup GROUP = EventGroup.of("TaCZClientEvents"); 9 | 10 | EventHandler GUN_INDEX_LOAD_REGISTER = GROUP.client("gunIndexLoad", () -> ClientGunIndexLoadEvent.class); 11 | 12 | EventHandler PLAYER_AIM_REGISTER = GROUP.client("playerAim", () -> LocalPlayerAimEvent.class); 13 | EventHandler PLAYER_SHOOT_REGISTER = GROUP.client("playerShoot", () -> LocalPlayerShootEvent.class); 14 | EventHandler PLAYER_MELEE_REGISTER = GROUP.client("playerMelee", () -> LocalPlayerMeleeEvent.class); 15 | EventHandler PLAYER_RELOAD_REGISTER = GROUP.client("playerReload", () -> LocalPlayerReloadEvent.class); 16 | } 17 | -------------------------------------------------------------------------------- /forge/src/main/resources/META-INF/mods.toml: -------------------------------------------------------------------------------- 1 | modLoader = "javafml" 2 | loaderVersion = "[47,)" 3 | issueTrackerURL = "https://github.com/gizmo-ds/taczjs-mod/issues" 4 | license = "GNU GPL 3.0" 5 | 6 | [[mods]] 7 | modId = "taczjs" 8 | version = "${version}" 9 | displayName = "TaCZ JS" 10 | authors = "Gizmo" 11 | description = ''' 12 | KubeJS TaCZ integration 13 | ''' 14 | logoFile = "taczjs-icon.png" 15 | 16 | [[dependencies.taczjs]] 17 | modId = "forge" 18 | mandatory = true 19 | versionRange = "[47,)" 20 | ordering = "NONE" 21 | side = "BOTH" 22 | 23 | [[dependencies.taczjs]] 24 | modId = "minecraft" 25 | mandatory = true 26 | versionRange = "[1.20.1,)" 27 | ordering = "NONE" 28 | side = "BOTH" 29 | 30 | [[dependencies.taczjs]] 31 | modId = "kubejs" 32 | mandatory = true 33 | versionRange = "[2001.6.4-build.95,)" 34 | ordering = "AFTER" 35 | side = "BOTH" 36 | 37 | [[dependencies.taczjs]] 38 | modId = "tacz" 39 | mandatory = true 40 | versionRange = "[1.1.4,1.1.8)" 41 | ordering = "NONE" 42 | side = "BOTH" 43 | -------------------------------------------------------------------------------- /example/tacz/startup_scripts/custom_index.js: -------------------------------------------------------------------------------- 1 | TaCZStartupEvents.gunIndexLoad((event) => { 2 | const id = event.getId().toString(); 3 | // 修改 p90 的枪械类型为 `rifle`(步枪) 4 | if (id === "tacz:p90") { 5 | const json = JSON.parse(event.getStdJson()); 6 | json.type = "rifle"; 7 | return event.setJson(JSON.stringify(json)); 8 | } 9 | 10 | // 删除 黄金沙漠之鹰 11 | if (id === "tacz:deagle_golden") { 12 | return event.removeGun(); 13 | } 14 | }) 15 | 16 | TaCZStartupEvents.ammoIndexLoad((event) => { 17 | const id = event.getId().toString(); 18 | // 修改 火箭弹 的堆叠数量为 33 19 | if (id === "tacz:rpg_rocket") { 20 | const json = JSON.parse(event.getStdJson()); 21 | json.stack_size = 33; 22 | return event.setJson(JSON.stringify(json)); 23 | } 24 | }) 25 | 26 | TaCZStartupEvents.attachmentIndexLoad((event) => { 27 | const id = event.getId().toString(); 28 | // 删除 狙击弹药扩容弹匣3 29 | if (id === "tacz:sniper_extended_mag_3") { 30 | return event.removeAttachment(); 31 | } 32 | }) 33 | -------------------------------------------------------------------------------- /.github/workflows/publish.yml: -------------------------------------------------------------------------------- 1 | name: Publish 2 | 3 | on: 4 | push: 5 | tags: 6 | - v*mc1.20.1 7 | 8 | permissions: 9 | contents: write 10 | 11 | jobs: 12 | build: 13 | runs-on: ubuntu-latest 14 | steps: 15 | - uses: actions/checkout@v3 16 | 17 | - name: Set up JDK 17 18 | uses: actions/setup-java@v3 19 | with: 20 | java-version: '17' 21 | distribution: 'temurin' 22 | cache: gradle 23 | 24 | - name: Grant execute permission for gradlew 25 | run: chmod +x gradlew 26 | 27 | - name: Build with Gradle 28 | uses: gradle/gradle-build-action@093dfe9d598ec5a42246855d09b49dc76803c005 29 | with: 30 | arguments: build --no-daemon 31 | 32 | - name: Publish to GitHub Releases 33 | uses: softprops/action-gh-release@c062e08bd532815e2082a85e87e3ef29c3e6d191 34 | if: startsWith(github.ref, 'refs/tags/') 35 | with: 36 | files: | 37 | forge/build/libs/*mc1.20.1.jar 38 | fabric/build/libs/*mc1.20.1.jar 39 | -------------------------------------------------------------------------------- /forge/src/main/java/dev/aika/taczjs/forge/mixin/client/ClientGunIndexMixin.java: -------------------------------------------------------------------------------- 1 | package dev.aika.taczjs.forge.mixin.client; 2 | 3 | import com.tacz.guns.client.resource.index.ClientGunIndex; 4 | import dev.aika.taczjs.forge.interfaces.client.IClientGun; 5 | import net.minecraftforge.api.distmarker.Dist; 6 | import net.minecraftforge.api.distmarker.OnlyIn; 7 | import org.spongepowered.asm.mixin.Implements; 8 | import org.spongepowered.asm.mixin.Interface; 9 | import org.spongepowered.asm.mixin.Mixin; 10 | import org.spongepowered.asm.mixin.Unique; 11 | 12 | @OnlyIn(Dist.CLIENT) 13 | @Implements(@Interface(iface = IClientGun.class, prefix = "taczjs$")) 14 | @Mixin(value = ClientGunIndex.class, remap = false) 15 | public abstract class ClientGunIndexMixin { 16 | @Unique 17 | private boolean taczjs$isVanillaInteract = false; 18 | 19 | public boolean taczjs$isVanillaInteract() { 20 | return taczjs$isVanillaInteract; 21 | } 22 | 23 | public void taczjs$setVanillaInteract(boolean v) { 24 | this.taczjs$isVanillaInteract = v; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /forge/src/main/resources/taczjs.mixins.json: -------------------------------------------------------------------------------- 1 | { 2 | "required": true, 3 | "package": "dev.aika.taczjs.forge.mixin", 4 | "compatibilityLevel": "JAVA_17", 5 | "minVersion": "0.8", 6 | "client": [ 7 | "client.AmmoItemBuilderMixin", 8 | "client.AttachmentItemBuilderMixin", 9 | "client.ClientGunIndexMixin", 10 | "client.ClientIndexManagerMixin", 11 | "client.ClientPreventGunClickMixin", 12 | "client.GunItemBuilderMixin", 13 | "client.InteractKeyTextOverlayMixin", 14 | "client.LocalPlayerAimMixin", 15 | "client.LocalPlayerMeleeMixin", 16 | "client.LocalPlayerReloadMixin", 17 | "client.LocalPlayerShootMixin", 18 | "client.ReloadableResourceManagerMixin" 19 | ], 20 | "mixins": [ 21 | "crafting.RecipeManagerMixin", 22 | "resource.manager.CommonDataManagerMixin", 23 | "shooter.LivingEntityAimMixin", 24 | "shooter.LivingEntityMeleeMixin", 25 | "shooter.LivingEntityReloadMixin", 26 | "shooter.LivingEntityShootMixin" 27 | ], 28 | "injectors": { 29 | "defaultRequire": 1 30 | }, 31 | "server": [ 32 | ] 33 | } 34 | -------------------------------------------------------------------------------- /forge/src/main/java/dev/aika/taczjs/forge/events/asset/AttachmentTagsLoadEvent.java: -------------------------------------------------------------------------------- 1 | package dev.aika.taczjs.forge.events.asset; 2 | 3 | import com.google.gson.JsonElement; 4 | import com.google.gson.reflect.TypeToken; 5 | import com.tacz.guns.resource.CommonAssetsManager; 6 | import dev.aika.taczjs.forge.events.AbstractIndexLoadEvent; 7 | import dev.latvian.mods.rhino.util.HideFromJS; 8 | import net.minecraft.resources.ResourceLocation; 9 | 10 | import java.util.List; 11 | 12 | @SuppressWarnings("unused") 13 | public class AttachmentTagsLoadEvent extends AbstractIndexLoadEvent { 14 | public AttachmentTagsLoadEvent(ResourceLocation resourceId, JsonElement json) { 15 | super(resourceId, json); 16 | } 17 | 18 | public String[] getAttachmentTags() { 19 | return getAttachmentTagsList().toArray(new String[0]); 20 | } 21 | 22 | @HideFromJS 23 | public List getAttachmentTagsList() { 24 | return CommonAssetsManager.GSON.fromJson(this.getJson(), new TypeToken<>() { 25 | }); 26 | } 27 | 28 | public void removeAttachmentTags() { 29 | this.setRemove(true); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /example/tacz/client_scripts/client.js: -------------------------------------------------------------------------------- 1 | TaCZClientEvents.gunIndexLoad((event) => { 2 | const gunId = event.getGunId().toString(); 3 | // RPG-7火箭筒 使用原版交互 4 | if (gunId === "tacz:rpg7") { 5 | event.setVanillaInteract(true); 6 | } 7 | }) 8 | 9 | TaCZClientEvents.playerAim((event) => { 10 | const gunId = event.getGunId().toString(); 11 | // 禁止 RPG-7火箭筒 进行瞄准 12 | if (gunId === "tacz:rpg7") { 13 | return event.cancelAim() 14 | } 15 | }) 16 | 17 | TaCZClientEvents.playerShoot((event) => { 18 | const gunId = event.getGunId().toString(); 19 | // 禁止 RPG-7火箭筒 进行射击 20 | if (gunId === "tacz:rpg7") { 21 | return event.cancelShoot() 22 | } 23 | }) 24 | 25 | TaCZClientEvents.playerMelee((event) => { 26 | const gunId = event.getGunId().toString(); 27 | // 禁止 RPG-7火箭筒 进行近战 28 | if (gunId === "tacz:rpg7") { 29 | return event.cancelMelee() 30 | } 31 | }) 32 | 33 | TaCZClientEvents.playerReload((event) => { 34 | const gunId = event.getGunId().toString(); 35 | // 禁止 RPG-7火箭筒 进行换弹 36 | if (gunId === "tacz:rpg7") { 37 | return event.cancelReload() 38 | } 39 | }) 40 | -------------------------------------------------------------------------------- /example/tacz/startup_scripts/custom_data.js: -------------------------------------------------------------------------------- 1 | TaCZStartupEvents.gunDataLoad((event) => { 2 | const id = event.getId().toString(); 3 | // 修改 p90 的弹药数量为 123 4 | if (id === "tacz:p90_data") { 5 | const json = JSON.parse(event.getStdJson()); 6 | json.ammo_amount = 123; 7 | return event.setJson(JSON.stringify(json)); 8 | } 9 | // 修改 黄金沙漠之鹰 的伤害为 999 10 | if (id === "tacz:deagle_golden_data") { 11 | const json = JSON.parse(event.getStdJson()); 12 | json.bullet.extra_damage.damage_adjust = [ 13 | { distance: 18, damage: 999 }, 14 | { distance: 36, damage: 999 }, 15 | { distance: 55, damage: 999 }, 16 | { distance: "infinite", damage: 999 }, 17 | ]; 18 | return event.setJson(JSON.stringify(json)); 19 | } 20 | }) 21 | 22 | TaCZStartupEvents.attachmentDataLoad((event) => { 23 | const id = event.getId().toString(); 24 | // 修改 克苏鲁K7制退器, 装备后会拥有 10 倍的垂直后坐力👍 25 | if (id === "tacz:muzzle_brake_cthulhu_data") { 26 | const json = JSON.parse(event.getStdJson()); 27 | json.recoil.pitch = {multiplier: 10} 28 | return event.setJson(JSON.stringify(json)); 29 | } 30 | }) 31 | -------------------------------------------------------------------------------- /example/tacz/server_scripts/custom_index.js: -------------------------------------------------------------------------------- 1 | // 与 `TaCZStartupEvents.gunIndexLoad` 功能一致, 但优先级更高 2 | TaCZServerEvents.gunIndexLoad((event) => { 3 | const id = event.getId().toString(); 4 | // 修改 p90 的枪械类型为 `rifle`(步枪) 5 | if (id === "tacz:p90") { 6 | const json = JSON.parse(event.getStdJson()); 7 | json.type = "rifle"; 8 | return event.setJson(JSON.stringify(json)); 9 | } 10 | 11 | // 删除 黄金沙漠之鹰 12 | if (id === "tacz:deagle_golden") { 13 | return event.removeGun(); 14 | } 15 | }) 16 | 17 | // 与 `TaCZStartupEvents.ammoIndexLoad` 功能一致, 但优先级更高 18 | TaCZServerEvents.ammoIndexLoad((event) => { 19 | const id = event.getId().toString(); 20 | // 修改 火箭弹 的堆叠数量为 33 21 | if (id === "tacz:rpg_rocket") { 22 | const json = JSON.parse(event.getStdJson()); 23 | json.stack_size = 33; 24 | return event.setJson(JSON.stringify(json)); 25 | } 26 | }) 27 | 28 | // 与 `TaCZStartupEvents.attachmentIndexLoad` 功能一致, 但优先级更高 29 | TaCZServerEvents.attachmentIndexLoad((event) => { 30 | const id = event.getId().toString(); 31 | // 删除 狙击弹药扩容弹匣3 32 | if (id === "tacz:sniper_extended_mag_3") { 33 | return event.removeAttachment(); 34 | } 35 | }) 36 | -------------------------------------------------------------------------------- /forge/src/main/java/dev/aika/taczjs/forge/mixin/client/InteractKeyTextOverlayMixin.java: -------------------------------------------------------------------------------- 1 | package dev.aika.taczjs.forge.mixin.client; 2 | 3 | import com.tacz.guns.client.gui.overlay.InteractKeyTextOverlay; 4 | import dev.aika.taczjs.forge.TaCZJSUtils; 5 | import net.minecraft.client.Minecraft; 6 | import net.minecraft.client.gui.Font; 7 | import net.minecraft.client.gui.GuiGraphics; 8 | import net.minecraftforge.api.distmarker.Dist; 9 | import net.minecraftforge.api.distmarker.OnlyIn; 10 | import org.spongepowered.asm.mixin.Mixin; 11 | import org.spongepowered.asm.mixin.injection.At; 12 | import org.spongepowered.asm.mixin.injection.Inject; 13 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 14 | 15 | @OnlyIn(Dist.CLIENT) 16 | @Mixin(value = InteractKeyTextOverlay.class, remap = false) 17 | public abstract class InteractKeyTextOverlayMixin { 18 | @Inject(method = "renderText", at = @At("HEAD"), cancellable = true) 19 | private static void renderText(GuiGraphics graphics, int width, int height, Font font, CallbackInfo ci) { 20 | TaCZJSUtils.getClientGun(Minecraft.getInstance().player).ifPresent(gun -> { 21 | if (gun.isVanillaInteract()) 22 | ci.cancel(); 23 | }); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /forge/src/main/java/dev/aika/taczjs/forge/mixin/client/ClientPreventGunClickMixin.java: -------------------------------------------------------------------------------- 1 | package dev.aika.taczjs.forge.mixin.client; 2 | 3 | import com.tacz.guns.client.event.ClientPreventGunClick; 4 | import dev.aika.taczjs.forge.TaCZJSUtils; 5 | import net.minecraft.client.Minecraft; 6 | import net.minecraftforge.api.distmarker.Dist; 7 | import net.minecraftforge.api.distmarker.OnlyIn; 8 | import net.minecraftforge.client.event.InputEvent; 9 | import org.spongepowered.asm.mixin.Mixin; 10 | import org.spongepowered.asm.mixin.injection.At; 11 | import org.spongepowered.asm.mixin.injection.Inject; 12 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 13 | 14 | @OnlyIn(Dist.CLIENT) 15 | @Mixin(value = ClientPreventGunClick.class, remap = false) 16 | public abstract class ClientPreventGunClickMixin { 17 | @Inject(method = "onClickInput", at = @At("HEAD"), cancellable = true) 18 | private static void onClickInput(InputEvent.InteractionKeyMappingTriggered event, CallbackInfo ci) { 19 | var mc = Minecraft.getInstance(); 20 | if (mc.options.keyAttack.isDown()) return; 21 | TaCZJSUtils.getClientGun(mc.player).ifPresent(gun -> { 22 | if (gun.isVanillaInteract()) ci.cancel(); 23 | }); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /forge/src/main/java/dev/aika/taczjs/forge/mixin/client/ClientIndexManagerMixin.java: -------------------------------------------------------------------------------- 1 | package dev.aika.taczjs.forge.mixin.client; 2 | 3 | import com.tacz.guns.client.resource.ClientIndexManager; 4 | import com.tacz.guns.resource.index.CommonGunIndex; 5 | import dev.aika.taczjs.forge.events.ModClientEvents; 6 | import dev.aika.taczjs.forge.events.client.ClientGunIndexLoadEvent; 7 | import net.minecraft.resources.ResourceLocation; 8 | import org.spongepowered.asm.mixin.Mixin; 9 | import org.spongepowered.asm.mixin.injection.At; 10 | import org.spongepowered.asm.mixin.injection.Inject; 11 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 12 | 13 | import java.util.Map; 14 | 15 | @Mixin(value = ClientIndexManager.class, remap = false) 16 | public abstract class ClientIndexManagerMixin { 17 | @Inject(method = "lambda$loadGunIndex$1", at = @At( 18 | value = "INVOKE", 19 | target = "Ljava/util/Map;put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;", 20 | shift = At.Shift.AFTER)) 21 | private static void loadGunIndex(Map.Entry index, CallbackInfo ci) { 22 | var event = new ClientGunIndexLoadEvent(index.getKey()); 23 | ModClientEvents.GUN_INDEX_LOAD_REGISTER.post(event); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /example/tacz/server_scripts/custom_data.js: -------------------------------------------------------------------------------- 1 | // 与 `TaCZStartupEvents.gunDataLoad` 功能一致, 但优先级更高 2 | TaCZServerEvents.gunDataLoad((event) => { 3 | const id = event.getId().toString(); 4 | // 修改 p90 的弹药数量为 123 5 | if (id === "tacz:p90_data") { 6 | const json = JSON.parse(event.getStdJson()); 7 | json.ammo_amount = 123; 8 | return event.setJson(JSON.stringify(json)); 9 | } 10 | // 修改 黄金沙漠之鹰 的伤害为 999 11 | if (id === "tacz:deagle_golden_data") { 12 | const json = JSON.parse(event.getStdJson()); 13 | json.bullet.extra_damage.damage_adjust = [ 14 | { distance: 18, damage: 999 }, 15 | { distance: 36, damage: 999 }, 16 | { distance: 55, damage: 999 }, 17 | { distance: "infinite", damage: 999 }, 18 | ]; 19 | return event.setJson(JSON.stringify(json)); 20 | } 21 | }) 22 | 23 | // 与 `TaCZStartupEvents.attachmentDataLoad` 功能一致, 但优先级更高 24 | TaCZServerEvents.attachmentDataLoad((event) => { 25 | const id = event.getId().toString(); 26 | // 修改 克苏鲁K7制退器, 装备后会拥有 10 倍的垂直后坐力👍 27 | if (id === "tacz:muzzle_brake_cthulhu_data") { 28 | const json = JSON.parse(event.getStdJson()); 29 | json.recoil.pitch = {multiplier: 10} 30 | return event.setJson(JSON.stringify(json)); 31 | } 32 | }) 33 | -------------------------------------------------------------------------------- /types/TaCZJSUtils.d.ts: -------------------------------------------------------------------------------- 1 | declare class TaCZJSUtils { 2 | /** client only */ 3 | static AnimationPlayType: typeof AnimationPlayType; 4 | /** client only */ 5 | static SoundPlayManager: SoundPlayManager; 6 | /** client only */ 7 | static openRefitScreen(): void; 8 | static mainHandHoldGun(livingEntity: LivingEntity): boolean; 9 | static getGunIndex(gunId: ResourceLocation): CommonGunIndex; 10 | static getAmmoIndex(ammoId: ResourceLocation): CommonAmmoIndex; 11 | static getAttachmentIndex(attachmentId: ResourceLocation): CommonAttachmentIndex; 12 | static getRecipe(recipeId: ResourceLocation): GunSmithTableRecipe; 13 | } 14 | 15 | enum AnimationPlayType { 16 | PLAY_ONCE_HOLD, 17 | PLAY_ONCE_STOP, 18 | LOOP 19 | } 20 | 21 | /** net.minecraft.resources.ResourceLocation */ 22 | type ResourceLocation = any; 23 | /** net.minecraft.world.entity.LivingEntity */ 24 | type LivingEntity = any; 25 | /** com.tacz.guns.client.sound.SoundPlayManager */ 26 | type SoundPlayManager = any; 27 | /** com.tacz.guns.resource.index.CommonGunIndex */ 28 | type CommonGunIndex = any; 29 | /** com.tacz.guns.resource.index.CommonAmmoIndex */ 30 | type CommonAmmoIndex = any; 31 | /** com.tacz.guns.resource.index.CommonAttachmentIndex */ 32 | type CommonAttachmentIndex = any; 33 | /** com.tacz.guns.resource.index.GunSmithTableRecipe */ 34 | type GunSmithTableRecipe = any; 35 | -------------------------------------------------------------------------------- /forge/src/main/java/dev/aika/taczjs/forge/events/crafting/AbstractRecipeEvent.java: -------------------------------------------------------------------------------- 1 | package dev.aika.taczjs.forge.events.crafting; 2 | 3 | import dev.latvian.mods.kubejs.event.EventJS; 4 | import dev.latvian.mods.rhino.util.HideFromJS; 5 | import net.minecraft.resources.ResourceLocation; 6 | 7 | @SuppressWarnings("unused") 8 | public abstract class AbstractRecipeEvent extends EventJS { 9 | private final ResourceLocation id; 10 | private final ResourceLocation recipeId; 11 | private Boolean cancelled; 12 | 13 | public AbstractRecipeEvent(ResourceLocation recipeId) { 14 | this.recipeId = recipeId; 15 | this.id = toId(recipeId); 16 | this.cancelled = false; 17 | } 18 | 19 | @HideFromJS 20 | public static ResourceLocation toId(ResourceLocation recipeId) { 21 | var paths = recipeId.getPath().split("/"); 22 | if (paths.length == 1) return recipeId; 23 | return new ResourceLocation(recipeId.getNamespace(), paths[paths.length - 1]); 24 | } 25 | 26 | public ResourceLocation getId() { 27 | return this.id; 28 | } 29 | 30 | public ResourceLocation getRecipeId() { 31 | return this.recipeId; 32 | } 33 | 34 | @HideFromJS 35 | public Boolean isRemove() { 36 | return this.cancelled; 37 | } 38 | 39 | @HideFromJS 40 | public void setRemove(boolean cancelled) { 41 | this.cancelled = cancelled; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /forge/src/main/java/dev/aika/taczjs/forge/events/shooter/AbstractShooterEvent.java: -------------------------------------------------------------------------------- 1 | package dev.aika.taczjs.forge.events.shooter; 2 | 3 | import com.tacz.guns.api.item.IGun; 4 | import dev.latvian.mods.kubejs.entity.LivingEntityEventJS; 5 | import dev.latvian.mods.rhino.util.HideFromJS; 6 | import net.minecraft.resources.ResourceLocation; 7 | import net.minecraft.world.entity.LivingEntity; 8 | import net.minecraft.world.item.ItemStack; 9 | 10 | @SuppressWarnings("unused") 11 | public abstract class AbstractShooterEvent extends LivingEntityEventJS { 12 | private final LivingEntity entity; 13 | private final ItemStack gunItem; 14 | private Boolean cancelled = false; 15 | 16 | public AbstractShooterEvent(LivingEntity entity, ItemStack gunItem) { 17 | this.entity = entity; 18 | this.gunItem = gunItem; 19 | } 20 | 21 | @Override 22 | public LivingEntity getEntity() { 23 | return entity; 24 | } 25 | 26 | public LivingEntity getShooter() { 27 | return this.getEntity(); 28 | } 29 | 30 | @HideFromJS 31 | public boolean isCancelled() { 32 | return cancelled; 33 | } 34 | 35 | @HideFromJS 36 | public void setCancelled() { 37 | cancelled = true; 38 | } 39 | 40 | public ResourceLocation getGunId() { 41 | if (gunItem.getItem() instanceof IGun iGun) return iGun.getGunId(gunItem); 42 | return null; 43 | } 44 | 45 | public ItemStack getGunItem() { 46 | return gunItem; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /forge/src/main/java/dev/aika/taczjs/forge/mixin/shooter/LivingEntityAimMixin.java: -------------------------------------------------------------------------------- 1 | package dev.aika.taczjs.forge.mixin.shooter; 2 | 3 | import com.tacz.guns.api.item.IGun; 4 | import com.tacz.guns.entity.shooter.LivingEntityAim; 5 | import com.tacz.guns.entity.shooter.ShooterDataHolder; 6 | import dev.aika.taczjs.forge.events.ModServerEvents; 7 | import dev.aika.taczjs.forge.events.shooter.LivingEntityAimEvent; 8 | import net.minecraft.world.entity.LivingEntity; 9 | import org.spongepowered.asm.mixin.Final; 10 | import org.spongepowered.asm.mixin.Mixin; 11 | import org.spongepowered.asm.mixin.Shadow; 12 | import org.spongepowered.asm.mixin.injection.At; 13 | import org.spongepowered.asm.mixin.injection.Inject; 14 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 15 | 16 | @Mixin(value = LivingEntityAim.class, remap = false) 17 | public abstract class LivingEntityAimMixin { 18 | @Shadow 19 | @Final 20 | private ShooterDataHolder data; 21 | 22 | @Shadow 23 | @Final 24 | private LivingEntity shooter; 25 | 26 | @Inject(method = "aim", at = @At("HEAD"), cancellable = true) 27 | private void onAim(boolean isAim, CallbackInfo ci) { 28 | if (this.data.currentGunItem == null || !(this.data.currentGunItem.get().getItem() instanceof IGun)) return; 29 | var event = new LivingEntityAimEvent(this.shooter, this.data.currentGunItem.get()); 30 | ModServerEvents.ENTITY_AIM_REGISTER.post(event); 31 | if (event.isCancelled()) ci.cancel(); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /forge/src/main/java/dev/aika/taczjs/forge/mixin/shooter/LivingEntityMeleeMixin.java: -------------------------------------------------------------------------------- 1 | package dev.aika.taczjs.forge.mixin.shooter; 2 | 3 | import com.tacz.guns.api.item.IGun; 4 | import com.tacz.guns.entity.shooter.LivingEntityMelee; 5 | import com.tacz.guns.entity.shooter.ShooterDataHolder; 6 | import dev.aika.taczjs.forge.events.ModServerEvents; 7 | import dev.aika.taczjs.forge.events.shooter.LivingEntityMeleeEvent; 8 | import net.minecraft.world.entity.LivingEntity; 9 | import org.spongepowered.asm.mixin.Final; 10 | import org.spongepowered.asm.mixin.Mixin; 11 | import org.spongepowered.asm.mixin.Shadow; 12 | import org.spongepowered.asm.mixin.injection.At; 13 | import org.spongepowered.asm.mixin.injection.Inject; 14 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 15 | 16 | @Mixin(value = LivingEntityMelee.class, remap = false) 17 | public abstract class LivingEntityMeleeMixin { 18 | @Shadow 19 | @Final 20 | private ShooterDataHolder data; 21 | 22 | @Shadow 23 | @Final 24 | private LivingEntity shooter; 25 | 26 | @Inject(method = "melee", at = @At("HEAD"), cancellable = true) 27 | private void onMelee(CallbackInfo ci) { 28 | if (this.data.currentGunItem == null || !(this.data.currentGunItem.get().getItem() instanceof IGun)) return; 29 | var event = new LivingEntityMeleeEvent(this.shooter, this.data.currentGunItem.get()); 30 | ModServerEvents.ENTITY_MELEE_REGISTER.post(event); 31 | if (event.isCancelled()) ci.cancel(); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /forge/src/main/java/dev/aika/taczjs/forge/mixin/shooter/LivingEntityReloadMixin.java: -------------------------------------------------------------------------------- 1 | package dev.aika.taczjs.forge.mixin.shooter; 2 | 3 | import com.tacz.guns.api.item.IGun; 4 | import com.tacz.guns.entity.shooter.LivingEntityReload; 5 | import com.tacz.guns.entity.shooter.ShooterDataHolder; 6 | import dev.aika.taczjs.forge.events.ModServerEvents; 7 | import dev.aika.taczjs.forge.events.shooter.LivingEntityReloadEvent; 8 | import net.minecraft.world.entity.LivingEntity; 9 | import org.spongepowered.asm.mixin.Final; 10 | import org.spongepowered.asm.mixin.Mixin; 11 | import org.spongepowered.asm.mixin.Shadow; 12 | import org.spongepowered.asm.mixin.injection.At; 13 | import org.spongepowered.asm.mixin.injection.Inject; 14 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 15 | 16 | @Mixin(value = LivingEntityReload.class, remap = false) 17 | public abstract class LivingEntityReloadMixin { 18 | @Shadow 19 | @Final 20 | private ShooterDataHolder data; 21 | 22 | @Shadow 23 | @Final 24 | private LivingEntity shooter; 25 | 26 | @Inject(method = "reload", at = @At("HEAD"), cancellable = true) 27 | private void onReload(CallbackInfo ci) { 28 | if (this.data.currentGunItem == null || !(this.data.currentGunItem.get().getItem() instanceof IGun)) return; 29 | var event = new LivingEntityReloadEvent(this.shooter, this.data.currentGunItem.get()); 30 | ModServerEvents.ENTITY_RELOAD_REGISTER.post(event); 31 | if (event.isCancelled()) ci.cancel(); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /forge/src/main/java/dev/aika/taczjs/forge/mixin/client/LocalPlayerMeleeMixin.java: -------------------------------------------------------------------------------- 1 | package dev.aika.taczjs.forge.mixin.client; 2 | 3 | import com.tacz.guns.api.item.gun.AbstractGunItem; 4 | import com.tacz.guns.client.gameplay.LocalPlayerMelee; 5 | import dev.aika.taczjs.forge.events.ModClientEvents; 6 | import dev.aika.taczjs.forge.events.client.LocalPlayerMeleeEvent; 7 | import net.minecraft.client.player.LocalPlayer; 8 | import net.minecraftforge.api.distmarker.Dist; 9 | import net.minecraftforge.api.distmarker.OnlyIn; 10 | import org.spongepowered.asm.mixin.Final; 11 | import org.spongepowered.asm.mixin.Mixin; 12 | import org.spongepowered.asm.mixin.Shadow; 13 | import org.spongepowered.asm.mixin.injection.At; 14 | import org.spongepowered.asm.mixin.injection.Inject; 15 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 16 | 17 | @OnlyIn(Dist.CLIENT) 18 | @Mixin(value = LocalPlayerMelee.class, remap = false) 19 | public abstract class LocalPlayerMeleeMixin { 20 | @Shadow 21 | @Final 22 | private LocalPlayer player; 23 | 24 | @Inject(method = "melee", at = @At("HEAD"), cancellable = true) 25 | private void melee(CallbackInfo ci) { 26 | var mainHandItem = this.player.getMainHandItem(); 27 | if (mainHandItem.getItem() instanceof AbstractGunItem gun) { 28 | var event = new LocalPlayerMeleeEvent(gun.getGunId(mainHandItem)); 29 | ModClientEvents.PLAYER_MELEE_REGISTER.post(event); 30 | if (event.isCancelled()) ci.cancel(); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /forge/src/main/java/dev/aika/taczjs/forge/mixin/client/LocalPlayerAimMixin.java: -------------------------------------------------------------------------------- 1 | package dev.aika.taczjs.forge.mixin.client; 2 | 3 | import com.tacz.guns.api.item.gun.AbstractGunItem; 4 | import com.tacz.guns.client.gameplay.LocalPlayerAim; 5 | import dev.aika.taczjs.forge.events.ModClientEvents; 6 | import dev.aika.taczjs.forge.events.client.LocalPlayerAimEvent; 7 | import net.minecraft.client.player.LocalPlayer; 8 | import net.minecraftforge.api.distmarker.Dist; 9 | import net.minecraftforge.api.distmarker.OnlyIn; 10 | import org.spongepowered.asm.mixin.Final; 11 | import org.spongepowered.asm.mixin.Mixin; 12 | import org.spongepowered.asm.mixin.Shadow; 13 | import org.spongepowered.asm.mixin.injection.At; 14 | import org.spongepowered.asm.mixin.injection.Inject; 15 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 16 | 17 | @OnlyIn(Dist.CLIENT) 18 | @Mixin(value = LocalPlayerAim.class, remap = false) 19 | public abstract class LocalPlayerAimMixin { 20 | @Shadow 21 | @Final 22 | private LocalPlayer player; 23 | 24 | @Inject(method = "aim", at = @At("HEAD"), cancellable = true) 25 | private void aim(boolean isAim, CallbackInfo ci) { 26 | var mainHandItem = this.player.getMainHandItem(); 27 | if (mainHandItem.getItem() instanceof AbstractGunItem gun) { 28 | var event = new LocalPlayerAimEvent(isAim, gun.getGunId(mainHandItem)); 29 | ModClientEvents.PLAYER_AIM_REGISTER.post(event); 30 | if (event.isCancelled()) 31 | ci.cancel(); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /forge/src/main/java/dev/aika/taczjs/forge/events/crafting/legacy/RecipeLoadBeginEvent.java: -------------------------------------------------------------------------------- 1 | package dev.aika.taczjs.forge.events.crafting.legacy; 2 | 3 | import com.google.gson.JsonElement; 4 | import dev.aika.taczjs.forge.TaCZJSHelper; 5 | import dev.latvian.mods.kubejs.event.EventJS; 6 | import dev.latvian.mods.kubejs.typings.Info; 7 | import dev.latvian.mods.rhino.util.HideFromJS; 8 | import net.minecraft.resources.ResourceLocation; 9 | 10 | import java.util.HashMap; 11 | import java.util.Map; 12 | 13 | @SuppressWarnings("unused") 14 | public class RecipeLoadBeginEvent extends EventJS { 15 | private Boolean removeAllRecipes; 16 | private final Map putRecipes; 17 | 18 | public RecipeLoadBeginEvent() { 19 | this.removeAllRecipes = false; 20 | this.putRecipes = new HashMap<>(); 21 | } 22 | 23 | public void removeAllRecipes() { 24 | this.removeAllRecipes = true; 25 | } 26 | 27 | @HideFromJS 28 | public boolean isRemoveAllRecipes() { 29 | return removeAllRecipes; 30 | } 31 | 32 | public void putRecipe(ResourceLocation id, String json) { 33 | this.putRecipes.put(id, TaCZJSHelper.toJsonObject(json)); 34 | } 35 | 36 | @Info("@deprecated This is an alias for `event.putRecipe`. Please use `event.putRecipe` instead.") 37 | public void addRecipe(ResourceLocation id, String json) { 38 | putRecipe(id, json); 39 | } 40 | 41 | @HideFromJS 42 | public Map getPutRecipes() { 43 | return putRecipes; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /forge/src/main/java/dev/aika/taczjs/forge/mixin/client/LocalPlayerShootMixin.java: -------------------------------------------------------------------------------- 1 | package dev.aika.taczjs.forge.mixin.client; 2 | 3 | import com.tacz.guns.api.entity.ShootResult; 4 | import com.tacz.guns.api.item.gun.AbstractGunItem; 5 | import com.tacz.guns.client.gameplay.LocalPlayerShoot; 6 | import dev.aika.taczjs.forge.events.ModClientEvents; 7 | import dev.aika.taczjs.forge.events.client.LocalPlayerShootEvent; 8 | import net.minecraft.client.player.LocalPlayer; 9 | import net.minecraftforge.api.distmarker.Dist; 10 | import net.minecraftforge.api.distmarker.OnlyIn; 11 | import org.spongepowered.asm.mixin.Final; 12 | import org.spongepowered.asm.mixin.Mixin; 13 | import org.spongepowered.asm.mixin.Shadow; 14 | import org.spongepowered.asm.mixin.injection.At; 15 | import org.spongepowered.asm.mixin.injection.Inject; 16 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; 17 | 18 | @OnlyIn(Dist.CLIENT) 19 | @Mixin(value = LocalPlayerShoot.class, remap = false) 20 | public abstract class LocalPlayerShootMixin { 21 | @Shadow 22 | @Final 23 | private LocalPlayer player; 24 | 25 | @Inject(method = "shoot", at = @At("HEAD"), cancellable = true) 26 | private void shoot(CallbackInfoReturnable cir) { 27 | var mainHandItem = this.player.getMainHandItem(); 28 | if (mainHandItem.getItem() instanceof AbstractGunItem gun) { 29 | var event = new LocalPlayerShootEvent(gun.getGunId(mainHandItem)); 30 | ModClientEvents.PLAYER_SHOOT_REGISTER.post(event); 31 | if (event.isCancelled()) 32 | cir.setReturnValue(ShootResult.SUCCESS); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /forge/src/main/java/dev/aika/taczjs/forge/mixin/client/LocalPlayerReloadMixin.java: -------------------------------------------------------------------------------- 1 | package dev.aika.taczjs.forge.mixin.client; 2 | 3 | import com.tacz.guns.api.item.gun.AbstractGunItem; 4 | import com.tacz.guns.client.gameplay.LocalPlayerReload; 5 | import dev.aika.taczjs.forge.events.ModClientEvents; 6 | import dev.aika.taczjs.forge.events.client.LocalPlayerReloadEvent; 7 | import net.minecraft.client.player.LocalPlayer; 8 | import net.minecraftforge.api.distmarker.Dist; 9 | import net.minecraftforge.api.distmarker.OnlyIn; 10 | import org.spongepowered.asm.mixin.Final; 11 | import org.spongepowered.asm.mixin.Mixin; 12 | import org.spongepowered.asm.mixin.Shadow; 13 | import org.spongepowered.asm.mixin.injection.At; 14 | import org.spongepowered.asm.mixin.injection.Inject; 15 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 16 | 17 | @OnlyIn(Dist.CLIENT) 18 | @Mixin(value = LocalPlayerReload.class, remap = false) 19 | public abstract class LocalPlayerReloadMixin { 20 | @Shadow 21 | @Final 22 | private LocalPlayer player; 23 | 24 | @Shadow public abstract void cancelReload(); 25 | 26 | @Inject(method = "reload", at = @At("HEAD"), cancellable = true) 27 | private void reload(CallbackInfo ci) { 28 | var mainHandItem = this.player.getMainHandItem(); 29 | if (mainHandItem.getItem() instanceof AbstractGunItem gun) { 30 | var event = new LocalPlayerReloadEvent(gun.getGunId(mainHandItem)); 31 | ModClientEvents.PLAYER_RELOAD_REGISTER.post(event); 32 | if (event.isCancelled()) { 33 | this.cancelReload(); 34 | ci.cancel(); 35 | } 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /forge/src/main/java/dev/aika/taczjs/forge/events/ModStartupEvents.java: -------------------------------------------------------------------------------- 1 | package dev.aika.taczjs.forge.events; 2 | 3 | import dev.aika.taczjs.forge.events.asset.*; 4 | import dev.aika.taczjs.forge.events.crafting.legacy.RecipeLoadBeginEvent; 5 | import dev.aika.taczjs.forge.events.crafting.legacy.RecipeLoadEndEvent; 6 | import dev.aika.taczjs.forge.events.crafting.legacy.RecipeLoadEvent; 7 | import dev.aika.taczjs.forge.events.index.*; 8 | import dev.latvian.mods.kubejs.event.EventGroup; 9 | import dev.latvian.mods.kubejs.event.EventHandler; 10 | 11 | public interface ModStartupEvents { 12 | EventGroup GROUP = EventGroup.of("TaCZStartupEvents"); 13 | 14 | EventHandler RECIPE_LOAD_BEGIN_REGISTER = GROUP.startup("recipeLoadBegin", () -> RecipeLoadBeginEvent.class); 15 | EventHandler RECIPE_LOAD_REGISTER = GROUP.startup("recipeLoad", () -> RecipeLoadEvent.class); 16 | EventHandler RECIPE_LOAD_END_REGISTER = GROUP.startup("recipeLoadEnd", () -> RecipeLoadEndEvent.class); 17 | 18 | EventHandler GUN_INDEX_LOAD_REGISTER = GROUP.startup("gunIndexLoad", () -> GunIndexLoadEvent.class); 19 | EventHandler AMMO_INDEX_LOAD_REGISTER = GROUP.startup("ammoIndexLoad", () -> AmmoIndexLoadEvent.class); 20 | EventHandler ATTACHMENT_INDEX_LOAD_REGISTER = GROUP.startup("attachmentIndexLoad", () -> AttachmentIndexLoadEvent.class); 21 | 22 | EventHandler GUN_DATA_LOAD_REGISTER = GROUP.startup("gunDataLoad", () -> GunDataLoadEvent.class); 23 | EventHandler ATTACHMENT_DATA_LOAD_REGISTER = GROUP.startup("attachmentDataLoad", () -> AttachmentDataLoadEvent.class); 24 | EventHandler ATTACHMENT_TAGS_LOAD_REGISTER = GROUP.startup("attachmentTagsLoad", () -> AttachmentTagsLoadEvent.class); 25 | } 26 | -------------------------------------------------------------------------------- /forge/src/main/java/dev/aika/taczjs/forge/mixin/shooter/LivingEntityShootMixin.java: -------------------------------------------------------------------------------- 1 | package dev.aika.taczjs.forge.mixin.shooter; 2 | 3 | import com.tacz.guns.api.entity.ShootResult; 4 | import com.tacz.guns.api.item.IGun; 5 | import com.tacz.guns.entity.shooter.LivingEntityShoot; 6 | import com.tacz.guns.entity.shooter.ShooterDataHolder; 7 | import dev.aika.taczjs.forge.events.ModServerEvents; 8 | import dev.aika.taczjs.forge.events.shooter.LivingEntityShootEvent; 9 | import net.minecraft.world.entity.LivingEntity; 10 | import org.spongepowered.asm.mixin.Final; 11 | import org.spongepowered.asm.mixin.Mixin; 12 | import org.spongepowered.asm.mixin.Shadow; 13 | import org.spongepowered.asm.mixin.injection.At; 14 | import org.spongepowered.asm.mixin.injection.Inject; 15 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; 16 | 17 | import java.util.function.Supplier; 18 | 19 | @Mixin(value = LivingEntityShoot.class, remap = false) 20 | public abstract class LivingEntityShootMixin { 21 | @Shadow 22 | @Final 23 | private ShooterDataHolder data; 24 | 25 | @Shadow 26 | @Final 27 | private LivingEntity shooter; 28 | 29 | @Inject(method = "shoot", at = @At("HEAD"), cancellable = true) 30 | private void onShoot(Supplier pitch, Supplier yaw, long timestamp, CallbackInfoReturnable cir) { 31 | if (this.data.currentGunItem == null || !(this.data.currentGunItem.get().getItem() instanceof IGun)) return; 32 | var event = new LivingEntityShootEvent(this.shooter, this.data.currentGunItem.get()); 33 | ModServerEvents.ENTITY_SHOOT_REGISTER.post(event); 34 | if (event.isCancelled()) cir.setReturnValue(ShootResult.NOT_GUN); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /example/tacz/startup_scripts/custom_recipe.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 旧版的配方修改, 新版本建议使用 KubeJS 的 `ServerEvents.recipes` 进行配方管理. 3 | * 当前配方修改方法可能会在未来的某个版本移除. 4 | */ 5 | 6 | // TaCZ 配方加载开始前触发 7 | TaCZStartupEvents.recipeLoadBegin((event) => { 8 | /** 9 | * `event.addRecipe`与`event.putRecipe`的作用都是修改或添加一个配方 10 | * `event.addRecipe`是一个错误的命名 11 | */ 12 | 13 | // 添加 p90 的配方 14 | event.putRecipe( 15 | new ResourceLocation("tacz:gun/p90"), 16 | JSON.stringify({ 17 | materials: [{item: {item: "minecraft:oak_button"}, count: 3}], 18 | result: {type: "gun", id: "tacz:p90", count: 1}, 19 | }), 20 | ) 21 | 22 | // 移除所有配方 23 | // event.removeAllRecipes(); 24 | }) 25 | 26 | // TaCZ 配方加载过程, 每个配方都会触发一次事件 27 | TaCZStartupEvents.recipeLoad((event) => { 28 | const id = event.getId().toString(); 29 | // 移除 AA12 的配方 30 | if (id === "tacz:aa12") return event.removeRecipe(); 31 | // 移除 762x54 的配方 32 | if (id === "tacz:762x54") return event.removeRecipe() 33 | // 修改 沙漠之鹰 的配方 34 | if (id === "tacz:deagle") 35 | return event.setJson(JSON.stringify({ 36 | materials: [{item: {item: "minecraft:apple"}, count: 1}], 37 | result: {type: "gun", id: "tacz:deagle"}, 38 | })); 39 | }); 40 | 41 | // TaCZ 配方加载结束后触发 42 | TaCZStartupEvents.recipeLoadEnd((event) => { 43 | /** 44 | * `event.addRecipe`与`event.putRecipe`的作用都是修改或添加一个配方 45 | * `event.addRecipe`是一个错误的命名 46 | */ 47 | 48 | // 添加 762x54 的配方 49 | event.putRecipe( 50 | new ResourceLocation("tacz:ammo/762x54"), 51 | JSON.stringify({ 52 | materials: [{item: {item: "minecraft:oak_button"}, count: 3}], 53 | result: {type: "ammo", id: "tacz:762x54", count: 60}, 54 | }), 55 | ); 56 | 57 | // 移除所有配方 58 | // event.removeAllRecipes(); 59 | }); 60 | -------------------------------------------------------------------------------- /forge/src/main/java/dev/aika/taczjs/forge/events/crafting/legacy/RecipeLoadEvent.java: -------------------------------------------------------------------------------- 1 | package dev.aika.taczjs.forge.events.crafting.legacy; 2 | 3 | import com.google.gson.JsonElement; 4 | import com.tacz.guns.resource.CommonAssetsManager; 5 | import com.tacz.guns.resource.pojo.data.recipe.TableRecipe; 6 | import dev.aika.taczjs.forge.TaCZJSHelper; 7 | import dev.aika.taczjs.forge.events.crafting.AbstractRecipeEvent; 8 | import dev.latvian.mods.kubejs.typings.Info; 9 | import dev.latvian.mods.rhino.util.HideFromJS; 10 | import net.minecraft.resources.ResourceLocation; 11 | 12 | @SuppressWarnings("unused") 13 | public class RecipeLoadEvent extends AbstractRecipeEvent { 14 | private String json; 15 | private Boolean modified; 16 | 17 | public RecipeLoadEvent(ResourceLocation recipeId, String json) { 18 | super(recipeId); 19 | this.json = json; 20 | this.modified = false; 21 | } 22 | 23 | public void removeRecipe() { 24 | this.setRemove(true); 25 | } 26 | 27 | @Info("@deprecated deprecated\nThe returned data may not conform to standard JSON format.") 28 | public String getJson() { 29 | return this.json; 30 | } 31 | 32 | @Info("@deprecated deprecated\nGet the JSON data in standard format.") 33 | public String getStdJson() { 34 | return getJson(); 35 | } 36 | 37 | public void setJson(String json) { 38 | this.json = json; 39 | this.modified = true; 40 | } 41 | 42 | public TableRecipe getTableRecipe() { 43 | return CommonAssetsManager.GSON.fromJson(this.getJson(), TableRecipe.class); 44 | } 45 | 46 | @HideFromJS 47 | public Boolean isModified() { 48 | return this.modified; 49 | } 50 | 51 | @HideFromJS 52 | public JsonElement getJsonElement() { 53 | return TaCZJSHelper.toJsonObject(this.json); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /forge/src/main/java/dev/aika/taczjs/forge/mixin/client/ReloadableResourceManagerMixin.java: -------------------------------------------------------------------------------- 1 | package dev.aika.taczjs.forge.mixin.client; 2 | 3 | import com.tacz.guns.api.TimelessAPI; 4 | import dev.aika.taczjs.forge.events.ModClientEvents; 5 | import dev.aika.taczjs.forge.events.client.ClientGunIndexLoadEvent; 6 | import dev.aika.taczjs.forge.interfaces.client.IClientGun; 7 | import net.minecraft.server.packs.PackResources; 8 | import net.minecraft.server.packs.resources.ReloadInstance; 9 | import net.minecraft.server.packs.resources.ReloadableResourceManager; 10 | import net.minecraft.util.Unit; 11 | import net.minecraftforge.api.distmarker.Dist; 12 | import net.minecraftforge.api.distmarker.OnlyIn; 13 | import org.spongepowered.asm.mixin.Mixin; 14 | import org.spongepowered.asm.mixin.injection.At; 15 | import org.spongepowered.asm.mixin.injection.Inject; 16 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; 17 | 18 | import java.util.List; 19 | import java.util.concurrent.CompletableFuture; 20 | import java.util.concurrent.Executor; 21 | 22 | @OnlyIn(Dist.CLIENT) 23 | @Mixin(ReloadableResourceManager.class) 24 | public abstract class ReloadableResourceManagerMixin { 25 | @Inject(method = "createReload", at = @At("RETURN")) 26 | private void onCreateReload(Executor backgroundExecutor, Executor gameExecutor, CompletableFuture waitingFor, List resourcePacks, CallbackInfoReturnable cir) { 27 | TimelessAPI.getAllCommonGunIndex().forEach(e -> { 28 | var gunId = e.getKey(); 29 | if (TimelessAPI.getClientGunIndex(gunId).orElse(null) instanceof IClientGun iClientGun) 30 | iClientGun.setVanillaInteract(false); 31 | var event = new ClientGunIndexLoadEvent(gunId); 32 | ModClientEvents.GUN_INDEX_LOAD_REGISTER.post(event); 33 | }); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /forge/src/main/java/dev/aika/taczjs/forge/events/AbstractIndexLoadEvent.java: -------------------------------------------------------------------------------- 1 | package dev.aika.taczjs.forge.events; 2 | 3 | import com.google.gson.JsonElement; 4 | import dev.latvian.mods.kubejs.event.EventJS; 5 | import dev.latvian.mods.rhino.util.HideFromJS; 6 | import net.minecraft.resources.ResourceLocation; 7 | import net.minecraft.util.GsonHelper; 8 | 9 | @SuppressWarnings("unused") 10 | public abstract class AbstractIndexLoadEvent extends EventJS { 11 | private final ResourceLocation id; 12 | private Boolean cancelled; 13 | private String newJson; 14 | private String json; 15 | private final JsonElement jsonElement; 16 | 17 | public AbstractIndexLoadEvent(ResourceLocation id, JsonElement json) { 18 | this.id = id; 19 | this.json = null; 20 | this.newJson = null; 21 | this.jsonElement = json; 22 | this.cancelled = false; 23 | } 24 | 25 | public ResourceLocation getId() { 26 | return this.id; 27 | } 28 | 29 | public String getJson() { 30 | if (this.newJson != null) return this.newJson; 31 | if (this.json != null) return this.json; 32 | if (this.jsonElement != null) { 33 | this.json = GsonHelper.toStableString(this.jsonElement); 34 | return this.json; 35 | } 36 | return null; 37 | } 38 | 39 | public String getStdJson() { 40 | return getJson(); 41 | } 42 | 43 | public void setJson(String json) { 44 | this.newJson = json; 45 | } 46 | 47 | @HideFromJS 48 | public Boolean isModified() { 49 | return this.newJson != null || this.json != null; 50 | } 51 | 52 | @HideFromJS 53 | public Boolean isRemove() { 54 | return this.cancelled; 55 | } 56 | 57 | @HideFromJS 58 | public void setRemove(boolean cancelled) { 59 | this.cancelled = cancelled; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /forge/src/main/java/dev/aika/taczjs/forge/events/ModServerEvents.java: -------------------------------------------------------------------------------- 1 | package dev.aika.taczjs.forge.events; 2 | 3 | import dev.aika.taczjs.forge.events.asset.AttachmentDataLoadEvent; 4 | import dev.aika.taczjs.forge.events.asset.AttachmentTagsLoadEvent; 5 | import dev.aika.taczjs.forge.events.asset.GunDataLoadEvent; 6 | import dev.aika.taczjs.forge.events.index.AmmoIndexLoadEvent; 7 | import dev.aika.taczjs.forge.events.index.AttachmentIndexLoadEvent; 8 | import dev.aika.taczjs.forge.events.index.GunIndexLoadEvent; 9 | import dev.aika.taczjs.forge.events.shooter.*; 10 | import dev.latvian.mods.kubejs.event.EventGroup; 11 | import dev.latvian.mods.kubejs.event.EventHandler; 12 | 13 | public interface ModServerEvents { 14 | EventGroup GROUP = EventGroup.of("TaCZServerEvents"); 15 | 16 | EventHandler ENTITY_SHOOT_REGISTER = GROUP.server("entityShoot", () -> LivingEntityShootEvent.class); 17 | EventHandler ENTITY_AIM_REGISTER = GROUP.server("entityAim", () -> LivingEntityAimEvent.class); 18 | EventHandler ENTITY_MELEE_REGISTER = GROUP.server("entityMelee", () -> LivingEntityMeleeEvent.class); 19 | EventHandler ENTITY_RELOAD_REGISTER = GROUP.server("entityReload", () -> LivingEntityReloadEvent.class); 20 | 21 | EventHandler GUN_INDEX_LOAD_REGISTER = GROUP.server("gunIndexLoad", () -> GunIndexLoadEvent.class); 22 | EventHandler AMMO_INDEX_LOAD_REGISTER = GROUP.server("ammoIndexLoad", () -> AmmoIndexLoadEvent.class); 23 | EventHandler ATTACHMENT_INDEX_LOAD_REGISTER = GROUP.server("attachmentIndexLoad", () -> AttachmentIndexLoadEvent.class); 24 | 25 | EventHandler GUN_DATA_LOAD_REGISTER = GROUP.server("gunDataLoad", () -> GunDataLoadEvent.class); 26 | EventHandler ATTACHMENT_DATA_LOAD_REGISTER = GROUP.server("attachmentDataLoad", () -> AttachmentDataLoadEvent.class); 27 | EventHandler ATTACHMENT_TAGS_LOAD_REGISTER = GROUP.server("attachmentTagsLoad", () -> AttachmentTagsLoadEvent.class); 28 | } 29 | -------------------------------------------------------------------------------- /types/TaCZClientEvents.d.ts: -------------------------------------------------------------------------------- 1 | import TaCZJSUtils from "./TaCZJSUtils" 2 | 3 | declare class TaCZClientEvents { 4 | static gunIndexLoad(event: ClientGunIndexLoadEvent); 5 | static playerAim(event: LocalPlayerAimEvent); 6 | static playerShoot(event: LocalPlayerShootEvent); 7 | static playerMelee(event: LocalPlayerMeleeEvent); 8 | static playerReload(event: LocalPlayerReloadEvent); 9 | } 10 | 11 | /** net.minecraft.resources.ResourceLocation */ 12 | type ResourceLocation = any; 13 | /** com.tacz.guns.client.resource.index.ClientGunIndex */ 14 | type ClientGunIndex = any; 15 | /** com.tacz.guns.api.client.gameplay.IClientPlayerGunOperator */ 16 | type IClientPlayerGunOperator = any; 17 | /** net.minecraft.world.phys.BlockHitResult */ 18 | type BlockHitResult = any; 19 | /** net.minecraft.world.phys.EntityHitResult */ 20 | type EntityHitResult = any; 21 | type float = number; 22 | 23 | interface AbstractClientGunEvent { 24 | getGunId(): ResourceLocation; 25 | getGunIndex(): ClientGunIndex; 26 | setVanillaInteract(v: boolean): void; 27 | isVanillaInteract(): boolean; 28 | getGunOperator(): IClientPlayerGunOperator; 29 | runMovementAnimation(animationName: string, type: TaCZJSUtils.AnimationPlayType, transitionTimeS: float); 30 | runMaimAnimation(animationName: string, type: TaCZJSUtils.AnimationPlayType, transitionTimeS: float); 31 | getBlockHitResult(): BlockHitResult; 32 | getEntityHitResult(): EntityHitResult; 33 | canInteractEntity(): boolean; 34 | } 35 | 36 | interface ClientGunIndexLoadEvent extends AbstractClientGunEvent {} 37 | interface LocalPlayerAimEvent extends AbstractClientGunEvent { 38 | isAim(): boolean; 39 | cancelAim(): void; 40 | } 41 | interface LocalPlayerShootEvent extends AbstractClientGunEvent { 42 | cancelShoot(): void; 43 | } 44 | interface LocalPlayerMeleeEvent extends AbstractClientGunEvent { 45 | cancelMelee(): void; 46 | } 47 | interface LocalPlayerReloadEvent extends AbstractClientGunEvent { 48 | cancelReload(): void; 49 | } 50 | -------------------------------------------------------------------------------- /forge/src/main/java/dev/aika/taczjs/forge/mixin/client/AmmoItemBuilderMixin.java: -------------------------------------------------------------------------------- 1 | package dev.aika.taczjs.forge.mixin.client; 2 | 3 | import com.tacz.guns.api.DefaultAssets; 4 | import com.tacz.guns.api.TimelessAPI; 5 | import com.tacz.guns.api.item.IAmmo; 6 | import com.tacz.guns.api.item.builder.AmmoItemBuilder; 7 | import com.tacz.guns.init.ModItems; 8 | import net.minecraft.resources.ResourceLocation; 9 | import net.minecraft.world.item.ItemStack; 10 | import net.minecraftforge.api.distmarker.Dist; 11 | import net.minecraftforge.api.distmarker.OnlyIn; 12 | import org.spongepowered.asm.mixin.Mixin; 13 | import org.spongepowered.asm.mixin.Shadow; 14 | import org.spongepowered.asm.mixin.injection.At; 15 | import org.spongepowered.asm.mixin.injection.Inject; 16 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; 17 | 18 | import java.util.Optional; 19 | 20 | @OnlyIn(Dist.CLIENT) 21 | @Mixin(value = AmmoItemBuilder.class, remap = false) 22 | public abstract class AmmoItemBuilderMixin { 23 | @Shadow 24 | private ResourceLocation ammoId; 25 | 26 | @Inject(method = "build", at = @At("HEAD"), cancellable = true) 27 | private void build(CallbackInfoReturnable cir) { 28 | StackWalker walker = StackWalker.getInstance(); 29 | walker.walk(f -> f.skip(2).findFirst()).ifPresent(f -> { 30 | if (!f.getClassName().equals("com.tacz.guns.init.ModCreativeTabs")) return; 31 | if (TimelessAPI.getCommonAmmoIndex(this.ammoId).isPresent()) return; 32 | var result = Optional.of(DefaultAssets.DEFAULT_AMMO_ID.getPath()) 33 | .flatMap(type -> TimelessAPI.getAllCommonAmmoIndex().stream().findFirst()) 34 | .map(first -> { 35 | var itemStack = new ItemStack(ModItems.AMMO.get(), 1); 36 | if (itemStack.getItem() instanceof IAmmo i) i.setAmmoId(itemStack, first.getKey()); 37 | return itemStack; 38 | }) 39 | .orElse(ModItems.GUN_SMITH_TABLE.get().getDefaultInstance()); 40 | cir.setReturnValue(result); 41 | }); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # User-specific stuff 2 | .idea/* 3 | !.idea/dictionaries 4 | 5 | *.iml 6 | *.ipr 7 | *.iws 8 | 9 | # IntelliJ 10 | out/ 11 | # mpeltonen/sbt-idea plugin 12 | .idea_modules/ 13 | 14 | # JIRA plugin 15 | atlassian-ide-plugin.xml 16 | 17 | # Compiled class file 18 | *.class 19 | 20 | # Log file 21 | *.log 22 | 23 | # BlueJ files 24 | *.ctxt 25 | 26 | # Package Files # 27 | *.jar 28 | *.war 29 | *.nar 30 | *.ear 31 | *.zip 32 | *.tar.gz 33 | *.rar 34 | 35 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 36 | hs_err_pid* 37 | 38 | *~ 39 | 40 | # temporary files which can be created if a process still has a handle open of a deleted file 41 | .fuse_hidden* 42 | 43 | # KDE directory preferences 44 | .directory 45 | 46 | # Linux trash folder which might appear on any partition or disk 47 | .Trash-* 48 | 49 | # .nfs files are created when an open file is removed but is still being accessed 50 | .nfs* 51 | 52 | # General 53 | .DS_Store 54 | .AppleDouble 55 | .LSOverride 56 | 57 | # Icon must end with two \r 58 | Icon 59 | 60 | # Thumbnails 61 | ._* 62 | 63 | # Files that might appear in the root of a volume 64 | .DocumentRevisions-V100 65 | .fseventsd 66 | .Spotlight-V100 67 | .TemporaryItems 68 | .Trashes 69 | .VolumeIcon.icns 70 | .com.apple.timemachine.donotpresent 71 | 72 | # Directories potentially created on remote AFP share 73 | .AppleDB 74 | .AppleDesktop 75 | Network Trash Folder 76 | Temporary Items 77 | .apdisk 78 | 79 | # Windows thumbnail cache files 80 | Thumbs.db 81 | Thumbs.db:encryptable 82 | ehthumbs.db 83 | ehthumbs_vista.db 84 | 85 | # Dump file 86 | *.stackdump 87 | 88 | # Folder config file 89 | [Dd]esktop.ini 90 | 91 | # Recycle Bin used on file shares 92 | $RECYCLE.BIN/ 93 | 94 | # Windows Installer files 95 | *.cab 96 | *.msi 97 | *.msix 98 | *.msm 99 | *.msp 100 | 101 | # Windows shortcuts 102 | *.lnk 103 | 104 | .gradle 105 | build/ 106 | 107 | # Ignore Gradle GUI config 108 | gradle-app.setting 109 | 110 | # Cache of project 111 | .gradletasknamecache 112 | 113 | **/build/ 114 | 115 | # Common working directory 116 | run/ 117 | runs/ 118 | 119 | # Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) 120 | !gradle-wrapper.jar 121 | -------------------------------------------------------------------------------- /forge/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'com.github.johnrengelman.shadow' 3 | } 4 | 5 | loom { 6 | forge { 7 | mixinConfig "taczjs.mixins.json" 8 | } 9 | } 10 | 11 | architectury { 12 | platformSetupLoomIde() 13 | forge() 14 | } 15 | 16 | configurations { 17 | common { 18 | canBeResolved = true 19 | canBeConsumed = false 20 | } 21 | compileClasspath.extendsFrom common 22 | runtimeClasspath.extendsFrom common 23 | developmentForge.extendsFrom common 24 | 25 | // Files in this configuration will be bundled into your mod using the Shadow plugin. 26 | // Don't use the `shadow` configuration from the plugin itself as it's meant for excluding files. 27 | shadowBundle { 28 | canBeResolved = true 29 | canBeConsumed = false 30 | } 31 | } 32 | 33 | repositories { 34 | } 35 | 36 | dependencies { 37 | forge "net.minecraftforge:forge:$rootProject.forge_version" 38 | 39 | modImplementation "curse.maven:timeless-and-classics-zero-1028108:$rootProject.tacz_forge_version" 40 | modImplementation "dev.latvian.mods:kubejs-forge:${rootProject.kubejs_version}" 41 | 42 | // Dev dependencies 43 | localRuntime("io.github.llamalad7:mixinextras-forge:0.3.6") 44 | forgeRuntimeLibrary 'org.apache.commons:commons-math3:3.6.1' 45 | forgeRuntimeLibrary 'com.github.FiguraMC.luaj:luaj-jse:3.0.8-figura' 46 | forgeRuntimeLibrary 'com.github.FiguraMC.luaj:luaj-core:3.0.8-figura' 47 | modLocalRuntime 'curse.maven:playeranimator-658587:4587214' 48 | modLocalRuntime("mezz.jei:jei-$rootProject.minecraft_version-forge:$rootProject.jei_version") { transitive = false } 49 | 50 | common(project(path: ':common', configuration: 'namedElements')) { transitive false } 51 | shadowBundle project(path: ':common', configuration: 'transformProductionForge') 52 | } 53 | 54 | processResources { 55 | inputs.property 'version', project.version 56 | 57 | filesMatching('META-INF/mods.toml') { 58 | expand version: project.version 59 | } 60 | from(rootProject.file("assets/icon-128x128.png")) { 61 | rename { "$rootProject.archives_name-icon.png" } 62 | } 63 | } 64 | 65 | shadowJar { 66 | configurations = [project.configurations.shadowBundle] 67 | archiveClassifier = 'dev-shadow' 68 | } 69 | 70 | remapJar { 71 | input.set shadowJar.archiveFile 72 | } 73 | -------------------------------------------------------------------------------- /forge/src/main/java/dev/aika/taczjs/forge/mixin/resource/manager/CommonDataManagerMixin.java: -------------------------------------------------------------------------------- 1 | package dev.aika.taczjs.forge.mixin.resource.manager; 2 | 3 | import com.google.gson.JsonElement; 4 | import com.tacz.guns.resource.manager.CommonDataManager; 5 | import com.tacz.guns.resource.network.DataType; 6 | import dev.aika.taczjs.TaCZJS; 7 | import dev.aika.taczjs.forge.TaCZJSHelper; 8 | import net.minecraft.resources.ResourceLocation; 9 | import net.minecraft.server.packs.resources.ResourceManager; 10 | import net.minecraft.util.GsonHelper; 11 | import net.minecraft.util.profiling.ProfilerFiller; 12 | import org.spongepowered.asm.mixin.Final; 13 | import org.spongepowered.asm.mixin.Mixin; 14 | import org.spongepowered.asm.mixin.Shadow; 15 | import org.spongepowered.asm.mixin.injection.At; 16 | import org.spongepowered.asm.mixin.injection.Inject; 17 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 18 | 19 | import java.util.*; 20 | 21 | @Mixin(value = CommonDataManager.class, remap = false) 22 | public abstract class CommonDataManagerMixin { 23 | @Shadow 24 | @Final 25 | private DataType type; 26 | 27 | @Inject(method = "apply(Ljava/util/Map;Lnet/minecraft/server/packs/resources/ResourceManager;Lnet/minecraft/util/profiling/ProfilerFiller;)V", at = @At("HEAD")) 28 | private void onApply(Map pObject, ResourceManager pResourceManager, ProfilerFiller pProfiler, CallbackInfo ci) { 29 | TaCZJS.LOGGER.debug("CommonDataManager::onApply: {}", this.type); 30 | ArrayList removes = new ArrayList<>(); 31 | Map modified = new HashMap<>(); 32 | if (EnumSet.of( 33 | DataType.GUN_INDEX, DataType.AMMO_INDEX, DataType.ATTACHMENT_INDEX, 34 | DataType.GUN_DATA, DataType.ATTACHMENT_DATA, 35 | DataType.ATTACHMENT_TAGS, DataType.ALLOW_ATTACHMENT_TAGS 36 | ).contains(this.type)) { 37 | for (Map.Entry entry : pObject.entrySet()) { 38 | var event = TaCZJSHelper.getLoadEventHandler(this.type, entry.getKey(), entry.getValue()); 39 | if (event == null) return; 40 | if (event.isRemove()) removes.add(event.getId()); 41 | else if (event.isModified()) modified.put(event.getId(), event.getJson()); 42 | } 43 | } 44 | if (!removes.isEmpty()) removes.forEach(pObject::remove); 45 | if (!modified.isEmpty()) modified.forEach((key, value) -> pObject.put(key, GsonHelper.parse(value))); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # TaCZ JS 2 | 3 | [![爱发电](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fafdian.com%2Fapi%2Fuser%2Fget-profile%3Fuser_id%3D75e549844b5111ed8df552540025c377&query=%24.data.user.name&label=%E7%88%B1%E5%8F%91%E7%94%B5&color=%23946ce6)](https://afdian.com/a/gizmo) 4 | [![Modrinth Downloads](https://img.shields.io/modrinth/dt/pAcsgLW2?logo=modrinth&label=Downloads)](https://modrinth.com/mod/pAcsgLW2) 5 | [![CurseForge Downloads](https://img.shields.io/curseforge/dt/1130998?logo=curseforge&label=Downloads)](https://www.curseforge.com/minecraft/mc-mods/tacz-js) 6 | ![GitHub License](https://img.shields.io/badge/GPL--3.0-x?label=License&color=%23f37f40) 7 | 8 | [KubeJS](https://github.com/KubeJS-Mods/KubeJS) [TaCZ](https://github.com/MCModderAnchor/TACZ) integration. 9 | 10 | > [!IMPORTANT] 11 | > This mod is not an official project of TaCZ. Please refrain from submitting issues or support requests related to this 12 | > mod to the TaCZ project maintainers. 13 | 14 | This mod was created to support my own modpack, with only the features I use and find useful. 15 | 16 | For usage examples, please refer to the [`example`](https://github.com/gizmo-ds/taczjs-mod/tree/v1.3.5+mc1.20.1/example) 17 | directory in this repository. This directory contains sample code and demonstrations to help you get started with the 18 | mod. [More examples(Simplified Chinese) 更多例子(简体中文)](https://wiki.aika.dev/taczjs/examples/recipes.html) 19 | 20 | You can also view the typescript type declaration file in 21 | the [types](https://github.com/gizmo-ds/taczjs-mod/tree/v1.3.5+mc1.20.1/types) directory. 22 | 23 | ## License 24 | 25 | ### Code 26 | 27 | Unless otherwise noted, the code in this project is licensed under the GNU General Public License v3.0 (GPL v3). You are 28 | free to use, modify, and distribute the code as long as your project is also licensed under the GPL v3 or a compatible 29 | license. For more information, please see the [GPL v3 license](./LICENSE). 30 | 31 | ### Assets 32 | 33 | Unless otherwise specified, all assets in this project (such as textures, models, and other media files) are licensed 34 | under the CC BY-NC-ND 4.0. This means you may share the assets as long as you give appropriate credit, do not use them 35 | for commercial purposes, and do not modify them. For further details, please refer to 36 | the [CC BY-NC-ND 4.0 license](https://creativecommons.org/licenses/by-nc-nd/4.0/). 37 | 38 | ## Sponsor ❤️ 39 | 40 | ❤ Enjoy `TaCZ JS` ? Support the author on [AFDIAN](https://afdian.com/a/gizmo)! ❤ 41 | 42 | [![金主爸爸](https://afdian-connect.deno.dev/sponsor.svg)](https://afdian.com/a/gizmo) 43 | -------------------------------------------------------------------------------- /types/TaCZStartupEvents.d.ts: -------------------------------------------------------------------------------- 1 | declare class TaCZStartupEvents { 2 | static recipeLoadBegin(event: RecipeLoadBeginEvent); 3 | static recipeLoad(event: RecipeLoadEvent); 4 | static recipeLoadEnd(event: RecipeLoadEndEvent); 5 | 6 | static gunIndexLoad(event: GunIndexLoadEvent); 7 | static ammoIndexLoad(event: AmmoIndexLoadEvent); 8 | static attachmentIndexLoad(event: AttachmentIndexLoadEvent); 9 | 10 | static gunDataLoad(event: GunDataLoadEvent); 11 | static attachmentDataLoad(event: AttachmentDataLoadEvent); 12 | static attachmentTagsLoad(event: AttachmentTagsLoadEvent); 13 | } 14 | 15 | /** net.minecraft.resources.ResourceLocation */ 16 | type ResourceLocation = any; 17 | /** com.tacz.guns.resource.pojo.data.recipe.TableRecipe */ 18 | type TableRecipe = any; 19 | /** com.tacz.guns.resource.pojo.data.gun.GunData */ 20 | type GunData = any; 21 | /** com.tacz.guns.resource.pojo.data.attachment.AttachmentData */ 22 | type AttachmentData = any; 23 | /** com.tacz.guns.resource.pojo.GunIndexPOJO */ 24 | type GunIndexPOJO = any; 25 | /** com.tacz.guns.resource.pojo.AmmoIndexPOJO */ 26 | type AmmoIndexPOJO = any; 27 | /** com.tacz.guns.resource.pojo.AttachmentIndexPOJO */ 28 | type AttachmentIndexPOJO = any; 29 | 30 | interface AbstractLoadEvent { 31 | getId(): ResourceLocation; 32 | getJson(): string; 33 | getStdJson(): string; 34 | setJson(json: string): void; 35 | } 36 | interface RecipeLoadEvent extends AbstractLoadEvent { 37 | getTableRecipe(): TableRecipe; 38 | removeRecipe(): void; 39 | } 40 | interface RecipeLoadBeginEvent { 41 | removeAllRecipes(): void; 42 | putRecipe(id: ResourceLocation, json: string): void; 43 | addRecipe(id: ResourceLocation, json: string): void; 44 | } 45 | interface RecipeLoadEndEvent extends RecipeLoadBeginEvent {} 46 | interface GunDataLoadEvent extends AbstractLoadEvent { 47 | getGunData(): GunData; 48 | removeGunData(): void; 49 | } 50 | interface AttachmentDataLoadEvent extends AbstractLoadEvent { 51 | getAttachmentData(): AttachmentData; 52 | removeAttachmentData(): void; 53 | } 54 | interface AttachmentTagsLoadEvent extends AbstractLoadEvent { 55 | getAttachmentTags(): string[]; 56 | removeAttachmentTags(): void; 57 | } 58 | interface GunIndexLoadEvent extends AbstractLoadEvent { 59 | getPOJO(): GunIndexPOJO; 60 | removeGun(): void; 61 | } 62 | interface AmmoIndexLoadEvent extends AbstractLoadEvent { 63 | getPOJO(): AmmoIndexPOJO; 64 | removeAmmo(): void; 65 | } 66 | interface AttachmentIndexLoadEvent extends AbstractLoadEvent { 67 | getPOJO(): AttachmentIndexPOJO; 68 | removeAttachment(): void; 69 | } 70 | -------------------------------------------------------------------------------- /forge/src/main/java/dev/aika/taczjs/forge/mixin/client/GunItemBuilderMixin.java: -------------------------------------------------------------------------------- 1 | package dev.aika.taczjs.forge.mixin.client; 2 | 3 | import com.tacz.guns.api.TimelessAPI; 4 | import com.tacz.guns.api.item.IGun; 5 | import com.tacz.guns.api.item.builder.GunItemBuilder; 6 | import com.tacz.guns.init.ModItems; 7 | import net.minecraft.resources.ResourceLocation; 8 | import net.minecraft.world.item.ItemStack; 9 | import net.minecraftforge.api.distmarker.Dist; 10 | import net.minecraftforge.api.distmarker.OnlyIn; 11 | import org.spongepowered.asm.mixin.Mixin; 12 | import org.spongepowered.asm.mixin.Shadow; 13 | import org.spongepowered.asm.mixin.injection.At; 14 | import org.spongepowered.asm.mixin.injection.Inject; 15 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; 16 | 17 | import java.util.Map; 18 | import java.util.Objects; 19 | import java.util.Optional; 20 | 21 | @OnlyIn(Dist.CLIENT) 22 | @Mixin(value = GunItemBuilder.class, remap = false) 23 | public abstract class GunItemBuilderMixin { 24 | @Shadow 25 | private ResourceLocation gunId; 26 | 27 | @Inject(method = "build", at = @At("HEAD"), cancellable = true) 28 | public void build(CallbackInfoReturnable cir) { 29 | StackWalker walker = StackWalker.getInstance(); 30 | walker.walk(f -> f.skip(2).findFirst()).ifPresent(f -> { 31 | if (!f.getClassName().equals("com.tacz.guns.init.ModCreativeTabs")) return; 32 | if (TimelessAPI.getCommonGunIndex(this.gunId).isPresent()) return; 33 | // https://github.com/MCModderAnchor/TACZ/blob/bd41964da0a869808ce963be5004dcb1d0fa4d69/src/main/java/com/tacz/guns/init/ModCreativeTabs.java#L72 34 | var GUN_TYPE_MAP = Map.of( 35 | "glock_17", "pistol", 36 | "ai_awp", "sniper", 37 | "ak47", "rifle", 38 | "db_short", "shotgun", 39 | "hk_mp5a5", "smg", 40 | "rpg7", "rpg", 41 | "m249", "mg" 42 | ); 43 | var result = Optional.ofNullable(GUN_TYPE_MAP.get(this.gunId.getPath())) 44 | .flatMap(type -> TimelessAPI.getAllCommonGunIndex().stream() 45 | .filter(x -> Objects.equals(x.getValue().getType(), type)) 46 | .findFirst() 47 | ) 48 | .map(first -> { 49 | var itemStack = new ItemStack(ModItems.MODERN_KINETIC_GUN.get(), 1); 50 | if (itemStack.getItem() instanceof IGun i) i.setGunId(itemStack, first.getKey()); 51 | return itemStack; 52 | }) 53 | .orElse(ModItems.GUN_SMITH_TABLE.get().getDefaultInstance()); 54 | cir.setReturnValue(result); 55 | }); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /types/TaCZServerEvents.d.ts: -------------------------------------------------------------------------------- 1 | declare class TaCZServerEvents { 2 | static entityShoot(event: LivingEntityShootEvent); 3 | static entityAim(event: LivingEntityAimEvent); 4 | static entityMelee(event: LivingEntityMeleeEvent); 5 | static entityReload(event: LivingEntityReloadEvent); 6 | 7 | static gunIndexLoad(event: GunIndexLoadEvent); 8 | static ammoIndexLoad(event: AmmoIndexLoadEvent); 9 | static attachmentIndexLoad(event: AttachmentIndexLoadEvent); 10 | 11 | static gunDataLoad(event: GunDataLoadEvent); 12 | static attachmentDataLoad(event: AttachmentDataLoadEvent); 13 | static attachmentTagsLoad(event: AttachmentTagsLoadEvent); 14 | } 15 | 16 | /** net.minecraft.world.entity.LivingEntity */ 17 | type LivingEntity = any; 18 | /** net.minecraft.resources.ResourceLocation */ 19 | type ResourceLocation = any; 20 | /** net.minecraft.world.item.ItemStack */ 21 | type ItemStack = any; 22 | /** com.tacz.guns.resource.pojo.data.gun.GunData */ 23 | type GunData = any; 24 | /** com.tacz.guns.resource.pojo.data.attachment.AttachmentData */ 25 | type AttachmentData = any; 26 | /** com.tacz.guns.resource.pojo.GunIndexPOJO */ 27 | type GunIndexPOJO = any; 28 | /** com.tacz.guns.resource.pojo.AmmoIndexPOJO */ 29 | type AmmoIndexPOJO = any; 30 | /** com.tacz.guns.resource.pojo.AttachmentIndexPOJO */ 31 | type AttachmentIndexPOJO = any; 32 | 33 | 34 | interface AbstractShooterEvent { 35 | getEntity(): LivingEntity; 36 | getShooter(): LivingEntity; 37 | getGunId(): ResourceLocation; 38 | getGunItem(): ItemStack; 39 | } 40 | 41 | interface LivingEntityShootEvent extends AbstractShooterEvent { 42 | cancelShoot(): void; 43 | } 44 | 45 | interface LivingEntityAimEvent extends AbstractShooterEvent { 46 | cancelAim(): void; 47 | } 48 | 49 | interface LivingEntityMeleeEvent extends AbstractShooterEvent { 50 | cancelMelee(): void; 51 | } 52 | 53 | interface LivingEntityReloadEvent extends AbstractShooterEvent { 54 | cancelReload(): void; 55 | } 56 | 57 | interface AbstractLoadEvent { 58 | getId(): ResourceLocation; 59 | getJson(): string; 60 | getStdJson(): string; 61 | setJson(json: string): void; 62 | } 63 | 64 | interface GunDataLoadEvent extends AbstractLoadEvent { 65 | getGunData(): GunData; 66 | removeGunData(): void; 67 | } 68 | interface AttachmentDataLoadEvent extends AbstractLoadEvent { 69 | getAttachmentData(): AttachmentData; 70 | removeAttachmentData(): void; 71 | } 72 | interface AttachmentTagsLoadEvent extends AbstractLoadEvent { 73 | getAttachmentTags(): string[]; 74 | removeAttachmentTags(): void; 75 | } 76 | interface GunIndexLoadEvent extends AbstractLoadEvent { 77 | getPOJO(): GunIndexPOJO; 78 | removeGun(): void; 79 | } 80 | interface AmmoIndexLoadEvent extends AbstractLoadEvent { 81 | getPOJO(): AmmoIndexPOJO; 82 | removeAmmo(): void; 83 | } 84 | interface AttachmentIndexLoadEvent extends AbstractLoadEvent { 85 | getPOJO(): AttachmentIndexPOJO; 86 | removeAttachment(): void; 87 | } 88 | -------------------------------------------------------------------------------- /forge/src/main/java/dev/aika/taczjs/forge/mixin/client/AttachmentItemBuilderMixin.java: -------------------------------------------------------------------------------- 1 | package dev.aika.taczjs.forge.mixin.client; 2 | 3 | import com.tacz.guns.api.TimelessAPI; 4 | import com.tacz.guns.api.item.IAttachment; 5 | import com.tacz.guns.api.item.attachment.AttachmentType; 6 | import com.tacz.guns.api.item.builder.AttachmentItemBuilder; 7 | import com.tacz.guns.init.ModItems; 8 | import net.minecraft.resources.ResourceLocation; 9 | import net.minecraft.world.item.ItemStack; 10 | import net.minecraftforge.api.distmarker.Dist; 11 | import net.minecraftforge.api.distmarker.OnlyIn; 12 | import org.spongepowered.asm.mixin.Mixin; 13 | import org.spongepowered.asm.mixin.Shadow; 14 | import org.spongepowered.asm.mixin.injection.At; 15 | import org.spongepowered.asm.mixin.injection.Inject; 16 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; 17 | 18 | import java.util.Map; 19 | import java.util.Objects; 20 | import java.util.Optional; 21 | 22 | @OnlyIn(Dist.CLIENT) 23 | @Mixin(value = AttachmentItemBuilder.class, remap = false) 24 | public abstract class AttachmentItemBuilderMixin { 25 | @Shadow 26 | private ResourceLocation attachmentId; 27 | 28 | @Inject(method = "build", at = @At("HEAD"), cancellable = true) 29 | private void build(CallbackInfoReturnable cir) { 30 | StackWalker walker = StackWalker.getInstance(); 31 | walker.walk(f -> f.skip(2).findFirst()).ifPresent(f -> { 32 | if (!f.getClassName().equals("com.tacz.guns.init.ModCreativeTabs")) return; 33 | if (TimelessAPI.getCommonAttachmentIndex(this.attachmentId).isPresent()) return; 34 | // https://github.com/MCModderAnchor/TACZ/blob/bd41964da0a869808ce963be5004dcb1d0fa4d69/src/main/java/com/tacz/guns/init/ModCreativeTabs.java#L42 35 | var ATTACHMENT_TYPE_MAP = Map.of( 36 | "scope_acog_ta31", AttachmentType.SCOPE, 37 | "muzzle_compensator_trident", AttachmentType.MUZZLE, 38 | "stock_militech_b5", AttachmentType.SCOPE, 39 | "grip_magpul_afg_2", AttachmentType.GRIP, 40 | "extended_mag_3", AttachmentType.EXTENDED_MAG 41 | ); 42 | var result = Optional.ofNullable(ATTACHMENT_TYPE_MAP.get(this.attachmentId.getPath())) 43 | .flatMap(type -> TimelessAPI.getAllCommonAttachmentIndex().stream() 44 | .filter(x -> Objects.equals(x.getValue().getType(), type)) 45 | .findFirst() 46 | ) 47 | .map(first -> { 48 | var itemStack = new ItemStack(ModItems.ATTACHMENT.get(), 1); 49 | if (itemStack.getItem() instanceof IAttachment i) i.setAttachmentId(itemStack, first.getKey()); 50 | return itemStack; 51 | }) 52 | .orElse(ModItems.GUN_SMITH_TABLE.get().getDefaultInstance()); 53 | cir.setReturnValue(result); 54 | }); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%"=="" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%"=="" set DIRNAME=. 29 | @rem This is normally unused 30 | set APP_BASE_NAME=%~n0 31 | set APP_HOME=%DIRNAME% 32 | 33 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 34 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 35 | 36 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 37 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 38 | 39 | @rem Find java.exe 40 | if defined JAVA_HOME goto findJavaFromJavaHome 41 | 42 | set JAVA_EXE=java.exe 43 | %JAVA_EXE% -version >NUL 2>&1 44 | if %ERRORLEVEL% equ 0 goto execute 45 | 46 | echo. 1>&2 47 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 48 | echo. 1>&2 49 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2 50 | echo location of your Java installation. 1>&2 51 | 52 | goto fail 53 | 54 | :findJavaFromJavaHome 55 | set JAVA_HOME=%JAVA_HOME:"=% 56 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 57 | 58 | if exist "%JAVA_EXE%" goto execute 59 | 60 | echo. 1>&2 61 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 62 | echo. 1>&2 63 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2 64 | echo location of your Java installation. 1>&2 65 | 66 | goto fail 67 | 68 | :execute 69 | @rem Setup the command line 70 | 71 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 72 | 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if %ERRORLEVEL% equ 0 goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | set EXIT_CODE=%ERRORLEVEL% 85 | if %EXIT_CODE% equ 0 set EXIT_CODE=1 86 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% 87 | exit /b %EXIT_CODE% 88 | 89 | :mainEnd 90 | if "%OS%"=="Windows_NT" endlocal 91 | 92 | :omega 93 | -------------------------------------------------------------------------------- /forge/src/main/java/dev/aika/taczjs/forge/TaCZJSHelper.java: -------------------------------------------------------------------------------- 1 | package dev.aika.taczjs.forge; 2 | 3 | import com.google.gson.JsonElement; 4 | import com.google.gson.JsonObject; 5 | import com.tacz.guns.init.ModRecipe; 6 | import com.tacz.guns.resource.PackConvertor; 7 | import com.tacz.guns.resource.network.DataType; 8 | import dev.aika.taczjs.forge.events.AbstractIndexLoadEvent; 9 | import dev.aika.taczjs.forge.events.ModServerEvents; 10 | import dev.aika.taczjs.forge.events.ModStartupEvents; 11 | import dev.aika.taczjs.forge.events.asset.AttachmentDataLoadEvent; 12 | import dev.aika.taczjs.forge.events.asset.AttachmentTagsLoadEvent; 13 | import dev.aika.taczjs.forge.events.asset.GunDataLoadEvent; 14 | import dev.aika.taczjs.forge.events.index.AmmoIndexLoadEvent; 15 | import dev.aika.taczjs.forge.events.index.AttachmentIndexLoadEvent; 16 | import dev.aika.taczjs.forge.events.index.GunIndexLoadEvent; 17 | import net.minecraft.resources.ResourceLocation; 18 | 19 | public class TaCZJSHelper { 20 | public static final String GunSmithTableRecipeType = ModRecipe.GUN_SMITH_TABLE_CRAFTING.getId().toString(); 21 | 22 | public static JsonObject toJsonObject(String json) { 23 | var object = PackConvertor.GSON.fromJson(json, JsonObject.class); 24 | if (!object.has("type")) object.addProperty("type", TaCZJSHelper.GunSmithTableRecipeType); 25 | return object; 26 | } 27 | 28 | public static AbstractIndexLoadEvent getLoadEventHandler(DataType type, ResourceLocation id, JsonElement json) { 29 | switch (type) { 30 | case GUN_INDEX: { 31 | var event = new GunIndexLoadEvent(id, json); 32 | ModStartupEvents.GUN_INDEX_LOAD_REGISTER.post(event); 33 | ModServerEvents.GUN_INDEX_LOAD_REGISTER.post(event); 34 | return event; 35 | } 36 | case AMMO_INDEX: { 37 | var event = new AmmoIndexLoadEvent(id, json); 38 | ModStartupEvents.AMMO_INDEX_LOAD_REGISTER.post(event); 39 | ModServerEvents.AMMO_INDEX_LOAD_REGISTER.post(event); 40 | return event; 41 | } 42 | case ATTACHMENT_INDEX: { 43 | var event = new AttachmentIndexLoadEvent(id, json); 44 | ModStartupEvents.ATTACHMENT_INDEX_LOAD_REGISTER.post(event); 45 | ModServerEvents.ATTACHMENT_INDEX_LOAD_REGISTER.post(event); 46 | return event; 47 | } 48 | case GUN_DATA: { 49 | var event = new GunDataLoadEvent(id, json); 50 | ModStartupEvents.GUN_DATA_LOAD_REGISTER.post(event); 51 | ModServerEvents.GUN_DATA_LOAD_REGISTER.post(event); 52 | return event; 53 | } 54 | case ATTACHMENT_DATA: { 55 | var event = new AttachmentDataLoadEvent(id, json); 56 | ModStartupEvents.ATTACHMENT_DATA_LOAD_REGISTER.post(event); 57 | ModServerEvents.ATTACHMENT_DATA_LOAD_REGISTER.post(event); 58 | return event; 59 | } 60 | case ATTACHMENT_TAGS: { 61 | var event = new AttachmentTagsLoadEvent(id, json); 62 | ModStartupEvents.ATTACHMENT_TAGS_LOAD_REGISTER.post(event); 63 | ModServerEvents.ATTACHMENT_TAGS_LOAD_REGISTER.post(event); 64 | return event; 65 | } 66 | default: 67 | return null; 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /forge/src/main/java/dev/aika/taczjs/forge/events/client/AbstractClientGunEvent.java: -------------------------------------------------------------------------------- 1 | package dev.aika.taczjs.forge.events.client; 2 | 3 | import com.tacz.guns.api.TimelessAPI; 4 | import com.tacz.guns.api.client.animation.ObjectAnimation; 5 | import com.tacz.guns.api.client.gameplay.IClientPlayerGunOperator; 6 | import com.tacz.guns.client.resource.index.ClientGunIndex; 7 | import com.tacz.guns.config.util.InteractKeyConfigRead; 8 | import dev.aika.taczjs.forge.TaCZJSUtils; 9 | import dev.aika.taczjs.forge.interfaces.client.IClientGun; 10 | import dev.latvian.mods.kubejs.client.ClientEventJS; 11 | import dev.latvian.mods.rhino.util.HideFromJS; 12 | import net.minecraft.client.Minecraft; 13 | import net.minecraft.resources.ResourceLocation; 14 | import net.minecraft.world.phys.BlockHitResult; 15 | import net.minecraft.world.phys.EntityHitResult; 16 | import net.minecraftforge.api.distmarker.Dist; 17 | import net.minecraftforge.api.distmarker.OnlyIn; 18 | 19 | @SuppressWarnings("unused") 20 | @OnlyIn(Dist.CLIENT) 21 | public abstract class AbstractClientGunEvent extends ClientEventJS { 22 | private Boolean cancelled = false; 23 | private final ResourceLocation gunId; 24 | 25 | AbstractClientGunEvent(ResourceLocation gunId) { 26 | this.gunId = gunId; 27 | } 28 | 29 | public ResourceLocation getGunId() { 30 | return gunId; 31 | } 32 | 33 | public ClientGunIndex getGunIndex() { 34 | return TimelessAPI.getClientGunIndex(gunId).orElse(null); 35 | } 36 | 37 | @HideFromJS 38 | public boolean isCancelled() { 39 | return cancelled; 40 | } 41 | 42 | @HideFromJS 43 | public void setCancelled() { 44 | cancelled = true; 45 | } 46 | 47 | public void setVanillaInteract(boolean v) { 48 | if (getGunIndex() instanceof IClientGun iClientGun) 49 | iClientGun.setVanillaInteract(v); 50 | } 51 | 52 | public boolean isVanillaInteract() { 53 | if (getGunIndex() instanceof IClientGun iClientGun) 54 | return iClientGun.isVanillaInteract(); 55 | return false; 56 | } 57 | 58 | public IClientPlayerGunOperator getGunOperator() { 59 | return IClientPlayerGunOperator.fromLocalPlayer(this.getPlayer()); 60 | } 61 | 62 | private ObjectAnimation.PlayType getPlayType(TaCZJSUtils.AnimationPlayType type) { 63 | return switch (type) { 64 | case PLAY_ONCE_HOLD -> ObjectAnimation.PlayType.PLAY_ONCE_HOLD; 65 | case PLAY_ONCE_STOP -> ObjectAnimation.PlayType.PLAY_ONCE_STOP; 66 | case LOOP -> ObjectAnimation.PlayType.LOOP; 67 | }; 68 | } 69 | 70 | public BlockHitResult getBlockHitResult() { 71 | var hitResult = Minecraft.getInstance().hitResult; 72 | if (hitResult instanceof BlockHitResult result) return result; 73 | return null; 74 | } 75 | 76 | public EntityHitResult getEntityHitResult() { 77 | var hitResult = Minecraft.getInstance().hitResult; 78 | if (hitResult instanceof EntityHitResult result) return result; 79 | return null; 80 | } 81 | 82 | public boolean canInteractEntity() { 83 | var hitResult = Minecraft.getInstance().hitResult; 84 | if (hitResult instanceof EntityHitResult result) 85 | return InteractKeyConfigRead.canInteractEntity(result.getEntity()); 86 | else if (hitResult instanceof BlockHitResult result) 87 | return InteractKeyConfigRead.canInteractBlock(this.getLevel().getBlockState(result.getBlockPos())); 88 | return false; 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /forge/src/main/java/dev/aika/taczjs/forge/mixin/crafting/RecipeManagerMixin.java: -------------------------------------------------------------------------------- 1 | package dev.aika.taczjs.forge.mixin.crafting; 2 | 3 | import com.google.gson.JsonElement; 4 | import dev.aika.taczjs.TaCZJS; 5 | import dev.aika.taczjs.forge.TaCZJSHelper; 6 | import dev.aika.taczjs.forge.events.ModStartupEvents; 7 | import dev.aika.taczjs.forge.events.crafting.legacy.RecipeLoadBeginEvent; 8 | import dev.aika.taczjs.forge.events.crafting.legacy.RecipeLoadEndEvent; 9 | import dev.aika.taczjs.forge.events.crafting.legacy.RecipeLoadEvent; 10 | import net.minecraft.resources.ResourceLocation; 11 | import net.minecraft.server.packs.resources.ResourceManager; 12 | import net.minecraft.util.GsonHelper; 13 | import net.minecraft.util.profiling.ProfilerFiller; 14 | import net.minecraft.world.item.crafting.RecipeManager; 15 | import org.spongepowered.asm.mixin.Mixin; 16 | import org.spongepowered.asm.mixin.injection.At; 17 | import org.spongepowered.asm.mixin.injection.Inject; 18 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 19 | 20 | import java.util.ArrayList; 21 | import java.util.HashMap; 22 | import java.util.Map; 23 | 24 | @Mixin(RecipeManager.class) 25 | public abstract class RecipeManagerMixin { 26 | /** 27 | * 兼容旧版 JS 的修改配方, 现在更加推荐使用 KubeJS 的 `ServerEvents.recipes` 进行配方管理. 可能会在未来的版本移除 28 | */ 29 | @Inject(method = "apply(Ljava/util/Map;Lnet/minecraft/server/packs/resources/ResourceManager;Lnet/minecraft/util/profiling/ProfilerFiller;)V", at = @At("HEAD")) 30 | private void onApply(Map object, ResourceManager resourceManager, ProfilerFiller profiler, CallbackInfo ci) { 31 | ArrayList removes = new ArrayList<>(); 32 | Map modified = new HashMap<>(); 33 | 34 | // RecipeLoadBeginEvent 35 | { 36 | var event = new RecipeLoadBeginEvent(); 37 | ModStartupEvents.RECIPE_LOAD_BEGIN_REGISTER.post(event); 38 | if (event.isRemoveAllRecipes()) object.clear(); 39 | var addRecipes = event.getPutRecipes(); 40 | if (!addRecipes.isEmpty()) object.putAll(addRecipes); 41 | } 42 | 43 | // RecipeLoadEvent 44 | for (Map.Entry entry : object.entrySet()) { 45 | ResourceLocation recipeId = entry.getKey(); 46 | JsonElement value = entry.getValue(); 47 | try { 48 | if (!value.isJsonObject()) continue; 49 | var obj = value.getAsJsonObject(); 50 | if (!obj.has("type")) continue; 51 | if (!obj.get("type").getAsString().equals(TaCZJSHelper.GunSmithTableRecipeType)) continue; 52 | } catch (Exception ex) { 53 | TaCZJS.LOGGER.warn("Failed to load recipe {}", entry.getKey(), ex); 54 | continue; 55 | } 56 | var jsonStr = GsonHelper.toStableString(value); 57 | var event = new RecipeLoadEvent(recipeId, jsonStr); 58 | ModStartupEvents.RECIPE_LOAD_REGISTER.post(event); 59 | if (event.isRemove()) removes.add(recipeId); 60 | if (event.isModified()) modified.put(recipeId, event.getJsonElement()); 61 | } 62 | 63 | removes.forEach(object::remove); 64 | object.putAll(modified); 65 | 66 | // RecipeLoadEndEvent 67 | { 68 | var event = new RecipeLoadEndEvent(); 69 | ModStartupEvents.RECIPE_LOAD_END_REGISTER.post(event); 70 | if (event.isRemoveAllRecipes()) object.clear(); 71 | var addRecipes = event.getPutRecipes(); 72 | if (!addRecipes.isEmpty()) object.putAll(addRecipes); 73 | } 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /forge/src/main/java/dev/aika/taczjs/forge/TaCZJSUtils.java: -------------------------------------------------------------------------------- 1 | package dev.aika.taczjs.forge; 2 | 3 | import com.tacz.guns.api.TimelessAPI; 4 | import com.tacz.guns.api.client.animation.ObjectAnimation; 5 | import com.tacz.guns.api.item.IGun; 6 | import com.tacz.guns.client.gui.GunRefitScreen; 7 | import com.tacz.guns.client.resource.GunDisplayInstance; 8 | import com.tacz.guns.resource.index.CommonAmmoIndex; 9 | import com.tacz.guns.resource.index.CommonAttachmentIndex; 10 | import com.tacz.guns.resource.index.CommonGunIndex; 11 | import com.tacz.guns.util.InputExtraCheck; 12 | import dev.aika.taczjs.forge.interfaces.client.IClientGun; 13 | import dev.latvian.mods.rhino.util.HideFromJS; 14 | import net.minecraft.client.Minecraft; 15 | import net.minecraft.client.player.LocalPlayer; 16 | import net.minecraft.resources.ResourceLocation; 17 | import net.minecraft.world.entity.LivingEntity; 18 | import net.minecraftforge.api.distmarker.Dist; 19 | import net.minecraftforge.api.distmarker.OnlyIn; 20 | 21 | import java.util.Optional; 22 | 23 | @SuppressWarnings("unused") 24 | public class TaCZJSUtils { 25 | @OnlyIn(Dist.CLIENT) 26 | public enum AnimationPlayType { 27 | PLAY_ONCE_HOLD, 28 | PLAY_ONCE_STOP, 29 | LOOP; 30 | 31 | @HideFromJS 32 | public ObjectAnimation.PlayType getPlayType() { 33 | return switch (this) { 34 | case PLAY_ONCE_HOLD -> ObjectAnimation.PlayType.PLAY_ONCE_HOLD; 35 | case PLAY_ONCE_STOP -> ObjectAnimation.PlayType.PLAY_ONCE_STOP; 36 | case LOOP -> ObjectAnimation.PlayType.LOOP; 37 | }; 38 | } 39 | } 40 | 41 | @OnlyIn(Dist.CLIENT) 42 | public static class SoundPlayManager extends com.tacz.guns.client.sound.SoundPlayManager { 43 | } 44 | 45 | @OnlyIn(Dist.CLIENT) 46 | public static void openRefitScreen() { 47 | if (!InputExtraCheck.isInGame()) return; 48 | var player = Minecraft.getInstance().player; 49 | if (player == null || player.isSpectator()) return; 50 | if (mainHandHoldGun(player)) { 51 | Minecraft.getInstance().setScreen(Minecraft.getInstance().screen == null ? new GunRefitScreen() : null); 52 | } 53 | } 54 | 55 | @OnlyIn(Dist.CLIENT) 56 | @HideFromJS 57 | public static Optional getClientGun(LocalPlayer player) { 58 | if (player == null || player.isSpectator()) return Optional.empty(); 59 | var mainHandItem = player.getMainHandItem(); 60 | if (mainHandItem.getItem() instanceof IGun iGun) { 61 | var gunId = iGun.getGunId(mainHandItem); 62 | return getClientGun(gunId); 63 | } 64 | return Optional.empty(); 65 | } 66 | 67 | @OnlyIn(Dist.CLIENT) 68 | @HideFromJS 69 | public static Optional getClientGun(ResourceLocation gunId) { 70 | var gunIndex = TimelessAPI.getClientGunIndex(gunId).orElse(null); 71 | if (gunIndex instanceof IClientGun) return Optional.of((IClientGun) gunIndex); 72 | return Optional.empty(); 73 | } 74 | 75 | @OnlyIn(Dist.CLIENT) 76 | public static GunDisplayInstance getGunDisplay() { 77 | var player = Minecraft.getInstance().player; 78 | if (player == null || player.isSpectator()) return null; 79 | return TimelessAPI.getGunDisplay(player.getMainHandItem()).orElse(null); 80 | } 81 | 82 | public static boolean mainHandHoldGun(LivingEntity livingEntity) { 83 | return livingEntity.getMainHandItem().getItem() instanceof IGun; 84 | } 85 | 86 | public static CommonGunIndex getGunIndex(ResourceLocation gunId) { 87 | return TimelessAPI.getCommonGunIndex(gunId).orElse(null); 88 | } 89 | 90 | public static CommonAmmoIndex getAmmoIndex(ResourceLocation ammoId) { 91 | return TimelessAPI.getCommonAmmoIndex(ammoId).orElse(null); 92 | } 93 | 94 | public static CommonAttachmentIndex getAttachmentIndex(ResourceLocation attachmentId) { 95 | return TimelessAPI.getCommonAttachmentIndex(attachmentId).orElse(null); 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # 4 | # Copyright © 2015-2021 the original authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | # 21 | # Gradle start up script for POSIX generated by Gradle. 22 | # 23 | # Important for running: 24 | # 25 | # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is 26 | # noncompliant, but you have some other compliant shell such as ksh or 27 | # bash, then to run this script, type that shell name before the whole 28 | # command line, like: 29 | # 30 | # ksh Gradle 31 | # 32 | # Busybox and similar reduced shells will NOT work, because this script 33 | # requires all of these POSIX shell features: 34 | # * functions; 35 | # * expansions «$var», «${var}», «${var:-default}», «${var+SET}», 36 | # «${var#prefix}», «${var%suffix}», and «$( cmd )»; 37 | # * compound commands having a testable exit status, especially «case»; 38 | # * various built-in commands including «command», «set», and «ulimit». 39 | # 40 | # Important for patching: 41 | # 42 | # (2) This script targets any POSIX shell, so it avoids extensions provided 43 | # by Bash, Ksh, etc; in particular arrays are avoided. 44 | # 45 | # The "traditional" practice of packing multiple parameters into a 46 | # space-separated string is a well documented source of bugs and security 47 | # problems, so this is (mostly) avoided, by progressively accumulating 48 | # options in "$@", and eventually passing that to Java. 49 | # 50 | # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, 51 | # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; 52 | # see the in-line comments for details. 53 | # 54 | # There are tweaks for specific operating systems such as AIX, CygWin, 55 | # Darwin, MinGW, and NonStop. 56 | # 57 | # (3) This script is generated from the Groovy template 58 | # https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt 59 | # within the Gradle project. 60 | # 61 | # You can find Gradle at https://github.com/gradle/gradle/. 62 | # 63 | ############################################################################## 64 | 65 | # Attempt to set APP_HOME 66 | 67 | # Resolve links: $0 may be a link 68 | app_path=$0 69 | 70 | # Need this for daisy-chained symlinks. 71 | while 72 | APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path 73 | [ -h "$app_path" ] 74 | do 75 | ls=$( ls -ld "$app_path" ) 76 | link=${ls#*' -> '} 77 | case $link in #( 78 | /*) app_path=$link ;; #( 79 | *) app_path=$APP_HOME$link ;; 80 | esac 81 | done 82 | 83 | # This is normally unused 84 | # shellcheck disable=SC2034 85 | APP_BASE_NAME=${0##*/} 86 | # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) 87 | APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit 88 | 89 | # Use the maximum available, or set MAX_FD != -1 to use that value. 90 | MAX_FD=maximum 91 | 92 | warn () { 93 | echo "$*" 94 | } >&2 95 | 96 | die () { 97 | echo 98 | echo "$*" 99 | echo 100 | exit 1 101 | } >&2 102 | 103 | # OS specific support (must be 'true' or 'false'). 104 | cygwin=false 105 | msys=false 106 | darwin=false 107 | nonstop=false 108 | case "$( uname )" in #( 109 | CYGWIN* ) cygwin=true ;; #( 110 | Darwin* ) darwin=true ;; #( 111 | MSYS* | MINGW* ) msys=true ;; #( 112 | NONSTOP* ) nonstop=true ;; 113 | esac 114 | 115 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 116 | 117 | 118 | # Determine the Java command to use to start the JVM. 119 | if [ -n "$JAVA_HOME" ] ; then 120 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 121 | # IBM's JDK on AIX uses strange locations for the executables 122 | JAVACMD=$JAVA_HOME/jre/sh/java 123 | else 124 | JAVACMD=$JAVA_HOME/bin/java 125 | fi 126 | if [ ! -x "$JAVACMD" ] ; then 127 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 128 | 129 | Please set the JAVA_HOME variable in your environment to match the 130 | location of your Java installation." 131 | fi 132 | else 133 | JAVACMD=java 134 | if ! command -v java >/dev/null 2>&1 135 | then 136 | die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 137 | 138 | Please set the JAVA_HOME variable in your environment to match the 139 | location of your Java installation." 140 | fi 141 | fi 142 | 143 | # Increase the maximum file descriptors if we can. 144 | if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then 145 | case $MAX_FD in #( 146 | max*) 147 | # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. 148 | # shellcheck disable=SC2039,SC3045 149 | MAX_FD=$( ulimit -H -n ) || 150 | warn "Could not query maximum file descriptor limit" 151 | esac 152 | case $MAX_FD in #( 153 | '' | soft) :;; #( 154 | *) 155 | # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. 156 | # shellcheck disable=SC2039,SC3045 157 | ulimit -n "$MAX_FD" || 158 | warn "Could not set maximum file descriptor limit to $MAX_FD" 159 | esac 160 | fi 161 | 162 | # Collect all arguments for the java command, stacking in reverse order: 163 | # * args from the command line 164 | # * the main class name 165 | # * -classpath 166 | # * -D...appname settings 167 | # * --module-path (only if needed) 168 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. 169 | 170 | # For Cygwin or MSYS, switch paths to Windows format before running java 171 | if "$cygwin" || "$msys" ; then 172 | APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) 173 | CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) 174 | 175 | JAVACMD=$( cygpath --unix "$JAVACMD" ) 176 | 177 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 178 | for arg do 179 | if 180 | case $arg in #( 181 | -*) false ;; # don't mess with options #( 182 | /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath 183 | [ -e "$t" ] ;; #( 184 | *) false ;; 185 | esac 186 | then 187 | arg=$( cygpath --path --ignore --mixed "$arg" ) 188 | fi 189 | # Roll the args list around exactly as many times as the number of 190 | # args, so each arg winds up back in the position where it started, but 191 | # possibly modified. 192 | # 193 | # NB: a `for` loop captures its iteration list before it begins, so 194 | # changing the positional parameters here affects neither the number of 195 | # iterations, nor the values presented in `arg`. 196 | shift # remove old arg 197 | set -- "$@" "$arg" # push replacement arg 198 | done 199 | fi 200 | 201 | 202 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 203 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 204 | 205 | # Collect all arguments for the java command: 206 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, 207 | # and any embedded shellness will be escaped. 208 | # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be 209 | # treated as '${Hostname}' itself on the command line. 210 | 211 | set -- \ 212 | "-Dorg.gradle.appname=$APP_BASE_NAME" \ 213 | -classpath "$CLASSPATH" \ 214 | org.gradle.wrapper.GradleWrapperMain \ 215 | "$@" 216 | 217 | # Stop when "xargs" is not available. 218 | if ! command -v xargs >/dev/null 2>&1 219 | then 220 | die "xargs is not available" 221 | fi 222 | 223 | # Use "xargs" to parse quoted args. 224 | # 225 | # With -n1 it outputs one arg per line, with the quotes and backslashes removed. 226 | # 227 | # In Bash we could simply go: 228 | # 229 | # readarray ARGS < <( xargs -n1 <<<"$var" ) && 230 | # set -- "${ARGS[@]}" "$@" 231 | # 232 | # but POSIX shell has neither arrays nor command substitution, so instead we 233 | # post-process each arg (as a line of input to sed) to backslash-escape any 234 | # character that might be a shell metacharacter, then use eval to reverse 235 | # that process (while maintaining the separation between arguments), and wrap 236 | # the whole thing up as a single "set" statement. 237 | # 238 | # This will of course break if any of these variables contains a newline or 239 | # an unmatched quote. 240 | # 241 | 242 | eval "set -- $( 243 | printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | 244 | xargs -n1 | 245 | sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | 246 | tr '\n' ' ' 247 | )" '"$@"' 248 | 249 | exec "$JAVACMD" "$@" 250 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2024 Gizmo 2 | 3 | This program is free software: you can redistribute it and/or modify 4 | it under the terms of the GNU General Public License as published by 5 | the Free Software Foundation, either version 3 of the License, or 6 | (at your option) any later version. 7 | 8 | This program is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU General Public License for more details. 12 | 13 | You should have received a copy of the GNU General Public License 14 | along with this program. If not, see 15 | 16 | 17 | 18 | GNU GENERAL PUBLIC LICENSE 19 | Version 3, 29 June 2007 20 | 21 | Copyright (C) 2007 Free Software Foundation, Inc. 22 | Everyone is permitted to copy and distribute verbatim copies 23 | of this license document, but changing it is not allowed. 24 | 25 | Preamble 26 | 27 | The GNU General Public License is a free, copyleft license for 28 | software and other kinds of works. 29 | 30 | The licenses for most software and other practical works are designed 31 | to take away your freedom to share and change the works. By contrast, 32 | the GNU General Public License is intended to guarantee your freedom to 33 | share and change all versions of a program--to make sure it remains free 34 | software for all its users. We, the Free Software Foundation, use the 35 | GNU General Public License for most of our software; it applies also to 36 | any other work released this way by its authors. You can apply it to 37 | your programs, too. 38 | 39 | When we speak of free software, we are referring to freedom, not 40 | price. Our General Public Licenses are designed to make sure that you 41 | have the freedom to distribute copies of free software (and charge for 42 | them if you wish), that you receive source code or can get it if you 43 | want it, that you can change the software or use pieces of it in new 44 | free programs, and that you know you can do these things. 45 | 46 | To protect your rights, we need to prevent others from denying you 47 | these rights or asking you to surrender the rights. Therefore, you have 48 | certain responsibilities if you distribute copies of the software, or if 49 | you modify it: responsibilities to respect the freedom of others. 50 | 51 | For example, if you distribute copies of such a program, whether 52 | gratis or for a fee, you must pass on to the recipients the same 53 | freedoms that you received. You must make sure that they, too, receive 54 | or can get the source code. And you must show them these terms so they 55 | know their rights. 56 | 57 | Developers that use the GNU GPL protect your rights with two steps: 58 | (1) assert copyright on the software, and (2) offer you this License 59 | giving you legal permission to copy, distribute and/or modify it. 60 | 61 | For the developers' and authors' protection, the GPL clearly explains 62 | that there is no warranty for this free software. For both users' and 63 | authors' sake, the GPL requires that modified versions be marked as 64 | changed, so that their problems will not be attributed erroneously to 65 | authors of previous versions. 66 | 67 | Some devices are designed to deny users access to install or run 68 | modified versions of the software inside them, although the manufacturer 69 | can do so. This is fundamentally incompatible with the aim of 70 | protecting users' freedom to change the software. The systematic 71 | pattern of such abuse occurs in the area of products for individuals to 72 | use, which is precisely where it is most unacceptable. Therefore, we 73 | have designed this version of the GPL to prohibit the practice for those 74 | products. If such problems arise substantially in other domains, we 75 | stand ready to extend this provision to those domains in future versions 76 | of the GPL, as needed to protect the freedom of users. 77 | 78 | Finally, every program is threatened constantly by software patents. 79 | States should not allow patents to restrict development and use of 80 | software on general-purpose computers, but in those that do, we wish to 81 | avoid the special danger that patents applied to a free program could 82 | make it effectively proprietary. To prevent this, the GPL assures that 83 | patents cannot be used to render the program non-free. 84 | 85 | The precise terms and conditions for copying, distribution and 86 | modification follow. 87 | 88 | TERMS AND CONDITIONS 89 | 90 | 0. Definitions. 91 | 92 | "This License" refers to version 3 of the GNU General Public License. 93 | 94 | "Copyright" also means copyright-like laws that apply to other kinds of 95 | works, such as semiconductor masks. 96 | 97 | "The Program" refers to any copyrightable work licensed under this 98 | License. Each licensee is addressed as "you". "Licensees" and 99 | "recipients" may be individuals or organizations. 100 | 101 | To "modify" a work means to copy from or adapt all or part of the work 102 | in a fashion requiring copyright permission, other than the making of an 103 | exact copy. The resulting work is called a "modified version" of the 104 | earlier work or a work "based on" the earlier work. 105 | 106 | A "covered work" means either the unmodified Program or a work based 107 | on the Program. 108 | 109 | To "propagate" a work means to do anything with it that, without 110 | permission, would make you directly or secondarily liable for 111 | infringement under applicable copyright law, except executing it on a 112 | computer or modifying a private copy. Propagation includes copying, 113 | distribution (with or without modification), making available to the 114 | public, and in some countries other activities as well. 115 | 116 | To "convey" a work means any kind of propagation that enables other 117 | parties to make or receive copies. Mere interaction with a user through 118 | a computer network, with no transfer of a copy, is not conveying. 119 | 120 | An interactive user interface displays "Appropriate Legal Notices" 121 | to the extent that it includes a convenient and prominently visible 122 | feature that (1) displays an appropriate copyright notice, and (2) 123 | tells the user that there is no warranty for the work (except to the 124 | extent that warranties are provided), that licensees may convey the 125 | work under this License, and how to view a copy of this License. If 126 | the interface presents a list of user commands or options, such as a 127 | menu, a prominent item in the list meets this criterion. 128 | 129 | 1. Source Code. 130 | 131 | The "source code" for a work means the preferred form of the work 132 | for making modifications to it. "Object code" means any non-source 133 | form of a work. 134 | 135 | A "Standard Interface" means an interface that either is an official 136 | standard defined by a recognized standards body, or, in the case of 137 | interfaces specified for a particular programming language, one that 138 | is widely used among developers working in that language. 139 | 140 | The "System Libraries" of an executable work include anything, other 141 | than the work as a whole, that (a) is included in the normal form of 142 | packaging a Major Component, but which is not part of that Major 143 | Component, and (b) serves only to enable use of the work with that 144 | Major Component, or to implement a Standard Interface for which an 145 | implementation is available to the public in source code form. A 146 | "Major Component", in this context, means a major essential component 147 | (kernel, window system, and so on) of the specific operating system 148 | (if any) on which the executable work runs, or a compiler used to 149 | produce the work, or an object code interpreter used to run it. 150 | 151 | The "Corresponding Source" for a work in object code form means all 152 | the source code needed to generate, install, and (for an executable 153 | work) run the object code and to modify the work, including scripts to 154 | control those activities. However, it does not include the work's 155 | System Libraries, or general-purpose tools or generally available free 156 | programs which are used unmodified in performing those activities but 157 | which are not part of the work. For example, Corresponding Source 158 | includes interface definition files associated with source files for 159 | the work, and the source code for shared libraries and dynamically 160 | linked subprograms that the work is specifically designed to require, 161 | such as by intimate data communication or control flow between those 162 | subprograms and other parts of the work. 163 | 164 | The Corresponding Source need not include anything that users 165 | can regenerate automatically from other parts of the Corresponding 166 | Source. 167 | 168 | The Corresponding Source for a work in source code form is that 169 | same work. 170 | 171 | 2. Basic Permissions. 172 | 173 | All rights granted under this License are granted for the term of 174 | copyright on the Program, and are irrevocable provided the stated 175 | conditions are met. This License explicitly affirms your unlimited 176 | permission to run the unmodified Program. The output from running a 177 | covered work is covered by this License only if the output, given its 178 | content, constitutes a covered work. This License acknowledges your 179 | rights of fair use or other equivalent, as provided by copyright law. 180 | 181 | You may make, run and propagate covered works that you do not 182 | convey, without conditions so long as your license otherwise remains 183 | in force. You may convey covered works to others for the sole purpose 184 | of having them make modifications exclusively for you, or provide you 185 | with facilities for running those works, provided that you comply with 186 | the terms of this License in conveying all material for which you do 187 | not control copyright. Those thus making or running the covered works 188 | for you must do so exclusively on your behalf, under your direction 189 | and control, on terms that prohibit them from making any copies of 190 | your copyrighted material outside their relationship with you. 191 | 192 | Conveying under any other circumstances is permitted solely under 193 | the conditions stated below. Sublicensing is not allowed; section 10 194 | makes it unnecessary. 195 | 196 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 197 | 198 | No covered work shall be deemed part of an effective technological 199 | measure under any applicable law fulfilling obligations under article 200 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 201 | similar laws prohibiting or restricting circumvention of such 202 | measures. 203 | 204 | When you convey a covered work, you waive any legal power to forbid 205 | circumvention of technological measures to the extent such circumvention 206 | is effected by exercising rights under this License with respect to 207 | the covered work, and you disclaim any intention to limit operation or 208 | modification of the work as a means of enforcing, against the work's 209 | users, your or third parties' legal rights to forbid circumvention of 210 | technological measures. 211 | 212 | 4. Conveying Verbatim Copies. 213 | 214 | You may convey verbatim copies of the Program's source code as you 215 | receive it, in any medium, provided that you conspicuously and 216 | appropriately publish on each copy an appropriate copyright notice; 217 | keep intact all notices stating that this License and any 218 | non-permissive terms added in accord with section 7 apply to the code; 219 | keep intact all notices of the absence of any warranty; and give all 220 | recipients a copy of this License along with the Program. 221 | 222 | You may charge any price or no price for each copy that you convey, 223 | and you may offer support or warranty protection for a fee. 224 | 225 | 5. Conveying Modified Source Versions. 226 | 227 | You may convey a work based on the Program, or the modifications to 228 | produce it from the Program, in the form of source code under the 229 | terms of section 4, provided that you also meet all of these conditions: 230 | 231 | a) The work must carry prominent notices stating that you modified 232 | it, and giving a relevant date. 233 | 234 | b) The work must carry prominent notices stating that it is 235 | released under this License and any conditions added under section 236 | 7. This requirement modifies the requirement in section 4 to 237 | "keep intact all notices". 238 | 239 | c) You must license the entire work, as a whole, under this 240 | License to anyone who comes into possession of a copy. This 241 | License will therefore apply, along with any applicable section 7 242 | additional terms, to the whole of the work, and all its parts, 243 | regardless of how they are packaged. This License gives no 244 | permission to license the work in any other way, but it does not 245 | invalidate such permission if you have separately received it. 246 | 247 | d) If the work has interactive user interfaces, each must display 248 | Appropriate Legal Notices; however, if the Program has interactive 249 | interfaces that do not display Appropriate Legal Notices, your 250 | work need not make them do so. 251 | 252 | A compilation of a covered work with other separate and independent 253 | works, which are not by their nature extensions of the covered work, 254 | and which are not combined with it such as to form a larger program, 255 | in or on a volume of a storage or distribution medium, is called an 256 | "aggregate" if the compilation and its resulting copyright are not 257 | used to limit the access or legal rights of the compilation's users 258 | beyond what the individual works permit. Inclusion of a covered work 259 | in an aggregate does not cause this License to apply to the other 260 | parts of the aggregate. 261 | 262 | 6. Conveying Non-Source Forms. 263 | 264 | You may convey a covered work in object code form under the terms 265 | of sections 4 and 5, provided that you also convey the 266 | machine-readable Corresponding Source under the terms of this License, 267 | in one of these ways: 268 | 269 | a) Convey the object code in, or embodied in, a physical product 270 | (including a physical distribution medium), accompanied by the 271 | Corresponding Source fixed on a durable physical medium 272 | customarily used for software interchange. 273 | 274 | b) Convey the object code in, or embodied in, a physical product 275 | (including a physical distribution medium), accompanied by a 276 | written offer, valid for at least three years and valid for as 277 | long as you offer spare parts or customer support for that product 278 | model, to give anyone who possesses the object code either (1) a 279 | copy of the Corresponding Source for all the software in the 280 | product that is covered by this License, on a durable physical 281 | medium customarily used for software interchange, for a price no 282 | more than your reasonable cost of physically performing this 283 | conveying of source, or (2) access to copy the 284 | Corresponding Source from a network server at no charge. 285 | 286 | c) Convey individual copies of the object code with a copy of the 287 | written offer to provide the Corresponding Source. This 288 | alternative is allowed only occasionally and noncommercially, and 289 | only if you received the object code with such an offer, in accord 290 | with subsection 6b. 291 | 292 | d) Convey the object code by offering access from a designated 293 | place (gratis or for a charge), and offer equivalent access to the 294 | Corresponding Source in the same way through the same place at no 295 | further charge. You need not require recipients to copy the 296 | Corresponding Source along with the object code. If the place to 297 | copy the object code is a network server, the Corresponding Source 298 | may be on a different server (operated by you or a third party) 299 | that supports equivalent copying facilities, provided you maintain 300 | clear directions next to the object code saying where to find the 301 | Corresponding Source. Regardless of what server hosts the 302 | Corresponding Source, you remain obligated to ensure that it is 303 | available for as long as needed to satisfy these requirements. 304 | 305 | e) Convey the object code using peer-to-peer transmission, provided 306 | you inform other peers where the object code and Corresponding 307 | Source of the work are being offered to the general public at no 308 | charge under subsection 6d. 309 | 310 | A separable portion of the object code, whose source code is excluded 311 | from the Corresponding Source as a System Library, need not be 312 | included in conveying the object code work. 313 | 314 | A "User Product" is either (1) a "consumer product", which means any 315 | tangible personal property which is normally used for personal, family, 316 | or household purposes, or (2) anything designed or sold for incorporation 317 | into a dwelling. In determining whether a product is a consumer product, 318 | doubtful cases shall be resolved in favor of coverage. For a particular 319 | product received by a particular user, "normally used" refers to a 320 | typical or common use of that class of product, regardless of the status 321 | of the particular user or of the way in which the particular user 322 | actually uses, or expects or is expected to use, the product. A product 323 | is a consumer product regardless of whether the product has substantial 324 | commercial, industrial or non-consumer uses, unless such uses represent 325 | the only significant mode of use of the product. 326 | 327 | "Installation Information" for a User Product means any methods, 328 | procedures, authorization keys, or other information required to install 329 | and execute modified versions of a covered work in that User Product from 330 | a modified version of its Corresponding Source. The information must 331 | suffice to ensure that the continued functioning of the modified object 332 | code is in no case prevented or interfered with solely because 333 | modification has been made. 334 | 335 | If you convey an object code work under this section in, or with, or 336 | specifically for use in, a User Product, and the conveying occurs as 337 | part of a transaction in which the right of possession and use of the 338 | User Product is transferred to the recipient in perpetuity or for a 339 | fixed term (regardless of how the transaction is characterized), the 340 | Corresponding Source conveyed under this section must be accompanied 341 | by the Installation Information. But this requirement does not apply 342 | if neither you nor any third party retains the ability to install 343 | modified object code on the User Product (for example, the work has 344 | been installed in ROM). 345 | 346 | The requirement to provide Installation Information does not include a 347 | requirement to continue to provide support service, warranty, or updates 348 | for a work that has been modified or installed by the recipient, or for 349 | the User Product in which it has been modified or installed. Access to a 350 | network may be denied when the modification itself materially and 351 | adversely affects the operation of the network or violates the rules and 352 | protocols for communication across the network. 353 | 354 | Corresponding Source conveyed, and Installation Information provided, 355 | in accord with this section must be in a format that is publicly 356 | documented (and with an implementation available to the public in 357 | source code form), and must require no special password or key for 358 | unpacking, reading or copying. 359 | 360 | 7. Additional Terms. 361 | 362 | "Additional permissions" are terms that supplement the terms of this 363 | License by making exceptions from one or more of its conditions. 364 | Additional permissions that are applicable to the entire Program shall 365 | be treated as though they were included in this License, to the extent 366 | that they are valid under applicable law. If additional permissions 367 | apply only to part of the Program, that part may be used separately 368 | under those permissions, but the entire Program remains governed by 369 | this License without regard to the additional permissions. 370 | 371 | When you convey a copy of a covered work, you may at your option 372 | remove any additional permissions from that copy, or from any part of 373 | it. (Additional permissions may be written to require their own 374 | removal in certain cases when you modify the work.) You may place 375 | additional permissions on material, added by you to a covered work, 376 | for which you have or can give appropriate copyright permission. 377 | 378 | Notwithstanding any other provision of this License, for material you 379 | add to a covered work, you may (if authorized by the copyright holders of 380 | that material) supplement the terms of this License with terms: 381 | 382 | a) Disclaiming warranty or limiting liability differently from the 383 | terms of sections 15 and 16 of this License; or 384 | 385 | b) Requiring preservation of specified reasonable legal notices or 386 | author attributions in that material or in the Appropriate Legal 387 | Notices displayed by works containing it; or 388 | 389 | c) Prohibiting misrepresentation of the origin of that material, or 390 | requiring that modified versions of such material be marked in 391 | reasonable ways as different from the original version; or 392 | 393 | d) Limiting the use for publicity purposes of names of licensors or 394 | authors of the material; or 395 | 396 | e) Declining to grant rights under trademark law for use of some 397 | trade names, trademarks, or service marks; or 398 | 399 | f) Requiring indemnification of licensors and authors of that 400 | material by anyone who conveys the material (or modified versions of 401 | it) with contractual assumptions of liability to the recipient, for 402 | any liability that these contractual assumptions directly impose on 403 | those licensors and authors. 404 | 405 | All other non-permissive additional terms are considered "further 406 | restrictions" within the meaning of section 10. If the Program as you 407 | received it, or any part of it, contains a notice stating that it is 408 | governed by this License along with a term that is a further 409 | restriction, you may remove that term. If a license document contains 410 | a further restriction but permits relicensing or conveying under this 411 | License, you may add to a covered work material governed by the terms 412 | of that license document, provided that the further restriction does 413 | not survive such relicensing or conveying. 414 | 415 | If you add terms to a covered work in accord with this section, you 416 | must place, in the relevant source files, a statement of the 417 | additional terms that apply to those files, or a notice indicating 418 | where to find the applicable terms. 419 | 420 | Additional terms, permissive or non-permissive, may be stated in the 421 | form of a separately written license, or stated as exceptions; 422 | the above requirements apply either way. 423 | 424 | 8. Termination. 425 | 426 | You may not propagate or modify a covered work except as expressly 427 | provided under this License. Any attempt otherwise to propagate or 428 | modify it is void, and will automatically terminate your rights under 429 | this License (including any patent licenses granted under the third 430 | paragraph of section 11). 431 | 432 | However, if you cease all violation of this License, then your 433 | license from a particular copyright holder is reinstated (a) 434 | provisionally, unless and until the copyright holder explicitly and 435 | finally terminates your license, and (b) permanently, if the copyright 436 | holder fails to notify you of the violation by some reasonable means 437 | prior to 60 days after the cessation. 438 | 439 | Moreover, your license from a particular copyright holder is 440 | reinstated permanently if the copyright holder notifies you of the 441 | violation by some reasonable means, this is the first time you have 442 | received notice of violation of this License (for any work) from that 443 | copyright holder, and you cure the violation prior to 30 days after 444 | your receipt of the notice. 445 | 446 | Termination of your rights under this section does not terminate the 447 | licenses of parties who have received copies or rights from you under 448 | this License. If your rights have been terminated and not permanently 449 | reinstated, you do not qualify to receive new licenses for the same 450 | material under section 10. 451 | 452 | 9. Acceptance Not Required for Having Copies. 453 | 454 | You are not required to accept this License in order to receive or 455 | run a copy of the Program. Ancillary propagation of a covered work 456 | occurring solely as a consequence of using peer-to-peer transmission 457 | to receive a copy likewise does not require acceptance. However, 458 | nothing other than this License grants you permission to propagate or 459 | modify any covered work. These actions infringe copyright if you do 460 | not accept this License. Therefore, by modifying or propagating a 461 | covered work, you indicate your acceptance of this License to do so. 462 | 463 | 10. Automatic Licensing of Downstream Recipients. 464 | 465 | Each time you convey a covered work, the recipient automatically 466 | receives a license from the original licensors, to run, modify and 467 | propagate that work, subject to this License. You are not responsible 468 | for enforcing compliance by third parties with this License. 469 | 470 | An "entity transaction" is a transaction transferring control of an 471 | organization, or substantially all assets of one, or subdividing an 472 | organization, or merging organizations. If propagation of a covered 473 | work results from an entity transaction, each party to that 474 | transaction who receives a copy of the work also receives whatever 475 | licenses to the work the party's predecessor in interest had or could 476 | give under the previous paragraph, plus a right to possession of the 477 | Corresponding Source of the work from the predecessor in interest, if 478 | the predecessor has it or can get it with reasonable efforts. 479 | 480 | You may not impose any further restrictions on the exercise of the 481 | rights granted or affirmed under this License. For example, you may 482 | not impose a license fee, royalty, or other charge for exercise of 483 | rights granted under this License, and you may not initiate litigation 484 | (including a cross-claim or counterclaim in a lawsuit) alleging that 485 | any patent claim is infringed by making, using, selling, offering for 486 | sale, or importing the Program or any portion of it. 487 | 488 | 11. Patents. 489 | 490 | A "contributor" is a copyright holder who authorizes use under this 491 | License of the Program or a work on which the Program is based. The 492 | work thus licensed is called the contributor's "contributor version". 493 | 494 | A contributor's "essential patent claims" are all patent claims 495 | owned or controlled by the contributor, whether already acquired or 496 | hereafter acquired, that would be infringed by some manner, permitted 497 | by this License, of making, using, or selling its contributor version, 498 | but do not include claims that would be infringed only as a 499 | consequence of further modification of the contributor version. For 500 | purposes of this definition, "control" includes the right to grant 501 | patent sublicenses in a manner consistent with the requirements of 502 | this License. 503 | 504 | Each contributor grants you a non-exclusive, worldwide, royalty-free 505 | patent license under the contributor's essential patent claims, to 506 | make, use, sell, offer for sale, import and otherwise run, modify and 507 | propagate the contents of its contributor version. 508 | 509 | In the following three paragraphs, a "patent license" is any express 510 | agreement or commitment, however denominated, not to enforce a patent 511 | (such as an express permission to practice a patent or covenant not to 512 | sue for patent infringement). To "grant" such a patent license to a 513 | party means to make such an agreement or commitment not to enforce a 514 | patent against the party. 515 | 516 | If you convey a covered work, knowingly relying on a patent license, 517 | and the Corresponding Source of the work is not available for anyone 518 | to copy, free of charge and under the terms of this License, through a 519 | publicly available network server or other readily accessible means, 520 | then you must either (1) cause the Corresponding Source to be so 521 | available, or (2) arrange to deprive yourself of the benefit of the 522 | patent license for this particular work, or (3) arrange, in a manner 523 | consistent with the requirements of this License, to extend the patent 524 | license to downstream recipients. "Knowingly relying" means you have 525 | actual knowledge that, but for the patent license, your conveying the 526 | covered work in a country, or your recipient's use of the covered work 527 | in a country, would infringe one or more identifiable patents in that 528 | country that you have reason to believe are valid. 529 | 530 | If, pursuant to or in connection with a single transaction or 531 | arrangement, you convey, or propagate by procuring conveyance of, a 532 | covered work, and grant a patent license to some of the parties 533 | receiving the covered work authorizing them to use, propagate, modify 534 | or convey a specific copy of the covered work, then the patent license 535 | you grant is automatically extended to all recipients of the covered 536 | work and works based on it. 537 | 538 | A patent license is "discriminatory" if it does not include within 539 | the scope of its coverage, prohibits the exercise of, or is 540 | conditioned on the non-exercise of one or more of the rights that are 541 | specifically granted under this License. You may not convey a covered 542 | work if you are a party to an arrangement with a third party that is 543 | in the business of distributing software, under which you make payment 544 | to the third party based on the extent of your activity of conveying 545 | the work, and under which the third party grants, to any of the 546 | parties who would receive the covered work from you, a discriminatory 547 | patent license (a) in connection with copies of the covered work 548 | conveyed by you (or copies made from those copies), or (b) primarily 549 | for and in connection with specific products or compilations that 550 | contain the covered work, unless you entered into that arrangement, 551 | or that patent license was granted, prior to 28 March 2007. 552 | 553 | Nothing in this License shall be construed as excluding or limiting 554 | any implied license or other defenses to infringement that may 555 | otherwise be available to you under applicable patent law. 556 | 557 | 12. No Surrender of Others' Freedom. 558 | 559 | If conditions are imposed on you (whether by court order, agreement or 560 | otherwise) that contradict the conditions of this License, they do not 561 | excuse you from the conditions of this License. If you cannot convey a 562 | covered work so as to satisfy simultaneously your obligations under this 563 | License and any other pertinent obligations, then as a consequence you may 564 | not convey it at all. For example, if you agree to terms that obligate you 565 | to collect a royalty for further conveying from those to whom you convey 566 | the Program, the only way you could satisfy both those terms and this 567 | License would be to refrain entirely from conveying the Program. 568 | 569 | 13. Use with the GNU Affero General Public License. 570 | 571 | Notwithstanding any other provision of this License, you have 572 | permission to link or combine any covered work with a work licensed 573 | under version 3 of the GNU Affero General Public License into a single 574 | combined work, and to convey the resulting work. The terms of this 575 | License will continue to apply to the part which is the covered work, 576 | but the special requirements of the GNU Affero General Public License, 577 | section 13, concerning interaction through a network will apply to the 578 | combination as such. 579 | 580 | 14. Revised Versions of this License. 581 | 582 | The Free Software Foundation may publish revised and/or new versions of 583 | the GNU General Public License from time to time. Such new versions will 584 | be similar in spirit to the present version, but may differ in detail to 585 | address new problems or concerns. 586 | 587 | Each version is given a distinguishing version number. If the 588 | Program specifies that a certain numbered version of the GNU General 589 | Public License "or any later version" applies to it, you have the 590 | option of following the terms and conditions either of that numbered 591 | version or of any later version published by the Free Software 592 | Foundation. If the Program does not specify a version number of the 593 | GNU General Public License, you may choose any version ever published 594 | by the Free Software Foundation. 595 | 596 | If the Program specifies that a proxy can decide which future 597 | versions of the GNU General Public License can be used, that proxy's 598 | public statement of acceptance of a version permanently authorizes you 599 | to choose that version for the Program. 600 | 601 | Later license versions may give you additional or different 602 | permissions. However, no additional obligations are imposed on any 603 | author or copyright holder as a result of your choosing to follow a 604 | later version. 605 | 606 | 15. Disclaimer of Warranty. 607 | 608 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 609 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 610 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 611 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 612 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 613 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 614 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 615 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 616 | 617 | 16. Limitation of Liability. 618 | 619 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 620 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 621 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 622 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 623 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 624 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 625 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 626 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 627 | SUCH DAMAGES. 628 | 629 | 17. Interpretation of Sections 15 and 16. 630 | 631 | If the disclaimer of warranty and limitation of liability provided 632 | above cannot be given local legal effect according to their terms, 633 | reviewing courts shall apply local law that most closely approximates 634 | an absolute waiver of all civil liability in connection with the 635 | Program, unless a warranty or assumption of liability accompanies a 636 | copy of the Program in return for a fee. 637 | 638 | END OF TERMS AND CONDITIONS 639 | 640 | How to Apply These Terms to Your New Programs 641 | 642 | If you develop a new program, and you want it to be of the greatest 643 | possible use to the public, the best way to achieve this is to make it 644 | free software which everyone can redistribute and change under these terms. 645 | 646 | To do so, attach the following notices to the program. It is safest 647 | to attach them to the start of each source file to most effectively 648 | state the exclusion of warranty; and each file should have at least 649 | the "copyright" line and a pointer to where the full notice is found. 650 | 651 | {one line to give the program's name and a brief idea of what it does.} 652 | Copyright (C) {year} {name of author} 653 | 654 | This program is free software: you can redistribute it and/or modify 655 | it under the terms of the GNU General Public License as published by 656 | the Free Software Foundation, either version 3 of the License, or 657 | (at your option) any later version. 658 | 659 | This program is distributed in the hope that it will be useful, 660 | but WITHOUT ANY WARRANTY; without even the implied warranty of 661 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 662 | GNU General Public License for more details. 663 | 664 | You should have received a copy of the GNU General Public License 665 | along with this program. If not, see . 666 | 667 | Also add information on how to contact you by electronic and paper mail. 668 | 669 | If the program does terminal interaction, make it output a short 670 | notice like this when it starts in an interactive mode: 671 | 672 | {project} Copyright (C) {year} {fullname} 673 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 674 | This is free software, and you are welcome to redistribute it 675 | under certain conditions; type `show c' for details. 676 | 677 | The hypothetical commands `show w' and `show c' should show the appropriate 678 | parts of the General Public License. Of course, your program's commands 679 | might be different; for a GUI interface, you would use an "about box". 680 | 681 | You should also get your employer (if you work as a programmer) or school, 682 | if any, to sign a "copyright disclaimer" for the program, if necessary. 683 | For more information on this, and how to apply and follow the GNU GPL, see 684 | . 685 | 686 | The GNU General Public License does not permit incorporating your program 687 | into proprietary programs. If your program is a subroutine library, you 688 | may consider it more useful to permit linking proprietary applications with 689 | the library. If this is what you want to do, use the GNU Lesser General 690 | Public License instead of this License. But first, please read 691 | . 692 | 693 | --------------------------------------------------------------------------------