From b6fad2316d816a290aac888c79ed177dbbd40551 Mon Sep 17 00:00:00 2001 From: sihuai2412 Date: Sun, 20 Oct 2024 16:32:22 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mod/datagen/ModChineseProvider.java | 4 +-- .../mod/datagen/ModEnglishProvider.java | 4 +-- .../org/confluence/mod/entity/boss/Boss.java | 7 +++++ .../confluence/mod/entity/boss/KingSlime.java | 2 +- .../mod/entity/boss/TerraBossBase.java | 6 +--- .../mod/entity/boss/geoEntity/CthulhuEye.java | 10 ------- .../boss/geoEntity/EaterOfWorldSegment.java | 5 ++++ .../mod/entity/minion/MinionEntity.java | 3 -- .../entity/monster/worm/TestWormEntity.java | 4 +-- .../org/confluence/mod/event/ForgeEvents.java | 28 ++++++++++++++----- .../org/confluence/mod/util/ModUtils.java | 3 +- 11 files changed, 43 insertions(+), 33 deletions(-) create mode 100644 src/main/java/org/confluence/mod/entity/boss/Boss.java diff --git a/src/main/java/org/confluence/mod/datagen/ModChineseProvider.java b/src/main/java/org/confluence/mod/datagen/ModChineseProvider.java index 356ee8a5a..3be2c27ce 100644 --- a/src/main/java/org/confluence/mod/datagen/ModChineseProvider.java +++ b/src/main/java/org/confluence/mod/datagen/ModChineseProvider.java @@ -69,8 +69,8 @@ protected void addTranslations() { add("generator.confluence.corruption", "腐化之地"); add("generator.confluence.tr_crimson", "猩红之地"); - add("bossevent.confluence.cthulhu_eye.generate", "克苏鲁之眼已经苏醒!"); - add("bossevent.confluence.cthulhu_eye.death", "克苏鲁之眼已被击败!"); + add("bossevent.confluence.boss_generate", "%s已经苏醒!"); + add("bossevent.confluence.boss_death", "%s已被击败!"); add("bossevent.confluence.cthulhu_eye.leave", "克苏鲁之眼离开了!"); add("entity.confluence.ice_slime", "冰冻史莱姆"); diff --git a/src/main/java/org/confluence/mod/datagen/ModEnglishProvider.java b/src/main/java/org/confluence/mod/datagen/ModEnglishProvider.java index 05e8cd6c3..2d68d8699 100644 --- a/src/main/java/org/confluence/mod/datagen/ModEnglishProvider.java +++ b/src/main/java/org/confluence/mod/datagen/ModEnglishProvider.java @@ -52,8 +52,8 @@ protected void addTranslations() { add("item.confluence.meteorite_ingot.tooltip", "Warm to the touch"); add("item.confluence.alpha.desc", "C418 - alpha"); - add("bossevent.confluence.cthulhu_eye.generate", "The CthulhuEye has awakened!"); - add("bossevent.confluence.cthulhu_eye.death", "The CthulhuEye been defeated!"); + add("bossevent.confluence.boss_generate", "The %s has awakened!"); + add("bossevent.confluence.boss_death", "The %s been defeated!"); add("bossevent.confluence.cthulhu_eye.leave", "The CthulhuEye leaved!"); add("curios.tooltip.speed_boots", "The wearer can run super fast"); diff --git a/src/main/java/org/confluence/mod/entity/boss/Boss.java b/src/main/java/org/confluence/mod/entity/boss/Boss.java new file mode 100644 index 000000000..3370d151b --- /dev/null +++ b/src/main/java/org/confluence/mod/entity/boss/Boss.java @@ -0,0 +1,7 @@ +package org.confluence.mod.entity.boss; + +public interface Boss { + default boolean shouldShowMessage(){ + return true; + } +} diff --git a/src/main/java/org/confluence/mod/entity/boss/KingSlime.java b/src/main/java/org/confluence/mod/entity/boss/KingSlime.java index 55a2c81de..f6943a72f 100644 --- a/src/main/java/org/confluence/mod/entity/boss/KingSlime.java +++ b/src/main/java/org/confluence/mod/entity/boss/KingSlime.java @@ -34,7 +34,7 @@ import static org.confluence.mod.util.ModUtils.switchByDifficulty; @SuppressWarnings("all") -public class KingSlime extends Slime implements DeathAnimOptions, IBossFSM { +public class KingSlime extends Slime implements DeathAnimOptions, IBossFSM, Boss { private static final int COLOR_INT = 0x73bcf4; // 缩小/膨胀时长,单位:刻 private static final int SHRINK_ENLARGE_DURATION = 20; diff --git a/src/main/java/org/confluence/mod/entity/boss/TerraBossBase.java b/src/main/java/org/confluence/mod/entity/boss/TerraBossBase.java index 32505d2e8..dc071f0eb 100644 --- a/src/main/java/org/confluence/mod/entity/boss/TerraBossBase.java +++ b/src/main/java/org/confluence/mod/entity/boss/TerraBossBase.java @@ -46,7 +46,7 @@ import static org.confluence.mod.util.ModUtils.switchByDifficulty; @SuppressWarnings("all") -public abstract class TerraBossBase extends Monster implements GeoEntity { +public abstract class TerraBossBase extends Monster implements GeoEntity, Boss { public int difficultyIdx; @@ -250,10 +250,6 @@ public void onRemovedFromWorld() { super.onRemovedFromWorld(); } - public void onDeath() {} - - public void onFinializeSpawn() {} - @Override // 取消墙体窒息伤害 public boolean isInWall() { return false; diff --git a/src/main/java/org/confluence/mod/entity/boss/geoEntity/CthulhuEye.java b/src/main/java/org/confluence/mod/entity/boss/geoEntity/CthulhuEye.java index 2d4415f58..342af1926 100644 --- a/src/main/java/org/confluence/mod/entity/boss/geoEntity/CthulhuEye.java +++ b/src/main/java/org/confluence/mod/entity/boss/geoEntity/CthulhuEye.java @@ -305,14 +305,4 @@ public void tick() { super.tick(); syncRot(); } - - @Override - public void onDeath() { - if (!level().isClientSide) level().players().forEach(player -> player.sendSystemMessage(Component.translatable("bossevent.confluence.cthulhu_eye.death").withStyle(ChatFormatting.DARK_PURPLE))); - } - - @Override - public void onFinializeSpawn() { - if (!level().isClientSide) level().players().forEach(player -> player.sendSystemMessage(Component.translatable("bossevent.confluence.cthulhu_eye.generate").withStyle(ChatFormatting.DARK_PURPLE))); - } } diff --git a/src/main/java/org/confluence/mod/entity/boss/geoEntity/EaterOfWorldSegment.java b/src/main/java/org/confluence/mod/entity/boss/geoEntity/EaterOfWorldSegment.java index 5fd18e218..a775fa547 100644 --- a/src/main/java/org/confluence/mod/entity/boss/geoEntity/EaterOfWorldSegment.java +++ b/src/main/java/org/confluence/mod/entity/boss/geoEntity/EaterOfWorldSegment.java @@ -66,6 +66,11 @@ public Vec3 getNextPos(){ return newPos; } + @Override + public boolean shouldShowMessage() { + return false; + } + public boolean isNoGravity(){ return true; } diff --git a/src/main/java/org/confluence/mod/entity/minion/MinionEntity.java b/src/main/java/org/confluence/mod/entity/minion/MinionEntity.java index 8b9d7445b..5bfeecce1 100644 --- a/src/main/java/org/confluence/mod/entity/minion/MinionEntity.java +++ b/src/main/java/org/confluence/mod/entity/minion/MinionEntity.java @@ -24,9 +24,6 @@ public void tick() { super.tick(); noPhysics = true; checkCollision(); - if (owner == null || owner.isDeadOrDying()){ - kill(); - } } private void checkCollision() { diff --git a/src/main/java/org/confluence/mod/entity/monster/worm/TestWormEntity.java b/src/main/java/org/confluence/mod/entity/monster/worm/TestWormEntity.java index 3b3339706..58993f50c 100644 --- a/src/main/java/org/confluence/mod/entity/monster/worm/TestWormEntity.java +++ b/src/main/java/org/confluence/mod/entity/monster/worm/TestWormEntity.java @@ -19,8 +19,8 @@ import java.util.ArrayList; public class TestWormEntity extends AbstractWormEntity { - public static final int WORM_LENGTH = 72; - public static final float WORM_HEALTH = 5f; + public static final int WORM_LENGTH = 5; + public static final float WORM_HEALTH = 1f; public static final WormMovementUtils.WormSegmentMovementOptions FOLLOW_INFO = new WormMovementUtils.WormSegmentMovementOptions() .setFollowDistance(0.5) diff --git a/src/main/java/org/confluence/mod/event/ForgeEvents.java b/src/main/java/org/confluence/mod/event/ForgeEvents.java index adc2c7313..77e07f7ec 100644 --- a/src/main/java/org/confluence/mod/event/ForgeEvents.java +++ b/src/main/java/org/confluence/mod/event/ForgeEvents.java @@ -38,7 +38,6 @@ import net.minecraftforge.event.entity.EntityJoinLevelEvent; import net.minecraftforge.event.entity.EntityMountEvent; import net.minecraftforge.event.entity.living.*; -import net.minecraftforge.event.entity.player.ItemTooltipEvent; import net.minecraftforge.event.level.BlockEvent; import net.minecraftforge.event.level.ExplosionEvent; import net.minecraftforge.event.server.ServerAboutToStartEvent; @@ -54,7 +53,6 @@ import org.confluence.mod.block.natural.LogBlocks; import org.confluence.mod.capability.ability.AbilityProvider; import org.confluence.mod.capability.mana.ManaProvider; -import org.confluence.mod.client.color.AnimateColor; import org.confluence.mod.client.particle.options.DamageIndicatorOptions; import org.confluence.mod.command.ConfluenceCommand; import org.confluence.mod.command.ConfluenceData; @@ -67,6 +65,7 @@ import org.confluence.mod.effect.harmful.ManaSicknessEffect; import org.confluence.mod.entity.FallingStarItemEntity; import org.confluence.mod.entity.ModEntities; +import org.confluence.mod.entity.boss.Boss; import org.confluence.mod.entity.boss.TerraBossBase; import org.confluence.mod.entity.monster.demoneye.DemonEye; import org.confluence.mod.entity.monster.demoneye.DemonEyeVariant; @@ -81,7 +80,6 @@ import org.confluence.mod.item.curio.movement.IFallResistance; import org.confluence.mod.item.sword.BloodButchereSword; import org.confluence.mod.item.sword.BreathingReed; -import org.confluence.mod.item.sword.DeveloperSword; import org.confluence.mod.item.sword.TentacleMaceSword; import org.confluence.mod.misc.ModAttributes; import org.confluence.mod.misc.ModConfigs; @@ -231,8 +229,15 @@ public static void livingDeath(LivingDeathEvent event) { } } if (!living.level().isClientSide) { - if (living instanceof TerraBossBase terra) { - terra.onDeath(); + if (living instanceof Boss boss) { + if (boss.shouldShowMessage()){ + LivingEntity e = (LivingEntity) boss; + Level level = e.level(); + if (!level.isClientSide) level.players(). + forEach(player -> + player.sendSystemMessage(Component.translatable("bossevent.confluence.boss_death", e.getDisplayName().getString()) + .withStyle(ChatFormatting.DARK_PURPLE))); + } } } } @@ -400,8 +405,17 @@ public static void mobFinalizeSpawn(MobSpawnEvent.FinalizeSpawn event) { demonEye.setVariant(DemonEyeVariant.random(randomSource)); } else if (mob instanceof BlackSlime blackSlime) { blackSlime.finalizeSpawn(randomSource, event.getDifficulty()); - } else if (mob instanceof TerraBossBase terra) { - terra.onFinializeSpawn(); + } else if (mob instanceof Boss boss) { + if (boss.shouldShowMessage()){ + LivingEntity e = (LivingEntity) boss; + Level level = e.level(); + if (!level.isClientSide) level.players(). + forEach(player -> + player.sendSystemMessage(Component.translatable( + "bossevent.confluence.boss_generate", + e.getDisplayName().getString()) + .withStyle(ChatFormatting.DARK_PURPLE))); + } } } diff --git a/src/main/java/org/confluence/mod/util/ModUtils.java b/src/main/java/org/confluence/mod/util/ModUtils.java index faa8d297c..0d81bcae4 100644 --- a/src/main/java/org/confluence/mod/util/ModUtils.java +++ b/src/main/java/org/confluence/mod/util/ModUtils.java @@ -32,6 +32,7 @@ import org.confluence.mod.Confluence; import org.confluence.mod.client.color.AnimateColor; import org.confluence.mod.client.color.FloatRGBA; +import org.confluence.mod.entity.boss.Boss; import org.confluence.mod.entity.boss.IBossFSM; import org.confluence.mod.item.ModItems; import org.confluence.mod.misc.ModConfigs; @@ -431,7 +432,7 @@ public static boolean hasBoss(double radius, Level level, AABB box){ boolean flag = false; for (Entity entity : getNearbyEntities(radius, level, Entity.class, box)) { - if (entity instanceof IBossFSM) { + if (entity instanceof Boss) { flag = true; break; }