优化NBT#SoundRadius
This commit is contained in:
parent
c95c00457e
commit
d26a2b6ee9
3 changed files with 13 additions and 8 deletions
|
@ -101,19 +101,21 @@ public class GunEventHandler {
|
||||||
);
|
);
|
||||||
|
|
||||||
if (charged.get()) {
|
if (charged.get()) {
|
||||||
|
float soundRadius = (float) GunsTool.getGunDoubleTag(stack, "SoundRadius");
|
||||||
|
|
||||||
SoundEvent sound3p = ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation(ModUtils.MODID, "sentinel_charge_fire_3p"));
|
SoundEvent sound3p = ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation(ModUtils.MODID, "sentinel_charge_fire_3p"));
|
||||||
if (sound3p != null) {
|
if (sound3p != null) {
|
||||||
player.playSound(sound3p, (float) stack.getOrCreateTag().getDouble("SoundRadius") * 0.4f, 1f);
|
player.playSound(sound3p, soundRadius * 0.4f, 1f);
|
||||||
}
|
}
|
||||||
|
|
||||||
SoundEvent soundFar = ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation(ModUtils.MODID, "sentinel_charge_far"));
|
SoundEvent soundFar = ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation(ModUtils.MODID, "sentinel_charge_far"));
|
||||||
if (soundFar != null) {
|
if (soundFar != null) {
|
||||||
player.playSound(soundFar, (float) stack.getOrCreateTag().getDouble("SoundRadius") * 0.7f, 1f);
|
player.playSound(soundFar, soundRadius * 0.7f, 1f);
|
||||||
}
|
}
|
||||||
|
|
||||||
SoundEvent soundVeryFar = ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation(ModUtils.MODID, "sentinel_charge_veryfar"));
|
SoundEvent soundVeryFar = ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation(ModUtils.MODID, "sentinel_charge_veryfar"));
|
||||||
if (soundVeryFar != null) {
|
if (soundVeryFar != null) {
|
||||||
player.playSound(soundVeryFar, (float) stack.getOrCreateTag().getDouble("SoundRadius"), 1f);
|
player.playSound(soundVeryFar, soundRadius, 1f);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -9,6 +9,7 @@ import com.atsuishio.superbwarfare.network.ModVariables;
|
||||||
import com.atsuishio.superbwarfare.perk.AmmoPerk;
|
import com.atsuishio.superbwarfare.perk.AmmoPerk;
|
||||||
import com.atsuishio.superbwarfare.perk.Perk;
|
import com.atsuishio.superbwarfare.perk.Perk;
|
||||||
import com.atsuishio.superbwarfare.perk.PerkHelper;
|
import com.atsuishio.superbwarfare.perk.PerkHelper;
|
||||||
|
import com.atsuishio.superbwarfare.tools.GunsTool;
|
||||||
import com.atsuishio.superbwarfare.tools.ParticleTool;
|
import com.atsuishio.superbwarfare.tools.ParticleTool;
|
||||||
import com.atsuishio.superbwarfare.tools.SoundTool;
|
import com.atsuishio.superbwarfare.tools.SoundTool;
|
||||||
import net.minecraft.core.particles.ParticleTypes;
|
import net.minecraft.core.particles.ParticleTypes;
|
||||||
|
@ -127,9 +128,11 @@ public class ShootMessage {
|
||||||
float pitch = tag.getDouble("heat") <= 40 ? 1 : (float) (1 - 0.025 * Math.abs(40 - tag.getDouble("heat")));
|
float pitch = tag.getDouble("heat") <= 40 ? 1 : (float) (1 - 0.025 * Math.abs(40 - tag.getDouble("heat")));
|
||||||
|
|
||||||
if (!player.level().isClientSide() && player instanceof ServerPlayer) {
|
if (!player.level().isClientSide() && player instanceof ServerPlayer) {
|
||||||
player.playSound(ModSounds.MINIGUN_FIRE_3P.get(), (float) stack.getOrCreateTag().getDouble("SoundRadius") * 0.2f, pitch);
|
float soundRadius = (float) GunsTool.getGunDoubleTag(stack, "SoundRadius");
|
||||||
player.playSound(ModSounds.MINIGUN_FAR.get(), (float) stack.getOrCreateTag().getDouble("SoundRadius") * 0.5f, pitch);
|
|
||||||
player.playSound(ModSounds.MINIGUN_VERYFAR.get(), (float) stack.getOrCreateTag().getDouble("SoundRadius"), pitch);
|
player.playSound(ModSounds.MINIGUN_FIRE_3P.get(), soundRadius * 0.2f, pitch);
|
||||||
|
player.playSound(ModSounds.MINIGUN_FAR.get(), soundRadius * 0.5f, pitch);
|
||||||
|
player.playSound(ModSounds.MINIGUN_VERYFAR.get(), soundRadius, pitch);
|
||||||
|
|
||||||
if (perk == ModPerks.BEAST_BULLET.get()) {
|
if (perk == ModPerks.BEAST_BULLET.get()) {
|
||||||
player.playSound(ModSounds.HENG.get(), 4f, pitch);
|
player.playSound(ModSounds.HENG.get(), 4f, pitch);
|
||||||
|
|
|
@ -55,7 +55,7 @@ public class GunsTool {
|
||||||
public static void initGun(Level level, ItemStack stack, String location) {
|
public static void initGun(Level level, ItemStack stack, String location) {
|
||||||
if (level.getServer() == null) return;
|
if (level.getServer() == null) return;
|
||||||
gunsData.get(location).forEach((k, v) -> {
|
gunsData.get(location).forEach((k, v) -> {
|
||||||
if (k.equals("EmptyReloadTime") || k.equals("FireMode") || k.equals("Weight")) {
|
if (k.equals("EmptyReloadTime") || k.equals("FireMode") || k.equals("Weight") || k.equals("SoundRadius")) {
|
||||||
CompoundTag tag = stack.getOrCreateTag();
|
CompoundTag tag = stack.getOrCreateTag();
|
||||||
CompoundTag data = tag.getCompound("GunData");
|
CompoundTag data = tag.getCompound("GunData");
|
||||||
data.putDouble(k, v);
|
data.putDouble(k, v);
|
||||||
|
@ -69,7 +69,7 @@ public class GunsTool {
|
||||||
public static void initCreativeGun(ItemStack stack, String location) {
|
public static void initCreativeGun(ItemStack stack, String location) {
|
||||||
if (gunsData != null && gunsData.get(location) != null) {
|
if (gunsData != null && gunsData.get(location) != null) {
|
||||||
gunsData.get(location).forEach((k, v) -> {
|
gunsData.get(location).forEach((k, v) -> {
|
||||||
if (k.equals("EmptyReloadTime") || k.equals("FireMode") || k.equals("Weight")) {
|
if (k.equals("EmptyReloadTime") || k.equals("FireMode") || k.equals("Weight") || k.equals("SoundRadius")) {
|
||||||
CompoundTag tag = stack.getOrCreateTag();
|
CompoundTag tag = stack.getOrCreateTag();
|
||||||
CompoundTag data = tag.getCompound("GunData");
|
CompoundTag data = tag.getCompound("GunData");
|
||||||
data.putDouble(k, v);
|
data.putDouble(k, v);
|
||||||
|
|
Loading…
Add table
Reference in a new issue