修改部分发射器发射逻辑
This commit is contained in:
parent
aa8e951e51
commit
4822382dc7
19 changed files with 162 additions and 201 deletions
|
@ -1,4 +1,4 @@
|
|||
// 1.21.1 2025-04-09T03:50:51.7343276 Tags for minecraft:item mod id superbwarfare
|
||||
// 1.21.1 2025-04-14T16:44:38.0133635 Tags for minecraft:item mod id superbwarfare
|
||||
44a232152f5941d0435a35483b37f8ed22fd10bf data/c/tags/item/dusts.json
|
||||
0fa06c2ff83bf09797e3ddff90f62d1124e645b4 data/c/tags/item/dusts/coal_coke.json
|
||||
295ddf906b7133a0558d03e9a60eea18281fe430 data/c/tags/item/dusts/iron.json
|
||||
|
@ -41,7 +41,7 @@ d39c5c787667ce78c214bc2fbd4931891ebaf936 data/superbwarfare/tags/item/launcher.j
|
|||
ab580f3989177c0589c43ca346db571011600187 data/superbwarfare/tags/item/launcher/grenade.json
|
||||
b404c6fd99d2ca68c6738f225cb7d68ee443c10a data/superbwarfare/tags/item/machine_gun.json
|
||||
a53020091752016da6602ee1b8b7e08823614344 data/superbwarfare/tags/item/military_armor.json
|
||||
35840286824cc674ec120615dd5dc14980769e15 data/superbwarfare/tags/item/normal_gun.json
|
||||
9e203e417380442166a000bca86744916a2fb1c5 data/superbwarfare/tags/item/normal_gun.json
|
||||
15328cd564c931cc0a4fc000596240f93a7b29a1 data/superbwarfare/tags/item/revolver.json
|
||||
aaa533157491a82b8e23b2914deef67c4078cbed data/superbwarfare/tags/item/rifle.json
|
||||
a249d9d052cdc24b34e0e51ab991329f6c76e8ab data/superbwarfare/tags/item/shotgun.json
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
"superbwarfare:m_4",
|
||||
"superbwarfare:devotion",
|
||||
"superbwarfare:trachelium",
|
||||
"superbwarfare:m_79",
|
||||
"superbwarfare:hunting_rifle",
|
||||
"superbwarfare:ntw_20",
|
||||
"superbwarfare:m_98b",
|
||||
|
@ -21,12 +22,15 @@
|
|||
"superbwarfare:m_870",
|
||||
"superbwarfare:marlin",
|
||||
"superbwarfare:glock_17",
|
||||
"superbwarfare:rpg",
|
||||
"superbwarfare:glock_18",
|
||||
"superbwarfare:m_1911",
|
||||
"superbwarfare:qbz_95",
|
||||
"superbwarfare:k_98",
|
||||
"superbwarfare:mosin_nagant",
|
||||
"superbwarfare:mp_443",
|
||||
"superbwarfare:insidious"
|
||||
"superbwarfare:insidious",
|
||||
"superbwarfare:secondary_cataclysm",
|
||||
"superbwarfare:taser"
|
||||
]
|
||||
}
|
|
@ -95,9 +95,10 @@ public class ModItemTagProvider extends ItemTagsProvider {
|
|||
|
||||
this.tag(ModTags.Items.NORMAL_GUN).add(
|
||||
ModItems.HOMEMADE_SHOTGUN.get(), 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.TRACHELIUM.get(),
|
||||
ModItems.HUNTING_RIFLE.get(), ModItems.NTW_20.get(), ModItems.M_98B.get(), ModItems.SENTINEL.get(), ModItems.M_870.get(), ModItems.MARLIN.get(), ModItems.GLOCK_17.get(),
|
||||
ModItems.GLOCK_18.get(), ModItems.M_1911.get(), ModItems.QBZ_95.get(), ModItems.K_98.get(), ModItems.MOSIN_NAGANT.get(), ModItems.MP_443.get(), ModItems.INSIDIOUS.get()
|
||||
ModItems.SKS.get(), ModItems.RPK.get(), ModItems.HK_416.get(), ModItems.AA_12.get(), ModItems.M_4.get(), ModItems.DEVOTION.get(), ModItems.TRACHELIUM.get(), ModItems.M_79.get(),
|
||||
ModItems.HUNTING_RIFLE.get(), ModItems.NTW_20.get(), ModItems.M_98B.get(), ModItems.SENTINEL.get(), ModItems.M_870.get(), ModItems.MARLIN.get(), ModItems.GLOCK_17.get(), ModItems.RPG.get(),
|
||||
ModItems.GLOCK_18.get(), ModItems.M_1911.get(), ModItems.QBZ_95.get(), ModItems.K_98.get(), ModItems.MOSIN_NAGANT.get(), ModItems.MP_443.get(), ModItems.INSIDIOUS.get(), ModItems.SECONDARY_CATACLYSM.get(),
|
||||
ModItems.TASER.get()
|
||||
);
|
||||
|
||||
this.tag(ModTags.Items.USE_HANDGUN_AMMO).add(
|
||||
|
|
|
@ -780,10 +780,19 @@ public class ClientEventHandler {
|
|||
var charged = cap != null && cap.getEnergyStored() > 0;
|
||||
|
||||
if (charged) {
|
||||
SoundEvent sound1p = BuiltInRegistries.SOUND_EVENT.get(Mod.loc("sentinel_charge_fire_1p"));
|
||||
if (sound1p != null) {
|
||||
SoundEvent sound1p = ModSounds.SENTINEL_CHARGE_FIRE_1P.get();
|
||||
player.playSound(sound1p, 2f, (float) ((2 * org.joml.Math.random() - 1) * 0.05f + 1.0f));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (stack.getItem() == ModItems.SECONDARY_CATACLYSM.get()) {
|
||||
var cap = stack.getCapability(Capabilities.EnergyStorage.ITEM);
|
||||
var charged = cap != null && cap.getEnergyStored() > 3000;
|
||||
|
||||
if (charged && zoom) {
|
||||
SoundEvent sound1p = ModSounds.SECONDARY_CATACLYSM_FIRE_1P_CHARGE.get();
|
||||
player.playSound(sound1p, 2f, (float) ((2 * org.joml.Math.random() - 1) * 0.05f + 1.0f));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import com.atsuishio.superbwarfare.entity.projectile.ProjectileEntity;
|
|||
import com.atsuishio.superbwarfare.event.events.ReloadEvent;
|
||||
import com.atsuishio.superbwarfare.init.*;
|
||||
import com.atsuishio.superbwarfare.item.gun.GunItem;
|
||||
import com.atsuishio.superbwarfare.item.gun.PressFireSpecialWeapon;
|
||||
import com.atsuishio.superbwarfare.item.gun.data.GunData;
|
||||
import com.atsuishio.superbwarfare.item.gun.data.value.AttachmentType;
|
||||
import com.atsuishio.superbwarfare.item.gun.data.value.ReloadState;
|
||||
|
@ -80,7 +81,7 @@ public class GunEventHandler {
|
|||
/**
|
||||
* 根据武器的注册名来寻找音效并播放
|
||||
*/
|
||||
public static void playGunSounds(Player player) {
|
||||
public static void playGunSounds(Player player, boolean zoom) {
|
||||
ItemStack stack = player.getMainHandItem();
|
||||
if (!(stack.getItem() instanceof GunItem)) return;
|
||||
var data = GunData.from(stack);
|
||||
|
@ -95,20 +96,24 @@ public class GunEventHandler {
|
|||
if (cap != null && cap.getEnergyStored() > 0) {
|
||||
float soundRadius = (float) data.soundRadius();
|
||||
|
||||
SoundEvent sound3p = BuiltInRegistries.SOUND_EVENT.get(Mod.loc("sentinel_charge_fire_3p"));
|
||||
if (sound3p != null) {
|
||||
player.playSound(sound3p, soundRadius * 0.4f, 1f);
|
||||
player.playSound(ModSounds.SENTINEL_CHARGE_FAR.get(), soundRadius * 0.7f, 1f);
|
||||
player.playSound(ModSounds.SENTINEL_CHARGE_FIRE_3P.get(), soundRadius * 0.4f, 1f);
|
||||
player.playSound(ModSounds.SENTINEL_CHARGE_VERYFAR.get(), soundRadius, 1f);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
SoundEvent soundFar = BuiltInRegistries.SOUND_EVENT.get(Mod.loc("sentinel_charge_far"));
|
||||
if (soundFar != null) {
|
||||
player.playSound(soundFar, soundRadius * 0.7f, 1f);
|
||||
}
|
||||
if (stack.getItem() == ModItems.SECONDARY_CATACLYSM.get()) {
|
||||
var cap = stack.getCapability(Capabilities.EnergyStorage.ITEM);
|
||||
|
||||
if (cap != null && cap.getEnergyStored() > 3000 && zoom) {
|
||||
float soundRadius = (float) data.soundRadius();
|
||||
|
||||
player.playSound(ModSounds.SECONDARY_CATACLYSM_FIRE_3P_CHARGE.get(), soundRadius * 0.4f, 1f);
|
||||
player.playSound(ModSounds.SECONDARY_CATACLYSM_FAR_CHARGE.get(), soundRadius * 0.7f, 1f);
|
||||
player.playSound(ModSounds.SECONDARY_CATACLYSM_VERYFAR_CHARGE.get(), soundRadius, 1f);
|
||||
|
||||
SoundEvent soundVeryFar = BuiltInRegistries.SOUND_EVENT.get(Mod.loc("sentinel_charge_veryfar"));
|
||||
if (soundVeryFar != null) {
|
||||
player.playSound(soundVeryFar, soundRadius, 1f);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -173,6 +178,9 @@ public class GunEventHandler {
|
|||
var stack = data.stack();
|
||||
|
||||
if (!player.level().isClientSide()) {
|
||||
if (stack.getItem() instanceof PressFireSpecialWeapon pressFireSpecialWeapon) {
|
||||
pressFireSpecialWeapon.fireOnPress(player, data, spared, zoom);
|
||||
} else {
|
||||
float headshot = (float) data.headshot();
|
||||
float damage = (float) data.damage();
|
||||
float velocity = (float) (data.velocity() * perkSpeed(data));
|
||||
|
@ -248,6 +256,7 @@ public class GunEventHandler {
|
|||
player.level().addFreshEntity(projectile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static double perkSpeed(GunData data) {
|
||||
var perk = data.perk.get(Perk.Type.AMMO);
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
package com.atsuishio.superbwarfare.item.gun;
|
||||
|
||||
import com.atsuishio.superbwarfare.item.gun.data.GunData;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
|
||||
/**
|
||||
* 不使用普通子弹的按下开火武器的开火处理
|
||||
*/
|
||||
public interface PressFireSpecialWeapon {
|
||||
|
||||
/**
|
||||
* 按下按键时武器发射处理
|
||||
*
|
||||
* @param player 玩家
|
||||
*/
|
||||
|
||||
default void fireOnPress(Player player, GunData data, double spread, boolean zoom) {
|
||||
}
|
||||
}
|
|
@ -7,7 +7,7 @@ import net.minecraft.world.entity.player.Player;
|
|||
/**
|
||||
* 拥有特殊开火方式的武器的开火处理
|
||||
*/
|
||||
public interface SpecialFireWeapon {
|
||||
public interface ReleaseSpecialWeapon {
|
||||
|
||||
|
||||
/**
|
|
@ -12,7 +12,7 @@ import com.atsuishio.superbwarfare.init.ModItems;
|
|||
import com.atsuishio.superbwarfare.init.ModPerks;
|
||||
import com.atsuishio.superbwarfare.init.ModSounds;
|
||||
import com.atsuishio.superbwarfare.item.gun.GunItem;
|
||||
import com.atsuishio.superbwarfare.item.gun.SpecialFireWeapon;
|
||||
import com.atsuishio.superbwarfare.item.gun.ReleaseSpecialWeapon;
|
||||
import com.atsuishio.superbwarfare.item.gun.data.GunData;
|
||||
import com.atsuishio.superbwarfare.network.message.receive.ShootClientMessage;
|
||||
import com.atsuishio.superbwarfare.perk.Perk;
|
||||
|
@ -56,7 +56,7 @@ import java.util.Optional;
|
|||
import java.util.Set;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class JavelinItem extends GunItem implements GeoItem, SpecialFireWeapon {
|
||||
public class JavelinItem extends GunItem implements GeoItem, ReleaseSpecialWeapon {
|
||||
|
||||
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
|
||||
public static ItemDisplayContext transformType;
|
||||
|
|
|
@ -9,21 +9,17 @@ import com.atsuishio.superbwarfare.init.ModItems;
|
|||
import com.atsuishio.superbwarfare.init.ModPerks;
|
||||
import com.atsuishio.superbwarfare.init.ModSounds;
|
||||
import com.atsuishio.superbwarfare.item.gun.GunItem;
|
||||
import com.atsuishio.superbwarfare.item.gun.SpecialFireWeapon;
|
||||
import com.atsuishio.superbwarfare.item.gun.PressFireSpecialWeapon;
|
||||
import com.atsuishio.superbwarfare.item.gun.data.GunData;
|
||||
import com.atsuishio.superbwarfare.network.message.receive.ShootClientMessage;
|
||||
import com.atsuishio.superbwarfare.perk.Perk;
|
||||
import com.atsuishio.superbwarfare.perk.PerkHelper;
|
||||
import com.atsuishio.superbwarfare.tools.ParticleTool;
|
||||
import com.atsuishio.superbwarfare.tools.SoundTool;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
import net.minecraft.core.particles.ParticleTypes;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.sounds.SoundSource;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.inventory.tooltip.TooltipComponent;
|
||||
|
@ -32,7 +28,6 @@ import net.minecraft.world.item.ItemDisplayContext;
|
|||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Rarity;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.neoforged.neoforge.network.PacketDistributor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import software.bernie.geckolib.animatable.GeoItem;
|
||||
import software.bernie.geckolib.animatable.instance.AnimatableInstanceCache;
|
||||
|
@ -45,7 +40,7 @@ import java.util.Optional;
|
|||
import java.util.Set;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class M79Item extends GunItem implements GeoItem, SpecialFireWeapon {
|
||||
public class M79Item extends GunItem implements GeoItem, PressFireSpecialWeapon {
|
||||
|
||||
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
|
||||
public static ItemDisplayContext transformType;
|
||||
|
@ -167,13 +162,11 @@ public class M79Item extends GunItem implements GeoItem, SpecialFireWeapon {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void fireOnPress(Player player, final GunData data, boolean zoom) {
|
||||
public void fireOnPress(Player player, final GunData data, double spread, boolean zoom) {
|
||||
if (data.reloading()) return;
|
||||
ItemStack stack = data.stack();
|
||||
if (player.getCooldowns().isOnCooldown(stack.getItem()) || data.ammo.get() <= 0) return;
|
||||
|
||||
double spread = data.spread();
|
||||
|
||||
if (player.level() instanceof ServerLevel serverLevel) {
|
||||
GunGrenadeEntity gunGrenadeEntity = new GunGrenadeEntity(player, serverLevel,
|
||||
(float) data.damage(),
|
||||
|
@ -206,19 +199,7 @@ public class M79Item extends GunItem implements GeoItem, SpecialFireWeapon {
|
|||
player.getY() + player.getBbHeight() - 0.1 + 1.8 * player.getLookAngle().y,
|
||||
player.getZ() + 1.8 * player.getLookAngle().z,
|
||||
4, 0.1, 0.1, 0.1, 0.002, true);
|
||||
|
||||
var serverPlayer = (ServerPlayer) player;
|
||||
|
||||
SoundTool.playLocalSound(serverPlayer, ModSounds.M_79_FIRE_1P.get(), 2, 1);
|
||||
serverPlayer.level().playSound(null, serverPlayer.getOnPos(), ModSounds.M_79_FIRE_3P.get(), SoundSource.PLAYERS, 2, 1);
|
||||
serverPlayer.level().playSound(null, serverPlayer.getOnPos(), ModSounds.M_79_FAR.get(), SoundSource.PLAYERS, 5, 1);
|
||||
serverPlayer.level().playSound(null, serverPlayer.getOnPos(), ModSounds.M_79_VERYFAR.get(), SoundSource.PLAYERS, 10, 1);
|
||||
|
||||
PacketDistributor.sendToPlayer(serverPlayer, new ShootClientMessage(10));
|
||||
}
|
||||
|
||||
player.getCooldowns().addCooldown(stack.getItem(), 2);
|
||||
data.ammo.set(data.ammo.get() - 1);
|
||||
}
|
||||
|
||||
}
|
|
@ -9,21 +9,17 @@ import com.atsuishio.superbwarfare.init.ModItems;
|
|||
import com.atsuishio.superbwarfare.init.ModPerks;
|
||||
import com.atsuishio.superbwarfare.init.ModSounds;
|
||||
import com.atsuishio.superbwarfare.item.gun.GunItem;
|
||||
import com.atsuishio.superbwarfare.item.gun.SpecialFireWeapon;
|
||||
import com.atsuishio.superbwarfare.item.gun.PressFireSpecialWeapon;
|
||||
import com.atsuishio.superbwarfare.item.gun.data.GunData;
|
||||
import com.atsuishio.superbwarfare.network.message.receive.ShootClientMessage;
|
||||
import com.atsuishio.superbwarfare.perk.Perk;
|
||||
import com.atsuishio.superbwarfare.perk.PerkHelper;
|
||||
import com.atsuishio.superbwarfare.tools.ParticleTool;
|
||||
import com.atsuishio.superbwarfare.tools.SoundTool;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
import net.minecraft.core.particles.ParticleTypes;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.sounds.SoundSource;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.inventory.tooltip.TooltipComponent;
|
||||
|
@ -32,7 +28,6 @@ import net.minecraft.world.item.ItemDisplayContext;
|
|||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Rarity;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.neoforged.neoforge.network.PacketDistributor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import software.bernie.geckolib.animatable.GeoItem;
|
||||
import software.bernie.geckolib.animatable.instance.AnimatableInstanceCache;
|
||||
|
@ -47,7 +42,7 @@ import java.util.Set;
|
|||
import java.util.function.Consumer;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class RpgItem extends GunItem implements GeoItem, SpecialFireWeapon {
|
||||
public class RpgItem extends GunItem implements GeoItem, PressFireSpecialWeapon {
|
||||
|
||||
@Override
|
||||
public String getAmmoDisplayName(GunData data) {
|
||||
|
@ -179,16 +174,10 @@ public class RpgItem extends GunItem implements GeoItem, SpecialFireWeapon {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void fireOnPress(Player player, final GunData data, boolean zoom) {
|
||||
public void fireOnPress(Player player, final GunData data, double spread, boolean zoom) {
|
||||
Level level = player.level();
|
||||
ItemStack stack = player.getMainHandItem();
|
||||
|
||||
if (data.reloading()
|
||||
|| player.getCooldowns().isOnCooldown(stack.getItem())
|
||||
|| data.ammo.get() <= 0
|
||||
) return;
|
||||
|
||||
double spread = data.spread();
|
||||
if (data.reloading()) return;
|
||||
|
||||
if (player.level() instanceof ServerLevel serverLevel) {
|
||||
RpgRocketEntity rocket = new RpgRocketEntity(player, level,
|
||||
|
@ -226,25 +215,11 @@ public class RpgItem extends GunItem implements GeoItem, SpecialFireWeapon {
|
|||
player.getZ() + 1.8 * player.getLookAngle().z,
|
||||
30, 0.4, 0.4, 0.4, 0.005, true);
|
||||
|
||||
var serverPlayer = (ServerPlayer) player;
|
||||
|
||||
SoundTool.playLocalSound(serverPlayer, ModSounds.RPG_FIRE_1P.get(), 2, 1);
|
||||
serverPlayer.level().playSound(null, serverPlayer.getOnPos(), ModSounds.RPG_FIRE_3P.get(), SoundSource.PLAYERS, 2, 1);
|
||||
serverPlayer.level().playSound(null, serverPlayer.getOnPos(), ModSounds.RPG_FAR.get(), SoundSource.PLAYERS, 5, 1);
|
||||
serverPlayer.level().playSound(null, serverPlayer.getOnPos(), ModSounds.RPG_VERYFAR.get(), SoundSource.PLAYERS, 10, 1);
|
||||
|
||||
PacketDistributor.sendToPlayer(serverPlayer, new ShootClientMessage(10));
|
||||
}
|
||||
|
||||
if (data.ammo.get() == 1) {
|
||||
data.isEmpty.set(true);
|
||||
data.closeHammer.set(true);
|
||||
}
|
||||
|
||||
player.getCooldowns().addCooldown(stack.getItem(), 10);
|
||||
data.ammo.set(data.ammo.get() - 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addReloadTimeBehavior(Map<Integer, Consumer<GunData>> behaviors) {
|
||||
super.addReloadTimeBehavior(behaviors);
|
||||
|
|
|
@ -8,24 +8,19 @@ import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
|||
import com.atsuishio.superbwarfare.init.ModEnumExtensions;
|
||||
import com.atsuishio.superbwarfare.init.ModItems;
|
||||
import com.atsuishio.superbwarfare.init.ModPerks;
|
||||
import com.atsuishio.superbwarfare.init.ModSounds;
|
||||
import com.atsuishio.superbwarfare.item.EnergyStorageItem;
|
||||
import com.atsuishio.superbwarfare.item.gun.GunItem;
|
||||
import com.atsuishio.superbwarfare.item.gun.SpecialFireWeapon;
|
||||
import com.atsuishio.superbwarfare.item.gun.PressFireSpecialWeapon;
|
||||
import com.atsuishio.superbwarfare.item.gun.data.GunData;
|
||||
import com.atsuishio.superbwarfare.network.message.receive.ShootClientMessage;
|
||||
import com.atsuishio.superbwarfare.perk.Perk;
|
||||
import com.atsuishio.superbwarfare.perk.PerkHelper;
|
||||
import com.atsuishio.superbwarfare.tools.InventoryTool;
|
||||
import com.atsuishio.superbwarfare.tools.ParticleTool;
|
||||
import com.atsuishio.superbwarfare.tools.SoundTool;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
import net.minecraft.core.particles.ParticleTypes;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.sounds.SoundSource;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EquipmentSlotGroup;
|
||||
import net.minecraft.world.entity.ai.attributes.AttributeModifier;
|
||||
|
@ -38,7 +33,6 @@ import net.minecraft.world.item.ItemStack;
|
|||
import net.minecraft.world.item.component.ItemAttributeModifiers;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.neoforged.neoforge.capabilities.Capabilities;
|
||||
import net.neoforged.neoforge.network.PacketDistributor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import software.bernie.geckolib.animatable.GeoItem;
|
||||
import software.bernie.geckolib.animatable.instance.AnimatableInstanceCache;
|
||||
|
@ -51,7 +45,7 @@ import java.util.ArrayList;
|
|||
import java.util.Optional;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class SecondaryCataclysm extends GunItem implements GeoItem, SpecialFireWeapon, EnergyStorageItem {
|
||||
public class SecondaryCataclysm extends GunItem implements GeoItem, PressFireSpecialWeapon, EnergyStorageItem {
|
||||
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
|
||||
public static ItemDisplayContext transformType;
|
||||
|
||||
|
@ -264,13 +258,11 @@ public class SecondaryCataclysm extends GunItem implements GeoItem, SpecialFireW
|
|||
}
|
||||
|
||||
@Override
|
||||
public void fireOnPress(Player player, final GunData data, boolean zoom) {
|
||||
public void fireOnPress(Player player, final GunData data, double spread, boolean zoom) {
|
||||
if (data.reloading()) return;
|
||||
ItemStack stack = data.stack();
|
||||
if (player.getCooldowns().isOnCooldown(stack.getItem()) || data.ammo.get() <= 0) return;
|
||||
|
||||
double spread = data.spread();
|
||||
|
||||
var stackCap = stack.getCapability(Capabilities.EnergyStorage.ITEM);
|
||||
var hasEnoughEnergy = stackCap != null && stackCap.getEnergyStored() >= 3000;
|
||||
|
||||
|
@ -310,31 +302,13 @@ public class SecondaryCataclysm extends GunItem implements GeoItem, SpecialFireW
|
|||
player.getZ() + 1.8 * player.getLookAngle().z,
|
||||
4, 0.1, 0.1, 0.1, 0.002, true);
|
||||
|
||||
|
||||
var serverPlayer = (ServerPlayer) player;
|
||||
|
||||
if (isChargedFire) {
|
||||
SoundTool.playLocalSound(serverPlayer, ModSounds.SECONDARY_CATACLYSM_FIRE_1P_CHARGE.get(), 1, 1);
|
||||
serverPlayer.level().playSound(null, serverPlayer.getOnPos(), ModSounds.SECONDARY_CATACLYSM_FIRE_3P_CHARGE.get(), SoundSource.PLAYERS, 3, 1);
|
||||
serverPlayer.level().playSound(null, serverPlayer.getOnPos(), ModSounds.SECONDARY_CATACLYSM_FAR_CHARGE.get(), SoundSource.PLAYERS, 5, 1);
|
||||
serverPlayer.level().playSound(null, serverPlayer.getOnPos(), ModSounds.SECONDARY_CATACLYSM_VERYFAR_CHARGE.get(), SoundSource.PLAYERS, 10, 1);
|
||||
|
||||
var itemCap = stack.getCapability(Capabilities.EnergyStorage.ITEM);
|
||||
if (itemCap != null) {
|
||||
itemCap.extractEnergy(3000, false);
|
||||
}
|
||||
} else {
|
||||
SoundTool.playLocalSound(serverPlayer, ModSounds.SECONDARY_CATACLYSM_FIRE_1P.get(), 1, 1);
|
||||
serverPlayer.level().playSound(null, serverPlayer.getOnPos(), ModSounds.SECONDARY_CATACLYSM_FIRE_3P.get(), SoundSource.PLAYERS, 3, 1);
|
||||
serverPlayer.level().playSound(null, serverPlayer.getOnPos(), ModSounds.SECONDARY_CATACLYSM_FAR.get(), SoundSource.PLAYERS, 5, 1);
|
||||
serverPlayer.level().playSound(null, serverPlayer.getOnPos(), ModSounds.SECONDARY_CATACLYSM_VERYFAR.get(), SoundSource.PLAYERS, 10, 1);
|
||||
}
|
||||
|
||||
PacketDistributor.sendToPlayer(serverPlayer, new ShootClientMessage(10));
|
||||
}
|
||||
|
||||
data.ammo.set(data.ammo.get() - 1);
|
||||
player.getCooldowns().addCooldown(stack.getItem(), 6);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -8,7 +8,7 @@ import com.atsuishio.superbwarfare.init.ModItems;
|
|||
import com.atsuishio.superbwarfare.init.ModPerks;
|
||||
import com.atsuishio.superbwarfare.init.ModSounds;
|
||||
import com.atsuishio.superbwarfare.item.gun.GunItem;
|
||||
import com.atsuishio.superbwarfare.item.gun.SpecialFireWeapon;
|
||||
import com.atsuishio.superbwarfare.item.gun.ReleaseSpecialWeapon;
|
||||
import com.atsuishio.superbwarfare.item.gun.data.GunData;
|
||||
import com.atsuishio.superbwarfare.network.message.receive.ShootClientMessage;
|
||||
import com.atsuishio.superbwarfare.perk.AmmoPerk;
|
||||
|
@ -40,7 +40,7 @@ import java.util.function.Supplier;
|
|||
|
||||
import static com.atsuishio.superbwarfare.network.message.send.FireMessage.spawnBullet;
|
||||
|
||||
public class BocekItem extends GunItem implements GeoItem, SpecialFireWeapon {
|
||||
public class BocekItem extends GunItem implements GeoItem, ReleaseSpecialWeapon {
|
||||
|
||||
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
|
||||
public static ItemDisplayContext transformType;
|
||||
|
|
|
@ -10,17 +10,14 @@ import com.atsuishio.superbwarfare.init.ModPerks;
|
|||
import com.atsuishio.superbwarfare.init.ModSounds;
|
||||
import com.atsuishio.superbwarfare.item.EnergyStorageItem;
|
||||
import com.atsuishio.superbwarfare.item.gun.GunItem;
|
||||
import com.atsuishio.superbwarfare.item.gun.SpecialFireWeapon;
|
||||
import com.atsuishio.superbwarfare.item.gun.PressFireSpecialWeapon;
|
||||
import com.atsuishio.superbwarfare.item.gun.data.GunData;
|
||||
import com.atsuishio.superbwarfare.network.message.receive.ShootClientMessage;
|
||||
import com.atsuishio.superbwarfare.perk.Perk;
|
||||
import com.atsuishio.superbwarfare.tools.SoundTool;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.sounds.SoundSource;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.inventory.tooltip.TooltipComponent;
|
||||
|
@ -30,7 +27,6 @@ import net.minecraft.world.item.ItemStack;
|
|||
import net.minecraft.world.item.Rarity;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.neoforged.neoforge.capabilities.Capabilities;
|
||||
import net.neoforged.neoforge.network.PacketDistributor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import software.bernie.geckolib.animatable.GeoItem;
|
||||
import software.bernie.geckolib.animatable.instance.AnimatableInstanceCache;
|
||||
|
@ -43,7 +39,7 @@ import java.util.Optional;
|
|||
import java.util.Set;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class TaserItem extends GunItem implements GeoItem, SpecialFireWeapon, EnergyStorageItem {
|
||||
public class TaserItem extends GunItem implements GeoItem, EnergyStorageItem, PressFireSpecialWeapon {
|
||||
|
||||
public static final int MAX_ENERGY = 6000;
|
||||
|
||||
|
@ -218,7 +214,7 @@ public class TaserItem extends GunItem implements GeoItem, SpecialFireWeapon, En
|
|||
}
|
||||
|
||||
@Override
|
||||
public void fireOnPress(Player player, final GunData data, boolean zoom) {
|
||||
public void fireOnPress(Player player, final GunData data, double spread, boolean zoom) {
|
||||
if (data.reloading()) return;
|
||||
ItemStack stack = data.stack();
|
||||
|
||||
|
@ -226,22 +222,14 @@ public class TaserItem extends GunItem implements GeoItem, SpecialFireWeapon, En
|
|||
var energyStorage = stack.getCapability(Capabilities.EnergyStorage.ITEM);
|
||||
var hasEnoughEnergy = energyStorage != null && energyStorage.getEnergyStored() >= 400 + 100 * perkLevel;
|
||||
|
||||
if (player.getCooldowns().isOnCooldown(stack.getItem())
|
||||
|| data.ammo.get() <= 0
|
||||
|| !hasEnoughEnergy
|
||||
) return;
|
||||
if (!hasEnoughEnergy) return;
|
||||
|
||||
player.getCooldowns().addCooldown(stack.getItem(), 5);
|
||||
|
||||
if (player instanceof ServerPlayer serverPlayer) {
|
||||
double spread = data.spread();
|
||||
|
||||
int volt = data.perk.getLevel(ModPerks.VOLT_OVERLOAD);
|
||||
int wireLength = data.perk.getLevel(ModPerks.LONGER_WIRE);
|
||||
|
||||
SoundTool.playLocalSound(serverPlayer, ModSounds.TASER_FIRE_1P.get(), 1, 1);
|
||||
serverPlayer.level().playSound(null, serverPlayer.getOnPos(), ModSounds.TASER_FIRE_3P.get(), SoundSource.PLAYERS, 1, 1);
|
||||
|
||||
var level = serverPlayer.level();
|
||||
|
||||
TaserBulletEntity taserBulletProjectile = new TaserBulletEntity(player, level,
|
||||
|
@ -251,11 +239,8 @@ public class TaserItem extends GunItem implements GeoItem, SpecialFireWeapon, En
|
|||
taserBulletProjectile.shoot(player.getLookAngle().x, player.getLookAngle().y, player.getLookAngle().z, (float) data.velocity(),
|
||||
(float) (zoom ? 0.1 : spread));
|
||||
level.addFreshEntity(taserBulletProjectile);
|
||||
|
||||
PacketDistributor.sendToPlayer(serverPlayer, new ShootClientMessage(10));
|
||||
}
|
||||
|
||||
data.ammo.set(data.ammo.get() - 1);
|
||||
energyStorage.extractEnergy(400 + 100 * perkLevel, false);
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ import com.atsuishio.superbwarfare.init.ModAttachments;
|
|||
import com.atsuishio.superbwarfare.init.ModPerks;
|
||||
import com.atsuishio.superbwarfare.init.ModTags;
|
||||
import com.atsuishio.superbwarfare.item.gun.GunItem;
|
||||
import com.atsuishio.superbwarfare.item.gun.SpecialFireWeapon;
|
||||
import com.atsuishio.superbwarfare.item.gun.ReleaseSpecialWeapon;
|
||||
import com.atsuishio.superbwarfare.item.gun.data.GunData;
|
||||
import com.atsuishio.superbwarfare.item.gun.special.BocekItem;
|
||||
import com.atsuishio.superbwarfare.perk.AmmoPerk;
|
||||
|
@ -62,15 +62,15 @@ public record FireMessage(int msgType, double power, boolean zoom) implements Cu
|
|||
cap.edit = false;
|
||||
|
||||
// 按下开火
|
||||
if (!(stack.getItem() instanceof SpecialFireWeapon specialFireWeapon)) return;
|
||||
specialFireWeapon.fireOnPress(player, data, zoom);
|
||||
if (!(stack.getItem() instanceof ReleaseSpecialWeapon releaseSpecialWeapon)) return;
|
||||
releaseSpecialWeapon.fireOnPress(player, data, zoom);
|
||||
} else if (type == 1) {
|
||||
// 松开开火
|
||||
if (stack.getItem() instanceof SpecialFireWeapon specialFireWeapon) {
|
||||
if (specialFireWeapon instanceof BocekItem) {
|
||||
specialFireWeapon.fireOnRelease(player, data, power, zoom);
|
||||
if (stack.getItem() instanceof ReleaseSpecialWeapon releaseSpecialWeapon) {
|
||||
if (releaseSpecialWeapon instanceof BocekItem) {
|
||||
releaseSpecialWeapon.fireOnRelease(player, data, power, zoom);
|
||||
} else {
|
||||
specialFireWeapon.fireOnRelease(player, data, 0, zoom);
|
||||
releaseSpecialWeapon.fireOnRelease(player, data, 0, zoom);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -92,7 +92,7 @@ public record ShootMessage(double spread, boolean zoom) implements CustomPacketP
|
|||
GunEventHandler.gunShoot(player, data, spared, zoom);
|
||||
}
|
||||
|
||||
GunEventHandler.playGunSounds(player);
|
||||
GunEventHandler.playGunSounds(player, zoom);
|
||||
}
|
||||
} else if (stack.is(ModItems.MINIGUN.get())) {
|
||||
var cap = player.getData(ModAttachments.PLAYER_VARIABLE).watch();
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"Spread": 1.5,
|
||||
"Spread": 3.5,
|
||||
"RecoilX": 0.004,
|
||||
"RecoilY": 0.023,
|
||||
"Damage": 40,
|
||||
|
@ -9,5 +9,6 @@
|
|||
"Magazine": 1,
|
||||
"Weight": 4,
|
||||
"EmptyReloadTime": 64,
|
||||
"RPM": 180,
|
||||
"AmmoType": "superbwarfare:grenade_40mm"
|
||||
}
|
|
@ -9,5 +9,6 @@
|
|||
"Magazine": 1,
|
||||
"Weight": 7,
|
||||
"EmptyReloadTime": 103,
|
||||
"RPM": 120,
|
||||
"AmmoType": "superbwarfare:rocket"
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"Spread": 1.5,
|
||||
"Spread": 5,
|
||||
"RecoilX": 0.004,
|
||||
"RecoilY": 0.023,
|
||||
"Damage": 30,
|
||||
|
@ -12,5 +12,6 @@
|
|||
"IterativeTime": 20,
|
||||
"FinishTime": 19,
|
||||
"SoundRadius": 8,
|
||||
"RPM": 300,
|
||||
"AmmoType": "superbwarfare:grenade_40mm"
|
||||
}
|
|
@ -7,5 +7,6 @@
|
|||
"Magazine": 1,
|
||||
"Weight": 1,
|
||||
"EmptyReloadTime": 58,
|
||||
"RPM": 240,
|
||||
"AmmoType": "superbwarfare:taser_electrode"
|
||||
}
|
Loading…
Add table
Reference in a new issue