优化两个taser的perk
This commit is contained in:
parent
e120a002f2
commit
7a24ea05d1
6 changed files with 93 additions and 10 deletions
|
@ -52,10 +52,40 @@ public class TaserBulletEntity extends AbstractArrow implements GeoEntity {
|
|||
this.wireLength = wireLength;
|
||||
}
|
||||
|
||||
public TaserBulletEntity(LivingEntity entity, Level level, float damage) {
|
||||
super(ModEntities.TASER_BULLET.get(), level);
|
||||
this.damage = damage;
|
||||
}
|
||||
|
||||
public TaserBulletEntity(EntityType<? extends TaserBulletEntity> type, Level world) {
|
||||
super(type, world);
|
||||
this.noCulling = true;
|
||||
}
|
||||
|
||||
public float getDamage() {
|
||||
return damage;
|
||||
}
|
||||
|
||||
public void setDamage(float damage) {
|
||||
this.damage = damage;
|
||||
}
|
||||
|
||||
public int getVolt() {
|
||||
return volt;
|
||||
}
|
||||
|
||||
public void setVolt(int volt) {
|
||||
this.volt = volt;
|
||||
}
|
||||
|
||||
public int getWireLength() {
|
||||
return wireLength;
|
||||
}
|
||||
|
||||
public void setWireLength(int wireLength) {
|
||||
this.wireLength = wireLength;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playerTouch(@NotNull Player pEntity) {
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ public class ModPerks {
|
|||
() -> new AmmoPerk(new AmmoPerk.Builder("poisonous_bullet", Perk.Type.AMMO).bypassArmorRate(0.0f).damageRate(1.0f).speedRate(1.0f).rgb(48, 131, 6)
|
||||
.mobEffect(MobEffects.POISON::value)));
|
||||
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> LONGER_WIRE = AMMO_PERKS.register("longer_wire", LongerWire::new);
|
||||
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", MicroMissile::new);
|
||||
|
||||
|
@ -66,7 +66,7 @@ public class ModPerks {
|
|||
public static final DeferredHolder<Perk, Perk> KILLING_TALLY = DAMAGE_PERKS.register("killing_tally", KillingTally::new);
|
||||
public static final DeferredHolder<Perk, Perk> HEAD_SEEKER = DAMAGE_PERKS.register("head_seeker", HeadSeeker::new);
|
||||
public static final DeferredHolder<Perk, Perk> MONSTER_HUNTER = DAMAGE_PERKS.register("monster_hunter", MonsterHunter::new);
|
||||
public static final DeferredHolder<Perk, Perk> VOLT_OVERLOAD = DAMAGE_PERKS.register("volt_overload", () -> new Perk("volt_overload", Perk.Type.DAMAGE));
|
||||
public static final DeferredHolder<Perk, Perk> VOLT_OVERLOAD = DAMAGE_PERKS.register("volt_overload", VoltOverload::new);
|
||||
public static final DeferredHolder<Perk, Perk> DESPERADO = DAMAGE_PERKS.register("desperado", Desperado::new);
|
||||
public static final DeferredHolder<Perk, Perk> VORPAL_WEAPON = DAMAGE_PERKS.register("vorpal_weapon", VorpalWeapon::new);
|
||||
|
||||
|
|
|
@ -181,17 +181,21 @@ public class TaserItem extends GunItem implements GeoItem, EnergyStorageItem {
|
|||
player.getCooldowns().addCooldown(stack.getItem(), 5);
|
||||
|
||||
if (player instanceof ServerPlayer serverPlayer) {
|
||||
int volt = data.perk.getLevel(ModPerks.VOLT_OVERLOAD);
|
||||
int wireLength = data.perk.getLevel(ModPerks.LONGER_WIRE);
|
||||
|
||||
var level = serverPlayer.level();
|
||||
TaserBulletEntity taserBulletProjectile = new TaserBulletEntity(player, level,
|
||||
(float) data.damage(), volt, wireLength);
|
||||
TaserBulletEntity projectile = new TaserBulletEntity(player, level,
|
||||
(float) data.damage());
|
||||
|
||||
taserBulletProjectile.setPos(player.getX(), player.getEyeY() - 0.1, player.getZ());
|
||||
taserBulletProjectile.shoot(player.getLookAngle().x, player.getLookAngle().y, player.getLookAngle().z, (float) data.velocity(),
|
||||
for (Perk.Type type : Perk.Type.values()) {
|
||||
var instance = data.perk.getInstance(type);
|
||||
if (instance != null) {
|
||||
instance.perk().modifyProjectile(data, instance, projectile);
|
||||
}
|
||||
}
|
||||
|
||||
projectile.setPos(player.getX(), player.getEyeY() - 0.1, player.getZ());
|
||||
projectile.shoot(player.getLookAngle().x, player.getLookAngle().y, player.getLookAngle().z, (float) data.velocity(),
|
||||
(float) (zoom ? 0.1 : spread));
|
||||
level.addFreshEntity(taserBulletProjectile);
|
||||
level.addFreshEntity(projectile);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -30,6 +30,12 @@ public class AmmoPerk extends Perk {
|
|||
this.mobEffects = () -> builder.mobEffects;
|
||||
}
|
||||
|
||||
public AmmoPerk(String descriptionId, Type type) {
|
||||
super(descriptionId, type);
|
||||
this.rgb = new float[]{1, 222 / 255f, 39 / 255f};
|
||||
this.mobEffects = ArrayList::new;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modifyProjectile(GunData data, PerkInstance instance, Entity entity) {
|
||||
if (!(entity instanceof ProjectileEntity projectile)) return;
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
package com.atsuishio.superbwarfare.perk.ammo;
|
||||
|
||||
import com.atsuishio.superbwarfare.entity.projectile.TaserBulletEntity;
|
||||
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 LongerWire extends AmmoPerk {
|
||||
|
||||
public LongerWire() {
|
||||
super("longer_wire", Perk.Type.AMMO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modifyProjectile(GunData data, PerkInstance instance, Entity entity) {
|
||||
if (entity instanceof TaserBulletEntity taserBulletEntity) {
|
||||
taserBulletEntity.setWireLength(instance.level());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package com.atsuishio.superbwarfare.perk.damage;
|
||||
|
||||
import com.atsuishio.superbwarfare.entity.projectile.TaserBulletEntity;
|
||||
import com.atsuishio.superbwarfare.item.gun.data.GunData;
|
||||
import com.atsuishio.superbwarfare.perk.Perk;
|
||||
import com.atsuishio.superbwarfare.perk.PerkInstance;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
|
||||
public class VoltOverload extends Perk {
|
||||
|
||||
public VoltOverload() {
|
||||
super("volt_overload", Perk.Type.DAMAGE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modifyProjectile(GunData data, PerkInstance instance, Entity entity) {
|
||||
if (entity instanceof TaserBulletEntity taserBulletEntity) {
|
||||
taserBulletEntity.setVolt(instance.level());
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue