Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Staff Mod 0.15.0 #38

Merged
merged 128 commits into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
128 commits
Select commit Hold shift + click to select a range
7db936d
Check for staffs tag instead of staff item, when inserting or removin…
opekope2 Apr 29, 2024
72b63b3
Reference StaffMod object directly when adding staff item to creative…
opekope2 Apr 30, 2024
9d5c0d4
Query staffs tag instead of staff item in the remaining places
opekope2 Apr 30, 2024
fcd3b92
Register staff item model suppliers in a separate method
opekope2 May 7, 2024
a5fd1b0
Remove IStaffMod.isPhysicalClient
opekope2 May 7, 2024
5641627
Rename VectorUtil to MathUtil
opekope2 May 9, 2024
59f5f10
Add missing @Environment(CLIENT)
opekope2 May 9, 2024
91db992
Add model predicates for new staff renderer
opekope2 May 10, 2024
75e7307
Add a MatrixStack utility function
opekope2 May 10, 2024
e592fbb
Add new staff rendering API
opekope2 May 11, 2024
dace007
Add a staff item renderer for a constant block state
opekope2 May 11, 2024
93e3b2f
Migrate supported vanilla items to the new renderer
opekope2 May 11, 2024
c5c86cb
Remove old model-based renderer
opekope2 May 11, 2024
7e512c4
Remove redundant model utilities
opekope2 May 11, 2024
d184cd4
Remove redundant RenderPlatform
opekope2 May 11, 2024
30a9ec0
Prefix IImpactTnt methods with staffMod$
opekope2 May 12, 2024
f488fbd
Add option to add temporary data to active item
opekope2 May 12, 2024
79fed60
Fix furnace staff rendering & packet spam
opekope2 May 12, 2024
5ec3e48
Fix jittery staff movement in 3rd person while holding RMB
opekope2 May 13, 2024
02c1118
Make StaffRenderer singleton as per Neo/Forge docs
opekope2 May 13, 2024
327edba
Move StaffModPlatform one package up
opekope2 May 14, 2024
fc4c0e6
Make item position in staff customizable
opekope2 May 15, 2024
a9b39b6
Add new staff items, models and textures
opekope2 May 16, 2024
4232acd
Update add/remove staff item translation
opekope2 May 16, 2024
0c7bcbf
Update StaffItem KDoc
opekope2 May 16, 2024
f8cdb5e
Refactor StaffMod API
opekope2 May 17, 2024
e71102d
Add Neo/Forge Item classes to render non-functional staff items as st…
opekope2 May 17, 2024
6cdee00
Automatically register FabricStaffItem for custom rendering
opekope2 May 17, 2024
724cfd7
Fix faint royal staff not rendering on Neo/Forge
opekope2 May 17, 2024
89ebeaf
Add Staff Mod item group
opekope2 May 17, 2024
08d22b3
Add rarity to staff items
opekope2 May 18, 2024
c4c0eee
Add Crown of King Orange
opekope2 May 18, 2024
099b85f
Fix right click holding with staffs
opekope2 May 18, 2024
b857453
Show lightning rod inside staff when in inventory or item frame
opekope2 May 18, 2024
c4ede5f
Make bell bigger in the staff
opekope2 May 18, 2024
f00b5d4
Adjust wither skeleton skull rendering
opekope2 May 18, 2024
d5953b2
Make piglins admire Crown of King Orange
opekope2 May 18, 2024
dbd3d22
Use Neo/Forge API for shield disabling
opekope2 May 19, 2024
d1a67dc
Refactor StaffItemHandler.attackEntity
opekope2 May 19, 2024
5a376b0
Refactor StaffItemHandler.attackBlock
opekope2 May 19, 2024
d16815e
Remove mixins from NeoForge project
opekope2 May 19, 2024
3970c87
Remove mixins from Forge project
opekope2 May 19, 2024
0266deb
Refactor StaffItemHandler.attack
opekope2 May 19, 2024
30d35b2
Replace @Invokers with access wideners
opekope2 May 19, 2024
4198329
Extract modifyLootTables from subscribeToEvents
opekope2 May 19, 2024
4b083fa
Move attackBlock and clientAttack into Initializer.kt
opekope2 May 19, 2024
594913f
Eliminate dead code
opekope2 May 20, 2024
bc08ae0
Update suppressions
opekope2 May 20, 2024
edb815e
Move utilities to utilities package
opekope2 May 20, 2024
e04b748
Refactor StaffItemHandler
opekope2 May 20, 2024
534d81e
Mention NeoForge where forgotten
opekope2 May 20, 2024
eade1dd
Use MOD_ID instead of hard-coding
opekope2 May 20, 2024
c2d96ed
Add staff infusion smithing template
opekope2 May 20, 2024
5744c84
Update StaffMod docs
opekope2 May 20, 2024
362cc69
Use kotlin syntax instead of java functional interface in PacketRegis…
opekope2 May 21, 2024
ff588b5
Migrate key binding handling to Architectury API
opekope2 May 21, 2024
2845950
Migrate particle registration to Architectury API
opekope2 May 21, 2024
1489bfb
Add royal staff ingredient
opekope2 May 21, 2024
53dd4d2
Move staff silhouette to smithing_table folder
opekope2 May 21, 2024
7ae5721
Make items not dependent on update 1.21 data pack
opekope2 May 21, 2024
d2349a5
Move interaction handlers to InteractionHandler.kt
opekope2 May 21, 2024
30b8798
Register CLIENT_LEFT_CLICK_AIR on client side only
opekope2 May 21, 2024
c5714db
Update gradle
opekope2 May 21, 2024
6fef4d7
Bump version
opekope2 May 21, 2024
d4427d5
Temporarily remove Forge
opekope2 May 21, 2024
e8aadd8
Update deps to Minecraft 1.20.6
opekope2 May 21, 2024
f10be4d
Migrate NBT to data components
opekope2 May 21, 2024
e8f5969
Update attribute modifiers to 1.20.6
opekope2 May 21, 2024
58c5a36
Update networking to 1.20.6
opekope2 May 21, 2024
0d1ec46
Update loot table modifications to 1.20.6
opekope2 May 21, 2024
754ce31
Update particles to 1.20.6
opekope2 May 21, 2024
0f46ba1
Update most other things to 1.20.6
opekope2 May 21, 2024
b7e93b4
Update Fabric mod to 1.20.6
opekope2 May 21, 2024
1ecf06b
Update NeoForge mod to 1.20.6
opekope2 May 21, 2024
3b159be
Update StaffItem docs
opekope2 May 21, 2024
a86a1a9
Register particles in mods, because Architectury API refuses
opekope2 May 21, 2024
07be4ae
Add translation for avm_staff:staffs tag
opekope2 May 21, 2024
da5b382
Replace TntEntityMixin with new ImpactTntEntity class
opekope2 May 21, 2024
44ea2dc
Add staff infusion smithing template to vault loot
opekope2 May 22, 2024
2b20792
Add crafting and smithing recipes
opekope2 May 22, 2024
0ae386b
Add advancements for showing recipes
opekope2 May 23, 2024
f64f23b
Make impact TNT not explode when colliding with a spectator
opekope2 May 23, 2024
f3419d9
Add StaffHandler.canSwingHand API
opekope2 May 23, 2024
456b66c
Update StaffHandler attack and interact docs
opekope2 May 23, 2024
f96ca64
Fix typo and missing backticks in docs
opekope2 May 23, 2024
852f279
Merge Fallback and Empty staff handler to default
opekope2 May 23, 2024
c43588d
Organize access widener
opekope2 May 23, 2024
7bd16e6
Make Staff Mod loot tables data-driven
opekope2 May 23, 2024
04083c7
Remove unnecessary .0 from float constants
opekope2 May 23, 2024
f5aff12
Rework anvil staff mechanics
opekope2 May 24, 2024
3de5782
Make wool staff not able to place wool inside entity hitboxes
opekope2 May 26, 2024
ca87608
Swap Blocks and Items wildcard import in VanillaStaffHandlers.kt
opekope2 May 26, 2024
8107634
Make anvil staff not able to break blocks
opekope2 May 26, 2024
cbcbae8
fixup! Rework anvil staff mechanics
opekope2 May 26, 2024
14a9451
Remove attackBlock Fabric parity because of its side effects
opekope2 May 26, 2024
e06e25f
Extend reach of staff by 1 block
opekope2 May 26, 2024
b4a4855
Move itemStackInStaff setter to mutableItemStackInStaff
opekope2 May 30, 2024
9feb9dc
Split MathUtil to VectorUtil and MatrixUtil
opekope2 May 30, 2024
06a76c1
Remove unused DfuUtil
opekope2 May 30, 2024
911848e
Change staff item component handling
opekope2 May 30, 2024
fe437e8
Balance some items
opekope2 Jun 4, 2024
8e1b6af
Add avm_staff:staff_renderer_override component
opekope2 Jun 6, 2024
1bdcdc7
Fix player attack cooldown not resetting after modifying a staff
opekope2 Jun 7, 2024
3a9232f
Fix sounds not playing on NeoForge in certain situations
opekope2 Jun 7, 2024
e164f81
Tweak bone block handler
opekope2 Jun 7, 2024
74dac33
Adjust wither skeleton skull handler
opekope2 Jun 7, 2024
b110c9b
Remove line break
opekope2 Jun 7, 2024
655acea
Rename AddItemToStaffC2SPacket to InsertItemIntoStaffC2SPacket
opekope2 Jun 7, 2024
6eb6506
Add AccessTransformer to NeoForge JAR
opekope2 Jun 8, 2024
1e0085e
Add ItemStaff in TagKey operator
opekope2 Jun 8, 2024
e2f0c51
Call StaffHandler.onStoppedUsing when item dropped or user dies
opekope2 Jun 8, 2024
f21352e
Fix furnace staff not turning on for other players
opekope2 Jun 8, 2024
87b6e36
Prevent item insertion and removal from staffs on cooldown
opekope2 Jun 9, 2024
72b8673
Replace temporary item textures with final ones
opekope2 Jun 9, 2024
068eaa7
Add credits to mod meta
opekope2 Jun 9, 2024
ed9c9f1
Update mod name&description in mod meta
opekope2 Jun 9, 2024
459e0fb
Update README
opekope2 Jun 10, 2024
840740d
Include README in JARs
opekope2 Jun 10, 2024
8db8ad8
Remove unused interface IImpactTnt
opekope2 Jun 10, 2024
5fedbeb
Update icon & add it to documentation
opekope2 Jun 10, 2024
f2a9cc4
Annotate BlockStateStaffItemRenderer with @Environment(CLIENT)
opekope2 Jun 10, 2024
993fa79
Annotate StaffInfusionSmithingRecipeTextures with @Environment(CLIENT)
opekope2 Jun 10, 2024
e92d489
Migrate to Minecraft Unit from UnitComponent
opekope2 Jun 10, 2024
b325412
Rename "Weapon modifier" to "Staff modifier"
opekope2 Jun 10, 2024
87dd990
Simplify anvil staff modifier creation
opekope2 Jun 10, 2024
69f9de3
Simplify default entity attribute modifier creation
opekope2 Jun 10, 2024
b4cbe63
Add +2 reach to lightning rod staff
opekope2 Jun 10, 2024
d8af4f0
Add missing reach extending modifiers
opekope2 Jun 10, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ jobs:
- name: JDK setup
uses: actions/[email protected]
with:
java-version: 17
java-version: 21
distribution: temurin
- name: Build project
if: inputs.build-project
Expand Down Expand Up @@ -91,7 +91,7 @@ jobs:
NeoForgeMod/build/libs/*.jar
if-no-files-found: error
- name: Upload Forge jars
if: inputs.build-project && inputs.upload-output
if: inputs.build-project && inputs.upload-output && false
uses: actions/[email protected]
with:
name: forge-jars
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ jobs:
name: neoforge-jars
path: dist/neoforge
- name: Download Forge jars
if: false
uses: actions/[email protected]
with:
name: forge-jars
Expand Down Expand Up @@ -95,6 +96,7 @@ jobs:
game-version-filter: releases
java: ${{ steps.load-java-version.outputs.value }}
- name: Publish Forge mod to Modrinth and CurseForge
if: false
uses: Kir-Antipov/[email protected]
with:
modrinth-id: ${{ vars.MODRINTH_ID }}
Expand Down Expand Up @@ -123,16 +125,13 @@ jobs:
dist/fabric/*-@(dev|sources|javadoc).jar
dist/neoforge/!(*-@(dev|sources|javadoc)).jar
dist/neoforge/*-@(dev|sources|javadoc).jar
dist/forge/!(*-@(dev|sources|javadoc)).jar
dist/forge/*-@(dev|sources|javadoc).jar
changelog-file: CHANGELOG.g.md
- name: Delete build output
uses: geekyeggo/[email protected]
with:
name: |
fabric-jars
neoforge-jars
forge-jars
useGlob: false
failOnError: false

Expand Down
20 changes: 20 additions & 0 deletions FabricMod/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
/*
* AvM Staff Mod
* Copyright (c) 2024 opekope2
*
* This mod is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This mod is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this mod. If not, see <https://www.gnu.org/licenses/>.
*/

plugins {
alias(libs.plugins.shadow)
}
Expand Down Expand Up @@ -77,6 +95,7 @@ tasks {

from(rootDir.resolve("COPYING"))
from(rootDir.resolve("COPYING.LESSER"))
from(rootDir.resolve("README.md"))
}

remapJar {
Expand All @@ -87,6 +106,7 @@ tasks {

from(rootDir.resolve("COPYING"))
from(rootDir.resolve("COPYING.LESSER"))
from(rootDir.resolve("README.md"))
}

sourcesJar {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/*
* AvM Staff Mod
* Copyright (c) 2024 opekope2
*
* This mod is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This mod is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this mod. If not, see <https://www.gnu.org/licenses/>.
*/

package opekope2.avm_staff.mixin.fabric;

import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.LivingEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Hand;
import net.minecraft.world.World;
import opekope2.avm_staff.api.StaffMod;
import opekope2.avm_staff.api.staff.StaffHandler;
import opekope2.avm_staff.util.StaffUtil;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(LivingEntity.class)
public abstract class LivingEntityMixin extends Entity {
private LivingEntityMixin(EntityType<?> type, World world) {
super(type, world);
}

@Shadow
public abstract ItemStack getMainHandStack();

@Shadow
public abstract ItemStack getStackInHand(Hand hand);

@Inject(method = "disablesShield", at = @At("HEAD"), cancellable = true)
public void disableShield(CallbackInfoReturnable<Boolean> cir) {
ItemStack mainHandStack = getMainHandStack();
if (!mainHandStack.isIn(StaffMod.getStaffsTag())) return;

Item itemInStaff = StaffUtil.getItemInStaff(mainHandStack);
if (itemInStaff == null) return;

StaffHandler handlerOfItem = StaffUtil.getStaffHandlerOrDefault(itemInStaff);
if (handlerOfItem.disablesShield()) {
cir.setReturnValue(true);
}
}

@SuppressWarnings("UnreachableCode") // Calm down IDEA, this is not what it looks like. Literally
@Inject(method = "swingHand(Lnet/minecraft/util/Hand;Z)V", at = @At("HEAD"), cancellable = true)
public void swingHand(Hand hand, boolean fromServerPlayer, CallbackInfo ci) {
ItemStack stackInHand = getStackInHand(hand);
if (stackInHand.isEmpty()) return;
if (!stackInHand.isIn(StaffMod.getStaffsTag())) return;

Item itemInStaff = StaffUtil.getItemInStaff(stackInHand);
if (itemInStaff == null) return;

StaffHandler handlerOfItem = StaffUtil.getStaffHandlerOrDefault(itemInStaff);
if (!handlerOfItem.canSwingHand(stackInHand, getEntityWorld(), (LivingEntity) (Object) this, hand)) {
ci.cancel();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* AvM Staff Mod
* Copyright (c) 2024 opekope2
*
* This mod is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This mod is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this mod. If not, see <https://www.gnu.org/licenses/>.
*/

package opekope2.avm_staff.mixin.fabric;

import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.mob.PiglinBrain;
import net.minecraft.item.ItemStack;
import opekope2.avm_staff.api.item.CrownItem;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(PiglinBrain.class)
public abstract class PiglinBrainMixin {
@Inject(method = "wearsGoldArmor", at = @At("HEAD"), cancellable = true)
private static void wearsGoldArmor(LivingEntity entity, CallbackInfoReturnable<Boolean> cir) {
for (ItemStack armorStack : entity.getArmorItems()) {
if (armorStack.getItem() instanceof CrownItem) {
cir.setReturnValue(true);
return;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,72 +18,41 @@

package opekope2.avm_staff.internal.fabric

import net.fabricmc.api.EnvType
import net.fabricmc.api.ModInitializer
import net.fabricmc.fabric.api.event.player.AttackBlockCallback
import net.fabricmc.fabric.api.event.player.AttackEntityCallback
import net.fabricmc.fabric.api.item.v1.FabricItemSettings
import net.fabricmc.fabric.api.particle.v1.FabricParticleTypes
import net.fabricmc.loader.api.FabricLoader
import net.minecraft.entity.Entity
import net.minecraft.entity.player.PlayerEntity
import net.minecraft.item.Item
import net.minecraft.particle.DefaultParticleType
import net.minecraft.registry.Registries
import net.minecraft.registry.Registry
import net.minecraft.registry.RegistryKeys
import net.minecraft.registry.tag.TagKey
import net.minecraft.util.ActionResult
import net.minecraft.util.Hand
import net.minecraft.util.Identifier
import net.minecraft.util.hit.EntityHitResult
import net.minecraft.world.World
import opekope2.avm_staff.IStaffMod
import opekope2.avm_staff.api.item.StaffItem
import opekope2.avm_staff.internal.event_handler.attackBlock
import opekope2.avm_staff.internal.event_handler.attackEntity
import opekope2.avm_staff.internal.fabric.item.FabricStaffItem
import opekope2.avm_staff.util.MOD_ID
import opekope2.avm_staff.api.staffsTag
import opekope2.avm_staff.util.contains
import opekope2.avm_staff.util.itemInStaff
import opekope2.avm_staff.util.staffHandler

@Suppress("unused")
object StaffMod : ModInitializer, IStaffMod {
override val staffItem: StaffItem = Registry.register(
Registries.ITEM,
Identifier(MOD_ID, "staff"),
FabricStaffItem(FabricItemSettings().maxCount(1))
)

override val isPhysicalClient: Boolean
get() = FabricLoader.getInstance().environmentType == EnvType.CLIENT

override val staffsTag: TagKey<Item> = TagKey.of(RegistryKeys.ITEM, Identifier(MOD_ID, "staffs"))

override val flamethrowerParticleType: DefaultParticleType = Registry.register(
Registries.PARTICLE_TYPE,
Identifier(MOD_ID, "flame"),
FabricParticleTypes.simple()
)

override val soulFlamethrowerParticleType: DefaultParticleType = Registry.register(
Registries.PARTICLE_TYPE,
Identifier(MOD_ID, "soul_fire_flame"),
FabricParticleTypes.simple()
)

object StaffMod : ModInitializer {
override fun onInitialize() {
AttackBlockCallback.EVENT.register(::attackBlock)
AttackEntityCallback.EVENT.register(::handleEntityAttackEvent)
}

@Suppress("UNUSED_PARAMETER")
private fun handleEntityAttackEvent(
player: PlayerEntity,
world: World,
hand: Hand,
target: Entity,
@Suppress("UNUSED_PARAMETER") hit: EntityHitResult?
hit: EntityHitResult?
): ActionResult {
if (world.isClient) return ActionResult.PASS // Handled with mixin
val itemStack = player.getStackInHand(hand)
if (itemStack !in staffsTag) return ActionResult.PASS

val itemInStaff = itemStack.itemInStaff ?: return ActionResult.PASS
val staffHandler = itemInStaff.staffHandler ?: return ActionResult.PASS

return attackEntity(player, world, hand, target)
val result = staffHandler.attackEntity(itemStack, world, player, target, hand)
return if (result.interruptsFurtherEvaluation()) ActionResult.SUCCESS
else ActionResult.PASS
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,65 +21,22 @@ package opekope2.avm_staff.internal.fabric
import net.fabricmc.api.ClientModInitializer
import net.fabricmc.api.EnvType
import net.fabricmc.api.Environment
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper
import net.fabricmc.fabric.api.client.model.loading.v1.ModelLoadingPlugin
import net.fabricmc.fabric.api.client.model.loading.v1.ModelModifier
import net.fabricmc.fabric.api.client.particle.v1.ParticleFactoryRegistry
import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents
import net.minecraft.client.item.ModelPredicateProviderRegistry
import net.minecraft.client.render.model.UnbakedModel
import net.minecraft.client.render.model.json.JsonUnbakedModel
import net.minecraft.item.ItemGroups
import net.minecraft.item.Items
import opekope2.avm_staff.IStaffMod
import opekope2.avm_staff.api.flamethrowerParticleType
import opekope2.avm_staff.api.particle.FlamethrowerParticle
import opekope2.avm_staff.internal.event_handler.ADD_REMOVE_KEYBINDING
import opekope2.avm_staff.internal.event_handler.handleKeyBindings
import opekope2.avm_staff.internal.fabric.item.model.UnbakedFabricStaffItemModel
import opekope2.avm_staff.internal.registerModelPredicateProviders
import opekope2.avm_staff.util.MOD_ID
import opekope2.avm_staff.api.soulFlamethrowerParticleType
import opekope2.avm_staff.internal.model.registerModelPredicateProviders

@Suppress("unused")
@Environment(EnvType.CLIENT)
object StaffModClient : ClientModInitializer {
override fun onInitializeClient() {
ItemGroupEvents.modifyEntriesEvent(ItemGroups.TOOLS).register { entries ->
entries.addAfter(Items.NETHERITE_HOE, StaffMod.staffItem)
ParticleFactoryRegistry.getInstance().apply {
register(flamethrowerParticleType.get(), FlamethrowerParticle::Factory)
register(soulFlamethrowerParticleType.get(), FlamethrowerParticle::Factory)
}
ItemGroupEvents.modifyEntriesEvent(ItemGroups.COMBAT).register { entries ->
entries.addAfter(Items.TRIDENT, StaffMod.staffItem)
}

ModelLoadingPlugin.register(::modelLoadingPlugin)

KeyBindingHelper.registerKeyBinding(ADD_REMOVE_KEYBINDING)

ClientTickEvents.END_CLIENT_TICK.register(::handleKeyBindings)

ParticleFactoryRegistry.getInstance().register(
IStaffMod.get().flamethrowerParticleType,
FlamethrowerParticle::Factory
)
ParticleFactoryRegistry.getInstance().register(
IStaffMod.get().soulFlamethrowerParticleType,
FlamethrowerParticle::Factory
)

registerModelPredicateProviders(ModelPredicateProviderRegistry::register)
}

private fun modelLoadingPlugin(pluginContext: ModelLoadingPlugin.Context) {
pluginContext.modifyModelBeforeBake().register(::modifyModelBeforeBake)
}

private fun modifyModelBeforeBake(model: UnbakedModel, context: ModelModifier.BeforeBake.Context): UnbakedModel {
if (context.id().namespace != MOD_ID) return model

return when (context.id().path) {
// TODO hardcoded paths
"staff", "item/staff_in_use" -> UnbakedFabricStaffItemModel(model as JsonUnbakedModel) // FIXME
else -> model
}
}
}
Loading