-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f3d8524
commit a383eab
Showing
4 changed files
with
54 additions
and
22 deletions.
There are no files selected for viewing
33 changes: 11 additions & 22 deletions
33
src/main/java/com/aaronhowser/mods/realisticsuffocation/RealisticSuffocation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,34 @@ | ||
package com.aaronhowser.mods.realisticsuffocation; | ||
|
||
import com.aaronhowser.mods.realisticsuffocation.sounds.ModSounds; | ||
import com.mojang.logging.LogUtils; | ||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.world.damagesource.DamageTypes; | ||
import net.neoforged.api.distmarker.Dist; | ||
import net.neoforged.bus.api.IEventBus; | ||
import net.neoforged.bus.api.SubscribeEvent; | ||
import net.neoforged.fml.ModContainer; | ||
import net.neoforged.fml.common.EventBusSubscriber; | ||
import net.neoforged.fml.common.Mod; | ||
import net.neoforged.fml.event.lifecycle.FMLClientSetupEvent; | ||
import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent; | ||
import net.neoforged.neoforge.common.NeoForge; | ||
import net.neoforged.neoforge.event.server.ServerStartingEvent; | ||
import net.neoforged.neoforge.event.entity.living.LivingDamageEvent; | ||
import org.slf4j.Logger; | ||
|
||
@Mod(RealisticSuffocation.MODID) | ||
public class RealisticSuffocation { | ||
|
||
public static final String MODID = "realisticsuffocation"; | ||
private static final Logger LOGGER = LogUtils.getLogger(); | ||
|
||
public RealisticSuffocation(IEventBus modEventBus, ModContainer modContainer) { | ||
modEventBus.addListener(this::commonSetup); | ||
|
||
NeoForge.EVENT_BUS.register(this); | ||
} | ||
|
||
private void commonSetup(final FMLCommonSetupEvent event) { | ||
LOGGER.info("HELLO FROM COMMON SETUP"); | ||
} | ||
|
||
@SubscribeEvent | ||
public void onServerStarting(ServerStartingEvent event) { | ||
LOGGER.info("HELLO from server starting"); | ||
ModSounds.register(modEventBus); | ||
} | ||
|
||
@EventBusSubscriber(modid = MODID, bus = EventBusSubscriber.Bus.MOD, value = Dist.CLIENT) | ||
public static class ClientModEvents { | ||
@EventBusSubscriber(modid = MODID, value = Dist.CLIENT) | ||
public static class CommonEvents { | ||
@SubscribeEvent | ||
public static void onClientSetup(FMLClientSetupEvent event) { | ||
LOGGER.info("HELLO FROM CLIENT SETUP"); | ||
LOGGER.info("MINECRAFT NAME >> {}", Minecraft.getInstance().getUser().getName()); | ||
public static void onLivingDamage(LivingDamageEvent event) { | ||
if (!event.getSource().is(DamageTypes.IN_WALL)) { | ||
// event.getEntity().playSound(ModSounds.RAGDOLL); | ||
} | ||
} | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
src/main/java/com/aaronhowser/mods/realisticsuffocation/sounds/ModSounds.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.aaronhowser.mods.realisticsuffocation.sounds; | ||
|
||
import com.aaronhowser.mods.realisticsuffocation.RealisticSuffocation; | ||
import net.minecraft.core.registries.BuiltInRegistries; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.sounds.SoundEvent; | ||
import net.neoforged.bus.api.IEventBus; | ||
import net.neoforged.neoforge.registries.DeferredHolder; | ||
import net.neoforged.neoforge.registries.DeferredRegister; | ||
|
||
public class ModSounds { | ||
|
||
public static DeferredRegister<SoundEvent> SOUND_EVENTS = | ||
DeferredRegister.create( | ||
BuiltInRegistries.SOUND_EVENT, | ||
RealisticSuffocation.MODID); | ||
|
||
public SoundEvent RAGDOLL = registerSoundEvent("ragdoll").get(); | ||
|
||
@SuppressWarnings("SameParameterValue") | ||
private DeferredHolder<SoundEvent, SoundEvent> registerSoundEvent(String name) { | ||
return SOUND_EVENTS.register( | ||
name, | ||
() -> SoundEvent.createFixedRangeEvent( | ||
new ResourceLocation("realisticsuffocation", name), | ||
1f | ||
) | ||
); | ||
} | ||
|
||
public static void register(IEventBus eventBus) { | ||
SOUND_EVENTS.register(eventBus); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"ragdoll": { | ||
"sounds": [ | ||
"realisticsuffocation:ragdoll" | ||
], | ||
"subtitle": "subtitle.realisticsuffocation.ragdoll" | ||
} | ||
} |
Binary file not shown.