添加泰瑟木仓电击的持续伤害
This commit is contained in:
parent
9537ede756
commit
08fbb285f7
3 changed files with 62 additions and 6 deletions
|
@ -113,11 +113,66 @@ public class TaserBulletProjectileEntity extends ThrowableItemProjectile {
|
|||
}
|
||||
|
||||
if (headshot) {
|
||||
entity.hurt(TargetModDamageTypes.causeShockDamage(this.level().registryAccess(), this, this.getOwner()), this.damage * 1.5f);
|
||||
entity.hurt(TargetModDamageTypes.causeShockDamage(this.level().registryAccess(), this.getOwner()), this.damage * 1.5f);
|
||||
} else {
|
||||
entity.hurt(TargetModDamageTypes.causeShockDamage(this.level().registryAccess(), this, this.getOwner()), this.damage);
|
||||
entity.hurt(TargetModDamageTypes.causeShockDamage(this.level().registryAccess(), this.getOwner()), this.damage);
|
||||
}
|
||||
|
||||
TargetMod.queueServerWork(20, () -> {
|
||||
if (entity == null || this.getOwner() == null || !entity.isAlive())
|
||||
return;
|
||||
if (!entity.level().isClientSide())
|
||||
entity.hurt(TargetModDamageTypes.causeShockDamage(this.level().registryAccess(), this.getOwner()), 1);
|
||||
entity.invulnerableTime = 0;
|
||||
if (this.getOwner() instanceof ServerPlayer player) {
|
||||
this.getOwner().level().playSound(null, this.getOwner().blockPosition(), TargetModSounds.INDICATION.get(), SoundSource.VOICE, 1, 1);
|
||||
TargetMod.PACKET_HANDLER.send(PacketDistributor.PLAYER.with(() -> player), new ClientIndicatorMessage(0, 5));
|
||||
}
|
||||
});
|
||||
TargetMod.queueServerWork(40, () -> {
|
||||
if (entity == null || this.getOwner() == null || !entity.isAlive())
|
||||
return;
|
||||
if (!entity.level().isClientSide())
|
||||
entity.hurt(TargetModDamageTypes.causeShockDamage(this.level().registryAccess(), this.getOwner()), 1);
|
||||
entity.invulnerableTime = 0;
|
||||
if (this.getOwner() instanceof ServerPlayer player) {
|
||||
this.getOwner().level().playSound(null, this.getOwner().blockPosition(), TargetModSounds.INDICATION.get(), SoundSource.VOICE, 1, 1);
|
||||
TargetMod.PACKET_HANDLER.send(PacketDistributor.PLAYER.with(() -> player), new ClientIndicatorMessage(0, 5));
|
||||
}
|
||||
});
|
||||
TargetMod.queueServerWork(60, () -> {
|
||||
if (entity == null || this.getOwner() == null || !entity.isAlive())
|
||||
return;
|
||||
if (!entity.level().isClientSide())
|
||||
entity.hurt(TargetModDamageTypes.causeShockDamage(this.level().registryAccess(), this.getOwner()), 1);
|
||||
entity.invulnerableTime = 0;
|
||||
if (this.getOwner() instanceof ServerPlayer player) {
|
||||
this.getOwner().level().playSound(null, this.getOwner().blockPosition(), TargetModSounds.INDICATION.get(), SoundSource.VOICE, 1, 1);
|
||||
TargetMod.PACKET_HANDLER.send(PacketDistributor.PLAYER.with(() -> player), new ClientIndicatorMessage(0, 5));
|
||||
}
|
||||
});
|
||||
TargetMod.queueServerWork(80, () -> {
|
||||
if (entity == null || this.getOwner() == null || !entity.isAlive())
|
||||
return;
|
||||
if (!entity.level().isClientSide())
|
||||
entity.hurt(TargetModDamageTypes.causeShockDamage(this.level().registryAccess(), this.getOwner()), 1);
|
||||
entity.invulnerableTime = 0;
|
||||
if (this.getOwner() instanceof ServerPlayer player) {
|
||||
this.getOwner().level().playSound(null, this.getOwner().blockPosition(), TargetModSounds.INDICATION.get(), SoundSource.VOICE, 1, 1);
|
||||
TargetMod.PACKET_HANDLER.send(PacketDistributor.PLAYER.with(() -> player), new ClientIndicatorMessage(0, 5));
|
||||
}
|
||||
});
|
||||
TargetMod.queueServerWork(100, () -> {
|
||||
if (entity == null || this.getOwner() == null || !entity.isAlive())
|
||||
return;
|
||||
if (!entity.level().isClientSide())
|
||||
entity.hurt(TargetModDamageTypes.causeShockDamage(this.level().registryAccess(), this.getOwner()), 1);
|
||||
entity.invulnerableTime = 0;
|
||||
if (this.getOwner() instanceof ServerPlayer player) {
|
||||
this.getOwner().level().playSound(null, this.getOwner().blockPosition(), TargetModSounds.INDICATION.get(), SoundSource.VOICE, 1, 1);
|
||||
TargetMod.PACKET_HANDLER.send(PacketDistributor.PLAYER.with(() -> player), new ClientIndicatorMessage(0, 5));
|
||||
}
|
||||
});
|
||||
this.discard();
|
||||
}
|
||||
|
||||
|
|
|
@ -44,8 +44,8 @@ public class TargetModDamageTypes {
|
|||
return new DamageMessages(registryAccess.registry(Registries.DAMAGE_TYPE).get().getHolderOrThrow(MINE), entity);
|
||||
}
|
||||
|
||||
public static DamageSource causeShockDamage(RegistryAccess registryAccess, @Nullable Entity directEntity, @Nullable Entity attacker) {
|
||||
return new DamageMessages(registryAccess.registry(Registries.DAMAGE_TYPE).get().getHolderOrThrow(SHOCK), directEntity, attacker);
|
||||
public static DamageSource causeShockDamage(RegistryAccess registryAccess, @Nullable Entity attacker) {
|
||||
return new DamageMessages(registryAccess.registry(Registries.DAMAGE_TYPE).get().getHolderOrThrow(SHOCK), attacker);
|
||||
}
|
||||
|
||||
private static class DamageMessages extends DamageSource {
|
||||
|
|
|
@ -23,7 +23,8 @@ public class LivingEntityMixin {
|
|||
@ModifyArg(method = "hurt", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/LivingEntity;knockback(DDD)V"), index = 0)
|
||||
private double modifyApplyKnockbackArgs(double original) {
|
||||
if (this.target$source.is(TargetModDamageTypes.GUN_FIRE) || this.target$source.is(TargetModDamageTypes.GUN_FIRE_HEADSHOT)
|
||||
|| this.target$source.is(TargetModDamageTypes.ARROW_IN_KNEE) || this.target$source.is(TargetModDamageTypes.ARROW_IN_BRAIN)) {
|
||||
|| this.target$source.is(TargetModDamageTypes.ARROW_IN_KNEE) || this.target$source.is(TargetModDamageTypes.ARROW_IN_BRAIN)
|
||||
|| this.target$source.is(TargetModDamageTypes.SHOCK)) {
|
||||
return 0.1 * original;
|
||||
}
|
||||
return original;
|
||||
|
|
Loading…
Add table
Reference in a new issue