diff --git a/src/main/java/com/sekwah/narutomod/NarutoMod.java b/src/main/java/com/sekwah/narutomod/NarutoMod.java index f765ef7c..166902a9 100644 --- a/src/main/java/com/sekwah/narutomod/NarutoMod.java +++ b/src/main/java/com/sekwah/narutomod/NarutoMod.java @@ -12,6 +12,7 @@ import com.sekwah.narutomod.commands.NarutoCommands; import com.sekwah.narutomod.entity.NarutoDataSerialisers; import com.sekwah.narutomod.entity.NarutoEntities; +import com.sekwah.narutomod.gameevents.NarutoGameEvents; import com.sekwah.narutomod.item.NarutoDispenseItemBehavior; import com.sekwah.narutomod.item.NarutoItems; import com.sekwah.narutomod.network.PacketHandler; @@ -63,6 +64,7 @@ public NarutoMod() { NarutoBlocks.register(eventBus); NarutoEntities.register(eventBus); NarutoAbilities.register(eventBus); + NarutoGameEvents.register(eventBus); DistExecutor.safeCallWhenOn(Dist.CLIENT, () -> NarutoInGameGUI::new); } diff --git a/src/main/java/com/sekwah/narutomod/abilities/utility/DoubleJumpAbility.java b/src/main/java/com/sekwah/narutomod/abilities/utility/DoubleJumpAbility.java index e808e63f..44907f2e 100644 --- a/src/main/java/com/sekwah/narutomod/abilities/utility/DoubleJumpAbility.java +++ b/src/main/java/com/sekwah/narutomod/abilities/utility/DoubleJumpAbility.java @@ -2,6 +2,7 @@ import com.sekwah.narutomod.abilities.Ability; import com.sekwah.narutomod.capabilities.INinjaData; +import com.sekwah.narutomod.gameevents.NarutoGameEvents; import com.sekwah.narutomod.sounds.NarutoSounds; import net.minecraft.core.particles.ParticleTypes; import net.minecraft.server.level.ServerLevel; @@ -57,5 +58,7 @@ public void performServer(Player player, INinjaData ninjaData, int ticksActive) player.getLevel().playSound(null, player, NarutoSounds.DOUBLE_JUMP.get(), SoundSource.PLAYERS, 1f, 1.0f); + + player.getLevel().gameEvent(player, NarutoGameEvents.DOUBLE_JUMP.get(), player.position()); } } diff --git a/src/main/java/com/sekwah/narutomod/abilities/utility/LeapAbility.java b/src/main/java/com/sekwah/narutomod/abilities/utility/LeapAbility.java index fb927d8b..29120260 100644 --- a/src/main/java/com/sekwah/narutomod/abilities/utility/LeapAbility.java +++ b/src/main/java/com/sekwah/narutomod/abilities/utility/LeapAbility.java @@ -2,6 +2,7 @@ import com.sekwah.narutomod.abilities.Ability; import com.sekwah.narutomod.capabilities.INinjaData; +import com.sekwah.narutomod.gameevents.NarutoGameEvents; import com.sekwah.narutomod.sounds.NarutoSounds; import com.sekwah.sekclib.util.PlayerUtil; import net.minecraft.ChatFormatting; @@ -54,5 +55,6 @@ public void performServer(Player player, INinjaData ninjaData, int ticksActive) , lookVector.z * horScale, true); player.getLevel().playSound(null, player, NarutoSounds.LEAP.get(), SoundSource.PLAYERS, 0.5f, 1.0f); + player.getLevel().gameEvent(player, NarutoGameEvents.LEAP.get(), player.position()); } } diff --git a/src/main/java/com/sekwah/narutomod/capabilities/NinjaData.java b/src/main/java/com/sekwah/narutomod/capabilities/NinjaData.java index 057b131f..69b1cebe 100644 --- a/src/main/java/com/sekwah/narutomod/capabilities/NinjaData.java +++ b/src/main/java/com/sekwah/narutomod/capabilities/NinjaData.java @@ -4,6 +4,7 @@ import com.sekwah.narutomod.abilities.Ability; import com.sekwah.narutomod.capabilities.toggleabilitydata.ToggleAbilityData; import com.sekwah.narutomod.config.NarutoConfig; +import com.sekwah.narutomod.gameevents.NarutoGameEvents; import com.sekwah.narutomod.registries.NarutoRegistries; import com.sekwah.sekclib.capabilitysync.capabilitysync.annotation.Sync; import net.minecraft.ChatFormatting; @@ -244,6 +245,7 @@ public void setCurrentlyChanneledAbility(Player player, Ability ability) { if (ability != null) { if (ability.castingSound() != null) { player.getLevel().playSound(null, player, ability.castingSound(), SoundSource.PLAYERS, 0.5f, 1.0f); + player.getLevel().gameEvent(player, NarutoGameEvents.JUTSU_CASTING.get(), player.position().add(0, player.getEyeHeight() * 0.7, 0)); } if(!(ability instanceof Ability.Channeled channeled && channeled.hideChannelMessages())) { diff --git a/src/main/java/com/sekwah/narutomod/datagen/NarutoDataGenerators.java b/src/main/java/com/sekwah/narutomod/datagen/NarutoDataGenerators.java index 0e4bed08..e5f2d3c7 100644 --- a/src/main/java/com/sekwah/narutomod/datagen/NarutoDataGenerators.java +++ b/src/main/java/com/sekwah/narutomod/datagen/NarutoDataGenerators.java @@ -13,5 +13,6 @@ public static void gatherData(GatherDataEvent event) { DataGenerator gen = event.getGenerator(); gen.addProvider(event.includeServer(), new RecipeGen(gen)); + gen.addProvider(event.includeServer(), new NarutoGameEventTagGen(gen, event.getExistingFileHelper())); } } diff --git a/src/main/java/com/sekwah/narutomod/datagen/NarutoGameEventTagGen.java b/src/main/java/com/sekwah/narutomod/datagen/NarutoGameEventTagGen.java new file mode 100644 index 00000000..ec1b68af --- /dev/null +++ b/src/main/java/com/sekwah/narutomod/datagen/NarutoGameEventTagGen.java @@ -0,0 +1,28 @@ +package com.sekwah.narutomod.datagen; + +import com.sekwah.narutomod.NarutoMod; +import com.sekwah.narutomod.gameevents.NarutoGameEvents; +import net.minecraft.data.DataGenerator; +import net.minecraft.data.tags.GameEventTagsProvider; +import net.minecraft.tags.GameEventTags; +import net.minecraft.world.level.gameevent.GameEvent; +import net.minecraftforge.common.data.ExistingFileHelper; + +public class NarutoGameEventTagGen extends GameEventTagsProvider { + public NarutoGameEventTagGen(DataGenerator p_176826_, ExistingFileHelper existingFileHelper) { + super(p_176826_, NarutoMod.MOD_ID, existingFileHelper); + } + + private void soundDetected(GameEvent event) { + this.tag(GameEventTags.WARDEN_CAN_LISTEN).add(event); + this.tag(GameEventTags.VIBRATIONS).add(event); + this.tag(GameEventTags.SHRIEKER_CAN_LISTEN).add(event); + } + + protected void addTags() { + soundDetected(NarutoGameEvents.JUTSU_CASTING.get()); + soundDetected(NarutoGameEvents.DOUBLE_JUMP.get()); + soundDetected(NarutoGameEvents.LEAP.get()); + } + +} diff --git a/src/main/java/com/sekwah/narutomod/gameevents/NarutoGameEvents.java b/src/main/java/com/sekwah/narutomod/gameevents/NarutoGameEvents.java new file mode 100644 index 00000000..cbb07bfd --- /dev/null +++ b/src/main/java/com/sekwah/narutomod/gameevents/NarutoGameEvents.java @@ -0,0 +1,30 @@ +package com.sekwah.narutomod.gameevents; + +import net.minecraft.core.Registry; +import net.minecraft.world.item.Item; +import net.minecraft.world.level.gameevent.GameEvent; +import net.minecraftforge.eventbus.api.IEventBus; +import net.minecraftforge.registries.DeferredRegister; +import net.minecraftforge.registries.RegistryObject; + +import static com.sekwah.narutomod.NarutoMod.MOD_ID; + +public class NarutoGameEvents { + + public static final DeferredRegister GAME_EVENTS = DeferredRegister.create(Registry.GAME_EVENT_REGISTRY, MOD_ID); + + public static final RegistryObject JUTSU_CASTING = GAME_EVENTS.register("jutsu_casting", () -> wardenAlert("jutsu_casting")); + + public static final RegistryObject LEAP = GAME_EVENTS.register("leap", () -> wardenAlert("leap")); + + public static final RegistryObject DOUBLE_JUMP = GAME_EVENTS.register("double_jump", () -> wardenAlert("double_jump")); + + public static GameEvent wardenAlert(String name) { + return new GameEvent(name, 16); + } + + + public static void register(IEventBus eventBus) { + GAME_EVENTS.register(eventBus); + } +} diff --git a/src/main/java/com/sekwah/narutomod/network/c2s/ServerAbilityActivatePacket.java b/src/main/java/com/sekwah/narutomod/network/c2s/ServerAbilityActivatePacket.java index b2143097..947cb0de 100644 --- a/src/main/java/com/sekwah/narutomod/network/c2s/ServerAbilityActivatePacket.java +++ b/src/main/java/com/sekwah/narutomod/network/c2s/ServerAbilityActivatePacket.java @@ -3,6 +3,7 @@ import com.sekwah.narutomod.abilities.Ability; import com.sekwah.narutomod.capabilities.NinjaCapabilityHandler; import com.sekwah.narutomod.capabilities.toggleabilitydata.ToggleAbilityData; +import com.sekwah.narutomod.gameevents.NarutoGameEvents; import com.sekwah.narutomod.registries.NarutoRegistries; import net.minecraft.ChatFormatting; import net.minecraft.network.FriendlyByteBuf; @@ -64,6 +65,7 @@ public static void handle(ServerAbilityActivatePacket msg, Supplier