优化阔剑判定逻辑
This commit is contained in:
parent
aa5214e5f2
commit
f253584120
5 changed files with 22 additions and 23 deletions
|
@ -145,6 +145,8 @@ public class KillMessageOverlay {
|
|||
icon = EXPLOSION;
|
||||
} else if (record.damageType == DamageTypes.PLAYER_ATTACK) {
|
||||
icon = KNIFE;
|
||||
} else if (record.damageType == TargetModDamageTypes.MINE) {
|
||||
icon = CLAYMORE;
|
||||
} else {
|
||||
icon = GENERIC;
|
||||
}
|
||||
|
|
|
@ -203,14 +203,10 @@ public class ClaymoreEntity extends TamableAnimal implements GeoEntity, Animated
|
|||
var y = this.getY();
|
||||
var z = this.getZ();
|
||||
|
||||
if (data.getInt("claymore") > 0) {
|
||||
data.putInt("claymore", data.getInt("claymore") - 1);
|
||||
}
|
||||
|
||||
data.putInt("life", data.getInt("life") + 1);
|
||||
if (data.getInt("life") >= 12000) {
|
||||
if (this.tickCount >= 12000) {
|
||||
if (!this.level().isClientSide()) this.discard();
|
||||
}
|
||||
|
||||
if (data.getDouble("def") >= 100) {
|
||||
if (!this.level().isClientSide()) this.discard();
|
||||
|
||||
|
@ -226,11 +222,14 @@ public class ClaymoreEntity extends TamableAnimal implements GeoEntity, Animated
|
|||
server.addFreshEntity(entityToSpawn);
|
||||
}
|
||||
}
|
||||
|
||||
this.removeAllEffects();
|
||||
this.clearFire();
|
||||
|
||||
if (data.getInt("trigger") <= 60) {
|
||||
data.putInt("trigger", data.getInt("trigger") + 1);
|
||||
}
|
||||
|
||||
if (data.getInt("trigger") >= 40) {
|
||||
final Vec3 center = new Vec3(x + 1.5 * this.getLookAngle().x, y + 1.5 * this.getLookAngle().y, z + 1.5 * this.getLookAngle().z);
|
||||
for (Entity target : level.getEntitiesOfClass(Entity.class, new AABB(center, center).inflate(2.5 / 2d), e -> true).stream().sorted(Comparator.comparingDouble(e -> e.distanceToSqr(center))).toList()) {
|
||||
|
@ -249,10 +248,10 @@ public class ClaymoreEntity extends TamableAnimal implements GeoEntity, Animated
|
|||
}
|
||||
this.discard();
|
||||
}
|
||||
target.getPersistentData().putInt("claymore", 5);
|
||||
|
||||
TargetMod.queueServerWork(1, () -> {
|
||||
if (!level.isClientSide())
|
||||
level.explode(this.getOwner(), target.getX(), target.getY(), target.getZ(), 6.5f, Level.ExplosionInteraction.NONE);
|
||||
level.explode(this, target.getX(), target.getY(), target.getZ(), 6.5f, Level.ExplosionInteraction.NONE);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -311,14 +310,14 @@ public class ClaymoreEntity extends TamableAnimal implements GeoEntity, Animated
|
|||
.add(Attributes.KNOCKBACK_RESISTANCE, 1);
|
||||
}
|
||||
|
||||
private PlayState movementPredicate(AnimationState event) {
|
||||
private PlayState movementPredicate(AnimationState<ClaymoreEntity> event) {
|
||||
if (this.animationProcedure.equals("empty")) {
|
||||
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.claymore.idle"));
|
||||
}
|
||||
return PlayState.STOP;
|
||||
}
|
||||
|
||||
private PlayState procedurePredicate(AnimationState event) {
|
||||
private PlayState procedurePredicate(AnimationState<ClaymoreEntity> event) {
|
||||
if (!animationProcedure.equals("empty") && event.getController().getAnimationState() == AnimationController.State.STOPPED) {
|
||||
event.getController().setAnimation(RawAnimation.begin().thenPlay(this.animationProcedure));
|
||||
if (event.getController().getAnimationState() == AnimationController.State.STOPPED) {
|
||||
|
@ -336,7 +335,6 @@ public class ClaymoreEntity extends TamableAnimal implements GeoEntity, Animated
|
|||
++this.deathTime;
|
||||
if (this.deathTime == 1) {
|
||||
this.remove(ClaymoreEntity.RemovalReason.KILLED);
|
||||
this.dropExperience();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package net.mcreator.target.event;
|
||||
|
||||
import net.mcreator.target.TargetMod;
|
||||
import net.mcreator.target.entity.ClaymoreEntity;
|
||||
import net.mcreator.target.init.TargetModDamageTypes;
|
||||
import net.mcreator.target.init.TargetModItems;
|
||||
import net.mcreator.target.init.TargetModSounds;
|
||||
|
@ -34,7 +35,7 @@ import net.minecraftforge.fml.common.Mod;
|
|||
import net.minecraftforge.network.PacketDistributor;
|
||||
|
||||
@Mod.EventBusSubscriber
|
||||
public class LivingEntityEventHandler {
|
||||
public class LivingEventHandler {
|
||||
@SubscribeEvent
|
||||
public static void onEntityHurt(LivingHurtEvent event) {
|
||||
if (event == null || event.getEntity() == null) {
|
||||
|
@ -106,15 +107,15 @@ public class LivingEntityEventHandler {
|
|||
private static void claymoreDamage(LivingAttackEvent event) {
|
||||
LivingEntity entity = event.getEntity();
|
||||
DamageSource source = event.getSource();
|
||||
Entity sourceentity = source.getDirectEntity();
|
||||
Entity sourceentity = source.getEntity();
|
||||
|
||||
if (event.getEntity() == null || entity == null || sourceentity == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ((source.is(DamageTypes.EXPLOSION) || source.is(DamageTypes.PLAYER_EXPLOSION)) && entity.getPersistentData().getDouble("claymore") > 0) {
|
||||
if ((source.is(DamageTypes.EXPLOSION) || source.is(DamageTypes.PLAYER_EXPLOSION)) && sourceentity instanceof ClaymoreEntity claymore) {
|
||||
event.setCanceled(true);
|
||||
entity.hurt(TargetModDamageTypes.causeMineDamage(entity.level().registryAccess(), sourceentity), event.getAmount());
|
||||
entity.hurt(TargetModDamageTypes.causeMineDamage(entity.level().registryAccess(), claymore.getOwner()), event.getAmount());
|
||||
}
|
||||
}
|
||||
|
|
@ -146,10 +146,6 @@
|
|||
"item.target.galena": "Raw Galena",
|
||||
"item.target.scheelite": "Raw Galena",
|
||||
|
||||
"death.attack.mine.item": "%1$s step on %2$s's Claymore",
|
||||
"death.attack.mine": "%1$s step on %2$s's Claymore",
|
||||
"death.attack.mine.player": "%1$s step on %2$s's Claymore",
|
||||
|
||||
"death.attack.gunfire": "%1$s was shoot by %2$s",
|
||||
"death.attack.gunfire.entity": "%1$s was shoot by %2$s",
|
||||
"death.attack.gunfire.item": "%1$s was shoot by %2$s using %3$s",
|
||||
|
@ -163,6 +159,9 @@
|
|||
"death.attack.arrow_in_brain.entity": "An arrow shot into %1$s's brain whilst trying to escape %2$s",
|
||||
"death.attack.arrow_in_brain.item": "%2$s used %3$s to make an arrow shot into %1$s's brain",
|
||||
"death.attack.beast_gun": "%1$s was killed by %2$s using BEAST guns",
|
||||
"death.attack.mine": "%1$s不慎踩到了阔剑地雷",
|
||||
"death.attack.mine.entity": "%1$s step on %2$s's Claymore",
|
||||
"death.attack.mine.item": "%1$s踩到了%2$s的阔剑地雷",
|
||||
|
||||
"Shell Estimated Range": "Estimated Range:",
|
||||
"gui.target.mortar_gui.label_proc_range": "Estimated Range:",
|
||||
|
|
|
@ -146,10 +146,6 @@
|
|||
"item.target.galena": "粗方铅矿",
|
||||
"item.target.scheelite": "白钨矿",
|
||||
|
||||
"death.attack.mine.item": "%1$s踩到了%2$s的阔剑地雷",
|
||||
"death.attack.mine": "%1$s踩到了%2$s的阔剑地雷",
|
||||
"death.attack.mine.player": "%1$s在逃离%2$s的时候踩到了阔剑地雷",
|
||||
|
||||
"death.attack.gunfire": "%1$s被%2$s射爆了",
|
||||
"death.attack.gunfire.entity": "%1$s被%2$s射爆了",
|
||||
"death.attack.gunfire.item": "%1$s被%2$s用%3$s射爆了",
|
||||
|
@ -163,6 +159,9 @@
|
|||
"death.attack.arrow_in_brain.entity": "%1$s在逃离%2$s的时候脑子进矢了",
|
||||
"death.attack.arrow_in_brain.item": "%2$s用%3$s让%1$s的脑子进矢了",
|
||||
"death.attack.beast_gun": "%1$s被%2$s用BEAST枪械臭炸了",
|
||||
"death.attack.mine": "%1$s不慎踩到了阔剑地雷",
|
||||
"death.attack.mine.entity": "%1$s踩到了%2$s的阔剑地雷",
|
||||
"death.attack.mine.item": "%1$s踩到了%2$s的阔剑地雷",
|
||||
|
||||
"Shell Estimated Range": "炮弹预估射程:",
|
||||
"gui.target.mortar_gui.label_proc_range": "预估射程:",
|
||||
|
|
Loading…
Add table
Reference in a new issue