添加更多声音细节

This commit is contained in:
Atsuihsio 2024-11-07 04:39:18 +08:00
parent 7e7a5792df
commit 4903a44b4c
12 changed files with 210 additions and 12 deletions

View file

@ -73,6 +73,7 @@ public class SentinelItemModel extends GeoModel<SentinelItem> {
CoreGeoBone holo = getAnimationProcessor().getBone("holo");
holo.setPosY(0.09f);
stack.getOrCreateTag().putBoolean("HoloHidden", !(gun.getPosX() > 2.4));
shen.setPosX((float) (0.95f * ClientEventHandler.recoilHorizon * fpz * fp));
shen.setPosY((float) (0.4f * fp + 0.44f * fr));

View file

@ -18,7 +18,6 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.util.Mth;
@ -281,11 +280,6 @@ public class ClientEventHandler {
if (stack.getItem() == ModItems.DEVOTION.get() && (stack.getOrCreateTag().getBoolean("is_normal_reloading") || stack.getOrCreateTag().getBoolean("is_empty_reloading"))) {
customRpm = 0;
}
double block_range = player.getEyePosition().distanceTo((Vec3.atLowerCornerOf(player.level().clip( new ClipContext(player.getEyePosition(), player.getEyePosition().add(new Vec3(0, -1 , 0).scale(10)),
ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, player)).getBlockPos())));
player.displayClientMessage(Component.literal(new java.text.DecimalFormat("##.#").format(block_range)), true);
}
public static void shootClient(Player player) {
@ -416,6 +410,8 @@ public class ClientEventHandler {
if (stack.is(ModTags.Items.HAS_SHELL_EFFECT)) {
if (stack.is(ModTags.Items.SHOTGUN)) {
player.playSound(ModSounds.SHELL_CASING_SHOTGUN.get(), (float) Math.max(0.75 - 0.12 * shooterHeight, 0), 1);
} else if (stack.is(ModTags.Items.SNIPER_RIFLE)) {
player.playSound(ModSounds.SHELL_CASING_50CAL.get(), (float) Math.max(1 - 0.15 * shooterHeight, 0), 1);
} else {
player.playSound(ModSounds.SHELL_CASING_NORMAL.get(), (float) Math.max(1.5 - 0.2 * shooterHeight, 0), 1);
}

View file

@ -183,6 +183,8 @@ public class GunEventHandler {
ModUtils.queueServerWork((int) (stack.getOrCreateTag().getDouble("bolt_action_time") / 2 + 1.5 * shooterHeight), () -> {
if (stack.is(ModTags.Items.SHOTGUN)) {
SoundTool.playLocalSound(serverPlayer, ModSounds.SHELL_CASING_SHOTGUN.get(), (float) Math.max(0.75 - 0.12 * shooterHeight, 0), 1);
} else if (stack.is(ModTags.Items.SNIPER_RIFLE)) {
SoundTool.playLocalSound(serverPlayer, ModSounds.SHELL_CASING_50CAL.get(), (float) Math.max(1 - 0.15 * shooterHeight, 0), 1);
} else {
SoundTool.playLocalSound(serverPlayer,ModSounds.SHELL_CASING_NORMAL.get(), (float) Math.max(1.5 - 0.2 * shooterHeight, 0), 1);
}
@ -734,6 +736,19 @@ public class GunEventHandler {
SoundEvent sound1p = ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation(ModUtils.MODID, name + "_prepare_empty"));
if (sound1p != null && player instanceof ServerPlayer serverPlayer) {
SoundTool.playLocalSound(serverPlayer, sound1p, 10f, 1f);
double shooterHeight = player.getEyePosition().distanceTo((Vec3.atLowerCornerOf(player.level().clip( new ClipContext(player.getEyePosition(), player.getEyePosition().add(new Vec3(0, -1 , 0).scale(10)),
ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, player)).getBlockPos())));
ModUtils.queueServerWork((int) (stack.getOrCreateTag().getDouble("prepare_empty") / 2 + 3 + 1.5 * shooterHeight), () -> {
if (stack.is(ModTags.Items.SHOTGUN)) {
SoundTool.playLocalSound(serverPlayer, ModSounds.SHELL_CASING_SHOTGUN.get(), (float) Math.max(0.75 - 0.12 * shooterHeight, 0), 1);
} else if (stack.is(ModTags.Items.SNIPER_RIFLE)) {
SoundTool.playLocalSound(serverPlayer, ModSounds.SHELL_CASING_50CAL.get(), (float) Math.max(1 - 0.15 * shooterHeight, 0), 1);
} else {
SoundTool.playLocalSound(serverPlayer,ModSounds.SHELL_CASING_NORMAL.get(), (float) Math.max(1.5 - 0.2 * shooterHeight, 0), 1);
}
});
}
}
}
@ -751,6 +766,19 @@ public class GunEventHandler {
SoundEvent sound1p = ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation(ModUtils.MODID, name + "_prepare_load"));
if (sound1p != null && player instanceof ServerPlayer serverPlayer) {
SoundTool.playLocalSound(serverPlayer, sound1p, 10f, 1f);
double shooterHeight = player.getEyePosition().distanceTo((Vec3.atLowerCornerOf(player.level().clip( new ClipContext(player.getEyePosition(), player.getEyePosition().add(new Vec3(0, -1 , 0).scale(10)),
ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, player)).getBlockPos())));
ModUtils.queueServerWork((int) (8 + 1.5 * shooterHeight), () -> {
if (stack.is(ModTags.Items.SHOTGUN)) {
SoundTool.playLocalSound(serverPlayer, ModSounds.SHELL_CASING_SHOTGUN.get(), (float) Math.max(0.75 - 0.12 * shooterHeight, 0), 1);
} else if (stack.is(ModTags.Items.SNIPER_RIFLE)) {
SoundTool.playLocalSound(serverPlayer, ModSounds.SHELL_CASING_50CAL.get(), (float) Math.max(1 - 0.15 * shooterHeight, 0), 1);
} else {
SoundTool.playLocalSound(serverPlayer,ModSounds.SHELL_CASING_NORMAL.get(), (float) Math.max(1.5 - 0.2 * shooterHeight, 0), 1);
}
});
}
}
}
@ -785,6 +813,15 @@ public class GunEventHandler {
SoundEvent sound1p = ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation(ModUtils.MODID, name + "_end"));
if (sound1p != null && player instanceof ServerPlayer serverPlayer) {
SoundTool.playLocalSound(serverPlayer, sound1p, 10f, 1f);
double shooterHeight = player.getEyePosition().distanceTo((Vec3.atLowerCornerOf(player.level().clip( new ClipContext(player.getEyePosition(), player.getEyePosition().add(new Vec3(0, -1 , 0).scale(10)),
ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, player)).getBlockPos())));
if (stack.is(ModItems.MARLIN.get())) {
ModUtils.queueServerWork((int) (5 + 1.5 * shooterHeight), () -> {
SoundTool.playLocalSound(serverPlayer,ModSounds.SHELL_CASING_NORMAL.get(), (float) Math.max(1.5 - 0.2 * shooterHeight, 0), 1);
});
}
}
}
}

View file

@ -313,4 +313,5 @@ public class ModSounds {
public static final RegistryObject<SoundEvent> EDIT = REGISTRY.register("edit", () -> SoundEvent.createVariableRangeEvent(new ResourceLocation(ModUtils.MODID, "edit")));
public static final RegistryObject<SoundEvent> SHELL_CASING_NORMAL = REGISTRY.register("shell_casing_normal", () -> SoundEvent.createVariableRangeEvent(new ResourceLocation(ModUtils.MODID, "shell_casing_normal")));
public static final RegistryObject<SoundEvent> SHELL_CASING_SHOTGUN = REGISTRY.register("shell_casing_shotgun", () -> SoundEvent.createVariableRangeEvent(new ResourceLocation(ModUtils.MODID, "shell_casing_shotgun")));
public static final RegistryObject<SoundEvent> SHELL_CASING_50CAL = REGISTRY.register("shell_casing_50cal", () -> SoundEvent.createVariableRangeEvent(new ResourceLocation(ModUtils.MODID, "shell_casing_50cal")));
}

View file

@ -410,6 +410,21 @@
"0.0": {
"vector": [0, 0, 0]
},
"0.025": {
"vector": [0, 0, 0]
},
"0.05": {
"vector": [0, 0, 0]
},
"0.1": {
"vector": [0, 0, 0]
},
"0.275": {
"vector": [0, 200, 0]
},
"0.3": {
"vector": [0, 0, 0]
},
"0.425": {
"vector": [-72.17961, -6.70014, 19.9484]
},
@ -460,6 +475,39 @@
"0.0": {
"vector": [0, 0, 0]
},
"0.025": {
"vector": [0, 0, 0]
},
"0.05": {
"vector": [0, 1.3, -0.2]
},
"0.1": {
"vector": [0, 1.3, 1.5]
},
"0.125": {
"vector": [-3.02654, 2.16069, 1.62913]
},
"0.15": {
"vector": [-5.37048, 2.22716, 1.20688]
},
"0.175": {
"vector": [-7.70182, 1.8835, 1.28384]
},
"0.2": {
"vector": [-9.97823, 1.2534, 1.84468]
},
"0.225": {
"vector": [-12.48333, 0.14037, 2.30914]
},
"0.25": {
"vector": [-14.74357, -1.21642, 3.06307]
},
"0.275": {
"vector": [-1508.57, 2.02, 2.78]
},
"0.3": {
"vector": [0, 0, 0]
},
"0.425": {
"vector": [9.31908, -6.8218, 3.01452]
},
@ -526,9 +574,15 @@
},
"scale": {
"0.0": {
"vector": [0, 0, 0]
},
"0.05": {
"vector": [1, 1, 1]
},
"0.025": {
"0.225": {
"vector": [1, 1, 1]
},
"0.25": {
"vector": [0, 0, 0]
},
"0.525": {
@ -1363,11 +1417,6 @@
}
}
}
},
"sound_effects": {
"0.0": {
"effect": "m_870_bolt"
}
}
},
"animation.m870.finish": {

View file

@ -1225,6 +1225,96 @@
"vector": [0, 0, 0]
}
}
},
"bullet": {
"rotation": {
"0.0": {
"vector": [0, 0, 0]
},
"0.0833": {
"vector": [0, 0, 0]
},
"0.1": {
"vector": [0, 0, 0]
},
"0.15": {
"vector": [0, 0, 0]
},
"0.3167": {
"vector": [0, 200, 0]
},
"0.35": {
"vector": [0, 0, 0]
}
},
"position": {
"0.0": {
"vector": [0, 0, 0]
},
"0.0833": {
"vector": [0, 0, 0]
},
"0.1": {
"vector": [0, 0, -0.2]
},
"0.15": {
"vector": [0, 0, 1.5]
},
"0.1833": {
"vector": [-2.34434, 0.88942, 2.40796]
},
"0.2": {
"vector": [-4.29619, 1.38606, 3.12538]
},
"0.2167": {
"vector": [-5.92165, 1.64297, 3.90861]
},
"0.2333": {
"vector": [-7.53146, 1.62292, 4.64291]
},
"0.25": {
"vector": [-9.00843, 1.30099, 5.30362]
},
"0.2667": {
"vector": [-10.27409, 0.81677, 6.27719]
},
"0.2833": {
"vector": [-11.60524, 0.00966, 7.71722]
},
"0.3": {
"vector": [-12.6657, -1.50606, 9.17722]
},
"0.3333": {
"vector": [-1508.57, 2.02, 2.78]
},
"0.35": {
"vector": [0, 0, 0]
}
},
"scale": {
"0.1": {
"vector": [1, 1, 1]
},
"0.2833": {
"vector": [1, 1, 1]
},
"0.3": {
"vector": [0, 0, 0]
}
}
},
"bullethead": {
"scale": {
"0.0": {
"vector": [0, 0, 0]
},
"0.3333": {
"vector": [0, 0, 0]
},
"0.3417": {
"vector": [1, 1, 1]
}
}
}
}
}

View file

@ -2213,5 +2213,29 @@
"stream": false
}
]
},
"shell_casing_50cal": {
"sounds": [
{
"name": "superbwarfare:shells/shell_casing_50cal_1",
"stream": false
},
{
"name": "superbwarfare:shells/shell_casing_50cal_2",
"stream": false
},
{
"name": "superbwarfare:shells/shell_casing_50cal_3",
"stream": false
},
{
"name": "superbwarfare:shells/shell_casing_50cal_4",
"stream": false
},
{
"name": "superbwarfare:shells/shell_casing_50cal_5",
"stream": false
}
]
}
}