优化微型missile perk和tooltip

This commit is contained in:
17146 2025-05-07 14:44:15 +08:00 committed by Light_Quanta
parent 279f86a6ab
commit e120a002f2
No known key found for this signature in database
GPG key ID: 11A39A1B8C890959
10 changed files with 64 additions and 50 deletions

View file

@ -25,7 +25,7 @@ public class ClientEnergyImageTooltip extends ClientGunImageTooltip {
renderLevelAndUpgradePointTooltip(font, guiGraphics, x, y + 10);
int yo = 20;
if (shouldRenderBypassAndHeadshotTooltip()) {
if (shouldRenderBypassAndHeadshotTooltip(stack)) {
renderBypassAndHeadshotTooltip(font, guiGraphics, x, y + yo);
yo += 10;
}

View file

@ -4,6 +4,7 @@ import com.atsuishio.superbwarfare.client.TooltipTool;
import com.atsuishio.superbwarfare.client.tooltip.component.GunImageComponent;
import com.atsuishio.superbwarfare.init.ModKeyMappings;
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.data.GunData;
import com.atsuishio.superbwarfare.perk.AmmoPerk;
@ -41,7 +42,7 @@ public class ClientGunImageTooltip implements ClientTooltipComponent {
renderLevelAndUpgradePointTooltip(font, guiGraphics, x, y + 10);
int yo = 20;
if (shouldRenderBypassAndHeadshotTooltip()) {
if (shouldRenderBypassAndHeadshotTooltip(stack)) {
renderBypassAndHeadshotTooltip(font, guiGraphics, x, y + yo);
yo += 10;
}
@ -61,8 +62,8 @@ public class ClientGunImageTooltip implements ClientTooltipComponent {
guiGraphics.pose().popPose();
}
protected boolean shouldRenderBypassAndHeadshotTooltip() {
return data.bypassArmor() > 0 || data.headshot() > 0;
protected boolean shouldRenderBypassAndHeadshotTooltip(ItemStack stack) {
return !stack.is(ModTags.Items.LAUNCHER);
}
protected boolean shouldRenderEditTooltip() {
@ -273,7 +274,7 @@ public class ClientGunImageTooltip implements ClientTooltipComponent {
protected int getDefaultMaxWidth(Font font) {
int width = font.width(getDamageComponent().getVisualOrderText()) + font.width(getRpmComponent().getVisualOrderText()) + 16;
width = Math.max(width, font.width(getLevelComponent().getVisualOrderText()) + font.width(getUpgradePointComponent().getVisualOrderText()) + 16);
if (shouldRenderBypassAndHeadshotTooltip()) {
if (shouldRenderBypassAndHeadshotTooltip(stack)) {
width = Math.max(width, font.width(getBypassComponent().getVisualOrderText()) + font.width(getHeadshotComponent().getVisualOrderText()) + 16);
}
if (shouldRenderEditTooltip()) {
@ -305,7 +306,7 @@ public class ClientGunImageTooltip implements ClientTooltipComponent {
public int getHeight() {
int height = Math.max(20, this.height);
if (shouldRenderBypassAndHeadshotTooltip()) height += 10;
if (shouldRenderBypassAndHeadshotTooltip(stack)) height += 10;
if (shouldRenderEditTooltip()) height += 20;
if (shouldRenderPerks()) {
height += 16;

View file

@ -86,7 +86,7 @@ public class ProjectileEntity extends Projectile implements IEntityWithComplexSp
protected int shooterId;
private float damage = 1f;
private float headShot = 1f;
private float monsterMultiple = 0.0f;
private float monsterMultiplier = 0.0f;
private float legShot = 0.5f;
private boolean beast = false;
private boolean zoom = false;
@ -315,7 +315,7 @@ public class ProjectileEntity extends Projectile implements IEntityWithComplexSp
protected void readAdditionalSaveData(CompoundTag tag) {
this.damage = tag.getFloat("Damage");
this.headShot = tag.getFloat("HeadShot");
this.monsterMultiple = tag.getFloat("MonsterMultiple");
this.monsterMultiplier = tag.getFloat("MonsterMultiplier");
this.legShot = tag.getFloat("LegShot");
this.bypassArmorRate = tag.getFloat("BypassArmorRate");
this.undeadMultiple = tag.getFloat("UndeadMultiple");
@ -333,7 +333,7 @@ public class ProjectileEntity extends Projectile implements IEntityWithComplexSp
protected void addAdditionalSaveData(CompoundTag tag) {
tag.putFloat("Damage", this.damage);
tag.putFloat("HeadShot", this.headShot);
tag.putFloat("MonsterMultiple", this.monsterMultiple);
tag.putFloat("MonsterMultiplier", this.monsterMultiplier);
tag.putFloat("LegShot", this.legShot);
tag.putFloat("BypassArmorRate", this.bypassArmorRate);
tag.putFloat("UndeadMultiple", this.undeadMultiple);
@ -379,7 +379,7 @@ public class ProjectileEntity extends Projectile implements IEntityWithComplexSp
this.onHitBlock(hitVec);
if (heLevel > 0) {
explosionBulletBlock(this, this.damage, heLevel, monsterMultiple + 1, hitVec);
explosionBulletBlock(this, this.damage, heLevel, monsterMultiplier + 1, hitVec);
}
if (fireLevel > 0 && this.level() instanceof ServerLevel serverLevel) {
ParticleTool.sendParticle(serverLevel, ParticleTypes.LAVA, hitVec.x, hitVec.y, hitVec.z,
@ -472,7 +472,7 @@ public class ProjectileEntity extends Projectile implements IEntityWithComplexSp
protected void onHitEntity(Entity entity, boolean headshot, boolean legShot) {
if (this.shooter == null) return;
float mMultiple = 1 + this.monsterMultiple;
float mMultiple = 1 + this.monsterMultiplier;
if (entity == null) return;
@ -842,8 +842,8 @@ public class ProjectileEntity extends Projectile implements IEntityWithComplexSp
return this;
}
public ProjectileEntity monsterMultiple(float monsterMultiple) {
this.monsterMultiple = monsterMultiple;
public ProjectileEntity setMonsterMultiplier(float monsterMultiplier) {
this.monsterMultiplier = monsterMultiplier;
return this;
}

View file

@ -40,8 +40,7 @@ public class ModPerks {
public static final DeferredHolder<Perk, Perk> BEAST_BULLET = AMMO_PERKS.register("beast_bullet", BeastBullet::new);
public static final DeferredHolder<Perk, Perk> LONGER_WIRE = AMMO_PERKS.register("longer_wire", () -> new Perk("longer_wire", Perk.Type.AMMO));
public static final DeferredHolder<Perk, Perk> INCENDIARY_BULLET = AMMO_PERKS.register("incendiary_bullet", IncendiaryBullet::new);
public static final DeferredHolder<Perk, Perk> MICRO_MISSILE = AMMO_PERKS.register("micro_missile",
() -> new AmmoPerk(new AmmoPerk.Builder("micro_missile", Perk.Type.AMMO).speedRate(1.2f)));
public static final DeferredHolder<Perk, Perk> MICRO_MISSILE = AMMO_PERKS.register("micro_missile", MicroMissile::new);
/**
* Functional Perks

View file

@ -26,7 +26,6 @@ import org.jetbrains.annotations.Nullable;
import java.util.Objects;
import java.util.UUID;
import java.util.WeakHashMap;
public class GunData {
public final ItemStack stack;
@ -251,7 +250,6 @@ public class GunData {
return item.getCustomWeight(stack);
}
public double defaultZoom() {
return defaultGunData().defaultZoom;
}

View file

@ -9,6 +9,7 @@ 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.data.GunData;
import com.atsuishio.superbwarfare.perk.AmmoPerk;
import com.atsuishio.superbwarfare.perk.Perk;
import com.atsuishio.superbwarfare.perk.PerkHelper;
import com.atsuishio.superbwarfare.tools.ParticleTool;
@ -131,23 +132,18 @@ public class M79Item extends GunItem implements GeoItem {
(float) data.explosionRadius()
);
float velocity = (float) data.velocity();
for (Perk.Type type : Perk.Type.values()) {
var instance = data.perk.getInstance(type);
if (instance != null) {
instance.perk().modifyProjectile(data, instance, gunGrenadeEntity);
if (instance.perk() instanceof AmmoPerk ammoPerk) {
velocity = (float) ammoPerk.getModifiedVelocity(data, instance);
}
}
}
gunGrenadeEntity.setNoGravity(data.perk.get(Perk.Type.AMMO) == ModPerks.MICRO_MISSILE.get());
float velocity = (float) data.velocity();
int perkLevel = data.perk.getLevel(ModPerks.MICRO_MISSILE);
if (perkLevel > 0) {
gunGrenadeEntity.setExplosionRadius((float) data.explosionRadius() * 0.5f);
gunGrenadeEntity.setDamage((float) data.explosionDamage() * (1.1f + perkLevel * 0.1f));
velocity *= 1.2f;
}
gunGrenadeEntity.setPos(player.getX(), player.getEyeY() - 0.1, player.getZ());
gunGrenadeEntity.shoot(player.getLookAngle().x, player.getLookAngle().y, player.getLookAngle().z, velocity,
(float) (zoom ? 0.1 : spread));

View file

@ -9,6 +9,7 @@ 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.data.GunData;
import com.atsuishio.superbwarfare.perk.AmmoPerk;
import com.atsuishio.superbwarfare.perk.Perk;
import com.atsuishio.superbwarfare.perk.PerkHelper;
import com.atsuishio.superbwarfare.tools.ParticleTool;
@ -156,23 +157,15 @@ public class RpgItem extends GunItem implements GeoItem {
(float) data.explosionRadius()
);
float velocity = (float) data.velocity();
for (Perk.Type type : Perk.Type.values()) {
var instance = data.perk.getInstance(type);
if (instance != null) {
instance.perk().modifyProjectile(data, instance, rocket);
}
}
float velocity = (float) data.velocity();
if (data.perk.get(Perk.Type.AMMO) == ModPerks.MICRO_MISSILE.get()) {
rocket.setNoGravity(true);
int perkLevel = data.perk.getLevel(ModPerks.MICRO_MISSILE);
if (perkLevel > 0) {
rocket.setExplosionRadius((float) (data.explosionRadius() * 0.5f));
rocket.setDamage((float) data.damage() * (1.1f + perkLevel * 0.1f));
velocity *= 1.2f;
if (instance.perk() instanceof AmmoPerk ammoPerk) {
velocity = (float) ammoPerk.getModifiedVelocity(data, instance);
}
}
}

View file

@ -12,6 +12,7 @@ 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.data.GunData;
import com.atsuishio.superbwarfare.perk.AmmoPerk;
import com.atsuishio.superbwarfare.perk.Perk;
import com.atsuishio.superbwarfare.perk.PerkHelper;
import com.atsuishio.superbwarfare.tools.ParticleTool;
@ -248,24 +249,20 @@ public class SecondaryCataclysm extends GunItem implements GeoItem, EnergyStorag
(float) data.explosionRadius()
);
float velocity = (float) data.velocity();
for (Perk.Type type : Perk.Type.values()) {
var instance = data.perk.getInstance(type);
if (instance != null) {
instance.perk().modifyProjectile(data, instance, gunGrenadeEntity);
if (instance.perk() instanceof AmmoPerk ammoPerk) {
velocity = (float) ammoPerk.getModifiedVelocity(data, instance);
}
}
}
gunGrenadeEntity.setNoGravity(data.perk.get(Perk.Type.AMMO) == ModPerks.MICRO_MISSILE.get());
gunGrenadeEntity.charged(isChargedFire);
float velocity = (float) data.velocity();
int perkLevel = data.perk.getLevel(ModPerks.MICRO_MISSILE);
if (perkLevel > 0) {
gunGrenadeEntity.setExplosionRadius((float) data.explosionRadius() * 0.5f);
gunGrenadeEntity.setDamage((float) data.damage() * (1.1f + perkLevel * 0.1f));
velocity *= 1.2f;
}
gunGrenadeEntity.setPos(player.getX(), player.getEyeY() - 0.1, player.getZ());
gunGrenadeEntity.shoot(player.getLookAngle().x, player.getLookAngle().y, player.getLookAngle().z, (isChargedFire ? 4 : 1) * velocity,
(float) (zoom ? 0.1 : spread));

View file

@ -0,0 +1,30 @@
package com.atsuishio.superbwarfare.perk.ammo;
import com.atsuishio.superbwarfare.entity.projectile.GunGrenadeEntity;
import com.atsuishio.superbwarfare.entity.projectile.RpgRocketEntity;
import com.atsuishio.superbwarfare.item.gun.data.GunData;
import com.atsuishio.superbwarfare.perk.AmmoPerk;
import com.atsuishio.superbwarfare.perk.Perk;
import com.atsuishio.superbwarfare.perk.PerkInstance;
import net.minecraft.world.entity.Entity;
public class MicroMissile extends AmmoPerk {
public MicroMissile() {
super(new AmmoPerk.Builder("micro_missile", Perk.Type.AMMO).speedRate(1.2f));
}
@Override
public void modifyProjectile(GunData data, PerkInstance instance, Entity entity) {
float radius = (float) (data.explosionRadius() * 0.5f);
float damage = (float) data.explosionDamage() * (1.1f + instance.level() * 0.1f);
entity.setNoGravity(true);
if (entity instanceof GunGrenadeEntity projectile) {
projectile.setExplosionRadius(radius);
projectile.setExplosionDamage(damage);
} else if (entity instanceof RpgRocketEntity projectile) {
projectile.setExplosionRadius(radius);
projectile.setExplosionDamage(damage);
}
}
}

View file

@ -19,7 +19,7 @@ public class MonsterHunter extends Perk {
public void modifyProjectile(GunData data, PerkInstance instance, Entity entity) {
float multiplier = 0.1f + 0.1f * instance.level();
if (entity instanceof ProjectileEntity projectile) {
projectile.monsterMultiple(multiplier);
projectile.setMonsterMultiplier(multiplier);
} else if (entity instanceof JavelinMissileEntity projectile) {
projectile.setMonsterMultiplier(multiplier);
} else if (entity instanceof GunGrenadeEntity projectile) {