优化近战相关代码
This commit is contained in:
parent
e93114b911
commit
8145f027c5
5 changed files with 20 additions and 12 deletions
|
@ -25,8 +25,6 @@ public class DefaultGunData {
|
||||||
public double spread;
|
public double spread;
|
||||||
@SerializedName("Damage")
|
@SerializedName("Damage")
|
||||||
public double damage;
|
public double damage;
|
||||||
@SerializedName("MeleeDamage")
|
|
||||||
public double meleeDamage;
|
|
||||||
@SerializedName("Headshot")
|
@SerializedName("Headshot")
|
||||||
public double headshot = 1.5;
|
public double headshot = 1.5;
|
||||||
@SerializedName("Velocity")
|
@SerializedName("Velocity")
|
||||||
|
@ -34,6 +32,13 @@ public class DefaultGunData {
|
||||||
@SerializedName("Magazine")
|
@SerializedName("Magazine")
|
||||||
public int magazine;
|
public int magazine;
|
||||||
|
|
||||||
|
@SerializedName("MeleeDamage")
|
||||||
|
public double meleeDamage;
|
||||||
|
@SerializedName("MeleeDuration")
|
||||||
|
public int meleeDuration = 26;
|
||||||
|
@SerializedName("MeleeDamageTime")
|
||||||
|
public int meleeDamageTime = 6;
|
||||||
|
|
||||||
@SerializedName("Projectile")
|
@SerializedName("Projectile")
|
||||||
public ProjectileInfo projectile = new ProjectileInfo();
|
public ProjectileInfo projectile = new ProjectileInfo();
|
||||||
|
|
||||||
|
|
|
@ -164,6 +164,14 @@ public class GunData {
|
||||||
return defaultGunData().meleeDamage;
|
return defaultGunData().meleeDamage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int meleeDuration() {
|
||||||
|
return Math.max(0, defaultGunData().meleeDuration);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int meleeDamageTime() {
|
||||||
|
return Math.min(meleeDuration(), defaultGunData().meleeDamageTime);
|
||||||
|
}
|
||||||
|
|
||||||
public double explosionDamage() {
|
public double explosionDamage() {
|
||||||
return defaultGunData().explosionDamage;
|
return defaultGunData().explosionDamage;
|
||||||
}
|
}
|
||||||
|
|
|
@ -419,11 +419,11 @@ public class ClientEventHandler {
|
||||||
&& !data.reloading()
|
&& !data.reloading()
|
||||||
&& !data.charging() && !player.getCooldowns().isOnCooldown(stack.getItem())
|
&& !data.charging() && !player.getCooldowns().isOnCooldown(stack.getItem())
|
||||||
) {
|
) {
|
||||||
gunMelee = 36;
|
gunMelee = data.meleeDuration();
|
||||||
cantFireTime = 40;
|
cantFireTime = gunMelee + 4;
|
||||||
player.playSound(SoundEvents.PLAYER_ATTACK_SWEEP, 1f, 1);
|
|
||||||
}
|
}
|
||||||
if (gunMelee == 22) {
|
if (gunMelee == data.meleeDuration() - data.meleeDamageTime()) {
|
||||||
|
player.playSound(SoundEvents.PLAYER_ATTACK_SWEEP, 1f, 1);
|
||||||
Entity lookingEntity = TraceTool.findMeleeEntity(player, player.entityInteractionRange());
|
Entity lookingEntity = TraceTool.findMeleeEntity(player, player.entityInteractionRange());
|
||||||
if (lookingEntity != null) {
|
if (lookingEntity != null) {
|
||||||
PacketDistributor.sendToServer(new MeleeAttackMessage(lookingEntity.getUUID()));
|
PacketDistributor.sendToServer(new MeleeAttackMessage(lookingEntity.getUUID()));
|
||||||
|
|
|
@ -312,7 +312,7 @@ public abstract class GunItem extends Item implements CustomRendererItem {
|
||||||
* @param stack 武器物品
|
* @param stack 武器物品
|
||||||
*/
|
*/
|
||||||
public boolean hasMeleeAttack(ItemStack stack) {
|
public boolean hasMeleeAttack(ItemStack stack) {
|
||||||
return false;
|
return GunData.from(stack).meleeDamage() > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -179,11 +179,6 @@ public class SecondaryCataclysm extends GunItem implements GeoItem, EnergyStorag
|
||||||
return Optional.of(new SecondaryCataclysmImageComponent(pStack));
|
return Optional.of(new SecondaryCataclysmImageComponent(pStack));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasMeleeAttack(ItemStack stack) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getAmmoDisplayName(GunData data) {
|
public String getAmmoDisplayName(GunData data) {
|
||||||
return "40mm Grenade";
|
return "40mm Grenade";
|
||||||
|
|
Loading…
Add table
Reference in a new issue