添加抛壳音效
This commit is contained in:
parent
a9ef282f03
commit
7e7a5792df
22 changed files with 134 additions and 5 deletions
|
@ -1,4 +1,4 @@
|
||||||
// 1.20.1 2024-10-30T03:13:00.7790602 Tags for minecraft:item mod id superbwarfare
|
// 1.20.1 2024-11-06T16:27:03.7101082 Tags for minecraft:item mod id superbwarfare
|
||||||
cf8d49a8d2872286d1a9c3d4a7e1c2b7690db0b8 data/forge/tags/items/dusts.json
|
cf8d49a8d2872286d1a9c3d4a7e1c2b7690db0b8 data/forge/tags/items/dusts.json
|
||||||
0fa06c2ff83bf09797e3ddff90f62d1124e645b4 data/forge/tags/items/dusts/coal_coke.json
|
0fa06c2ff83bf09797e3ddff90f62d1124e645b4 data/forge/tags/items/dusts/coal_coke.json
|
||||||
295ddf906b7133a0558d03e9a60eea18281fe430 data/forge/tags/items/dusts/iron.json
|
295ddf906b7133a0558d03e9a60eea18281fe430 data/forge/tags/items/dusts/iron.json
|
||||||
|
@ -36,6 +36,7 @@ af6fd64b4a685c353f243763db268f7b2304c009 data/forge/tags/items/storage_blocks/le
|
||||||
dff9ff6d6637951191906cb55a210ae5a3ad5cd6 data/superbwarfare/tags/items/extra_one_ammo.json
|
dff9ff6d6637951191906cb55a210ae5a3ad5cd6 data/superbwarfare/tags/items/extra_one_ammo.json
|
||||||
52598e22974c8da0d2852defe4c9005e1d67744b data/superbwarfare/tags/items/gun.json
|
52598e22974c8da0d2852defe4c9005e1d67744b data/superbwarfare/tags/items/gun.json
|
||||||
62eb408544731ce4cfcd119d8a6cc74731189ac0 data/superbwarfare/tags/items/handgun.json
|
62eb408544731ce4cfcd119d8a6cc74731189ac0 data/superbwarfare/tags/items/handgun.json
|
||||||
|
49fbb8c030fdfafec1f291acc1cdff406c777c7e data/superbwarfare/tags/items/has_shell_effect.json
|
||||||
dae3f86663e841d336efff9d23d8910aa7247be5 data/superbwarfare/tags/items/is_auto_weapon.json
|
dae3f86663e841d336efff9d23d8910aa7247be5 data/superbwarfare/tags/items/is_auto_weapon.json
|
||||||
68ec25b0ccd68abbbe2f33ab7097572c2140c9da data/superbwarfare/tags/items/launcher.json
|
68ec25b0ccd68abbbe2f33ab7097572c2140c9da data/superbwarfare/tags/items/launcher.json
|
||||||
b404c6fd99d2ca68c6738f225cb7d68ee443c10a data/superbwarfare/tags/items/machine_gun.json
|
b404c6fd99d2ca68c6738f225cb7d68ee443c10a data/superbwarfare/tags/items/machine_gun.json
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
{
|
||||||
|
"values": [
|
||||||
|
"superbwarfare:ak_47",
|
||||||
|
"superbwarfare:ak_12",
|
||||||
|
"superbwarfare:svd",
|
||||||
|
"superbwarfare:m_60",
|
||||||
|
"superbwarfare:mk_14",
|
||||||
|
"superbwarfare:vector",
|
||||||
|
"superbwarfare:sks",
|
||||||
|
"superbwarfare:rpk",
|
||||||
|
"superbwarfare:hk_416",
|
||||||
|
"superbwarfare:aa_12",
|
||||||
|
"superbwarfare:m_4",
|
||||||
|
"superbwarfare:devotion",
|
||||||
|
"superbwarfare:glock_17",
|
||||||
|
"superbwarfare:glock_18",
|
||||||
|
"superbwarfare:m_1911",
|
||||||
|
"superbwarfare:qbz_95"
|
||||||
|
]
|
||||||
|
}
|
|
@ -83,11 +83,16 @@ public class ModUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Collection<AbstractMap.SimpleEntry<Runnable, Integer>> workQueue = new ConcurrentLinkedQueue<>();
|
private static final Collection<AbstractMap.SimpleEntry<Runnable, Integer>> workQueue = new ConcurrentLinkedQueue<>();
|
||||||
|
private static final Collection<AbstractMap.SimpleEntry<Runnable, Integer>> workQueueC = new ConcurrentLinkedQueue<>();
|
||||||
|
|
||||||
public static void queueServerWork(int tick, Runnable action) {
|
public static void queueServerWork(int tick, Runnable action) {
|
||||||
workQueue.add(new AbstractMap.SimpleEntry<>(action, tick));
|
workQueue.add(new AbstractMap.SimpleEntry<>(action, tick));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void queueClientWork(int tick, Runnable action) {
|
||||||
|
workQueueC.add(new AbstractMap.SimpleEntry<>(action, tick));
|
||||||
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void tick(TickEvent.ServerTickEvent event) {
|
public void tick(TickEvent.ServerTickEvent event) {
|
||||||
if (event.phase == TickEvent.Phase.END) {
|
if (event.phase == TickEvent.Phase.END) {
|
||||||
|
@ -102,6 +107,20 @@ public class ModUtils {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public void tick(TickEvent.ClientTickEvent event) {
|
||||||
|
if (event.phase == TickEvent.Phase.END) {
|
||||||
|
List<AbstractMap.SimpleEntry<Runnable, Integer>> actions = new ArrayList<>();
|
||||||
|
workQueueC.forEach(work -> {
|
||||||
|
work.setValue(work.getValue() - 1);
|
||||||
|
if (work.getValue() == 0)
|
||||||
|
actions.add(work);
|
||||||
|
});
|
||||||
|
actions.forEach(e -> e.getKey().run());
|
||||||
|
workQueueC.removeAll(actions);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void onCommonSetup(final FMLCommonSetupEvent event) {
|
public void onCommonSetup(final FMLCommonSetupEvent event) {
|
||||||
addNetworkMessage(ZoomMessage.class, ZoomMessage::encode, ZoomMessage::decode, ZoomMessage::handler);
|
addNetworkMessage(ZoomMessage.class, ZoomMessage::encode, ZoomMessage::decode, ZoomMessage::handler);
|
||||||
addNetworkMessage(DoubleJumpMessage.class, DoubleJumpMessage::encode, DoubleJumpMessage::decode, DoubleJumpMessage::handler);
|
addNetworkMessage(DoubleJumpMessage.class, DoubleJumpMessage::encode, DoubleJumpMessage::decode, DoubleJumpMessage::handler);
|
||||||
|
|
|
@ -110,6 +110,10 @@ public class ModItemTagProvider extends ItemTagsProvider {
|
||||||
ModItems.RPK.get(), ModItems.HK_416.get(), ModItems.AA_12.get(), ModItems.M_4.get(), ModItems.DEVOTION.get(),ModItems.NTW_20.get(), ModItems.M_98B.get(),
|
ModItems.RPK.get(), ModItems.HK_416.get(), ModItems.AA_12.get(), ModItems.M_4.get(), ModItems.DEVOTION.get(),ModItems.NTW_20.get(), ModItems.M_98B.get(),
|
||||||
ModItems.SENTINEL.get(), ModItems.GLOCK_17.get(),ModItems.GLOCK_18.get(), ModItems.M_1911.get(), ModItems.QBZ_95.get());
|
ModItems.SENTINEL.get(), ModItems.GLOCK_17.get(),ModItems.GLOCK_18.get(), ModItems.M_1911.get(), ModItems.QBZ_95.get());
|
||||||
|
|
||||||
|
this.tag(ModTags.Items.HAS_SHELL_EFFECT).add(ModItems.AK_47.get(), ModItems.AK_12.get(), ModItems.SVD.get(), ModItems.M_60.get(), ModItems.MK_14.get(), ModItems.VECTOR.get(),
|
||||||
|
ModItems.SKS.get(), ModItems.RPK.get(), ModItems.HK_416.get(), ModItems.AA_12.get(), ModItems.M_4.get(), ModItems.DEVOTION.get(), ModItems.GLOCK_17.get(),
|
||||||
|
ModItems.GLOCK_18.get(), ModItems.M_1911.get(), ModItems.QBZ_95.get());
|
||||||
|
|
||||||
this.tag(ModTags.Items.MILITARY_ARMOR).add(ModItems.RU_CHEST_6B43.get(), ModItems.US_CHEST_IOTV.get());
|
this.tag(ModTags.Items.MILITARY_ARMOR).add(ModItems.RU_CHEST_6B43.get(), ModItems.US_CHEST_IOTV.get());
|
||||||
|
|
||||||
this.tag(ModTags.Items.CAN_CUSTOM_GUN).add(ModItems.AK_12.get(), ModItems.AK_47.get(), ModItems.M_4.get(), ModItems.HK_416.get());
|
this.tag(ModTags.Items.CAN_CUSTOM_GUN).add(ModItems.AK_12.get(), ModItems.AK_47.get(), ModItems.M_4.get(), ModItems.HK_416.get());
|
||||||
|
|
|
@ -18,6 +18,7 @@ import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.multiplayer.ClientLevel;
|
import net.minecraft.client.multiplayer.ClientLevel;
|
||||||
import net.minecraft.client.player.LocalPlayer;
|
import net.minecraft.client.player.LocalPlayer;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.sounds.SoundEvent;
|
import net.minecraft.sounds.SoundEvent;
|
||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
|
@ -280,6 +281,11 @@ public class ClientEventHandler {
|
||||||
if (stack.getItem() == ModItems.DEVOTION.get() && (stack.getOrCreateTag().getBoolean("is_normal_reloading") || stack.getOrCreateTag().getBoolean("is_empty_reloading"))) {
|
if (stack.getItem() == ModItems.DEVOTION.get() && (stack.getOrCreateTag().getBoolean("is_normal_reloading") || stack.getOrCreateTag().getBoolean("is_empty_reloading"))) {
|
||||||
customRpm = 0;
|
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) {
|
public static void shootClient(Player player) {
|
||||||
|
@ -402,6 +408,20 @@ public class ClientEventHandler {
|
||||||
if (sound1p != null) {
|
if (sound1p != null) {
|
||||||
player.playSound(sound1p, 2, 1);
|
player.playSound(sound1p, 2, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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.queueClientWork((int) (1 + 1.5 * shooterHeight), () -> {
|
||||||
|
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 {
|
||||||
|
player.playSound(ModSounds.SHELL_CASING_NORMAL.get(), (float) Math.max(1.5 - 0.2 * shooterHeight, 0), 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
|
|
|
@ -21,6 +21,8 @@ import net.minecraft.sounds.SoundEvent;
|
||||||
import net.minecraft.world.effect.MobEffectInstance;
|
import net.minecraft.world.effect.MobEffectInstance;
|
||||||
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.minecraft.world.level.ClipContext;
|
||||||
|
import net.minecraft.world.phys.Vec3;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.minecraftforge.common.capabilities.ForgeCapabilities;
|
import net.minecraftforge.common.capabilities.ForgeCapabilities;
|
||||||
import net.minecraftforge.event.TickEvent;
|
import net.minecraftforge.event.TickEvent;
|
||||||
|
@ -174,6 +176,17 @@ public class GunEventHandler {
|
||||||
SoundEvent sound1p = ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation(ModUtils.MODID, name + "_bolt"));
|
SoundEvent sound1p = ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation(ModUtils.MODID, name + "_bolt"));
|
||||||
if (sound1p != null && player instanceof ServerPlayer serverPlayer) {
|
if (sound1p != null && player instanceof ServerPlayer serverPlayer) {
|
||||||
SoundTool.playLocalSound(serverPlayer, sound1p, 2f, 1f);
|
SoundTool.playLocalSound(serverPlayer, sound1p, 2f, 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("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 {
|
||||||
|
SoundTool.playLocalSound(serverPlayer,ModSounds.SHELL_CASING_NORMAL.get(), (float) Math.max(1.5 - 0.2 * shooterHeight, 0), 1);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -311,4 +311,6 @@ public class ModSounds {
|
||||||
|
|
||||||
public static final RegistryObject<SoundEvent> EDIT_MODE = REGISTRY.register("edit_mode", () -> SoundEvent.createVariableRangeEvent(new ResourceLocation(ModUtils.MODID, "edit_mode")));
|
public static final RegistryObject<SoundEvent> EDIT_MODE = REGISTRY.register("edit_mode", () -> SoundEvent.createVariableRangeEvent(new ResourceLocation(ModUtils.MODID, "edit_mode")));
|
||||||
public static final RegistryObject<SoundEvent> EDIT = REGISTRY.register("edit", () -> SoundEvent.createVariableRangeEvent(new ResourceLocation(ModUtils.MODID, "edit")));
|
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")));
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,6 +39,8 @@ public class ModTags {
|
||||||
public static final TagKey<Item> CAN_APPLY_MAGAZINE = tag("can_apply_magazine");
|
public static final TagKey<Item> CAN_APPLY_MAGAZINE = tag("can_apply_magazine");
|
||||||
public static final TagKey<Item> CAN_APPLY_STOCK= tag("can_apply_stock");
|
public static final TagKey<Item> CAN_APPLY_STOCK= tag("can_apply_stock");
|
||||||
|
|
||||||
|
public static final TagKey<Item> HAS_SHELL_EFFECT= tag("has_shell_effect");
|
||||||
|
|
||||||
public static final TagKey<Item> MILITARY_ARMOR = tag("military_armor");
|
public static final TagKey<Item> MILITARY_ARMOR = tag("military_armor");
|
||||||
public static final TagKey<Item> MILITARY_ARMOR_HEAVY = tag("military_armor_heavy");
|
public static final TagKey<Item> MILITARY_ARMOR_HEAVY = tag("military_armor_heavy");
|
||||||
|
|
||||||
|
|
|
@ -10376,13 +10376,13 @@
|
||||||
{
|
{
|
||||||
"name": "CrossAlt",
|
"name": "CrossAlt",
|
||||||
"parent": "Cross",
|
"parent": "Cross",
|
||||||
"pivot": [0, 6.00078, -96],
|
"pivot": [0, 5.95391, -96],
|
||||||
"cubes": [
|
"cubes": [
|
||||||
{
|
{
|
||||||
"origin": [-0.20958, 5.7912, -96],
|
"origin": [-0.36509, 5.58882, -96],
|
||||||
"size": [0.41917, 0.41917, 0],
|
"size": [0.73019, 0.73019, 0],
|
||||||
"uv": {
|
"uv": {
|
||||||
"south": {"uv": [80.2627, 62.97217], "uv_size": [16.25, 16.25]}
|
"south": {"uv": [100.0127, 61.72217], "uv_size": [16.25, 16.25]}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
|
@ -2165,5 +2165,53 @@
|
||||||
"stream": false
|
"stream": false
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
"shell_casing_normal": {
|
||||||
|
"sounds": [
|
||||||
|
{
|
||||||
|
"name": "superbwarfare:shells/shell_casing_normal_1",
|
||||||
|
"stream": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "superbwarfare:shells/shell_casing_normal_2",
|
||||||
|
"stream": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "superbwarfare:shells/shell_casing_normal_3",
|
||||||
|
"stream": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "superbwarfare:shells/shell_casing_normal_4",
|
||||||
|
"stream": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "superbwarfare:shells/shell_casing_normal_5",
|
||||||
|
"stream": false
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"shell_casing_shotgun": {
|
||||||
|
"sounds": [
|
||||||
|
{
|
||||||
|
"name": "superbwarfare:shells/shell_casing_shotgun_1",
|
||||||
|
"stream": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "superbwarfare:shells/shell_casing_shotgun_2",
|
||||||
|
"stream": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "superbwarfare:shells/shell_casing_shotgun_3",
|
||||||
|
"stream": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "superbwarfare:shells/shell_casing_shotgun_4",
|
||||||
|
"stream": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "superbwarfare:shells/shell_casing_shotgun_5",
|
||||||
|
"stream": false
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 85 KiB After Width: | Height: | Size: 86 KiB |
Binary file not shown.
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 17 KiB |
Loading…
Add table
Reference in a new issue