调整无人机榴弹的伤害
This commit is contained in:
parent
88dc8d574d
commit
aa6118e27f
3 changed files with 11 additions and 24 deletions
|
@ -6,9 +6,12 @@ import net.mcreator.target.entity.DroneEntity;
|
||||||
import net.mcreator.target.init.TargetModItems;
|
import net.mcreator.target.init.TargetModItems;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.renderer.GameRenderer;
|
import net.minecraft.client.renderer.GameRenderer;
|
||||||
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
import net.minecraft.world.level.ClipContext;
|
||||||
|
import net.minecraft.world.phys.Vec3;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.client.event.RenderGuiEvent;
|
import net.minecraftforge.client.event.RenderGuiEvent;
|
||||||
import net.minecraftforge.eventbus.api.EventPriority;
|
import net.minecraftforge.eventbus.api.EventPriority;
|
||||||
|
@ -46,16 +49,12 @@ public class DroneUIOverlay {
|
||||||
double distance = player.distanceTo(entity);
|
double distance = player.distanceTo(entity);
|
||||||
int color = -1;
|
int color = -1;
|
||||||
|
|
||||||
event.getGuiGraphics().drawString(Minecraft.getInstance().font, "MaxDistance:" + new DecimalFormat("##.#").format(MAX_DISTANCE) + "M", w / 2 + 10, h / 2 + 50, color, false);
|
// event.getGuiGraphics().drawString(Minecraft.getInstance().font, "MaxDistance:" + new DecimalFormat("##.#").format(MAX_DISTANCE) + "M", w / 2 + 10, h / 2 + 50, color, false);
|
||||||
|
|
||||||
if (distance > MAX_DISTANCE) {
|
if (distance > MAX_DISTANCE - 48) {
|
||||||
event.getGuiGraphics().drawString(Minecraft.getInstance().font, "WARNING", w / 2 + -18, h / 2 + -47, -65536, false);
|
event.getGuiGraphics().drawString(Minecraft.getInstance().font, "WARNING", w / 2 + -18, h / 2 + -47, -65536, false);
|
||||||
color = -65536;
|
color = -65536;
|
||||||
}
|
}
|
||||||
|
|
||||||
event.getGuiGraphics().drawString(Minecraft.getInstance().font, "Distance:" + new DecimalFormat("##.#").format(distance) + "M", w / 2 + 10, h / 2 + 33, color, false);
|
|
||||||
event.getGuiGraphics().drawString(Minecraft.getInstance().font, "Health:" + new DecimalFormat("##.#").format(entity.getHealth()) + "/" + new DecimalFormat("##").format(entity.getMaxHealth()), w / 2 - 77, h / 2 + 33, -1, false);
|
|
||||||
event.getGuiGraphics().drawString(Minecraft.getInstance().font, "AMMO:" + new DecimalFormat("##.#").format(entity.getEntityData().get(AMMO)) + " / 6", w / 2 + 12, h / 2 + -37, -1, false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
RenderSystem.depthMask(true);
|
RenderSystem.depthMask(true);
|
||||||
|
|
|
@ -58,22 +58,9 @@ public class DroneGrenadeEntity extends ThrowableItemProjectile {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onHitEntity(EntityHitResult result) {
|
protected void onHitEntity(EntityHitResult result) {
|
||||||
Entity entity = result.getEntity();
|
|
||||||
if (this.getOwner() instanceof LivingEntity living) {
|
|
||||||
if (!living.level().isClientSide() && living instanceof ServerPlayer player) {
|
|
||||||
living.level().playSound(null, living.blockPosition(), TargetModSounds.INDICATION.get(), SoundSource.VOICE, 1, 1);
|
|
||||||
TargetMod.PACKET_HANDLER.send(PacketDistributor.PLAYER.with(() -> player), new ClientIndicatorMessage(0, 5));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (entity instanceof LivingEntity) {
|
|
||||||
entity.invulnerableTime = 0;
|
|
||||||
}
|
|
||||||
entity.hurt(TargetModDamageTypes.causeProjectileBoomDamage(this.level().registryAccess(), this, this.getOwner()), 5);
|
|
||||||
if (this.level() instanceof ServerLevel) {
|
if (this.level() instanceof ServerLevel) {
|
||||||
causeExplode();
|
causeExplode();
|
||||||
this.discard();
|
|
||||||
}
|
}
|
||||||
this.discard();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -82,7 +69,6 @@ public class DroneGrenadeEntity extends ThrowableItemProjectile {
|
||||||
if (this.level() instanceof ServerLevel) {
|
if (this.level() instanceof ServerLevel) {
|
||||||
causeExplode();
|
causeExplode();
|
||||||
}
|
}
|
||||||
this.discard();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -96,18 +82,18 @@ public class DroneGrenadeEntity extends ThrowableItemProjectile {
|
||||||
if (this.level() instanceof ServerLevel) {
|
if (this.level() instanceof ServerLevel) {
|
||||||
causeExplode();
|
causeExplode();
|
||||||
}
|
}
|
||||||
this.discard();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void causeExplode() {
|
private void causeExplode() {
|
||||||
CustomExplosion explosion = new CustomExplosion(this.level(), this,
|
CustomExplosion explosion = new CustomExplosion(this.level(), this,
|
||||||
TargetModDamageTypes.causeProjectileBoomDamage(this.level().registryAccess(), this, this.getOwner()), 60,
|
TargetModDamageTypes.causeProjectileBoomDamage(this.level().registryAccess(), this, this.getOwner()), 55,
|
||||||
this.getX(), this.getY(), this.getZ(), 5f, Explosion.BlockInteraction.KEEP).setDamageMultiplier(1);
|
this.getX(), this.getY(), this.getZ(), 6.5f, Explosion.BlockInteraction.KEEP).setDamageMultiplier(1);
|
||||||
explosion.explode();
|
explosion.explode();
|
||||||
net.minecraftforge.event.ForgeEventFactory.onExplosionStart(this.level(), explosion);
|
net.minecraftforge.event.ForgeEventFactory.onExplosionStart(this.level(), explosion);
|
||||||
explosion.finalizeExplosion(false);
|
explosion.finalizeExplosion(false);
|
||||||
ParticleTool.spawnMediumExplosionParticles(this.level(), this.position());
|
ParticleTool.spawnMediumExplosionParticles(this.level(), this.position());
|
||||||
|
this.discard();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -152,7 +152,9 @@ public class CustomExplosion extends Explosion {
|
||||||
} else {
|
} else {
|
||||||
entity.hurt(this.damageSource, (float) ((int) damageFinal));
|
entity.hurt(this.damageSource, (float) ((int) damageFinal));
|
||||||
}
|
}
|
||||||
|
if (entity instanceof LivingEntity) {
|
||||||
|
entity.invulnerableTime = 0;
|
||||||
|
}
|
||||||
if (fireTime > 0) {
|
if (fireTime > 0) {
|
||||||
entity.setSecondsOnFire(fireTime);
|
entity.setSecondsOnFire(fireTime);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue