补全没修改的配件效果

This commit is contained in:
Atsuihsio 2024-10-21 02:31:08 +08:00
parent 2cea1f38b5
commit 72cab16f45
3 changed files with 18 additions and 22 deletions

View file

@ -13,6 +13,7 @@ import net.mcreator.superbwarfare.network.message.ShootMessage;
import net.mcreator.superbwarfare.perk.AmmoPerk; import net.mcreator.superbwarfare.perk.AmmoPerk;
import net.mcreator.superbwarfare.perk.Perk; import net.mcreator.superbwarfare.perk.Perk;
import net.mcreator.superbwarfare.perk.PerkHelper; import net.mcreator.superbwarfare.perk.PerkHelper;
import net.mcreator.superbwarfare.tools.GunsTool;
import net.mcreator.superbwarfare.tools.MillisTimer; import net.mcreator.superbwarfare.tools.MillisTimer;
import net.mcreator.superbwarfare.tools.SeekTool; import net.mcreator.superbwarfare.tools.SeekTool;
import net.minecraft.client.CameraType; import net.minecraft.client.CameraType;
@ -613,21 +614,17 @@ public class ClientEventHandler {
CompoundTag tag = player.getMainHandItem().getOrCreateTag(); CompoundTag tag = player.getMainHandItem().getOrCreateTag();
float times = (float) Math.min(Minecraft.getInstance().getDeltaFrameTime(), 1.6); float times = (float) Math.min(Minecraft.getInstance().getDeltaFrameTime(), 1.6);
int barrelType = tag.getInt("barrel_type"); int barrelType = GunsTool.getAttachmentType(player.getMainHandItem(), GunsTool.AttachmentType.BARREL);
double recoil = 1.8; double recoil = switch (barrelType) {
case 1 -> 0.7;
if (barrelType == 1) { case 2 -> 1;
recoil = 0.7; default -> 1.8;
} else if (barrelType == 2) { };
recoil = 1;
}
float gunRecoilX = (float) tag.getDouble("recoil_x") * 60; float gunRecoilX = (float) tag.getDouble("recoil_x") * 60;
if (recoilHorizon > 0) { if (recoilHorizon > 0) {
recoilHorizon = recoilHorizon - Math.min(Math.pow(recoilHorizon, 2), 6) * times + recoilY; recoilHorizon = recoilHorizon - Math.min(Math.pow(recoilHorizon, 2), 6) * times + recoilY;
} else { } else {

View file

@ -152,23 +152,24 @@ public class GunEventHandler {
float soundRadius = (float) (stack.getOrCreateTag().getDouble("SoundRadius") * stack.getOrCreateTag().getDouble("CustomSoundRadius")); float soundRadius = (float) (stack.getOrCreateTag().getDouble("SoundRadius") * stack.getOrCreateTag().getDouble("CustomSoundRadius"));
int barrelType = GunsTool.getAttachmentType(stack, GunsTool.AttachmentType.BARREL);
SoundEvent sound1p = ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation(ModUtils.MODID, name + (stack.getOrCreateTag().getInt("barrel_type") == 2 ? "_fire_1p_s" : "_fire_1p"))); SoundEvent sound1p = ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation(ModUtils.MODID, name + (barrelType == 2 ? "_fire_1p_s" : "_fire_1p")));
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);
} }
SoundEvent sound3p = ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation(ModUtils.MODID, name + (stack.getOrCreateTag().getInt("barrel_type") == 2 ? "_fire_3p_s" : "_fire_3p"))); SoundEvent sound3p = ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation(ModUtils.MODID, name + (barrelType == 2 ? "_fire_3p_s" : "_fire_3p")));
if (sound3p != null) { if (sound3p != null) {
player.level().playSound(null, player.getOnPos(), sound3p, SoundSource.PLAYERS, soundRadius * 0.2f, 1f); player.level().playSound(null, player.getOnPos(), sound3p, SoundSource.PLAYERS, soundRadius * 0.2f, 1f);
} }
SoundEvent soundFar = ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation(ModUtils.MODID, name + (stack.getOrCreateTag().getInt("barrel_type") == 2 ? "_far_s" : "_far"))); SoundEvent soundFar = ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation(ModUtils.MODID, name + (barrelType == 2 ? "_far_s" : "_far")));
if (soundFar != null) { if (soundFar != null) {
player.level().playSound(null, player.getOnPos(), soundFar, SoundSource.PLAYERS, soundRadius * 0.5f, 1f); player.level().playSound(null, player.getOnPos(), soundFar, SoundSource.PLAYERS, soundRadius * 0.5f, 1f);
} }
SoundEvent soundVeryFar = ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation(ModUtils.MODID, name + (stack.getOrCreateTag().getInt("barrel_type") == 2 ? "_veryfar_s" : "_veryfar"))); SoundEvent soundVeryFar = ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation(ModUtils.MODID, name + (barrelType == 2 ? "_veryfar_s" : "_veryfar")));
if (soundVeryFar != null) { if (soundVeryFar != null) {
player.level().playSound(null, player.getOnPos(), soundVeryFar, SoundSource.PLAYERS, soundRadius, 1f); player.level().playSound(null, player.getOnPos(), soundVeryFar, SoundSource.PLAYERS, soundRadius, 1f);
} }

View file

@ -135,16 +135,14 @@ public class AK12Item extends GunItem implements GeoItem, AnimatedItem {
int scopeType = stack.getOrCreateTag().getInt("scope_type"); int scopeType = stack.getOrCreateTag().getInt("scope_type");
int barrelType = stack.getOrCreateTag().getInt("barrel_type"); int barrelType = stack.getOrCreateTag().getInt("barrel_type");
int magType = stack.getOrCreateTag().getInt("magazine_type"); int magType = GunsTool.getAttachmentType(stack, GunsTool.AttachmentType.MAGAZINE);
int stockType = stack.getOrCreateTag().getInt("stock_type"); int stockType = stack.getOrCreateTag().getInt("stock_type");
int customMag = 0; int customMag = switch (magType) {
case 1 -> 15;
if (magType == 1) { case 2 -> 45;
customMag = 15; default -> 0;
} else if (magType == 2) { };
customMag = 45;
}
// if (scopeType == 1) { // if (scopeType == 1) {
// //