修改部分音效命名

This commit is contained in:
17146 2024-05-10 00:37:03 +08:00
parent f0ef7b196f
commit 4b5c1a7525
15 changed files with 50 additions and 45 deletions

View file

@ -5,9 +5,12 @@ import net.mcreator.target.init.TargetModAttributes;
import net.mcreator.target.init.TargetModTags; import net.mcreator.target.init.TargetModTags;
import net.mcreator.target.procedures.BulletFireNormalProcedure; import net.mcreator.target.procedures.BulletFireNormalProcedure;
import net.mcreator.target.tools.ItemNBTTool; import net.mcreator.target.tools.ItemNBTTool;
import net.minecraft.core.Holder;
import net.minecraft.network.protocol.game.ClientboundSoundPacket;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.level.ServerPlayer;
import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundEvent;
import net.minecraft.sounds.SoundSource;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraftforge.event.TickEvent; import net.minecraftforge.event.TickEvent;
@ -137,9 +140,9 @@ public class GunEventHandler {
} }
playGunSounds(player); playGunSounds(player);
}
}
}
}
public static void playGunSounds(Player player) { public static void playGunSounds(Player player) {
ItemStack stack = player.getMainHandItem(); ItemStack stack = player.getMainHandItem();
@ -151,16 +154,18 @@ public class GunEventHandler {
String origin = stack.getItem().getDescriptionId(); String origin = stack.getItem().getDescriptionId();
String name = origin.substring(origin.lastIndexOf(".") + 1); String name = origin.substring(origin.lastIndexOf(".") + 1);
ResourceLocation resourceLocation = new ResourceLocation(TargetMod.MODID, name + "_fire_1p"); SoundEvent sound1p = ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation(TargetMod.MODID, name + "_fire_1p"));
if (sound1p != null && player instanceof ServerPlayer serverPlayer) {
System.out.println(resourceLocation); serverPlayer.connection.send(new ClientboundSoundPacket(new Holder.Direct<>(sound1p),
SoundSource.PLAYERS, serverPlayer.getX(), serverPlayer.getY(), serverPlayer.getZ(), 2f, 1f, serverPlayer.level().random.nextLong()));
SoundEvent sound = ForgeRegistries.SOUND_EVENTS.getValue(resourceLocation);
if (sound != null) {
player.playSound(sound);
} }
// ((ServerPlayer) player).connection.send SoundEvent sound3p = ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation(TargetMod.MODID, name + "_fire_3p"));
if (sound3p != null) {
player.playSound(sound3p, 4f, 1f);
}
} }

View file

@ -78,18 +78,18 @@ public class TargetModSounds {
public static final RegistryObject<SoundEvent> MORTAR_LOAD = REGISTRY.register("mortar_load", () -> SoundEvent.createVariableRangeEvent(new ResourceLocation("target", "mortar_load"))); public static final RegistryObject<SoundEvent> MORTAR_LOAD = REGISTRY.register("mortar_load", () -> SoundEvent.createVariableRangeEvent(new ResourceLocation("target", "mortar_load")));
public static final RegistryObject<SoundEvent> MORTAR_DISTANT = REGISTRY.register("mortar_distant", () -> SoundEvent.createVariableRangeEvent(new ResourceLocation("target", "mortar_distant"))); public static final RegistryObject<SoundEvent> MORTAR_DISTANT = REGISTRY.register("mortar_distant", () -> SoundEvent.createVariableRangeEvent(new ResourceLocation("target", "mortar_distant")));
public static final RegistryObject<SoundEvent> FIRERATE = REGISTRY.register("firerate", () -> SoundEvent.createVariableRangeEvent(new ResourceLocation("target", "firerate"))); public static final RegistryObject<SoundEvent> FIRERATE = REGISTRY.register("firerate", () -> SoundEvent.createVariableRangeEvent(new ResourceLocation("target", "firerate")));
public static final RegistryObject<SoundEvent> M4_FIRE_1P = REGISTRY.register("m4_fire_1p", () -> SoundEvent.createVariableRangeEvent(new ResourceLocation("target", "m4_fire_1p"))); public static final RegistryObject<SoundEvent> M_4_FIRE_1P = REGISTRY.register("m_4_fire_1p", () -> SoundEvent.createVariableRangeEvent(new ResourceLocation("target", "m_4_fire_1p")));
public static final RegistryObject<SoundEvent> M4_FIRE_3P = REGISTRY.register("m4_fire_3p", () -> SoundEvent.createVariableRangeEvent(new ResourceLocation("target", "m4_fire_3p"))); public static final RegistryObject<SoundEvent> M_4_FIRE_3P = REGISTRY.register("m_4_fire_3p", () -> SoundEvent.createVariableRangeEvent(new ResourceLocation("target", "m_4_fire_3p")));
public static final RegistryObject<SoundEvent> M4_FAR = REGISTRY.register("m4_far", () -> SoundEvent.createVariableRangeEvent(new ResourceLocation("target", "m4_far"))); public static final RegistryObject<SoundEvent> M_4_FAR = REGISTRY.register("m_4_far", () -> SoundEvent.createVariableRangeEvent(new ResourceLocation("target", "m_4_far")));
public static final RegistryObject<SoundEvent> M4_VERYFAR = REGISTRY.register("m4_veryfar", () -> SoundEvent.createVariableRangeEvent(new ResourceLocation("target", "m4_veryfar"))); public static final RegistryObject<SoundEvent> M_4_VERYFAR = REGISTRY.register("m_4_veryfar", () -> SoundEvent.createVariableRangeEvent(new ResourceLocation("target", "m_4_veryfar")));
public static final RegistryObject<SoundEvent> M4_RELOAD_NORMAL = REGISTRY.register("m4_reload_normal", () -> SoundEvent.createVariableRangeEvent(new ResourceLocation("target", "m4_reload_normal"))); public static final RegistryObject<SoundEvent> M_4_RELOAD_NORMAL = REGISTRY.register("m_4_reload_normal", () -> SoundEvent.createVariableRangeEvent(new ResourceLocation("target", "m_4_reload_normal")));
public static final RegistryObject<SoundEvent> M4_RELOAD_EMPTY = REGISTRY.register("m4_reload_empty", () -> SoundEvent.createVariableRangeEvent(new ResourceLocation("target", "m4_reload_empty"))); public static final RegistryObject<SoundEvent> M_4_RELOAD_EMPTY = REGISTRY.register("m_4_reload_empty", () -> SoundEvent.createVariableRangeEvent(new ResourceLocation("target", "m_4_reload_empty")));
public static final RegistryObject<SoundEvent> AA12_FIRE_1P = REGISTRY.register("aa12_fire_1p", () -> SoundEvent.createVariableRangeEvent(new ResourceLocation("target", "aa12_fire_1p"))); public static final RegistryObject<SoundEvent> AA_12_FIRE_1P = REGISTRY.register("aa_12_fire_1p", () -> SoundEvent.createVariableRangeEvent(new ResourceLocation("target", "aa_12_fire_1p")));
public static final RegistryObject<SoundEvent> AA12_FIRE_3P = REGISTRY.register("aa12_fire_3p", () -> SoundEvent.createVariableRangeEvent(new ResourceLocation("target", "aa12_fire_3p"))); public static final RegistryObject<SoundEvent> AA_12_FIRE_3P = REGISTRY.register("aa_12_fire_3p", () -> SoundEvent.createVariableRangeEvent(new ResourceLocation("target", "aa_12_fire_3p")));
public static final RegistryObject<SoundEvent> AA12_FAR = REGISTRY.register("aa12_far", () -> SoundEvent.createVariableRangeEvent(new ResourceLocation("target", "aa12_far"))); public static final RegistryObject<SoundEvent> AA_12_FAR = REGISTRY.register("aa_12_far", () -> SoundEvent.createVariableRangeEvent(new ResourceLocation("target", "aa_12_far")));
public static final RegistryObject<SoundEvent> AA12_VERYFAR = REGISTRY.register("aa12_veryfar", () -> SoundEvent.createVariableRangeEvent(new ResourceLocation("target", "aa12_veryfar"))); public static final RegistryObject<SoundEvent> AA_12_VERYFAR = REGISTRY.register("aa_12_veryfar", () -> SoundEvent.createVariableRangeEvent(new ResourceLocation("target", "aa_12_veryfar")));
public static final RegistryObject<SoundEvent> AA12_RELOAD_NORMAL = REGISTRY.register("aa12_reload_normal", () -> SoundEvent.createVariableRangeEvent(new ResourceLocation("target", "aa12_reload_normal"))); public static final RegistryObject<SoundEvent> AA_12_RELOAD_NORMAL = REGISTRY.register("aa_12_reload_normal", () -> SoundEvent.createVariableRangeEvent(new ResourceLocation("target", "aa_12_reload_normal")));
public static final RegistryObject<SoundEvent> AA12_RELOAD_EMPTY = REGISTRY.register("aa12_reload_empty", () -> SoundEvent.createVariableRangeEvent(new ResourceLocation("target", "aa12_reload_empty"))); public static final RegistryObject<SoundEvent> AA_12_RELOAD_EMPTY = REGISTRY.register("aa_12_reload_empty", () -> SoundEvent.createVariableRangeEvent(new ResourceLocation("target", "aa_12_reload_empty")));
public static final RegistryObject<SoundEvent> BOCEK_ZOOM_FIRE_1P = REGISTRY.register("bocek_zoom_fire_1p", () -> SoundEvent.createVariableRangeEvent(new ResourceLocation("target", "bocek_zoom_fire_1p"))); public static final RegistryObject<SoundEvent> BOCEK_ZOOM_FIRE_1P = REGISTRY.register("bocek_zoom_fire_1p", () -> SoundEvent.createVariableRangeEvent(new ResourceLocation("target", "bocek_zoom_fire_1p")));
public static final RegistryObject<SoundEvent> BOCEK_ZOOM_FIRE_3P = REGISTRY.register("bocek_zoom_fire_3p", () -> SoundEvent.createVariableRangeEvent(new ResourceLocation("target", "bocek_zoom_fire_3p"))); public static final RegistryObject<SoundEvent> BOCEK_ZOOM_FIRE_3P = REGISTRY.register("bocek_zoom_fire_3p", () -> SoundEvent.createVariableRangeEvent(new ResourceLocation("target", "bocek_zoom_fire_3p")));
public static final RegistryObject<SoundEvent> BOCEK_SHATTER_CAP_FIRE_1P = REGISTRY.register("bocek_shatter_cap_fire_1p", () -> SoundEvent.createVariableRangeEvent(new ResourceLocation("target", "bocek_shatter_cap_fire_1p"))); public static final RegistryObject<SoundEvent> BOCEK_SHATTER_CAP_FIRE_1P = REGISTRY.register("bocek_shatter_cap_fire_1p", () -> SoundEvent.createVariableRangeEvent(new ResourceLocation("target", "bocek_shatter_cap_fire_1p")));

View file

@ -384,99 +384,99 @@
] ]
}, },
"m4_fire_1p": { "m_4_fire_1p": {
"sounds": [ "sounds": [
{ {
"name": "target:m4/m4_fire_1p", "name": "target:m_4/m_4_fire_1p",
"stream": false "stream": false
} }
] ]
}, },
"m4_fire_3p": { "m_4_fire_3p": {
"sounds": [ "sounds": [
{ {
"name": "target:m4/m4_fire_3p", "name": "target:m_4/m_4_fire_3p",
"stream": false "stream": false
} }
] ]
}, },
"m4_far": { "m_4_far": {
"sounds": [ "sounds": [
{ {
"name": "target:m4/m4_far", "name": "target:m_4/m_4_far",
"stream": false "stream": false
} }
] ]
}, },
"m4_veryfar": { "m_4_veryfar": {
"sounds": [ "sounds": [
{ {
"name": "target:m4/m4_veryfar", "name": "target:m_4/m_4_veryfar",
"stream": false "stream": false
} }
] ]
}, },
"m4_reload_normal": { "m_4_reload_normal": {
"sounds": [ "sounds": [
{ {
"name": "target:m4/m4_reload_normal", "name": "target:m_4/m_4_reload_normal",
"stream": false "stream": false
} }
] ]
}, },
"m4_reload_empty": { "m_4_reload_empty": {
"sounds": [ "sounds": [
{ {
"name": "target:m4/m4_reload_empty", "name": "target:m_4/m_4_reload_empty",
"stream": false "stream": false
} }
] ]
}, },
"aa12_fire_1p": { "aa_12_fire_1p": {
"sounds": [ "sounds": [
{ {
"name": "target:aa12/aa12_fire_1p", "name": "target:aa_12/aa_12_fire_1p",
"stream": false "stream": false
} }
] ]
}, },
"aa12_fire_3p": { "aa_12_fire_3p": {
"sounds": [ "sounds": [
{ {
"name": "target:aa12/aa12_fire_3p", "name": "target:aa_12/aa_12_fire_3p",
"stream": false "stream": false
} }
] ]
}, },
"aa12_far": { "aa_12_far": {
"sounds": [ "sounds": [
{ {
"name": "target:aa12/aa12_far", "name": "target:aa_12/aa_12_far",
"stream": false "stream": false
} }
] ]
}, },
"aa12_veryfar": { "aa_12_veryfar": {
"sounds": [ "sounds": [
{ {
"name": "target:aa12/aa12_veryfar", "name": "target:aa_12/aa_12_veryfar",
"stream": false "stream": false
} }
] ]
}, },
"aa12_reload_normal": { "aa_12_reload_normal": {
"sounds": [ "sounds": [
{ {
"name": "target:aa12/aa12_reload_normal", "name": "target:aa_12/aa_12_reload_normal",
"stream": false "stream": false
} }
] ]
}, },
"aa12_reload_empty": { "aa_12_reload_empty": {
"sounds": [ "sounds": [
{ {
"name": "target:aa12/aa12_reload_empty", "name": "target:aa_12/aa_12_reload_empty",
"stream": false "stream": false
} }
] ]