diff --git a/.gitignore b/.gitignore index 823a020..49f9ac0 100644 --- a/.gitignore +++ b/.gitignore @@ -44,4 +44,5 @@ reasonix.toml null work scripts -export \ No newline at end of file +export +.gradle_user_home \ No newline at end of file diff --git a/src/main/java/com/lzxnone/terraria/attachment/ModAttachments.java b/src/main/java/com/lzxnone/terraria/attachment/ModAttachments.java index cdb6254..8ed5ae7 100644 --- a/src/main/java/com/lzxnone/terraria/attachment/ModAttachments.java +++ b/src/main/java/com/lzxnone/terraria/attachment/ModAttachments.java @@ -1,12 +1,15 @@ package com.lzxnone.terraria.attachment; import com.mojang.serialization.Codec; +import net.minecraft.world.entity.Entity; import net.neoforged.neoforge.attachment.AttachmentType; import net.neoforged.neoforge.registries.DeferredRegister; import net.neoforged.neoforge.registries.NeoForgeRegistries; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.Optional; import java.util.UUID; import java.util.function.Supplier; @@ -39,4 +42,12 @@ public class ModAttachments { public static final Supplier> LAVA_IMMUNITY = ATTACHMENT_TYPES.register("lava_immunity", () -> AttachmentType.builder(LavaImmunity::new).build()); + //按攻击来源隔离的命中冷却:key = 攻击来源实体 UUID,value = 下次最早允许命中的服务器时间(刻) + public static final Supplier>> SOURCE_HIT_COOLDOWNS = + ATTACHMENT_TYPES.register("source_hit_cooldowns", () -> AttachmentType.>builder((Supplier>) HashMap::new).build()); + + //玩家当前活跃的刀光实体引用列表(双端各自维护,供渲染层判断刀光是否在场,行为名从实体 entityData 获取) + public static final Supplier>> ACTIVE_BEAMS = + ATTACHMENT_TYPES.register("active_beams", () -> AttachmentType.>builder((Supplier>) ArrayList::new).build()); + } diff --git a/src/main/java/com/lzxnone/terraria/client/entity/beam/ISwordBeamRenderBehavior.java b/src/main/java/com/lzxnone/terraria/client/entity/beam/ISwordBeamRenderBehavior.java index 8082998..9de0d0a 100644 --- a/src/main/java/com/lzxnone/terraria/client/entity/beam/ISwordBeamRenderBehavior.java +++ b/src/main/java/com/lzxnone/terraria/client/entity/beam/ISwordBeamRenderBehavior.java @@ -7,11 +7,14 @@ import com.lzxnone.terraria.utils.RenderUtil; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; import com.mojang.math.Axis; +import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.LightTexture; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.texture.OverlayTexture; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.Entity; +import net.minecraft.world.item.ItemDisplayContext; +import net.minecraft.world.item.ItemStack; import org.joml.Matrix4f; import org.joml.Vector3f; @@ -115,7 +118,7 @@ public interface ISwordBeamRenderBehavior { RenderUtil.applyTranslate(poseStack, dirs[0], dirs[2], (progress + 0.05f) * 180, SwordBeam.DIST * 1.15f); RenderUtil.applyRotate(poseStack, dirs[0], dirs[1], (0.5f - progress - 0.05f) * 180, rotate); poseStack.scale(1.0f, 1.0f, 1.0f); - for(int i = 0;i < 20;i++) { + for(int i = 0;i < 3;i++) { renderQuad(poseStack.last().pose(), vertexConsumer2, color1.x(), color1.y(), color1.z(), alpha, halfWidth, halfHeight, 0f, 0f, 0.03f); } @@ -133,6 +136,44 @@ public interface ISwordBeamRenderBehavior { color1.x(), color1.y(), color1.z(), alpha, 32 * SwordBeam.SCALE, 32 * SwordBeam.SCALE, 0f, 0f, 0.03f); } poseStack.popPose(); + + renderSword(entity, entityYaw, partialTick, poseStack, bufferSource, packedLight); + } + + default void renderSword(Entity entity, float entityYaw, float partialTick, + PoseStack poseStack, MultiBufferSource bufferSource, int packedLight) { + if(!(entity instanceof SwordBeam beam)) return; + ItemStack stack = beam.getEntityData().get(SwordBeam.STACK_SOURCE); + if(stack.isEmpty()) return; + Entity owner = beam.getOwner(); + if(owner == null) return; + + int age = beam.getEntityData().get(SwordBeam.AGE); + int lifetime = Math.max(1, beam.getEntityData().get(SwordBeam.LIFETIME)); + float progress = (age + partialTick) / (float) lifetime; + if(progress > 1.0f) return; + if(beam.getEntityData().get(SwordBeam.RIGHT)) progress = 1.0f - progress; + + Vector3f[] dirs = MathUtil.computeCoordinateSystem(owner); + dirs = MathUtil.rotateCoordinateSystem(dirs[0], dirs[2], beam.getEntityData().get(SwordBeam.ROTATE)); + float rotate = beam.getEntityData().get(SwordBeam.ROTATE); + + poseStack.pushPose(); + RenderUtil.applyTranslate(poseStack, dirs[0], dirs[2], (progress + 0.1f) * 180, SwordBeam.DIST * 0.75); + RenderUtil.applyRotate(poseStack, dirs[0], dirs[1], (0.5f - (progress + 0.05f)) * 180, rotate); + poseStack.mulPose(Axis.ZP.rotationDegrees(-45)); + poseStack.scale(1.8f, 1.8f, 1.8f); + Minecraft.getInstance().getItemRenderer().renderStatic( + stack, + ItemDisplayContext.NONE, + packedLight, + OverlayTexture.NO_OVERLAY, + poseStack, + bufferSource, + entity.level(), + 0 + ); + poseStack.popPose(); } default void renderQuad(Matrix4f matrix, VertexConsumer consumer, float r, float g, float b, float a, float halfWidth, float halfHeight, float offsetX, float offsetY, float offsetZ) { diff --git a/src/main/java/com/lzxnone/terraria/client/entity/projectile/ClientStaticProjectileRenderBehaviors.java b/src/main/java/com/lzxnone/terraria/client/entity/projectile/ClientStaticProjectileRenderBehaviors.java index 3defb04..eabe2a7 100644 --- a/src/main/java/com/lzxnone/terraria/client/entity/projectile/ClientStaticProjectileRenderBehaviors.java +++ b/src/main/java/com/lzxnone/terraria/client/entity/projectile/ClientStaticProjectileRenderBehaviors.java @@ -12,6 +12,7 @@ import com.lzxnone.terraria.client.item.melee.ClientZenith; import com.lzxnone.terraria.client.item.ranged.ClientFlamethrower; import com.lzxnone.terraria.client.item.ranged.ClientSuperStarShooter; import com.lzxnone.terraria.client.item.summon.ClientPossession; +import com.lzxnone.terraria.client.item.summon.ClientStardustCellStaff; import com.lzxnone.terraria.entity.projectile.StaticProjectileBehaviors; import java.util.HashMap; @@ -40,6 +41,7 @@ public class ClientStaticProjectileRenderBehaviors { BEHAVIORS.put(StaticProjectileBehaviors.ACCESSORY_FALLEN_STAR_PROJECTILE, ClientAccessoryFallenStar.PROJECTILE_BEHAVIOR); BEHAVIORS.put(StaticProjectileBehaviors.NEBULA_ARCANUM_ORBIT_PROJECTILE, ClientNebulaArcanum.PROJECTILE_BEHAVIOR); BEHAVIORS.put(StaticProjectileBehaviors.STELLAR_TUNE_PROJECTILE, ClientStellarTune.PROJECTILE_BEHAVIOR); + BEHAVIORS.put(StaticProjectileBehaviors.STARDUST_CELL_PROJECTILE, ClientStardustCellStaff.PROJECTILE_BEHAVIOR); } public static IStaticProjectileRenderBehavior getBehavior(String id) { diff --git a/src/main/java/com/lzxnone/terraria/client/entity/summon/ClientStaticSummonRenderBehaviors.java b/src/main/java/com/lzxnone/terraria/client/entity/summon/ClientStaticSummonRenderBehaviors.java index f0c401a..b21f3ec 100644 --- a/src/main/java/com/lzxnone/terraria/client/entity/summon/ClientStaticSummonRenderBehaviors.java +++ b/src/main/java/com/lzxnone/terraria/client/entity/summon/ClientStaticSummonRenderBehaviors.java @@ -23,6 +23,7 @@ import com.lzxnone.terraria.client.item.ranged.ClientSnowballCannon; import com.lzxnone.terraria.client.item.ranged.ClientStarCannon; import com.lzxnone.terraria.client.item.ranged.ClientSuperStarShooter; import com.lzxnone.terraria.client.item.summon.ClientStardustDragonStaff; +import com.lzxnone.terraria.client.item.summon.ClientStardustCellStaff; import com.lzxnone.terraria.client.item.summon.ClientTerraprisma; import com.lzxnone.terraria.client.item.summon.ClientWhip; import com.lzxnone.terraria.entity.summon.StaticSummonBehaviors; @@ -67,6 +68,8 @@ public class ClientStaticSummonRenderBehaviors { BEHAVIORS.put(StaticSummonBehaviors.POSSESSION, ClientWhip.SUMMON_BEHAVIOR); BEHAVIORS.put(StaticSummonBehaviors.POSSESSION_VISION, DEFAULT_BEHAVIOR); BEHAVIORS.put(StaticSummonBehaviors.STARDUST_DRAGON_STAFF, ClientStardustDragonStaff.SUMMON_BEHAVIOR); + BEHAVIORS.put(StaticSummonBehaviors.STARDUST_CELL_STAFF, ClientStardustCellStaff.SUMMON_BEHAVIOR); + BEHAVIORS.put(StaticSummonBehaviors.STARDUST_CELL_STUCK_PROJECTILE, ClientStardustCellStaff.SUMMON_BEHAVIOR); BEHAVIORS.put(StaticSummonBehaviors.MUSKET_BALL, ClientBulletAmmo.SUMMON_BEHAVIOR); BEHAVIORS.put(StaticSummonBehaviors.METEOR_SHOT, ClientBulletAmmo.SUMMON_BEHAVIOR); diff --git a/src/main/java/com/lzxnone/terraria/client/event/ItemTooltipHandler.java b/src/main/java/com/lzxnone/terraria/client/event/ItemTooltipHandler.java index 7e4918c..7dd8d17 100644 --- a/src/main/java/com/lzxnone/terraria/client/event/ItemTooltipHandler.java +++ b/src/main/java/com/lzxnone/terraria/client/event/ItemTooltipHandler.java @@ -2,6 +2,7 @@ package com.lzxnone.terraria.client.event; import com.lzxnone.terraria.LzxnoneTerraria; import com.lzxnone.terraria.item.weapon.MagicWeapon; +import com.lzxnone.terraria.item.weapon.MeleeWeapon; import com.lzxnone.terraria.item.weapon.RangedWeapon; import com.lzxnone.terraria.item.weapon.SummonWeapon; import com.lzxnone.terraria.item.weapon.summon.minion.MinionWeapon; @@ -29,6 +30,7 @@ public class ItemTooltipHandler { public static void onItemTooltip(ItemTooltipEvent event) { addEnchantedBookTooltip(event); addMinionWeaponTooltip(event); + addMeleeWeaponTooltip(event); addRangedWeaponTooltip(event); addSummonWeaponTooltip(event); addMagicWeaponTooltip(event); @@ -93,6 +95,24 @@ public class ItemTooltipHandler { } } + private static void addMeleeWeaponTooltip(ItemTooltipEvent event) { + ItemStack stack = event.getItemStack(); + if(stack.getItem() instanceof MeleeWeapon meleeWeapon) { + Player player = event.getEntity(); + if(player != null) { + float damage = meleeWeapon.getTooltipDamage(stack, player); + if(damage > 0.0F) { + event.getToolTip().add( + Component.translatable( + "tooltip.lzxnoneterraria.melee_weapon_damage", + damage == Math.rint(damage) ? String.valueOf((int) damage) : String.format("%.2f", damage) + ).withStyle(ChatFormatting.RED) + ); + } + } + } + } + private static void addRangedWeaponTooltip(ItemTooltipEvent event) { ItemStack stack = event.getItemStack(); if(stack.getItem() instanceof RangedWeapon rangedWeapon) { diff --git a/src/main/java/com/lzxnone/terraria/client/item/melee/ClientNightsEdge.java b/src/main/java/com/lzxnone/terraria/client/item/melee/ClientNightsEdge.java index 00976e1..97effd7 100644 --- a/src/main/java/com/lzxnone/terraria/client/item/melee/ClientNightsEdge.java +++ b/src/main/java/com/lzxnone/terraria/client/item/melee/ClientNightsEdge.java @@ -9,6 +9,7 @@ import com.mojang.blaze3d.vertex.VertexConsumer; import com.mojang.math.Axis; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.nbt.CompoundTag; +import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.Entity; import net.minecraft.world.item.*; import net.minecraft.world.phys.*; @@ -16,7 +17,6 @@ import org.joml.Quaternionf; import org.joml.Vector3f; import com.lzxnone.terraria.client.entity.summon.IStaticSummonRenderBehavior; import com.lzxnone.terraria.client.entity.beam.ISwordBeamRenderBehavior; -import static com.lzxnone.terraria.item.weapon.melee.NightsEdge.*; public class ClientNightsEdge { public static final ISwordBeamRenderBehavior SWORD_BEAM_BEHAVIOR = new ISwordBeamRenderBehavior() { @@ -105,10 +105,21 @@ public class ClientNightsEdge { color1.x(), color1.y(), color1.z(), alpha, 32 * SwordBeam.SCALE, 32 * SwordBeam.SCALE, 0f, 0f, 0.03f); } poseStack.popPose(); + + ISwordBeamRenderBehavior.super.renderSword(entity, entityYaw, partialTick, poseStack, bufferSource, packedLight); } }; public static final IStaticSummonRenderBehavior SUMMON_BEHAVIOR = new IStaticSummonRenderBehavior() { + public static final Vector3f COLOR0 = new Vector3f(0.278f, 0.141f, 0.588f); + + public static final ResourceLocation RES0 = ResourceLocation.parse("lzxnoneterraria:textures/vfx/terra_beam0.png"); + public static final ResourceLocation RES1 = ResourceLocation.parse("lzxnoneterraria:textures/vfx/terra_beam3.png"); + public static final ResourceLocation RES2 = ResourceLocation.parse("lzxnoneterraria:textures/vfx/beam_sparkle.png"); + + public static final float FADE_IN = 0.33f; + public static final float FADE_OUT = 0.67f; + @Override public void render(Entity entity, float entityYaw, float partialTick, PoseStack poseStack, MultiBufferSource bufferSource, int packedLight) { diff --git a/src/main/java/com/lzxnone/terraria/client/item/melee/ClientTerraBlade.java b/src/main/java/com/lzxnone/terraria/client/item/melee/ClientTerraBlade.java index 4a4e8f1..bee87ab 100644 --- a/src/main/java/com/lzxnone/terraria/client/item/melee/ClientTerraBlade.java +++ b/src/main/java/com/lzxnone/terraria/client/item/melee/ClientTerraBlade.java @@ -3,21 +3,31 @@ package com.lzxnone.terraria.client.item.melee; import com.lzxnone.terraria.entity.ModRenderTypes; import com.lzxnone.terraria.entity.beam.SwordBeam; import com.lzxnone.terraria.entity.summon.StaticSummon; +import com.lzxnone.terraria.item.weapon.melee.TerraBlade; import com.lzxnone.terraria.utils.*; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; import com.mojang.math.Axis; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.nbt.CompoundTag; +import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.Entity; import net.minecraft.world.item.*; import net.minecraft.world.phys.*; import org.joml.Vector3f; import com.lzxnone.terraria.client.entity.summon.IStaticSummonRenderBehavior; -import static com.lzxnone.terraria.item.weapon.melee.TerraBlade.*; public class ClientTerraBlade { public static final IStaticSummonRenderBehavior SUMMON_BEHAVIOR = new IStaticSummonRenderBehavior() { + public static final Vector3f COLOR0 = new Vector3f(0.255f, 0.420f, 0.302f); + public static final Vector3f COLOR1 = new Vector3f(0.173f, 0.482f, 0.796f); + public static final Vector3f COLOR2 = new Vector3f(0.431f, 0.729f, 0.396f); + + public static final ResourceLocation RES0 = ResourceLocation.parse("lzxnoneterraria:textures/vfx/terra_beam0.png"); + public static final ResourceLocation RES1 = ResourceLocation.parse("lzxnoneterraria:textures/vfx/terra_beam3.png"); + public static final ResourceLocation RES2 = ResourceLocation.parse("lzxnoneterraria:textures/vfx/terra_beam4.png"); + public static final ResourceLocation RES3 = ResourceLocation.parse("lzxnoneterraria:textures/vfx/beam_sparkle.png"); + @Override public void render(Entity entity, float entityYaw, float partialTick, PoseStack poseStack, MultiBufferSource bufferSource, int packedLight) { @@ -29,10 +39,10 @@ public class ClientTerraBlade { float progress = (summon.getEntityData().get(StaticSummon.AGE) + partialTick) / (float) summon.getEntityData().get(StaticSummon.LIFETIME); float alpha; - if(progress <= FADE_IN) { - alpha = 1 - (FADE_IN - progress) / FADE_IN; - }else if(progress >= FADE_OUT) { - alpha = 1 - (progress - FADE_OUT) / (1 - FADE_OUT); + if(progress <= TerraBlade.FADE_IN) { + alpha = 1 - (TerraBlade.FADE_IN - progress) / TerraBlade.FADE_IN; + }else if(progress >= TerraBlade.FADE_OUT) { + alpha = 1 - (progress - TerraBlade.FADE_OUT) / (1 - TerraBlade.FADE_OUT); }else { alpha = 1.0f; } @@ -135,12 +145,12 @@ public class ClientTerraBlade { float sparkleAlpha; - if (progress < FADE_IN) { + if (progress < TerraBlade.FADE_IN) { sparkleAlpha = 0; - } else if (progress > FADE_OUT) { - sparkleAlpha = 1.0f - (progress - FADE_OUT) / (1.0f - FADE_OUT); + } else if (progress > TerraBlade.FADE_OUT) { + sparkleAlpha = 1.0f - (progress - TerraBlade.FADE_OUT) / (1.0f - TerraBlade.FADE_OUT); } else { - sparkleAlpha = (progress - FADE_IN) / (FADE_OUT - FADE_IN); + sparkleAlpha = (progress - TerraBlade.FADE_IN) / (TerraBlade.FADE_OUT - TerraBlade.FADE_IN); } VertexConsumer vertexConsumer3 = bufferSource.getBuffer(ModRenderTypes.entityTranslucentEmissive(RES3)); diff --git a/src/main/java/com/lzxnone/terraria/client/item/melee/ClientTrueExcalibur.java b/src/main/java/com/lzxnone/terraria/client/item/melee/ClientTrueExcalibur.java index 974a8c2..f8d8168 100644 --- a/src/main/java/com/lzxnone/terraria/client/item/melee/ClientTrueExcalibur.java +++ b/src/main/java/com/lzxnone/terraria/client/item/melee/ClientTrueExcalibur.java @@ -112,7 +112,7 @@ public class ClientTrueExcalibur { RenderUtil.applyTranslate(poseStack, dirs[0], dirs[2], (progress + 0.05f) * 180, SwordBeam.DIST * 1.725f); RenderUtil.applyRotate(poseStack, dirs[0], dirs[1], (0.5f - (progress + 0.05f)) * 180, rotate); poseStack.scale(1.5f, 1.5f, 1.5f); - for(int i = 0;i < 20;i++) { + for(int i = 0;i < 3;i++) { renderQuad(poseStack.last().pose(), vertexConsumer2, color1.x(), color1.y(), color1.z(), alpha, halfWidth, halfHeight, 0f, 0f, -0.03f); } @@ -133,6 +133,7 @@ public class ClientTrueExcalibur { poseStack.popPose(); ISwordBeamRenderBehavior.super.render(entity, entityYaw, partialTick, poseStack, bufferSource, packedLight); + ISwordBeamRenderBehavior.super.renderSword(entity, entityYaw, partialTick, poseStack, bufferSource, packedLight); } }; } diff --git a/src/main/java/com/lzxnone/terraria/client/item/melee/ClientTrueNightsEdge.java b/src/main/java/com/lzxnone/terraria/client/item/melee/ClientTrueNightsEdge.java index a8e7ec3..352bd79 100644 --- a/src/main/java/com/lzxnone/terraria/client/item/melee/ClientTrueNightsEdge.java +++ b/src/main/java/com/lzxnone/terraria/client/item/melee/ClientTrueNightsEdge.java @@ -9,6 +9,7 @@ import com.mojang.blaze3d.vertex.VertexConsumer; import com.mojang.math.Axis; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.nbt.CompoundTag; +import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.Entity; import net.minecraft.world.item.*; import net.minecraft.world.phys.*; @@ -16,7 +17,6 @@ import org.joml.Quaternionf; import org.joml.Vector3f; import com.lzxnone.terraria.client.entity.summon.IStaticSummonRenderBehavior; import com.lzxnone.terraria.client.entity.beam.ISwordBeamRenderBehavior; -import static com.lzxnone.terraria.item.weapon.melee.TrueNightsEdge.*; public class ClientTrueNightsEdge { public static final ISwordBeamRenderBehavior SWORD_BEAM_BEHAVIOR = new ISwordBeamRenderBehavior() { @@ -105,10 +105,23 @@ public class ClientTrueNightsEdge { color1.x(), color1.y(), color1.z(), alpha, 32 * SwordBeam.SCALE, 32 * SwordBeam.SCALE, 0f, 0f, 0.03f); } poseStack.popPose(); + + ISwordBeamRenderBehavior.super.renderSword(entity, entityYaw, partialTick, poseStack, bufferSource, packedLight); } }; public static final IStaticSummonRenderBehavior SUMMON_BEHAVIOR = new IStaticSummonRenderBehavior() { + public static final Vector3f COLOR0 = new Vector3f(0.400f, 0.659f, 0.290f); + public static final Vector3f COLOR1 = new Vector3f(0.475f, 0.612f, 0.247f); + public static final Vector3f COLOR2 = new Vector3f(0.631f, 0.871f, 0.192f); + + public static final ResourceLocation RES0 = ResourceLocation.parse("lzxnoneterraria:textures/vfx/terra_beam0.png"); + public static final ResourceLocation RES1 = ResourceLocation.parse("lzxnoneterraria:textures/vfx/terra_beam3.png"); + public static final ResourceLocation RES2 = ResourceLocation.parse("lzxnoneterraria:textures/vfx/beam_sparkle.png"); + + public static final float FADE_IN = 0.33f; + public static final float FADE_OUT = 0.67f; + @Override public void render(Entity entity, float entityYaw, float partialTick, PoseStack poseStack, MultiBufferSource bufferSource, int packedLight) { diff --git a/src/main/java/com/lzxnone/terraria/client/item/summon/ClientStardustCellStaff.java b/src/main/java/com/lzxnone/terraria/client/item/summon/ClientStardustCellStaff.java new file mode 100644 index 0000000..595c187 --- /dev/null +++ b/src/main/java/com/lzxnone/terraria/client/item/summon/ClientStardustCellStaff.java @@ -0,0 +1,121 @@ +package com.lzxnone.terraria.client.item.summon; + +import com.lzxnone.terraria.client.entity.projectile.IStaticProjectileRenderBehavior; +import com.lzxnone.terraria.client.entity.summon.IStaticSummonRenderBehavior; +import com.lzxnone.terraria.entity.ModRenderTypes; +import com.lzxnone.terraria.entity.projectile.StaticProjectile; +import com.lzxnone.terraria.entity.summon.StaticSummon; +import com.lzxnone.terraria.entity.summon.StaticSummonBehaviors; +import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.vertex.VertexConsumer; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.LightTexture; +import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.client.renderer.texture.OverlayTexture; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.util.Mth; +import net.minecraft.world.entity.Entity; + +public class ClientStardustCellStaff { + private static final ResourceLocation[] CELL_FRAMES = { + ResourceLocation.parse("lzxnoneterraria:textures/vfx/stardust_cell0.png"), + ResourceLocation.parse("lzxnoneterraria:textures/vfx/stardust_cell1.png"), + ResourceLocation.parse("lzxnoneterraria:textures/vfx/stardust_cell2.png"), + ResourceLocation.parse("lzxnoneterraria:textures/vfx/stardust_cell3.png") + }; + private static final ResourceLocation[] CELL_MINI_FRAMES = { + ResourceLocation.parse("lzxnoneterraria:textures/vfx/stardust_cell_mini0.png"), + ResourceLocation.parse("lzxnoneterraria:textures/vfx/stardust_cell_mini1.png"), + ResourceLocation.parse("lzxnoneterraria:textures/vfx/stardust_cell_mini2.png"), + ResourceLocation.parse("lzxnoneterraria:textures/vfx/stardust_cell_mini3.png") + }; + + private static final float FRAME_HALF_SIZE = 0.5625F; + private static final int FRAME_LOOP_TICKS = 6; + + private static int frameForAge(float age) { + int t = Mth.floor(age) % FRAME_LOOP_TICKS; + if(t < 1) return 0; + if(t < 3) return 1; + if(t < 4) return 2; + return 3; + } + + public static final IStaticSummonRenderBehavior SUMMON_BEHAVIOR = new IStaticSummonRenderBehavior() { + @Override + public void render(Entity entity, float entityYaw, float partialTick, PoseStack poseStack, + MultiBufferSource bufferSource, int packedLight) { + if(!(entity instanceof StaticSummon summon)) return; + float age = summon.getEntityData().get(StaticSummon.AGE) + partialTick; + int frame = frameForAge(age); + if(summon.getEntityData().get(StaticSummon.BEHAVIOR).equals(StaticSummonBehaviors.STARDUST_CELL_STAFF)) { + renderBillboardFrame( + poseStack, + bufferSource, + CELL_FRAMES[frame], + summon.getEntityData().get(StaticSummon.SCALE_X) * FRAME_HALF_SIZE, + summon.getEntityData().get(StaticSummon.SCALE_Y) * FRAME_HALF_SIZE, + summon.getEntityData().get(StaticSummon.COLOR_R), + summon.getEntityData().get(StaticSummon.COLOR_G), + summon.getEntityData().get(StaticSummon.COLOR_B), + summon.getEntityData().get(StaticSummon.COLOR_A) + ); + }else { + renderBillboardFrame( + poseStack, + bufferSource, + CELL_MINI_FRAMES[frame], + summon.getEntityData().get(StaticSummon.SCALE_X) * FRAME_HALF_SIZE, + summon.getEntityData().get(StaticSummon.SCALE_Y) * FRAME_HALF_SIZE, + summon.getEntityData().get(StaticSummon.COLOR_R), + summon.getEntityData().get(StaticSummon.COLOR_G), + summon.getEntityData().get(StaticSummon.COLOR_B), + summon.getEntityData().get(StaticSummon.COLOR_A) + ); + } + } + }; + + public static final IStaticProjectileRenderBehavior PROJECTILE_BEHAVIOR = new IStaticProjectileRenderBehavior() { + @Override + public void render(Entity entity, float entityYaw, float partialTick, PoseStack poseStack, + MultiBufferSource bufferSource, int packedLight) { + if(!(entity instanceof StaticProjectile projectile)) return; + float age = projectile.getEntityData().get(StaticProjectile.AGE) + partialTick; + int frame = frameForAge(age); + renderBillboardFrame( + poseStack, + bufferSource, + CELL_MINI_FRAMES[frame], + projectile.getEntityData().get(StaticProjectile.SCALE_X) * FRAME_HALF_SIZE, + projectile.getEntityData().get(StaticProjectile.SCALE_Y) * FRAME_HALF_SIZE, + projectile.getEntityData().get(StaticProjectile.COLOR_R), + projectile.getEntityData().get(StaticProjectile.COLOR_G), + projectile.getEntityData().get(StaticProjectile.COLOR_B), + projectile.getEntityData().get(StaticProjectile.COLOR_A) + ); + } + }; + + private static void renderBillboardFrame(PoseStack poseStack, MultiBufferSource bufferSource, ResourceLocation texture, + float halfWidth, float halfHeight, + float r, float g, float b, float a) { + poseStack.pushPose(); + poseStack.mulPose(Minecraft.getInstance().getEntityRenderDispatcher().cameraOrientation()); + + VertexConsumer consumer = bufferSource.getBuffer(ModRenderTypes.entityTranslucentEmissive(texture)); + consumer.addVertex(poseStack.last().pose(), -halfWidth, -halfHeight, 0.0F) + .setColor(r, g, b, a).setUv(0.0F, 1.0F) + .setOverlay(OverlayTexture.NO_OVERLAY).setLight(LightTexture.FULL_BRIGHT).setNormal(0.0F, 1.0F, 0.0F); + consumer.addVertex(poseStack.last().pose(), halfWidth, -halfHeight, 0.0F) + .setColor(r, g, b, a).setUv(1.0F, 1.0F) + .setOverlay(OverlayTexture.NO_OVERLAY).setLight(LightTexture.FULL_BRIGHT).setNormal(0.0F, 1.0F, 0.0F); + consumer.addVertex(poseStack.last().pose(), halfWidth, halfHeight, 0.0F) + .setColor(r, g, b, a).setUv(1.0F, 0.0F) + .setOverlay(OverlayTexture.NO_OVERLAY).setLight(LightTexture.FULL_BRIGHT).setNormal(0.0F, 1.0F, 0.0F); + consumer.addVertex(poseStack.last().pose(), -halfWidth, halfHeight, 0.0F) + .setColor(r, g, b, a).setUv(0.0F, 0.0F) + .setOverlay(OverlayTexture.NO_OVERLAY).setLight(LightTexture.FULL_BRIGHT).setNormal(0.0F, 1.0F, 0.0F); + poseStack.popPose(); + } +} diff --git a/src/main/java/com/lzxnone/terraria/creative_mode_tab/ModCreativeModeTabs.java b/src/main/java/com/lzxnone/terraria/creative_mode_tab/ModCreativeModeTabs.java index 191a1a6..a586aa5 100644 --- a/src/main/java/com/lzxnone/terraria/creative_mode_tab/ModCreativeModeTabs.java +++ b/src/main/java/com/lzxnone/terraria/creative_mode_tab/ModCreativeModeTabs.java @@ -234,6 +234,7 @@ public class ModCreativeModeTabs { .displayItems((parameters, output) -> { output.accept(ModItems.TERRAPRISMA.get()); output.accept(ModItems.STARDUST_DRAGON_STAFF.get()); + output.accept(ModItems.STARDUST_CELL_STAFF.get()); output.accept(ModItems.POSSESSION.get()); output.accept(ModItems.SUMMONING_POTION.get()); }).build()); diff --git a/src/main/java/com/lzxnone/terraria/effect/CelledEffect.java b/src/main/java/com/lzxnone/terraria/effect/CelledEffect.java new file mode 100644 index 0000000..afc213a --- /dev/null +++ b/src/main/java/com/lzxnone/terraria/effect/CelledEffect.java @@ -0,0 +1,56 @@ +package com.lzxnone.terraria.effect; + +import com.lzxnone.terraria.LzxnoneTerraria; +import com.lzxnone.terraria.ui.config.ConfigListItem; +import com.lzxnone.terraria.ui.config.IConfigData; +import com.lzxnone.terraria.ui.config.struct.ConfigFloat; +import com.lzxnone.terraria.ui.config.struct.ConfigStruct; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.effect.MobEffect; +import net.minecraft.world.effect.MobEffectCategory; +import net.minecraft.world.entity.LivingEntity; + +public class CelledEffect extends MobEffect { + public static final ConfigFloat DAMAGE_PER_LEVEL = new ConfigFloat( + "effect.celled.damage_per_level", + "celled_damage_per_level", + 5.0F, + 0.0F, + 8388600.0F + ); + + public static final IConfigData CONFIG_DATA = new IConfigData() { + @Override + public void onConfigLoad() { + ConfigStruct.loadAll(DAMAGE_PER_LEVEL); + } + }; + + public static final ConfigListItem CONFIG_LIST_ITEM = new ConfigListItem( + "celled", + ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "textures/mob_effect/celled.png"), + Component.translatable("effect.lzxnoneterraria.celled"), + CONFIG_DATA + ); + + public CelledEffect() { + super(MobEffectCategory.HARMFUL, 0x318CE7); + } + + @Override + public boolean shouldApplyEffectTickThisTick(int duration, int amplifier) { + return true; + } + + @Override + public boolean applyEffectTick(LivingEntity entity, int amplifier) { + if(entity.level() instanceof ServerLevel && entity.tickCount % 20 == 0) { + if(entity.hurt(entity.damageSources().magic(), DAMAGE_PER_LEVEL.get() * (amplifier + 1))) { + entity.invulnerableTime = 10; + } + } + return true; + } +} diff --git a/src/main/java/com/lzxnone/terraria/effect/ModEffects.java b/src/main/java/com/lzxnone/terraria/effect/ModEffects.java index a0d9da5..bd9ac8f 100644 --- a/src/main/java/com/lzxnone/terraria/effect/ModEffects.java +++ b/src/main/java/com/lzxnone/terraria/effect/ModEffects.java @@ -28,6 +28,8 @@ public class ModEffects { MOB_EFFECTS.register("betsys_curse", BetsysCurseEffect::new); public static final DeferredHolder ACID_VENOM = MOB_EFFECTS.register("acid_venom", AcidVenomEffect::new); + public static final DeferredHolder CELLED = + MOB_EFFECTS.register("celled", CelledEffect::new); public static final DeferredHolder SUMMON = MOB_EFFECTS.register("summon", SummonEffect::new); public static final DeferredHolder MANA_SICKNESS = diff --git a/src/main/java/com/lzxnone/terraria/entity/beam/ISwordBeamBehavior.java b/src/main/java/com/lzxnone/terraria/entity/beam/ISwordBeamBehavior.java index fbfa8b3..f0d6ebe 100644 --- a/src/main/java/com/lzxnone/terraria/entity/beam/ISwordBeamBehavior.java +++ b/src/main/java/com/lzxnone/terraria/entity/beam/ISwordBeamBehavior.java @@ -5,8 +5,10 @@ import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.nbt.CompoundTag; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.HumanoidArm; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.EntityHitResult; @@ -14,14 +16,38 @@ import net.minecraft.world.phys.Vec3; import org.joml.Vector3f; public interface ISwordBeamBehavior { + private static String behaviorOf(ItemStack stack) { + return stack.isEmpty() ? "" : BuiltInRegistries.ITEM.getKey(stack.getItem()).getPath(); + } + default void generate(Entity entity, CompoundTag beamData) { if(entity == null) return; SwordBeam beam = new SwordBeam(ModEntities.SWORD_BEAM.get(), entity.level()); beam.setOwner(entity); - if(entity instanceof Player player) beam.getEntityData().set(SwordBeam.STACK_SOURCE, player.getWeaponItem().copy()); Vec3 pos = new Vec3(entity.getX(), entity.getY() + entity.getBbHeight() / 2, entity.getZ()); beam.setPos(pos); - if(beamData.contains("behavior")) beam.getEntityData().set(SwordBeam.BEHAVIOR, beamData.getString("behavior")); + if(beamData.contains("behavior")) { + String behavior = beamData.getString("behavior"); + beam.getEntityData().set(SwordBeam.BEHAVIOR, behavior); + Item item = BuiltInRegistries.ITEM.get(ResourceLocation.fromNamespaceAndPath("lzxnoneterraria", behavior)); + if(item != Items.AIR) beam.getEntityData().set(SwordBeam.STACK_SOURCE, new ItemStack(item)); + //记录使用手(主手优先,映射为物理右手):武器在主手槽 → 右手 = 主手设置是 RIGHT;仅副手槽 → 右手 = 主手设置是 LEFT(左撇子) + boolean rightHand = true; + if(entity instanceof Player player) { + ItemStack mainStack = player.getMainHandItem(); + ItemStack offStack = player.getOffhandItem(); + boolean mainHolds = behaviorOf(mainStack).equals(behavior); + boolean offHolds = behaviorOf(offStack).equals(behavior); + if(mainHolds) { + rightHand = player.getMainArm() == HumanoidArm.RIGHT; + }else if(offHolds) { + rightHand = player.getMainArm() == HumanoidArm.LEFT; + }else { + rightHand = player.getMainArm() == HumanoidArm.RIGHT; + } + } + beam.getEntityData().set(SwordBeam.RIGHT_HAND, rightHand); + } if(beamData.contains("rotate")) beam.getEntityData().set(SwordBeam.ROTATE, beamData.getInt("rotate")); if(beamData.contains("right")) beam.getEntityData().set(SwordBeam.RIGHT, beamData.getBoolean("right")); if(beamData.contains("inflate")) beam.getEntityData().set(SwordBeam.INFLATE, beamData.getFloat("inflate")); @@ -40,11 +66,6 @@ public interface ISwordBeamBehavior { if(beamData.contains("age")) beam.getEntityData().set(SwordBeam.AGE, beamData.getInt("age")); if(beamData.contains("lifetime")) beam.getEntityData().set(SwordBeam.LIFETIME, beamData.getInt("lifetime")); if(beamData.contains("customData")) beam.getEntityData().set(SwordBeam.CUSTOM_DATA, beamData.getCompound("customData").copy()); - if(beamData.contains("behavior") && beamData.contains("cooldown") && entity instanceof Player player) { - ResourceLocation itemKey = ResourceLocation.fromNamespaceAndPath("lzxnoneterraria", beamData.getString("behavior")); - Item item = BuiltInRegistries.ITEM.get(itemKey); - if(item != Items.AIR) player.getCooldowns().addCooldown(item, beamData.getInt("cooldown")); - } entity.level().addFreshEntity(beam); } diff --git a/src/main/java/com/lzxnone/terraria/entity/beam/SwordBeam.java b/src/main/java/com/lzxnone/terraria/entity/beam/SwordBeam.java index ee30d76..993de72 100644 --- a/src/main/java/com/lzxnone/terraria/entity/beam/SwordBeam.java +++ b/src/main/java/com/lzxnone/terraria/entity/beam/SwordBeam.java @@ -1,5 +1,7 @@ package com.lzxnone.terraria.entity.beam; +import com.lzxnone.terraria.LzxnoneTerraria; +import com.lzxnone.terraria.attachment.ModAttachments; import com.lzxnone.terraria.utils.FilterUtil; import com.lzxnone.terraria.utils.MathUtil; import net.minecraft.nbt.CompoundTag; @@ -9,6 +11,7 @@ import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.ClipContext; import net.minecraft.world.level.Level; @@ -41,6 +44,8 @@ public class SwordBeam extends Entity { SynchedEntityData.defineId(SwordBeam.class, EntityDataSerializers.VECTOR3); public static final EntityDataAccessor RIGHT = SynchedEntityData.defineId(SwordBeam.class, EntityDataSerializers.BOOLEAN); + public static final EntityDataAccessor RIGHT_HAND = + SynchedEntityData.defineId(SwordBeam.class, EntityDataSerializers.BOOLEAN); public static final EntityDataAccessor INFLATE = SynchedEntityData.defineId(SwordBeam.class, EntityDataSerializers.FLOAT); public static final EntityDataAccessor OUTLINE = @@ -58,6 +63,7 @@ public class SwordBeam extends Entity { SynchedEntityData.defineId(SwordBeam.class, EntityDataSerializers.COMPOUND_TAG); private Entity owner = null; + private boolean registeredToOwner = false; public Vec3 prevPosition = null; public Vec3 currentPosition = null; @@ -69,6 +75,30 @@ public class SwordBeam extends Entity { this.noPhysics = true; } + public static SwordBeam getActiveBeam(Player player, String behavior) { + List beams = player.getData(ModAttachments.ACTIVE_BEAMS); + beams.removeIf(beam -> !beam.isAlive()); + for(Entity beam : beams) { + if(beam instanceof SwordBeam swordBeam + && swordBeam.getEntityData().get(SwordBeam.BEHAVIOR).equals(behavior)) { + return swordBeam; + } + } + return null; + } + + public static boolean hasActiveBeam(Player player, String behavior) { + return getActiveBeam(player, behavior) != null; + } + + @Override + public void onRemovedFromLevel() { + if(getOwner() instanceof Player player) { + player.getData(ModAttachments.ACTIVE_BEAMS).removeIf(beam -> beam == this); + } + super.onRemovedFromLevel(); + } + public void setOwner(Entity entity) { if(entity == null) return; this.entityData.set(OWNER, Optional.of(entity.getUUID())); @@ -107,8 +137,27 @@ public class SwordBeam extends Entity { this.getEntityData().set(AGE, this.getEntityData().get(AGE) + 1); } - if(this.getOwner() != null) { - this.setPos(this.getOwner().getX(), this.getOwner().getY() + this.getOwner().getBbHeight() * 0.5, this.getOwner().getZ()); + Entity owner = this.getOwner(); + if(owner != null) { + if(this.level().isClientSide() && !this.registeredToOwner && owner instanceof Player player) { + player.getData(ModAttachments.ACTIVE_BEAMS).add(this); + this.registeredToOwner = true; + } + + Vector3f[] dirs = MathUtil.computeCoordinateSystem(owner); + Vec3 eyePos = owner.getEyePosition(); + Vector3f offset; + if(getEntityData().get(SwordBeam.RIGHT_HAND)) { + offset = new Vector3f(-0.3f, -0.35f, 0.4f); + }else { + offset = new Vector3f(0.3f, -0.35f, 0.4f); + } + Vec3 pos = new Vec3( + eyePos.x + dirs[0].x * offset.z + dirs[1].x * offset.y + dirs[2].x * offset.x, + eyePos.y + dirs[0].y * offset.z + dirs[1].y * offset.y + dirs[2].y * offset.x, + eyePos.z + dirs[0].z * offset.z + dirs[1].z * offset.y + dirs[2].z * offset.x + ); + this.setPos(pos); }else { SwordBeamBehaviors.getBehavior(this.entityData.get(BEHAVIOR)).onDied(this); return; @@ -198,6 +247,7 @@ public class SwordBeam extends Entity { builder.define(BEHAVIOR, "default"); builder.define(ROTATE, 0); builder.define(RIGHT, false); + builder.define(RIGHT_HAND, true); builder.define(INFLATE, 0.0f); builder.define(OUTLINE, false); builder.define(COLOR0, new Vector3f(1.0f, 1.0f, 1.0f)); @@ -216,6 +266,7 @@ public class SwordBeam extends Entity { tag.putString("behavior", this.entityData.get(BEHAVIOR)); tag.putInt("rotate", this.entityData.get(ROTATE)); tag.putBoolean("right", this.entityData.get(RIGHT)); + tag.putBoolean("rightHand", this.entityData.get(RIGHT_HAND)); tag.putFloat("inflate", this.entityData.get(INFLATE)); tag.putBoolean("outline", this.entityData.get(OUTLINE)); Vector3f c0 = this.entityData.get(COLOR0); @@ -247,6 +298,7 @@ public class SwordBeam extends Entity { if(tag.contains("behavior")) this.entityData.set(BEHAVIOR, tag.getString("behavior")); if(tag.contains("rotate")) this.entityData.set(ROTATE, tag.getInt("rotate")); if(tag.contains("right")) this.entityData.set(RIGHT, tag.getBoolean("right")); + if(tag.contains("rightHand")) this.entityData.set(RIGHT_HAND, tag.getBoolean("rightHand")); if(tag.contains("inflate")) this.entityData.set(INFLATE, tag.getFloat("inflate")); if(tag.contains("outline")) this.entityData.set(OUTLINE, tag.getBoolean("outline")); if(tag.contains("color0R")) { diff --git a/src/main/java/com/lzxnone/terraria/entity/projectile/StaticProjectileBehaviors.java b/src/main/java/com/lzxnone/terraria/entity/projectile/StaticProjectileBehaviors.java index 7635331..88ebb43 100644 --- a/src/main/java/com/lzxnone/terraria/entity/projectile/StaticProjectileBehaviors.java +++ b/src/main/java/com/lzxnone/terraria/entity/projectile/StaticProjectileBehaviors.java @@ -8,6 +8,7 @@ import com.lzxnone.terraria.item.weapon.melee.*; import com.lzxnone.terraria.item.weapon.ranged.Flamethrower; import com.lzxnone.terraria.item.weapon.ranged.SuperStarShooter; import com.lzxnone.terraria.item.weapon.summon.whip.Possession; +import com.lzxnone.terraria.item.weapon.summon.minion.StardustCellStaff; import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.EntityHitResult; @@ -35,6 +36,7 @@ public class StaticProjectileBehaviors { public static final String ACCESSORY_FALLEN_STAR_PROJECTILE = "accessory_fallen_star_projectile"; public static final String NEBULA_ARCANUM_ORBIT_PROJECTILE = "nebula_arcanum_orbit_projectile"; public static final String STELLAR_TUNE_PROJECTILE = "stellar_tune_projectile"; + public static final String STARDUST_CELL_PROJECTILE = "stardust_cell_projectile"; static { BEHAVIORS.put(DEFAULT, new IStaticProjectileBehavior() { @@ -68,6 +70,7 @@ public class StaticProjectileBehaviors { BEHAVIORS.put(ACCESSORY_FALLEN_STAR_PROJECTILE, FallenStarSummoner.PROJECTILE_BEHAVIOR); BEHAVIORS.put(NEBULA_ARCANUM_ORBIT_PROJECTILE, NebulaArcanum.PROJECTILE_BEHAVIOR); BEHAVIORS.put(STELLAR_TUNE_PROJECTILE, StellarTune.PROJECTILE_BEHAVIOR); + BEHAVIORS.put(STARDUST_CELL_PROJECTILE, StardustCellStaff.PROJECTILE_BEHAVIOR); } public static IStaticProjectileBehavior getBehavior(String id) { diff --git a/src/main/java/com/lzxnone/terraria/entity/summon/BeeSummon.java b/src/main/java/com/lzxnone/terraria/entity/summon/BeeSummon.java index 971d90d..56f3c0a 100644 --- a/src/main/java/com/lzxnone/terraria/entity/summon/BeeSummon.java +++ b/src/main/java/com/lzxnone/terraria/entity/summon/BeeSummon.java @@ -127,7 +127,7 @@ public class BeeSummon extends Bee { if(owner == null) return false; boolean isHurt; if(owner instanceof Player) { - isHurt = DamageUtil.meleeAttack(this, target, stackSource, (float) damage, 1.0f, -1); + isHurt = DamageUtil.meleeAttack(this, target, stackSource, (float) damage, 1.0f, 10); }else { DamageSource damageSource = this.damageSources().mobAttack(owner); isHurt = target.hurt(damageSource, (float) damage); diff --git a/src/main/java/com/lzxnone/terraria/entity/summon/StaticSummonBehaviors.java b/src/main/java/com/lzxnone/terraria/entity/summon/StaticSummonBehaviors.java index 592f0bd..77510c9 100644 --- a/src/main/java/com/lzxnone/terraria/entity/summon/StaticSummonBehaviors.java +++ b/src/main/java/com/lzxnone/terraria/entity/summon/StaticSummonBehaviors.java @@ -16,6 +16,7 @@ import com.lzxnone.terraria.item.weapon.ranged.SnowballCannon; import com.lzxnone.terraria.item.weapon.ranged.StarCannon; import com.lzxnone.terraria.item.weapon.ranged.SuperStarShooter; import com.lzxnone.terraria.item.weapon.summon.minion.StardustDragonStaff; +import com.lzxnone.terraria.item.weapon.summon.minion.StardustCellStaff; import com.lzxnone.terraria.item.weapon.summon.minion.Terraprisma; import com.lzxnone.terraria.item.weapon.summon.whip.Possession; import com.lzxnone.terraria.item.weapon.summon.whip.Whip; @@ -60,6 +61,8 @@ public class StaticSummonBehaviors { public static final String NEBULA_ARCANUM_SMALL_PROJECTILE = "nebula_arcanum_small_projectile"; public static final String TERRAPRISMA = "terraprisma"; public static final String STARDUST_DRAGON_STAFF = "stardust_dragon_staff"; + public static final String STARDUST_CELL_STAFF = "stardust_cell_staff"; + public static final String STARDUST_CELL_STUCK_PROJECTILE = "stardust_cell_stuck_projectile"; public static final String POSSESSION = "possession"; public static final String POSSESSION_VISION = "possession_vision"; @@ -121,6 +124,8 @@ public class StaticSummonBehaviors { BEHAVIORS.put(NEBULA_ARCANUM_SMALL_PROJECTILE, NebulaArcanum.SUMMON_BEHAVIOR2); BEHAVIORS.put(TERRAPRISMA, Terraprisma.SUMMON_BEHAVIOR); BEHAVIORS.put(STARDUST_DRAGON_STAFF, StardustDragonStaff.SUMMON_BEHAVIOR); + BEHAVIORS.put(STARDUST_CELL_STAFF, StardustCellStaff.SUMMON_BEHAVIOR); + BEHAVIORS.put(STARDUST_CELL_STUCK_PROJECTILE, StardustCellStaff.SUMMON_BEHAVIOR2); BEHAVIORS.put(POSSESSION, Whip.SUMMON_BEHAVIOR); BEHAVIORS.put(POSSESSION_VISION, Possession.SUMMON_BEHAVIOR); diff --git a/src/main/java/com/lzxnone/terraria/event/EntityEventHandler.java b/src/main/java/com/lzxnone/terraria/event/EntityEventHandler.java index dc29458..ee2ec3d 100644 --- a/src/main/java/com/lzxnone/terraria/event/EntityEventHandler.java +++ b/src/main/java/com/lzxnone/terraria/event/EntityEventHandler.java @@ -20,7 +20,9 @@ import com.lzxnone.terraria.item.accessory.AccessoryUtil; import com.lzxnone.terraria.item.weapon.RangedWeapon; import com.lzxnone.terraria.item.weapon.Weapon; import com.lzxnone.terraria.item.weapon.melee.DevilsDevastation; +import com.lzxnone.terraria.item.weapon.summon.minion.StardustCellStaff; import com.lzxnone.terraria.item.weapon.summon.whip.Possession; +import com.lzxnone.terraria.utils.ParticleUtil; import net.minecraft.nbt.CompoundTag; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; @@ -239,6 +241,13 @@ public class EntityEventHandler { if(owner instanceof Player) killer = owner; } if(livingEntity.level() instanceof ServerLevel serverLevel) { + //细胞附着死亡爆散 + if(livingEntity.hasEffect(ModEffects.CELLED)) { + Vec3 center = livingEntity.getBoundingBox().getCenter(); + ParticleUtil.addParticles(serverLevel, StardustCellStaff.CELL_CIRCLE_BLUE, center, Vec3.ZERO, 0.35D, 25); + ParticleUtil.addParticles(serverLevel, StardustCellStaff.CELL_CIRCLE_CYAN, center, Vec3.ZERO, 0.35D, 25); + } + //迈达斯生成绿宝石 if(livingEntity.hasEffect(ModEffects.MIDAS) && livingEntity.getRandom().nextFloat() < MidasEffect.getDropChance()) { livingEntity.spawnAtLocation(new ItemStack(Items.EMERALD)); diff --git a/src/main/java/com/lzxnone/terraria/item/ModItems.java b/src/main/java/com/lzxnone/terraria/item/ModItems.java index a57750f..707d9dd 100644 --- a/src/main/java/com/lzxnone/terraria/item/ModItems.java +++ b/src/main/java/com/lzxnone/terraria/item/ModItems.java @@ -17,6 +17,7 @@ import com.lzxnone.terraria.item.weapon.ranged.SuperStarShooter; import com.lzxnone.terraria.item.weapon.ranged.bow.DaedalusStormbow; import com.lzxnone.terraria.item.weapon.ranged.gun.*; import com.lzxnone.terraria.item.weapon.summon.minion.StardustDragonStaff; +import com.lzxnone.terraria.item.weapon.summon.minion.StardustCellStaff; import com.lzxnone.terraria.item.weapon.summon.minion.Terraprisma; import com.lzxnone.terraria.item.weapon.summon.whip.Possession; import net.minecraft.world.item.BlockItem; @@ -93,6 +94,7 @@ public class ModItems { //召唤武器 public static final DeferredItem TERRAPRISMA = ITEMS.register("terraprisma", Terraprisma::new); public static final DeferredItem STARDUST_DRAGON_STAFF = ITEMS.register("stardust_dragon_staff", StardustDragonStaff::new); + public static final DeferredItem STARDUST_CELL_STAFF = ITEMS.register("stardust_cell_staff", StardustCellStaff::new); public static final DeferredItem POSSESSION = ITEMS.register("possession", Possession::new); //近战武器 灾厄 diff --git a/src/main/java/com/lzxnone/terraria/item/ammo/ChlorophyteBullet.java b/src/main/java/com/lzxnone/terraria/item/ammo/ChlorophyteBullet.java index ec64f9c..b6ed590 100644 --- a/src/main/java/com/lzxnone/terraria/item/ammo/ChlorophyteBullet.java +++ b/src/main/java/com/lzxnone/terraria/item/ammo/ChlorophyteBullet.java @@ -141,7 +141,7 @@ public class ChlorophyteBullet extends BulletAmmo { CompoundTag customData = summon.getEntityData().get(StaticSummon.CUSTOM_DATA); float damage = customData.contains("damage") ? customData.getFloat("damage") : 0; float knockbackScale = customData.contains("knockbackScale") ? customData.getFloat("knockbackScale") : 1.0f; - int invulnerableTime = customData.contains("invulnerableTime") ? customData.getInt("invulnerableTime") : 20; + int invulnerableTime = customData.contains("invulnerableTime") ? customData.getInt("invulnerableTime") : 10; ItemStack sourceStack = summon.getEntityData().get(StaticSummon.STACK_SOURCE); Entity hitTarget = targets.getFirst(); diff --git a/src/main/java/com/lzxnone/terraria/item/ammo/CrystalBullet.java b/src/main/java/com/lzxnone/terraria/item/ammo/CrystalBullet.java index 90e6de7..94b4595 100644 --- a/src/main/java/com/lzxnone/terraria/item/ammo/CrystalBullet.java +++ b/src/main/java/com/lzxnone/terraria/item/ammo/CrystalBullet.java @@ -79,7 +79,7 @@ public class CrystalBullet extends BulletAmmo { CompoundTag customData = summon.getEntityData().get(StaticSummon.CUSTOM_DATA); float damage = customData.contains("damage") ? customData.getFloat("damage") : 0; float knockbackScale = customData.contains("knockbackScale") ? customData.getFloat("knockbackScale") : 1.0f; - int invulnerableTime = customData.contains("invulnerableTime") ? customData.getInt("invulnerableTime") : 20; + int invulnerableTime = customData.contains("invulnerableTime") ? customData.getInt("invulnerableTime") : 10; ItemStack sourceStack = summon.getEntityData().get(StaticSummon.STACK_SOURCE); Entity target = targets.getFirst(); @@ -131,7 +131,7 @@ public class CrystalBullet extends BulletAmmo { if(!FilterUtil.createTargetFilter(owner).test(target) || !(owner instanceof Player player)) return; CompoundTag customData = projectile.getEntityData().get(StaticProjectile.CUSTOM_DATA); float damage = customData.contains("damage") ? customData.getFloat("damage") : 0; - if(DamageUtil.rangedAttack(projectile, target, projectile.getEntityData().get(StaticProjectile.STACK_SOURCE), damage, 1.0f, 5)) { + if(DamageUtil.rangedAttack(projectile, target, projectile.getEntityData().get(StaticProjectile.STACK_SOURCE), damage, 1.0f, 10)) { onDied(projectile); } } diff --git a/src/main/java/com/lzxnone/terraria/item/ammo/CursedBullet.java b/src/main/java/com/lzxnone/terraria/item/ammo/CursedBullet.java index b87bbd3..efa9a99 100644 --- a/src/main/java/com/lzxnone/terraria/item/ammo/CursedBullet.java +++ b/src/main/java/com/lzxnone/terraria/item/ammo/CursedBullet.java @@ -74,7 +74,7 @@ public class CursedBullet extends BulletAmmo { CompoundTag customData = summon.getEntityData().get(StaticSummon.CUSTOM_DATA); float damage = customData.contains("damage") ? customData.getFloat("damage") : 0; float knockbackScale = customData.contains("knockbackScale") ? customData.getFloat("knockbackScale") : 1.0f; - int invulnerableTime = customData.contains("invulnerableTime") ? customData.getInt("invulnerableTime") : 20; + int invulnerableTime = customData.contains("invulnerableTime") ? customData.getInt("invulnerableTime") : 10; ItemStack sourceStack = summon.getEntityData().get(StaticSummon.STACK_SOURCE); Entity target = targets.getFirst(); diff --git a/src/main/java/com/lzxnone/terraria/item/ammo/ExplodingBullet.java b/src/main/java/com/lzxnone/terraria/item/ammo/ExplodingBullet.java index c5deabf..308a6d9 100644 --- a/src/main/java/com/lzxnone/terraria/item/ammo/ExplodingBullet.java +++ b/src/main/java/com/lzxnone/terraria/item/ammo/ExplodingBullet.java @@ -83,7 +83,7 @@ public class ExplodingBullet extends BulletAmmo { CompoundTag customData = summon.getEntityData().get(StaticSummon.CUSTOM_DATA); float damage = customData.contains("damage") ? customData.getFloat("damage") : 0; float knockbackScale = customData.contains("knockbackScale") ? customData.getFloat("knockbackScale") : 1.0f; - int invulnerableTime = customData.contains("invulnerableTime") ? customData.getInt("invulnerableTime") : 20; + int invulnerableTime = customData.contains("invulnerableTime") ? customData.getInt("invulnerableTime") : 10; ItemStack sourceStack = summon.getEntityData().get(StaticSummon.STACK_SOURCE); boolean dead = false; diff --git a/src/main/java/com/lzxnone/terraria/item/ammo/GoldenBullet.java b/src/main/java/com/lzxnone/terraria/item/ammo/GoldenBullet.java index affa81c..9c5223f 100644 --- a/src/main/java/com/lzxnone/terraria/item/ammo/GoldenBullet.java +++ b/src/main/java/com/lzxnone/terraria/item/ammo/GoldenBullet.java @@ -74,7 +74,7 @@ public class GoldenBullet extends BulletAmmo { CompoundTag customData = summon.getEntityData().get(StaticSummon.CUSTOM_DATA); float damage = customData.contains("damage") ? customData.getFloat("damage") : 0; float knockbackScale = customData.contains("knockbackScale") ? customData.getFloat("knockbackScale") : 1.0f; - int invulnerableTime = customData.contains("invulnerableTime") ? customData.getInt("invulnerableTime") : 20; + int invulnerableTime = customData.contains("invulnerableTime") ? customData.getInt("invulnerableTime") : 10; ItemStack sourceStack = summon.getEntityData().get(StaticSummon.STACK_SOURCE); Entity target = targets.getFirst(); diff --git a/src/main/java/com/lzxnone/terraria/item/ammo/HighVelocityBullet.java b/src/main/java/com/lzxnone/terraria/item/ammo/HighVelocityBullet.java index 8ff0710..e9058b0 100644 --- a/src/main/java/com/lzxnone/terraria/item/ammo/HighVelocityBullet.java +++ b/src/main/java/com/lzxnone/terraria/item/ammo/HighVelocityBullet.java @@ -72,7 +72,7 @@ public class HighVelocityBullet extends BulletAmmo { CompoundTag customData = summon.getEntityData().get(StaticSummon.CUSTOM_DATA); float damage = customData.contains("damage") ? customData.getFloat("damage") : 0; float knockbackScale = customData.contains("knockbackScale") ? customData.getFloat("knockbackScale") : 1.0f; - int invulnerableTime = customData.contains("invulnerableTime") ? customData.getInt("invulnerableTime") : 20; + int invulnerableTime = customData.contains("invulnerableTime") ? customData.getInt("invulnerableTime") : 10; ItemStack sourceStack = summon.getEntityData().get(StaticSummon.STACK_SOURCE); diff --git a/src/main/java/com/lzxnone/terraria/item/ammo/IchorBullet.java b/src/main/java/com/lzxnone/terraria/item/ammo/IchorBullet.java index 0829480..a416755 100644 --- a/src/main/java/com/lzxnone/terraria/item/ammo/IchorBullet.java +++ b/src/main/java/com/lzxnone/terraria/item/ammo/IchorBullet.java @@ -74,7 +74,7 @@ public class IchorBullet extends BulletAmmo { CompoundTag customData = summon.getEntityData().get(StaticSummon.CUSTOM_DATA); float damage = customData.contains("damage") ? customData.getFloat("damage") : 0; float knockbackScale = customData.contains("knockbackScale") ? customData.getFloat("knockbackScale") : 1.0f; - int invulnerableTime = customData.contains("invulnerableTime") ? customData.getInt("invulnerableTime") : 20; + int invulnerableTime = customData.contains("invulnerableTime") ? customData.getInt("invulnerableTime") : 10; ItemStack sourceStack = summon.getEntityData().get(StaticSummon.STACK_SOURCE); Entity target = targets.getFirst(); diff --git a/src/main/java/com/lzxnone/terraria/item/ammo/LuminiteBullet.java b/src/main/java/com/lzxnone/terraria/item/ammo/LuminiteBullet.java index fd1b40f..64b470a 100644 --- a/src/main/java/com/lzxnone/terraria/item/ammo/LuminiteBullet.java +++ b/src/main/java/com/lzxnone/terraria/item/ammo/LuminiteBullet.java @@ -81,7 +81,7 @@ public class LuminiteBullet extends BulletAmmo { CompoundTag customData = summon.getEntityData().get(StaticSummon.CUSTOM_DATA); float damage = customData.contains("damage") ? customData.getFloat("damage") : 0; float knockbackScale = customData.contains("knockbackScale") ? customData.getFloat("knockbackScale") : 1.0f; - int invulnerableTime = customData.contains("invulnerableTime") ? customData.getInt("invulnerableTime") : 20; + int invulnerableTime = customData.contains("invulnerableTime") ? customData.getInt("invulnerableTime") : 10; ItemStack sourceStack = summon.getEntityData().get(StaticSummon.STACK_SOURCE); diff --git a/src/main/java/com/lzxnone/terraria/item/ammo/MeteorShot.java b/src/main/java/com/lzxnone/terraria/item/ammo/MeteorShot.java index 528ae4a..b57ed8c 100644 --- a/src/main/java/com/lzxnone/terraria/item/ammo/MeteorShot.java +++ b/src/main/java/com/lzxnone/terraria/item/ammo/MeteorShot.java @@ -76,7 +76,7 @@ public class MeteorShot extends BulletAmmo { CompoundTag customData = summon.getEntityData().get(StaticSummon.CUSTOM_DATA); float damage = customData.contains("damage") ? customData.getFloat("damage") : 0; float knockbackScale = customData.contains("knockbackScale") ? customData.getFloat("knockbackScale") : 1.0f; - int invulnerableTime = customData.contains("invulnerableTime") ? customData.getInt("invulnerableTime") : 20; + int invulnerableTime = customData.contains("invulnerableTime") ? customData.getInt("invulnerableTime") : 10; ItemStack sourceStack = summon.getEntityData().get(StaticSummon.STACK_SOURCE); for(Entity target : targets) { diff --git a/src/main/java/com/lzxnone/terraria/item/ammo/MusketBall.java b/src/main/java/com/lzxnone/terraria/item/ammo/MusketBall.java index 79bd51d..cacfe38 100644 --- a/src/main/java/com/lzxnone/terraria/item/ammo/MusketBall.java +++ b/src/main/java/com/lzxnone/terraria/item/ammo/MusketBall.java @@ -68,7 +68,7 @@ public class MusketBall extends BulletAmmo { CompoundTag customData = summon.getEntityData().get(StaticSummon.CUSTOM_DATA); float damage = customData.contains("damage") ? customData.getFloat("damage") : 0; float knockbackScale = customData.contains("knockbackScale") ? customData.getFloat("knockbackScale") : 1.0f; - int invulnerableTime = customData.contains("invulnerableTime") ? customData.getInt("invulnerableTime") : 20; + int invulnerableTime = customData.contains("invulnerableTime") ? customData.getInt("invulnerableTime") : 10; ItemStack sourceStack = summon.getEntityData().get(StaticSummon.STACK_SOURCE); Entity target = targets.getFirst(); diff --git a/src/main/java/com/lzxnone/terraria/item/ammo/NanoBullet.java b/src/main/java/com/lzxnone/terraria/item/ammo/NanoBullet.java index c1a6143..4d1a668 100644 --- a/src/main/java/com/lzxnone/terraria/item/ammo/NanoBullet.java +++ b/src/main/java/com/lzxnone/terraria/item/ammo/NanoBullet.java @@ -81,7 +81,7 @@ public class NanoBullet extends BulletAmmo { CompoundTag customData = summon.getEntityData().get(StaticSummon.CUSTOM_DATA); float damage = customData.contains("damage") ? customData.getFloat("damage") : 0; float knockbackScale = customData.contains("knockbackScale") ? customData.getFloat("knockbackScale") : 1.0f; - int invulnerableTime = customData.contains("invulnerableTime") ? customData.getInt("invulnerableTime") : 20; + int invulnerableTime = customData.contains("invulnerableTime") ? customData.getInt("invulnerableTime") : 10; ItemStack sourceStack = summon.getEntityData().get(StaticSummon.STACK_SOURCE); Entity target = targets.getFirst(); diff --git a/src/main/java/com/lzxnone/terraria/item/ammo/PartyBullet.java b/src/main/java/com/lzxnone/terraria/item/ammo/PartyBullet.java index d1ce55a..ec95fe4 100644 --- a/src/main/java/com/lzxnone/terraria/item/ammo/PartyBullet.java +++ b/src/main/java/com/lzxnone/terraria/item/ammo/PartyBullet.java @@ -71,7 +71,7 @@ public class PartyBullet extends BulletAmmo { CompoundTag customData = summon.getEntityData().get(StaticSummon.CUSTOM_DATA); float damage = customData.contains("damage") ? customData.getFloat("damage") : 0; float knockbackScale = customData.contains("knockbackScale") ? customData.getFloat("knockbackScale") : 1.0f; - int invulnerableTime = customData.contains("invulnerableTime") ? customData.getInt("invulnerableTime") : 20; + int invulnerableTime = customData.contains("invulnerableTime") ? customData.getInt("invulnerableTime") : 10; ItemStack sourceStack = summon.getEntityData().get(StaticSummon.STACK_SOURCE); Entity target = targets.getFirst(); diff --git a/src/main/java/com/lzxnone/terraria/item/ammo/SilverBullet.java b/src/main/java/com/lzxnone/terraria/item/ammo/SilverBullet.java index 940dc31..c8d0f08 100644 --- a/src/main/java/com/lzxnone/terraria/item/ammo/SilverBullet.java +++ b/src/main/java/com/lzxnone/terraria/item/ammo/SilverBullet.java @@ -73,7 +73,7 @@ public class SilverBullet extends BulletAmmo { CompoundTag customData = summon.getEntityData().get(StaticSummon.CUSTOM_DATA); float damage = customData.contains("damage") ? customData.getFloat("damage") : 0; float knockbackScale = customData.contains("knockbackScale") ? customData.getFloat("knockbackScale") : 1.0f; - int invulnerableTime = customData.contains("invulnerableTime") ? customData.getInt("invulnerableTime") : 20; + int invulnerableTime = customData.contains("invulnerableTime") ? customData.getInt("invulnerableTime") : 10; ItemStack sourceStack = summon.getEntityData().get(StaticSummon.STACK_SOURCE); Entity target = targets.getFirst(); diff --git a/src/main/java/com/lzxnone/terraria/item/ammo/TungstenBullet.java b/src/main/java/com/lzxnone/terraria/item/ammo/TungstenBullet.java index 37694b1..506a8a3 100644 --- a/src/main/java/com/lzxnone/terraria/item/ammo/TungstenBullet.java +++ b/src/main/java/com/lzxnone/terraria/item/ammo/TungstenBullet.java @@ -68,7 +68,7 @@ public class TungstenBullet extends BulletAmmo { CompoundTag customData = summon.getEntityData().get(StaticSummon.CUSTOM_DATA); float damage = customData.contains("damage") ? customData.getFloat("damage") : 0; float knockbackScale = customData.contains("knockbackScale") ? customData.getFloat("knockbackScale") : 1.0f; - int invulnerableTime = customData.contains("invulnerableTime") ? customData.getInt("invulnerableTime") : 20; + int invulnerableTime = customData.contains("invulnerableTime") ? customData.getInt("invulnerableTime") : 10; ItemStack sourceStack = summon.getEntityData().get(StaticSummon.STACK_SOURCE); Entity target = targets.getFirst(); diff --git a/src/main/java/com/lzxnone/terraria/item/ammo/VenomBullet.java b/src/main/java/com/lzxnone/terraria/item/ammo/VenomBullet.java index 5596c87..936cd9b 100644 --- a/src/main/java/com/lzxnone/terraria/item/ammo/VenomBullet.java +++ b/src/main/java/com/lzxnone/terraria/item/ammo/VenomBullet.java @@ -74,7 +74,7 @@ public class VenomBullet extends BulletAmmo { CompoundTag customData = summon.getEntityData().get(StaticSummon.CUSTOM_DATA); float damage = customData.contains("damage") ? customData.getFloat("damage") : 0; float knockbackScale = customData.contains("knockbackScale") ? customData.getFloat("knockbackScale") : 1.0f; - int invulnerableTime = customData.contains("invulnerableTime") ? customData.getInt("invulnerableTime") : 20; + int invulnerableTime = customData.contains("invulnerableTime") ? customData.getInt("invulnerableTime") : 10; ItemStack sourceStack = summon.getEntityData().get(StaticSummon.STACK_SOURCE); Entity target = targets.getFirst(); diff --git a/src/main/java/com/lzxnone/terraria/item/ammo/WoodenArrow.java b/src/main/java/com/lzxnone/terraria/item/ammo/WoodenArrow.java index c3ba5c0..0841286 100644 --- a/src/main/java/com/lzxnone/terraria/item/ammo/WoodenArrow.java +++ b/src/main/java/com/lzxnone/terraria/item/ammo/WoodenArrow.java @@ -78,7 +78,7 @@ public class WoodenArrow extends ArrowAmmo { if(!targets.isEmpty()) { float damage = customData.contains("damage") ? customData.getFloat("damage") : 0.0f; float knockbackScale = customData.contains("knockbackScale") ? customData.getFloat("knockbackScale") : 1.0f; - int invulnerableTime = customData.contains("invulnerableTime") ? customData.getInt("invulnerableTime") : 20; + int invulnerableTime = customData.contains("invulnerableTime") ? customData.getInt("invulnerableTime") : 10; ItemStack sourceStack = summon.getEntityData().get(StaticSummon.STACK_SOURCE); Entity target = targets.getFirst(); diff --git a/src/main/java/com/lzxnone/terraria/item/effect/FallenStarSummoner.java b/src/main/java/com/lzxnone/terraria/item/effect/FallenStarSummoner.java index f3c86b1..a2291cb 100644 --- a/src/main/java/com/lzxnone/terraria/item/effect/FallenStarSummoner.java +++ b/src/main/java/com/lzxnone/terraria/item/effect/FallenStarSummoner.java @@ -52,7 +52,7 @@ public interface FallenStarSummoner { fallenStarDamage[0] = Math.max(summoner.getFallenStarDamage(accessoryStack, player), fallenStarDamage[0]); } }); - if(DamageUtil.meleeAttack(projectile, target, stack, (float) fallenStarDamage[0], 1.0f, 5)) { + if(DamageUtil.meleeAttack(projectile, target, stack, (float) fallenStarDamage[0], 1.0f, 10)) { } } } diff --git a/src/main/java/com/lzxnone/terraria/item/weapon/MeleeWeapon.java b/src/main/java/com/lzxnone/terraria/item/weapon/MeleeWeapon.java index d5a2cf6..f410b49 100644 --- a/src/main/java/com/lzxnone/terraria/item/weapon/MeleeWeapon.java +++ b/src/main/java/com/lzxnone/terraria/item/weapon/MeleeWeapon.java @@ -8,16 +8,21 @@ import com.lzxnone.terraria.ui.config.ConfigListItem; import com.lzxnone.terraria.ui.config.IConfigData; import com.lzxnone.terraria.ui.config.struct.ConfigFloat; import com.lzxnone.terraria.ui.config.struct.ConfigStruct; +import com.lzxnone.terraria.utils.DamageUtil; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.EquipmentSlotGroup; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.ai.attributes.AttributeModifier; import net.minecraft.world.entity.ai.attributes.Attributes; +import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Tier; import net.minecraft.world.item.component.ItemAttributeModifiers; import net.minecraft.world.item.enchantment.EnchantmentHelper; +import net.minecraft.world.item.enchantment.Enchantments; +import net.neoforged.neoforge.common.ItemAbilities; +import net.neoforged.neoforge.common.ItemAbility; public class MeleeWeapon extends Weapon { private static final float BASE_MELEE_DAMAGE_MIN = 0.0F; @@ -77,6 +82,19 @@ public class MeleeWeapon extends Weapon { return -2.4F; } + public float getTooltipDamage(ItemStack weaponStack, LivingEntity entity) { + float damage = getBaseMeleeDamage(weaponStack); + //锋利附魔 + int sharpnessLevel = getEnchantmentLevel(entity, weaponStack, Enchantments.SHARPNESS); + if(sharpnessLevel > 0) { + damage += 1.0F + Math.max(0, sharpnessLevel - 1) * 0.5F; + } + //药水 + if(entity instanceof Player player) damage = DamageUtil.applyPlayerDamageEffects(player, damage); + //近战加成 + return applyMeleeDamageBonus(weaponStack, entity, damage); + } + @Override public ItemAttributeModifiers getDefaultAttributeModifiers(ItemStack stack) { return ItemAttributeModifiers.builder() @@ -89,8 +107,12 @@ public class MeleeWeapon extends Weapon { .build(); } - public static float applyMeleeDamageBonus(ItemStack stack, LivingEntity entity, float damage) { - double finalDamage = damage; + @Override + public boolean canPerformAction(ItemStack stack, ItemAbility itemAbility) { + return itemAbility == ItemAbilities.SWORD_SWEEP || super.canPerformAction(stack, itemAbility); + } + + public static float applyMeleeDamageBonus(ItemStack stack, LivingEntity entity, float damage) { double finalDamage = damage; //饰品 double[] multiplier = {1.0D}; AccessoryUtil.forEachAccessory(entity, (accessory, accessoryStack) -> { diff --git a/src/main/java/com/lzxnone/terraria/item/weapon/magic/BubbleGun.java b/src/main/java/com/lzxnone/terraria/item/weapon/magic/BubbleGun.java index 21da7fb..990b99f 100644 --- a/src/main/java/com/lzxnone/terraria/item/weapon/magic/BubbleGun.java +++ b/src/main/java/com/lzxnone/terraria/item/weapon/magic/BubbleGun.java @@ -28,6 +28,7 @@ import net.minecraft.server.level.ServerLevel; import net.minecraft.sounds.SoundSource; import net.minecraft.world.InteractionHand; import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.HumanoidArm; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.Item; @@ -55,7 +56,7 @@ public class BubbleGun extends MagicWeapon { public static final ConfigFloat DAMAGE = new ConfigFloat("weapon.bubble_gun.damage", "bubble_gun_damage", 10.0F, 0.0F, 8388600.0F); public static final ConfigDouble SPEED = new ConfigDouble("weapon.bubble_gun.speed", "bubble_gun_speed", 1.2D, 0.0D, 10.0D); public static final ConfigDouble DRAG = new ConfigDouble("weapon.bubble_gun.drag", "bubble_gun_drag", 0.94D, 0.0D, 1.0D); - public static final ConfigDouble MANA_CONSUME = new ConfigDouble("weapon.bubble_gun.mana_consume", "bubble_gun_mana_consume", 5.0D, 0.0D, 10000.0D); + public static final ConfigDouble MANA_CONSUME = new ConfigDouble("weapon.bubble_gun.mana_consume", "bubble_gun_mana_consume", 2.5D, 0.0D, 10000.0D); public static final IConfigData CONFIG_DATA = new IConfigData() { @Override @@ -99,7 +100,7 @@ public class BubbleGun extends MagicWeapon { ); if(!targets.isEmpty()) { Entity target = targets.getFirst(); - if(DamageUtil.magicAttack(summon, target, summon.getEntityData().get(StaticSummon.STACK_SOURCE), DAMAGE.get(), 0.2F, 5)) { + if(DamageUtil.magicAttack(summon, target, summon.getEntityData().get(StaticSummon.STACK_SOURCE), DAMAGE.get(), 0.2F, 10)) { } onDied(summon); return; @@ -177,7 +178,7 @@ public class BubbleGun extends MagicWeapon { .normalize(); Vector3f offset = new Vector3f( - hand == InteractionHand.OFF_HAND ? -OFFSET.x : OFFSET.x, + hand == (player.getMainArm() == HumanoidArm.RIGHT ? InteractionHand.OFF_HAND : InteractionHand.MAIN_HAND) ? -OFFSET.x : OFFSET.x, OFFSET.y, OFFSET.z ); diff --git a/src/main/java/com/lzxnone/terraria/item/weapon/magic/LastPrism.java b/src/main/java/com/lzxnone/terraria/item/weapon/magic/LastPrism.java index a67030c..9971c48 100644 --- a/src/main/java/com/lzxnone/terraria/item/weapon/magic/LastPrism.java +++ b/src/main/java/com/lzxnone/terraria/item/weapon/magic/LastPrism.java @@ -55,7 +55,7 @@ public class LastPrism extends MagicWeapon { public static final ConfigFloat DAMAGE = new ConfigFloat( "weapon.last_prism.damage", "last_prism_damage", - 2.0f, + 3.0f, 0.0f, 8388600.0f ); @@ -241,7 +241,7 @@ public class LastPrism extends MagicWeapon { AABB entityBox = hitEntity.getBoundingBox().inflate(beamData.radius()); Optional clipResult = entityBox.clip(beamData.start(), beamData.end()); if(entityBox.contains(beamData.start()) || clipResult.isPresent()) { - if(DamageUtil.magicAttack(beam, hitEntity, beam.getEntityData().get(StaticSummon.STACK_SOURCE), DAMAGE.get() * beamData.ratio(), 0.1f, 5)) { + if(DamageUtil.magicAttack(beam, hitEntity, beam.getEntityData().get(StaticSummon.STACK_SOURCE), DAMAGE.get() * beamData.ratio(), 0.1f, 2)) { } } } diff --git a/src/main/java/com/lzxnone/terraria/item/weapon/magic/NebulaArcanum.java b/src/main/java/com/lzxnone/terraria/item/weapon/magic/NebulaArcanum.java index 44a475e..b5826c1 100644 --- a/src/main/java/com/lzxnone/terraria/item/weapon/magic/NebulaArcanum.java +++ b/src/main/java/com/lzxnone/terraria/item/weapon/magic/NebulaArcanum.java @@ -43,15 +43,15 @@ import java.util.List; import java.util.Locale; public class NebulaArcanum extends MagicWeapon { - public static final ConfigFloat DAMAGE = new ConfigFloat("weapon.nebula_arcanum.damage", "nebula_arcanum_damage", 15.0F, 0.0F, 8388600.0F); + public static final ConfigFloat DAMAGE = new ConfigFloat("weapon.nebula_arcanum.damage", "nebula_arcanum_damage", 8.0F, 0.0F, 8388600.0F); public static final ConfigDouble MANA_CONSUME = new ConfigDouble("weapon.nebula_arcanum.mana_consume", "nebula_arcanum_mana_consume", 30.0D, 0.0D, 10000.0D); public static final ConfigDouble SPEED = new ConfigDouble("weapon.nebula_arcanum.speed", "nebula_arcanum_speed", 0.5D, 0.0D, 10.0D); public static final ConfigInt LIFETIME = new ConfigInt("weapon.nebula_arcanum.lifetime", "nebula_arcanum_lifetime", 220, 1, 72000); public static final ConfigDouble TARGET_RANGE = new ConfigDouble("weapon.nebula_arcanum.target_range", "nebula_arcanum_target_range", 24.0D, 0.0D, 128.0D); public static final ConfigDouble EXPLOSION_RANGE = new ConfigDouble("weapon.nebula_arcanum.explosion_range", "nebula_arcanum_explosion_range", 4.0D, 0.0D, 64.0D); public static final ConfigInt HIT_COUNT = new ConfigInt("weapon.nebula_arcanum.hit_count", "nebula_arcanum_hit_count", 3, 1, 128); - public static final ConfigFloat ORBIT_PROJECTILE_DAMAGE = new ConfigFloat("weapon.nebula_arcanum.orbit_projectile_damage", "nebula_arcanum_orbit_projectile_damage", 7.0F, 0.0F, 8388600.0F); - public static final ConfigFloat SMALL_PROJECTILE_DAMAGE = new ConfigFloat("weapon.nebula_arcanum.small_projectile_damage", "nebula_arcanum_small_projectile_damage", 10.0F, 0.0F, 8388600.0F); + public static final ConfigFloat ORBIT_PROJECTILE_DAMAGE = new ConfigFloat("weapon.nebula_arcanum.orbit_projectile_damage", "nebula_arcanum_orbit_projectile_damage", 6.0F, 0.0F, 8388600.0F); + public static final ConfigFloat SMALL_PROJECTILE_DAMAGE = new ConfigFloat("weapon.nebula_arcanum.small_projectile_damage", "nebula_arcanum_small_projectile_damage", 2.0F, 0.0F, 8388600.0F); private static final int TRACK_DELAY = 20; private static final int ORBIT_PROJECTILE_SPAWN_INTERVAL = 20; @@ -236,7 +236,7 @@ public class NebulaArcanum extends MagicWeapon { if(!targets.isEmpty()) { CompoundTag customData = summon.getEntityData().get(StaticSummon.CUSTOM_DATA); ItemStack sourceStack = summon.getEntityData().get(StaticSummon.STACK_SOURCE); - if(DamageUtil.magicAttack(summon, targets.getFirst(), sourceStack, DAMAGE.get(), 0.75F, 15)) { + if(DamageUtil.magicAttack(summon, targets.getFirst(), sourceStack, DAMAGE.get(), 0.75F, 10)) { int hitCount = customData.getInt("hitCount") + 1; customData.putInt("hitCount", hitCount); summon.getEntityData().set(StaticSummon.CUSTOM_DATA, customData); @@ -276,7 +276,7 @@ public class NebulaArcanum extends MagicWeapon { FilterUtil.createTargetFilter(summon, summon.getOwner()) )) { if(target.distanceToSqr(pos) > explosionRange * explosionRange) continue; - DamageUtil.magicAttack(summon, target, sourceStack, DAMAGE.get(), 0.75F, 5); + DamageUtil.magicAttack(summon, target, sourceStack, DAMAGE.get(), 0.75F, 10); } } SoundUtil.playServerSound(summon.level(), ModSounds.BOOM.get(), summon.position()); @@ -350,7 +350,7 @@ public class NebulaArcanum extends MagicWeapon { ); if(!targets.isEmpty()) { ItemStack sourceStack = summon.getEntityData().get(StaticSummon.STACK_SOURCE); - if(DamageUtil.magicAttack(summon, targets.getFirst(), sourceStack, SMALL_PROJECTILE_DAMAGE.get(), 0.4F, 15)) { + if(DamageUtil.magicAttack(summon, targets.getFirst(), sourceStack, SMALL_PROJECTILE_DAMAGE.get(), 0.4F, 10)) { onDied(summon); return; } diff --git a/src/main/java/com/lzxnone/terraria/item/weapon/magic/NebulaBlaze.java b/src/main/java/com/lzxnone/terraria/item/weapon/magic/NebulaBlaze.java index ea6ff34..e058947 100644 --- a/src/main/java/com/lzxnone/terraria/item/weapon/magic/NebulaBlaze.java +++ b/src/main/java/com/lzxnone/terraria/item/weapon/magic/NebulaBlaze.java @@ -23,6 +23,7 @@ import net.minecraft.server.level.ServerLevel; import net.minecraft.sounds.SoundSource; import net.minecraft.world.InteractionHand; import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.HumanoidArm; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.Item; @@ -152,7 +153,7 @@ public class NebulaBlaze extends MagicWeapon { Vector3f[] dirs = MathUtil.computeCoordinateSystem(player); Vector3f offset = new Vector3f( - hand == InteractionHand.OFF_HAND ? -OFFSET.x : OFFSET.x, + hand == (player.getMainArm() == HumanoidArm.RIGHT ? InteractionHand.OFF_HAND : InteractionHand.MAIN_HAND) ? -OFFSET.x : OFFSET.x, OFFSET.y, OFFSET.z ); @@ -302,7 +303,7 @@ public class NebulaBlaze extends MagicWeapon { FilterUtil.createTargetFilter(summon, summon.getOwner()) )) { if(target.distanceToSqr(pos) > explosionRange * explosionRange) continue; - if(DamageUtil.magicAttack(summon, target, sourceStack, damage, 0.4F, 5)) { + if(DamageUtil.magicAttack(summon, target, sourceStack, damage, 0.4F, 10)) { } } } diff --git a/src/main/java/com/lzxnone/terraria/item/weapon/magic/StellarTune.java b/src/main/java/com/lzxnone/terraria/item/weapon/magic/StellarTune.java index 877f4ab..bcf78ce 100644 --- a/src/main/java/com/lzxnone/terraria/item/weapon/magic/StellarTune.java +++ b/src/main/java/com/lzxnone/terraria/item/weapon/magic/StellarTune.java @@ -27,6 +27,7 @@ import net.minecraft.server.level.ServerLevel; import net.minecraft.sounds.SoundSource; import net.minecraft.world.InteractionHand; import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.HumanoidArm; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.Item; @@ -122,7 +123,11 @@ public class StellarTune extends MagicWeapon { double targetRange = TARGET_RANGE.get(); Vector3f[] playerDirs = MathUtil.computeCoordinateSystem(player); - Vector3f offset = AmmoUtil.getOffset(hand, OFFSET); + Vector3f offset = new Vector3f( + hand == (player.getMainArm() == HumanoidArm.RIGHT ? InteractionHand.OFF_HAND : InteractionHand.MAIN_HAND) ? -OFFSET.x : OFFSET.x, + OFFSET.y, + OFFSET.z + ); Vec3 eyePos = player.getEyePosition(); Vec3 start = new Vec3( eyePos.x + playerDirs[0].x * offset.z + playerDirs[1].x * offset.y + playerDirs[2].x * offset.x, diff --git a/src/main/java/com/lzxnone/terraria/item/weapon/melee/BladeOfGrass.java b/src/main/java/com/lzxnone/terraria/item/weapon/melee/BladeOfGrass.java index 0e9bf9f..a3a4683 100644 --- a/src/main/java/com/lzxnone/terraria/item/weapon/melee/BladeOfGrass.java +++ b/src/main/java/com/lzxnone/terraria/item/weapon/melee/BladeOfGrass.java @@ -38,6 +38,7 @@ import com.lzxnone.terraria.ui.config.struct.ConfigInt; import com.lzxnone.terraria.ui.config.struct.ConfigStruct; import java.util.List; +import net.minecraft.world.item.enchantment.Enchantments; public class BladeOfGrass extends MeleeWeapon { public static final String ID = "blade_of_grass"; @@ -115,6 +116,20 @@ public class BladeOfGrass extends MeleeWeapon { super(Tiers.IRON, new Item.Properties()); } + @Override + public float getTooltipDamage(ItemStack weaponStack, LivingEntity entity) { + float damage = PROJECTILE_DAMAGE.get(); + //锋利附魔 + int sharpnessLevel = getEnchantmentLevel(entity, weaponStack, Enchantments.SHARPNESS); + if(sharpnessLevel > 0) { + damage += 1.0F + Math.max(0, sharpnessLevel - 1) * 0.5F; + } + //药水 + if(entity instanceof Player player) damage = DamageUtil.applyPlayerDamageEffects(player, damage); + //近战加成 + return MeleeWeapon.applyMeleeDamageBonus(weaponStack, entity, damage); + } + @Override protected float getBaseMeleeDamage(ItemStack stack) { return BASE_MELEE_DAMAGE.get(); @@ -150,7 +165,7 @@ public class BladeOfGrass extends MeleeWeapon { CompoundTag customData = projectile.getEntityData().get(StaticProjectile.CUSTOM_DATA); if(!customData.contains("hitCount") || customData.getInt("hitCount") >= PROJECTILE_MAX_HIT_COUNT.get()) return; if(!FilterUtil.createTargetFilter(owner).test(target) || !(owner instanceof Player player)) return; - if(DamageUtil.meleeAttack(projectile, target, projectile.getEntityData().get(StaticProjectile.STACK_SOURCE), (float) PROJECTILE_DAMAGE.get(), 1.0f, -1)) { + if(DamageUtil.meleeAttack(projectile, target, projectile.getEntityData().get(StaticProjectile.STACK_SOURCE), (float) PROJECTILE_DAMAGE.get(), 1.0f, 10)) { int count = customData.getInt("hitCount"); count++; if(target instanceof LivingEntity livingEntity && projectile.getRandom().nextInt(4) == 0) { diff --git a/src/main/java/com/lzxnone/terraria/item/weapon/melee/DevilsDevastation.java b/src/main/java/com/lzxnone/terraria/item/weapon/melee/DevilsDevastation.java index e3dfe1d..e211c67 100644 --- a/src/main/java/com/lzxnone/terraria/item/weapon/melee/DevilsDevastation.java +++ b/src/main/java/com/lzxnone/terraria/item/weapon/melee/DevilsDevastation.java @@ -50,6 +50,7 @@ import com.lzxnone.terraria.ui.config.struct.ConfigStruct; import java.util.*; +import net.minecraft.world.item.enchantment.Enchantments; public class DevilsDevastation extends MeleeWeapon { @@ -219,6 +220,20 @@ public class DevilsDevastation extends MeleeWeapon { super(Tiers.NETHERITE, new Properties().fireResistant().rarity(Rarity.EPIC)); } + @Override + public float getTooltipDamage(ItemStack weaponStack, LivingEntity entity) { + float damage = KILL_MODE_PROJECTILE_DAMAGE.get(); + //锋利附魔 + int sharpnessLevel = getEnchantmentLevel(entity, weaponStack, Enchantments.SHARPNESS); + if(sharpnessLevel > 0) { + damage += 1.0F + Math.max(0, sharpnessLevel - 1) * 0.5F; + } + //药水 + if(entity instanceof Player player) damage = DamageUtil.applyPlayerDamageEffects(player, damage); + //近战加成 + return MeleeWeapon.applyMeleeDamageBonus(weaponStack, entity, damage); + } + @Override protected float getBaseMeleeDamage(ItemStack stack) { return BASE_MELEE_DAMAGE.get(); @@ -320,7 +335,7 @@ public class DevilsDevastation extends MeleeWeapon { Entity owner = projectile.getOwner(); if(owner == null) return; if(!FilterUtil.createTargetFilter(owner).test(target) || !(owner instanceof Player player)) return; - if(DamageUtil.meleeAttack(projectile, target, projectile.getEntityData().get(StaticProjectile.STACK_SOURCE), (float) PROJECTILE_DAMAGE.get(), 1.0f, 5)) { + if(DamageUtil.meleeAttack(projectile, target, projectile.getEntityData().get(StaticProjectile.STACK_SOURCE), (float) PROJECTILE_DAMAGE.get(), 1.0f, 10)) { if(target instanceof LivingEntity le) { MobEffectInstance effectInstance = new MobEffectInstance(ModEffects.DEMONIC_FLAMES, PROJECTILE_EFFECT_DURATION.get(), 0); le.addEffect(effectInstance); @@ -503,7 +518,7 @@ public class DevilsDevastation extends MeleeWeapon { Entity owner = projectile.getOwner(); if(owner == null) return; if(!FilterUtil.createTargetFilter(owner).test(target) || !(owner instanceof Player player)) return; - if(DamageUtil.meleeAttack(projectile, target, projectile.getEntityData().get(StaticProjectile.STACK_SOURCE), (float) STUCK_PROJECTILE_DAMAGE.get(), 1.0f, -1)) { + if(DamageUtil.meleeAttack(projectile, target, projectile.getEntityData().get(StaticProjectile.STACK_SOURCE), (float) STUCK_PROJECTILE_DAMAGE.get(), 1.0f, 10)) { if(target instanceof LivingEntity le) { MobEffectInstance effectInstance = new MobEffectInstance(ModEffects.DEMONIC_FLAMES, STUCK_PROJECTILE_EFFECT_DURATION.get(), 0); le.addEffect(effectInstance); @@ -613,7 +628,7 @@ public class DevilsDevastation extends MeleeWeapon { Entity target = result.getEntity(); List tempStuckList = target.getData(ModAttachments.STUCK_DEVILS_DEVASTATION_PROJECTILE); boolean valid = !tempStuckList.isEmpty(); - if(projectile.getOwner() instanceof Player player && DamageUtil.meleeAttack(projectile, target, projectile.getEntityData().get(StaticProjectile.STACK_SOURCE), (float) KILL_MODE_PROJECTILE_DAMAGE.get(), 4.0f, -1)) { + if(projectile.getOwner() instanceof Player player && DamageUtil.meleeAttack(projectile, target, projectile.getEntityData().get(StaticProjectile.STACK_SOURCE), (float) KILL_MODE_PROJECTILE_DAMAGE.get(), 4.0f, 10)) { if(target instanceof LivingEntity le) { MobEffectInstance effectInstance = new MobEffectInstance(ModEffects.DEMONIC_FLAMES, KILL_MODE_PROJECTILE_EFFECT_DURATION.get(), 1); le.addEffect(effectInstance); @@ -800,7 +815,7 @@ public class DevilsDevastation extends MeleeWeapon { UUID uuid = customData.getUUID("uuid"); Entity entity = serverLevel.getEntity(uuid); if(entity instanceof Player player) { - DamageUtil.meleeAttack(player, owner, summon.getEntityData().get(StaticSummon.STACK_SOURCE), (float) MARK_LIGHTNING_DAMAGE.get(), 1.0f, -1); + DamageUtil.meleeAttack(player, owner, summon.getEntityData().get(StaticSummon.STACK_SOURCE), (float) MARK_LIGHTNING_DAMAGE.get(), 1.0f, 10); StaticSummon newSummon = new StaticSummon(ModEntities.STATIC_SUMMON.get(), serverLevel); newSummon.setOwner(player); newSummon.getEntityData().set(StaticSummon.STACK_SOURCE, summon.getEntityData().get(StaticSummon.STACK_SOURCE).copy()); diff --git a/src/main/java/com/lzxnone/terraria/item/weapon/melee/EnchantedSword.java b/src/main/java/com/lzxnone/terraria/item/weapon/melee/EnchantedSword.java index 57bc71f..b3bce8c 100644 --- a/src/main/java/com/lzxnone/terraria/item/weapon/melee/EnchantedSword.java +++ b/src/main/java/com/lzxnone/terraria/item/weapon/melee/EnchantedSword.java @@ -34,6 +34,7 @@ import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.EntityHitResult; import net.minecraft.world.phys.Vec3; import org.joml.Vector3f; +import net.minecraft.world.item.enchantment.Enchantments; public class EnchantedSword extends MeleeWeapon { public static final String ID = "enchanted_sword"; @@ -64,6 +65,20 @@ public class EnchantedSword extends MeleeWeapon { super(Tiers.IRON, new Item.Properties()); } + @Override + public float getTooltipDamage(ItemStack weaponStack, LivingEntity entity) { + float damage = DAMAGE.get(); + //锋利附魔 + int sharpnessLevel = getEnchantmentLevel(entity, weaponStack, Enchantments.SHARPNESS); + if(sharpnessLevel > 0) { + damage += 1.0F + Math.max(0, sharpnessLevel - 1) * 0.5F; + } + //药水 + if(entity instanceof Player player) damage = DamageUtil.applyPlayerDamageEffects(player, damage); + //近战加成 + return MeleeWeapon.applyMeleeDamageBonus(weaponStack, entity, damage); + } + @Override protected float getBaseMeleeDamage(ItemStack stack) { return BASE_MELEE_DAMAGE.get(); @@ -105,7 +120,7 @@ public class EnchantedSword extends MeleeWeapon { Entity owner = projectile.getOwner(); if(owner == null) return; if(!FilterUtil.createTargetFilter(owner).test(target) || !(owner instanceof Player player)) return; - if(DamageUtil.meleeAttack(projectile, target, projectile.getEntityData().get(StaticProjectile.STACK_SOURCE),(float) DAMAGE.get(), 1.0f, 5)) { + if(DamageUtil.meleeAttack(projectile, target, projectile.getEntityData().get(StaticProjectile.STACK_SOURCE),(float) DAMAGE.get(), 1.0f, 10)) { ParticleUtil.addParticles( (ServerLevel) projectile.level(), ModParticles.COLORFUL_PARTICLE, projectile.position(), new Vec3(0.2, 0.2, 0.2), diff --git a/src/main/java/com/lzxnone/terraria/item/weapon/melee/Excalibur.java b/src/main/java/com/lzxnone/terraria/item/weapon/melee/Excalibur.java index 7077ec7..8bbd79f 100644 --- a/src/main/java/com/lzxnone/terraria/item/weapon/melee/Excalibur.java +++ b/src/main/java/com/lzxnone/terraria/item/weapon/melee/Excalibur.java @@ -20,6 +20,7 @@ import net.minecraft.server.level.ServerLevel; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResultHolder; import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.*; import net.minecraft.world.level.Level; @@ -34,6 +35,9 @@ import com.lzxnone.terraria.ui.config.IConfigData; import com.lzxnone.terraria.ui.config.struct.ConfigFloat; import com.lzxnone.terraria.ui.config.struct.ConfigInt; import com.lzxnone.terraria.ui.config.struct.ConfigStruct; +import com.lzxnone.terraria.item.ModItems; +import net.minecraft.world.item.enchantment.Enchantments; +import org.jspecify.annotations.NonNull; public class Excalibur extends MeleeWeapon { public static final String ID = "excalibur"; @@ -79,6 +83,20 @@ public class Excalibur extends MeleeWeapon { super(Tiers.IRON, new Item.Properties().rarity(Rarity.UNCOMMON)); } + @Override + public float getTooltipDamage(ItemStack weaponStack, LivingEntity entity) { + float damage = DAMAGE.get(); + //锋利附魔 + int sharpnessLevel = getEnchantmentLevel(entity, weaponStack, Enchantments.SHARPNESS); + if(sharpnessLevel > 0) { + damage += 1.0F + Math.max(0, sharpnessLevel - 1) * 0.5F; + } + //药水 + if(entity instanceof Player player) damage = DamageUtil.applyPlayerDamageEffects(player, damage); + //近战加成 + return MeleeWeapon.applyMeleeDamageBonus(weaponStack, entity, damage); + } + @Override protected float getBaseMeleeDamage(ItemStack stack) { return BASE_MELEE_DAMAGE.get(); @@ -91,8 +109,6 @@ public class Excalibur extends MeleeWeapon { public static final CompoundTag BEAM_DATA = Util.make(new CompoundTag(), tag -> { tag.putString("behavior", "excalibur"); - tag.putInt("lifetime", 5); - tag.putInt("cooldown", 5); tag.putFloat("color0R", 0.745f); tag.putFloat("color0G", 0.620f); tag.putFloat("color0B", 0.243f); @@ -135,7 +151,7 @@ public class Excalibur extends MeleeWeapon { if(custom_data.contains("hitEntityCount")) { int count = custom_data.getInt("hitEntityCount"); if(count < MAX_HIT_COUNT.get()) { - if(DamageUtil.meleeAttack(beam, target, beam.getEntityData().get(SwordBeam.STACK_SOURCE), (float) DAMAGE.get(), 1.0f, 20)) { + if(DamageUtil.meleeAttack(beam, target, beam.getEntityData().get(SwordBeam.STACK_SOURCE), (float) DAMAGE.get(), 1.0f, 10)) { count++; custom_data.putInt("hitEntityCount", count); beam.getEntityData().set(SwordBeam.CUSTOM_DATA, custom_data); @@ -154,7 +170,11 @@ public class Excalibur extends MeleeWeapon { @Override public void generate(Entity entity, CompoundTag beamData) { beamData.putInt("rotate", (int) (ROTATE_RANGE.get() * (Math.random() * 2 - 1))); + beamData.putInt("lifetime", Math.max(1, getUseTime() / 3)); ISwordBeamBehavior.super.generate(entity, beamData); + if(entity instanceof Player player) { + player.getCooldowns().addCooldown(ModItems.EXCALIBUR.get(), Math.max(1, getUseTime() / 3)); + } } }; @@ -188,12 +208,58 @@ public class Excalibur extends MeleeWeapon { @Override public InteractionResultHolder use(Level level, Player player, InteractionHand hand) { ItemStack stack = player.getItemInHand(hand); - if(!level.isClientSide()) { - SwordBeamBehaviors.getBehavior("excalibur").generate(player, BEAM_DATA); - }else { - SoundUtil.playClientSound(player, ModSounds.WAVE.get()); + if(player.getCooldowns().isOnCooldown(stack.getItem()) || !tryShoot(level, player, hand, stack)) return InteractionResultHolder.fail(stack); + player.startUsingItem(hand); + player.getCooldowns().addCooldown(stack.getItem(), Math.max(1, getUseTime() / 3)); + return InteractionResultHolder.consume(stack); + } + + @Override + public void onUseTick(Level level, LivingEntity livingEntity, ItemStack stack, int count) { + if(!(livingEntity instanceof Player player)) return; + if(!shouldShootThisTick(stack, livingEntity, count)) return; + + if(!tryShoot(level, player, player.getUsedItemHand(), stack)) { + player.stopUsingItem(); } - return InteractionResultHolder.sidedSuccess(stack, level.isClientSide()); + } + + public boolean shouldShootThisTick(ItemStack weaponStack, LivingEntity entity, int remainingUseTicks) { + int useTime = Math.max(1, getUseTime()); + int elapsedMinecraftTicks = getUseDuration(weaponStack, entity) - remainingUseTicks; + if(elapsedMinecraftTicks <= 0) return false; + + int currentShot = elapsedMinecraftTicks * 3 / useTime; + int previousShot = (elapsedMinecraftTicks - 1) * 3 / useTime; + return currentShot > previousShot; + } + + public boolean tryShoot(Level level, Player player, InteractionHand hand, ItemStack stack) { + shoot(level, player, hand, stack); + return true; + } + + public void shoot(Level level, Player player, InteractionHand hand, ItemStack stack) { + SoundUtil.playClientSound(player, ModSounds.WAVE.get()); + int randomAngle = (int) (ROTATE_RANGE.get() * (Math.random() * 2 - 1)); + CompoundTag beamData = BEAM_DATA.copy(); + beamData.putInt("rotate", randomAngle); + beamData.putInt("lifetime", Math.max(1, getUseTime() / 3)); + SwordBeamBehaviors.getBehavior(SwordBeamBehaviors.DEFAULT).generate(player, beamData); + } + + public static int getUseTime() { + return 20; + } + + @Override + public int getUseDuration(ItemStack stack, LivingEntity entity) { + return 72000; + } + + @Override + public @NonNull UseAnim getUseAnimation(ItemStack stack) { + return UseAnim.NONE; } } diff --git a/src/main/java/com/lzxnone/terraria/item/weapon/melee/FirstFractal.java b/src/main/java/com/lzxnone/terraria/item/weapon/melee/FirstFractal.java index 73fca98..59a8dff 100644 --- a/src/main/java/com/lzxnone/terraria/item/weapon/melee/FirstFractal.java +++ b/src/main/java/com/lzxnone/terraria/item/weapon/melee/FirstFractal.java @@ -33,6 +33,7 @@ import com.lzxnone.terraria.ui.config.struct.ConfigStruct; import java.util.List; import java.util.UUID; +import net.minecraft.world.item.enchantment.Enchantments; public class FirstFractal extends MeleeWeapon { public static final String ID = "first_fractal"; @@ -41,7 +42,7 @@ public class FirstFractal extends MeleeWeapon { public static final ConfigFloat PROJECTILE_DAMAGE = new ConfigFloat( "weapon.first_fractal.projectile_damage", "first_fractal_projectile_damage", - 10.0f, + 25.0f, 0.0f, 8388600.0f ); @@ -128,6 +129,20 @@ public class FirstFractal extends MeleeWeapon { super(Tiers.NETHERITE, new Item.Properties().fireResistant().rarity(Rarity.EPIC)); } + @Override + public float getTooltipDamage(ItemStack weaponStack, LivingEntity entity) { + float damage = PROJECTILE_DAMAGE.get(); + //锋利附魔 + int sharpnessLevel = getEnchantmentLevel(entity, weaponStack, Enchantments.SHARPNESS); + if(sharpnessLevel > 0) { + damage += 1.0F + Math.max(0, sharpnessLevel - 1) * 0.5F; + } + //药水 + if(entity instanceof Player player) damage = DamageUtil.applyPlayerDamageEffects(player, damage); + //近战加成 + return MeleeWeapon.applyMeleeDamageBonus(weaponStack, entity, damage); + } + @Override protected float getBaseMeleeDamage(ItemStack stack) { return BASE_MELEE_DAMAGE.get(); @@ -174,10 +189,6 @@ public class FirstFractal extends MeleeWeapon { }; public static final IStaticSummonBehavior SUMMON_BEHAVIOR = new IStaticSummonBehavior() { - public static final ResourceLocation RES = ResourceLocation.parse("lzxnoneterraria:textures/vfx/beam_sparkle.png"); - public static final ResourceLocation RES2 = ResourceLocation.parse("lzxnoneterraria:textures/vfx/first_fractal_star.png"); - - @Override public void tick(StaticSummon summon) { this.checkBeforeTick(summon); @@ -267,21 +278,49 @@ public class FirstFractal extends MeleeWeapon { @Override public InteractionResultHolder use(Level level, Player player, InteractionHand hand) { ItemStack stack = player.getItemInHand(hand); + if(player.getCooldowns().isOnCooldown(stack.getItem()) || !tryShoot(level, player, hand, stack)) return InteractionResultHolder.fail(stack); player.startUsingItem(hand); - return InteractionResultHolder.consume(stack); + player.getCooldowns().addCooldown(stack.getItem(), Math.max(1, getUseTime() / 3)); + return InteractionResultHolder.sidedSuccess(stack, level.isClientSide()); } @Override public void onUseTick(Level level, LivingEntity livingEntity, ItemStack stack, int count) { if(!(livingEntity instanceof Player player)) return; - if(player.tickCount % 3 == 0) { - double deltaDist = stack.getOrDefault(DataComponents.CUSTOM_DATA, CustomData.EMPTY) - .copyTag().getDouble("deltaDist"); - summon(player, deltaDist); - SoundUtil.playClientSound(player, ModSounds.WAVE.get()); + if(!shouldShootThisTick(stack, livingEntity, count)) return; + + if(!tryShoot(level, player, player.getUsedItemHand(), stack)) { + player.stopUsingItem(); } } + public boolean shouldShootThisTick(ItemStack weaponStack, LivingEntity entity, int remainingUseTicks) { + int useTime = Math.max(1, getUseTime()); + int elapsedMinecraftTicks = getUseDuration(weaponStack, entity) - remainingUseTicks; + if(elapsedMinecraftTicks <= 0) return false; + + int currentShot = elapsedMinecraftTicks * 3 / useTime; + int previousShot = (elapsedMinecraftTicks - 1) * 3 / useTime; + return currentShot > previousShot; + } + + public boolean tryShoot(Level level, Player player, InteractionHand hand, ItemStack stack) { + shoot(level, player, hand, stack); + return true; + } + + public void shoot(Level level, Player player, InteractionHand hand, ItemStack stack) { + SoundUtil.playClientSound(player, ModSounds.WAVE.get()); + if(level.isClientSide()) return; + double deltaDist = stack.getOrDefault(DataComponents.CUSTOM_DATA, CustomData.EMPTY) + .copyTag().getDouble("deltaDist"); + summon(player, deltaDist); + } + + public int getUseTime() { + return 10; + } + @Override public int getUseDuration(ItemStack stack, LivingEntity entity) { return 72000; diff --git a/src/main/java/com/lzxnone/terraria/item/weapon/melee/InfluxWaver.java b/src/main/java/com/lzxnone/terraria/item/weapon/melee/InfluxWaver.java index d2f47b3..a6ad71b 100644 --- a/src/main/java/com/lzxnone/terraria/item/weapon/melee/InfluxWaver.java +++ b/src/main/java/com/lzxnone/terraria/item/weapon/melee/InfluxWaver.java @@ -39,6 +39,7 @@ import com.lzxnone.terraria.ui.config.struct.ConfigStruct; import java.util.List; import java.util.Locale; +import net.minecraft.world.item.enchantment.Enchantments; public class InfluxWaver extends MeleeWeapon { public static final String ID = "influx_waver"; @@ -100,6 +101,20 @@ public class InfluxWaver extends MeleeWeapon { super(Tiers.DIAMOND, new Item.Properties().rarity(Rarity.RARE)); } + @Override + public float getTooltipDamage(ItemStack weaponStack, LivingEntity entity) { + float damage = DAMAGE.get(); + //锋利附魔 + int sharpnessLevel = getEnchantmentLevel(entity, weaponStack, Enchantments.SHARPNESS); + if(sharpnessLevel > 0) { + damage += 1.0F + Math.max(0, sharpnessLevel - 1) * 0.5F; + } + //药水 + if(entity instanceof Player player) damage = DamageUtil.applyPlayerDamageEffects(player, damage); + //近战加成 + return MeleeWeapon.applyMeleeDamageBonus(weaponStack, entity, damage); + } + @Override protected float getBaseMeleeDamage(ItemStack stack) { return BASE_MELEE_DAMAGE.get(); @@ -203,7 +218,7 @@ public class InfluxWaver extends MeleeWeapon { Entity target = customData.contains("target") ? summon.level().getEntity(customData.getInt("target")) : null; if(target != null && !hitTarget.getUUID().equals(target.getUUID())) return; if(summon.getOwner() instanceof Player player && FilterUtil.createTargetFilter(player).test(hitTarget)) { - if(DamageUtil.meleeAttack(summon, hitTarget, summon.getEntityData().get(StaticSummon.STACK_SOURCE), (float) DAMAGE.get(), 1.0f, 2)) { + if(DamageUtil.meleeAttack(summon, hitTarget, summon.getEntityData().get(StaticSummon.STACK_SOURCE), (float) DAMAGE.get(), 1.0f, 10)) { } customData.putBoolean("dead", false); summon.getEntityData().set(StaticSummon.CUSTOM_DATA, customData); diff --git a/src/main/java/com/lzxnone/terraria/item/weapon/melee/LightsBane.java b/src/main/java/com/lzxnone/terraria/item/weapon/melee/LightsBane.java index f702a65..1ee26d2 100644 --- a/src/main/java/com/lzxnone/terraria/item/weapon/melee/LightsBane.java +++ b/src/main/java/com/lzxnone/terraria/item/weapon/melee/LightsBane.java @@ -141,7 +141,7 @@ public class LightsBane extends MeleeWeapon { List targets = summon.level().getEntitiesOfClass(Entity.class, summon.getBoundingBox(), FilterUtil.createTargetFilter(summon, summon.getOwner())); for(Entity target : targets) { float damage = customData.contains("big") && customData.getBoolean("big") ? (float) BIG_DAMAGE.get() : (float) SMALL_DAMAGE.get(); - if(DamageUtil.meleeAttack(summon, target, summon.getEntityData().get(StaticSummon.STACK_SOURCE), damage, 1.0f, -1)) { + if(DamageUtil.meleeAttack(summon, target, summon.getEntityData().get(StaticSummon.STACK_SOURCE), damage, 1.0f, 10)) { } } diff --git a/src/main/java/com/lzxnone/terraria/item/weapon/melee/Mace.java b/src/main/java/com/lzxnone/terraria/item/weapon/melee/Mace.java index 474464c..61702ca 100644 --- a/src/main/java/com/lzxnone/terraria/item/weapon/melee/Mace.java +++ b/src/main/java/com/lzxnone/terraria/item/weapon/melee/Mace.java @@ -39,6 +39,7 @@ import com.lzxnone.terraria.ui.config.struct.ConfigInt; import com.lzxnone.terraria.ui.config.struct.ConfigStruct; import java.util.List; +import net.minecraft.world.item.enchantment.Enchantments; public class Mace extends MeleeWeapon { public static final String ID = "mace"; @@ -100,6 +101,20 @@ public class Mace extends MeleeWeapon { super(Tiers.IRON, new Item.Properties()); } + @Override + public float getTooltipDamage(ItemStack weaponStack, LivingEntity entity) { + float damage = DAMAGE.get(); + //锋利附魔 + int sharpnessLevel = getEnchantmentLevel(entity, weaponStack, Enchantments.SHARPNESS); + if(sharpnessLevel > 0) { + damage += 1.0F + Math.max(0, sharpnessLevel - 1) * 0.5F; + } + //药水 + if(entity instanceof Player player) damage = DamageUtil.applyPlayerDamageEffects(player, damage); + //近战加成 + return MeleeWeapon.applyMeleeDamageBonus(weaponStack, entity, damage); + } + @Override protected float getBaseMeleeDamage(ItemStack stack) { return BASE_MELEE_DAMAGE.get(); @@ -164,7 +179,7 @@ public class Mace extends MeleeWeapon { FilterUtil.createTargetFilter(projectile, player) ); for(Entity target : targets) { - if(DamageUtil.meleeAttack(projectile, target, projectile.getEntityData().get(StaticProjectile.STACK_SOURCE), (float) DAMAGE.get(), 1.0f, 15)) { + if(DamageUtil.meleeAttack(projectile, target, projectile.getEntityData().get(StaticProjectile.STACK_SOURCE), (float) DAMAGE.get(), 1.0f, 10)) { } } } @@ -293,7 +308,7 @@ public class Mace extends MeleeWeapon { FilterUtil.createTargetFilter(summon, summon.getOwner()) ); for(Entity target : targets) { - DamageUtil.meleeAttack(summon, target, summon.getEntityData().get(StaticSummon.STACK_SOURCE), (float) DAMAGE.get(), 1.0f, -1); + DamageUtil.meleeAttack(summon, target, summon.getEntityData().get(StaticSummon.STACK_SOURCE), (float) DAMAGE.get(), 1.0f, 10); } }else if(state == State.THROWING_BACK.ordinal()){ Vec3 moveDir = player.getEyePosition().subtract(summon.position()); diff --git a/src/main/java/com/lzxnone/terraria/item/weapon/melee/Meowmere.java b/src/main/java/com/lzxnone/terraria/item/weapon/melee/Meowmere.java index 7850ff4..1a6ff1a 100644 --- a/src/main/java/com/lzxnone/terraria/item/weapon/melee/Meowmere.java +++ b/src/main/java/com/lzxnone/terraria/item/weapon/melee/Meowmere.java @@ -29,6 +29,7 @@ import net.minecraft.world.phys.*; import org.joml.Vector3f; import java.util.List; +import net.minecraft.world.item.enchantment.Enchantments; public class Meowmere extends MeleeWeapon { public static final String ID = "meowmere"; @@ -59,6 +60,20 @@ public class Meowmere extends MeleeWeapon { super(Tiers.DIAMOND, new Item.Properties().rarity(Rarity.RARE)); } + @Override + public float getTooltipDamage(ItemStack weaponStack, LivingEntity entity) { + float damage = DAMAGE.get(); + //锋利附魔 + int sharpnessLevel = getEnchantmentLevel(entity, weaponStack, Enchantments.SHARPNESS); + if(sharpnessLevel > 0) { + damage += 1.0F + Math.max(0, sharpnessLevel - 1) * 0.5F; + } + //药水 + if(entity instanceof Player player) damage = DamageUtil.applyPlayerDamageEffects(player, damage); + //近战加成 + return MeleeWeapon.applyMeleeDamageBonus(weaponStack, entity, damage); + } + @Override protected float getBaseMeleeDamage(ItemStack stack) { return BASE_MELEE_DAMAGE.get(); @@ -130,7 +145,7 @@ public class Meowmere extends MeleeWeapon { if(entityHitResult != null) { Entity target = entityHitResult.getEntity(); if(summon.getOwner() instanceof Player player) { - if(DamageUtil.meleeAttack(summon, target, summon.getEntityData().get(StaticSummon.STACK_SOURCE), (float) DAMAGE.get(), 1.0f, 2)) { + if(DamageUtil.meleeAttack(summon, target, summon.getEntityData().get(StaticSummon.STACK_SOURCE), (float) DAMAGE.get(), 1.0f, 10)) { if(customData.contains("hitEntity") && customData.getInt("hitEntity") < 4) { customData.putInt("hitEntity", customData.getInt("hitEntity") + 1); summon.getEntityData().set(StaticSummon.CUSTOM_DATA, customData); diff --git a/src/main/java/com/lzxnone/terraria/item/weapon/melee/Muramasa.java b/src/main/java/com/lzxnone/terraria/item/weapon/melee/Muramasa.java index fcd43bd..069ded9 100644 --- a/src/main/java/com/lzxnone/terraria/item/weapon/melee/Muramasa.java +++ b/src/main/java/com/lzxnone/terraria/item/weapon/melee/Muramasa.java @@ -28,6 +28,7 @@ import com.lzxnone.terraria.ui.config.ConfigListItem; import com.lzxnone.terraria.ui.config.IConfigData; import com.lzxnone.terraria.ui.config.struct.ConfigFloat; import com.lzxnone.terraria.ui.config.struct.ConfigStruct; +import net.minecraft.world.item.enchantment.Enchantments; public class Muramasa extends MeleeWeapon { public static final String ID = "muramasa"; @@ -57,6 +58,20 @@ public class Muramasa extends MeleeWeapon { super(Tiers.IRON, new Item.Properties()); } + @Override + public float getTooltipDamage(ItemStack weaponStack, LivingEntity entity) { + float damage = BEAM_DAMAGE.get(); + //锋利附魔 + int sharpnessLevel = getEnchantmentLevel(entity, weaponStack, Enchantments.SHARPNESS); + if(sharpnessLevel > 0) { + damage += 1.0F + Math.max(0, sharpnessLevel - 1) * 0.5F; + } + //药水 + if(entity instanceof Player player) damage = DamageUtil.applyPlayerDamageEffects(player, damage); + //近战加成 + return MeleeWeapon.applyMeleeDamageBonus(weaponStack, entity, damage); + } + @Override protected float getBaseMeleeDamage(ItemStack stack) { return BASE_MELEE_DAMAGE.get(); @@ -192,7 +207,7 @@ public class Muramasa extends MeleeWeapon { Entity owner = projectile.getOwner(); if(owner == null) return; if(!FilterUtil.createTargetFilter(owner).test(target) || !(owner instanceof Player player)) return; - if(DamageUtil.meleeAttack(projectile, target, projectile.getEntityData().get(StaticProjectile.STACK_SOURCE), (float) BEAM_DAMAGE.get(), 1.0f, -1)) { + if(DamageUtil.meleeAttack(projectile, target, projectile.getEntityData().get(StaticProjectile.STACK_SOURCE), (float) BEAM_DAMAGE.get(), 1.0f, 10)) { } } diff --git a/src/main/java/com/lzxnone/terraria/item/weapon/melee/NightsEdge.java b/src/main/java/com/lzxnone/terraria/item/weapon/melee/NightsEdge.java index 91f959d..a609cbe 100644 --- a/src/main/java/com/lzxnone/terraria/item/weapon/melee/NightsEdge.java +++ b/src/main/java/com/lzxnone/terraria/item/weapon/melee/NightsEdge.java @@ -40,18 +40,16 @@ import com.lzxnone.terraria.ui.config.struct.ConfigDouble; import com.lzxnone.terraria.ui.config.struct.ConfigFloat; import com.lzxnone.terraria.ui.config.struct.ConfigInt; import com.lzxnone.terraria.ui.config.struct.ConfigStruct; +import com.lzxnone.terraria.item.ModItems; import java.util.List; +import net.minecraft.world.item.enchantment.Enchantments; +import org.jspecify.annotations.NonNull; public class NightsEdge extends MeleeWeapon { public static final String ID = "nights_edge"; public static final ConfigFloat BASE_MELEE_DAMAGE = createBaseMeleeDamageConfig(ID, 6.0F); public static final ConfigFloat BASE_MELEE_ATTACK_SPEED = createBaseMeleeAttackSpeedConfig(ID, -1.5F); - public static final ConfigBoolean PROJECTILE_ALIGN_TO_BLADE = new ConfigBoolean( - "weapon.nights_edge.projectile_align_to_blade", - "nights_edge_projectile_align_to_blade", - true - ); public static final ConfigInt ROTATE_RANGE = new ConfigInt( "weapon.nights_edge.rotate_range", "nights_edge_rotate_range", @@ -59,13 +57,6 @@ public class NightsEdge extends MeleeWeapon { 0, 90 ); - public static final ConfigInt PROJECTILE_ROTATE_RANGE = new ConfigInt( - "weapon.nights_edge.projectile_rotate_range", - "nights_edge_projectile_rotate_range", - 40, - 0, - 90 - ); public static final ConfigInt MAX_HIT_COUNT = new ConfigInt( "weapon.nights_edge.max_hit_count", "nights_edge_max_hit_count", @@ -83,14 +74,14 @@ public class NightsEdge extends MeleeWeapon { public static final ConfigFloat DAMAGE = new ConfigFloat( "weapon.nights_edge.damage", "nights_edge_damage", - 7.0f, + 4.0f, 0.0f, 8388600.0f ); public static final ConfigFloat PROJECTILE_DAMAGE = new ConfigFloat( "weapon.nights_edge.projectile_damage", "nights_edge_projectile_damage", - 7.0f, + 3.0f, 0.0f, 8388600.0f ); @@ -121,9 +112,7 @@ public class NightsEdge extends MeleeWeapon { ConfigStruct.loadAll( BASE_MELEE_DAMAGE, BASE_MELEE_ATTACK_SPEED, - PROJECTILE_ALIGN_TO_BLADE, ROTATE_RANGE, - PROJECTILE_ROTATE_RANGE, MAX_HIT_COUNT, PROJECTILE_MAX_HIT_COUNT, DAMAGE, @@ -141,6 +130,20 @@ public class NightsEdge extends MeleeWeapon { super(Tiers.IRON, new Item.Properties().rarity(Rarity.UNCOMMON)); } + @Override + public float getTooltipDamage(ItemStack weaponStack, LivingEntity entity) { + float damage = DAMAGE.get() + PROJECTILE_DAMAGE.get(); + //锋利附魔 + int sharpnessLevel = getEnchantmentLevel(entity, weaponStack, Enchantments.SHARPNESS); + if(sharpnessLevel > 0) { + damage += 1.0F + Math.max(0, sharpnessLevel - 1) * 0.5F; + } + //药水 + if(entity instanceof Player player) damage = DamageUtil.applyPlayerDamageEffects(player, damage); + //近战加成 + return MeleeWeapon.applyMeleeDamageBonus(weaponStack, entity, damage); + } + @Override protected float getBaseMeleeDamage(ItemStack stack) { return BASE_MELEE_DAMAGE.get(); @@ -153,8 +156,6 @@ public class NightsEdge extends MeleeWeapon { public static final CompoundTag BEAM_DATA = Util.make(new CompoundTag(), tag -> { tag.putString("behavior", "nights_edge"); - tag.putInt("lifetime", 7); - tag.putInt("cooldown", 7); tag.putFloat("color0R", 0.165f); tag.putFloat("color0G", 0.098f); tag.putFloat("color0B", 0.247f); @@ -198,7 +199,7 @@ public class NightsEdge extends MeleeWeapon { if(custom_data.contains("hitEntityCount")) { int count = custom_data.getInt("hitEntityCount"); if(count < MAX_HIT_COUNT.get()) { - if(DamageUtil.meleeAttack(beam, target, beam.getEntityData().get(SwordBeam.STACK_SOURCE), (float) DAMAGE.get(), 1.0f, 20)) { + if(DamageUtil.meleeAttack(beam, target, beam.getEntityData().get(SwordBeam.STACK_SOURCE), (float) DAMAGE.get(), 1.0f, 10)) { ParticleUtil.addParticles( (ServerLevel) target.level(), ModParticles.NIGHTS_EDGE_HIT_PARTICLE.get(), new Vec3(target.getX(), target.getY() + target.getBbHeight() / 2.0, target.getZ()), new Vec3(0, 0, 0), @@ -218,20 +219,15 @@ public class NightsEdge extends MeleeWeapon { public void generate(Entity entity, CompoundTag beamData) { int randomAngle = (int) (ROTATE_RANGE.get() * (Math.random() * 2 - 1)); beamData.putInt("rotate", randomAngle); + beamData.putInt("lifetime", Math.max(1, getUseTime() / 3)); ISwordBeamBehavior.super.generate(entity, beamData); + if(entity instanceof Player player) { + player.getCooldowns().addCooldown(ModItems.NIGHTS_EDGE.get(), Math.max(1, getUseTime() / 3)); + } if(entity instanceof Player player) summon(player, randomAngle); } }; - public static final Vector3f COLOR0 = new Vector3f(0.278f, 0.141f, 0.588f); - - public static final ResourceLocation RES0 = ResourceLocation.parse("lzxnoneterraria:textures/vfx/terra_beam0.png"); - public static final ResourceLocation RES1 = ResourceLocation.parse("lzxnoneterraria:textures/vfx/terra_beam3.png"); - public static final ResourceLocation RES2 = ResourceLocation.parse("lzxnoneterraria:textures/vfx/beam_sparkle.png"); - - public static final float FADE_IN = 0.33f; - public static final float FADE_OUT = 0.67f; - public static final IStaticSummonBehavior SUMMON_BEHAVIOR = new IStaticSummonBehavior() { @Override @@ -255,7 +251,7 @@ public class NightsEdge extends MeleeWeapon { List targets = summon.level().getEntitiesOfClass(Entity.class, summon.getBoundingBox(), FilterUtil.createTargetFilter(summon, summon.getOwner())); for(Entity target : targets) { if(count >= PROJECTILE_MAX_HIT_COUNT.get()) break; - if(DamageUtil.meleeAttack(summon, target, summon.getEntityData().get(StaticSummon.STACK_SOURCE), (float) PROJECTILE_DAMAGE.get(), 1.0f, 20)) { + if(DamageUtil.meleeAttack(summon, target, summon.getEntityData().get(StaticSummon.STACK_SOURCE), (float) PROJECTILE_DAMAGE.get(), 1.0f, 10)) { count++; ParticleUtil.addParticles( (ServerLevel) target.level(), ModParticles.NIGHTS_EDGE_HIT_PARTICLE.get(), @@ -299,8 +295,7 @@ public class NightsEdge extends MeleeWeapon { Vec3 pos = new Vec3(player.getX(), player.getEyeY() - 0.1, player.getZ()); summon.setPos(pos); - if(!PROJECTILE_ALIGN_TO_BLADE.get()) randomAngle = (int) (PROJECTILE_ROTATE_RANGE.get() * (Math.random() * 2 - 1)); - + //弹射方向始终与刀光对齐(硬编码) Vector3f[] dirs = MathUtil.computeCoordinateSystem(player); dirs = MathUtil.rotateCoordinateSystem(dirs[0], dirs[2], randomAngle); float[] xyRot = MathUtil.computeXYRot(dirs[0], dirs[1]); @@ -385,12 +380,59 @@ public class NightsEdge extends MeleeWeapon { @Override public InteractionResultHolder use(Level level, Player player, InteractionHand hand) { ItemStack stack = player.getItemInHand(hand); - if(!level.isClientSide()) { - SwordBeamBehaviors.getBehavior("nights_edge").generate(player, BEAM_DATA); - }else { - SoundUtil.playClientSound(player, ModSounds.WAVE.get()); + if(player.getCooldowns().isOnCooldown(stack.getItem()) || !tryShoot(level, player, hand, stack)) return InteractionResultHolder.fail(stack); + player.startUsingItem(hand); + player.getCooldowns().addCooldown(stack.getItem(), Math.max(1, getUseTime() / 3)); + return InteractionResultHolder.consume(stack); + } + + @Override + public void onUseTick(Level level, LivingEntity livingEntity, ItemStack stack, int count) { + if(!(livingEntity instanceof Player player)) return; + if(!shouldShootThisTick(stack, livingEntity, count)) return; + + if(!tryShoot(level, player, player.getUsedItemHand(), stack)) { + player.stopUsingItem(); } - return InteractionResultHolder.sidedSuccess(stack, level.isClientSide()); + } + + public boolean shouldShootThisTick(ItemStack weaponStack, LivingEntity entity, int remainingUseTicks) { + int useTime = Math.max(1, getUseTime()); + int elapsedMinecraftTicks = getUseDuration(weaponStack, entity) - remainingUseTicks; + if(elapsedMinecraftTicks <= 0) return false; + + int currentShot = elapsedMinecraftTicks * 3 / useTime; + int previousShot = (elapsedMinecraftTicks - 1) * 3 / useTime; + return currentShot > previousShot; + } + + public boolean tryShoot(Level level, Player player, InteractionHand hand, ItemStack stack) { + shoot(level, player, hand, stack); + return true; + } + + public void shoot(Level level, Player player, InteractionHand hand, ItemStack stack) { + SoundUtil.playClientSound(player, ModSounds.WAVE.get()); + int randomAngle = (int) (ROTATE_RANGE.get() * (Math.random() * 2 - 1)); + CompoundTag beamData = BEAM_DATA.copy(); + beamData.putInt("rotate", randomAngle); + beamData.putInt("lifetime", Math.max(1, getUseTime() / 3)); + SwordBeamBehaviors.getBehavior(SwordBeamBehaviors.DEFAULT).generate(player, beamData); + summon(player, randomAngle); + } + + public static int getUseTime() { + return 25; + } + + @Override + public int getUseDuration(ItemStack stack, LivingEntity entity) { + return 72000; + } + + @Override + public @NonNull UseAnim getUseAnimation(ItemStack stack) { + return UseAnim.NONE; } } diff --git a/src/main/java/com/lzxnone/terraria/item/weapon/melee/Seedler.java b/src/main/java/com/lzxnone/terraria/item/weapon/melee/Seedler.java index 629813d..311c0f5 100644 --- a/src/main/java/com/lzxnone/terraria/item/weapon/melee/Seedler.java +++ b/src/main/java/com/lzxnone/terraria/item/weapon/melee/Seedler.java @@ -33,6 +33,7 @@ import net.minecraft.world.phys.*; import org.joml.Vector3f; import java.util.List; +import net.minecraft.world.item.enchantment.Enchantments; public class Seedler extends MeleeWeapon { public static final String ID = "seedler"; @@ -84,6 +85,20 @@ public class Seedler extends MeleeWeapon { super(Tiers.DIAMOND, new Item.Properties().rarity(Rarity.UNCOMMON)); } + @Override + public float getTooltipDamage(ItemStack weaponStack, LivingEntity entity) { + float damage = THORN_DAMAGE.get(); + //锋利附魔 + int sharpnessLevel = getEnchantmentLevel(entity, weaponStack, Enchantments.SHARPNESS); + if(sharpnessLevel > 0) { + damage += 1.0F + Math.max(0, sharpnessLevel - 1) * 0.5F; + } + //药水 + if(entity instanceof Player player) damage = DamageUtil.applyPlayerDamageEffects(player, damage); + //近战加成 + return MeleeWeapon.applyMeleeDamageBonus(weaponStack, entity, damage); + } + @Override protected float getBaseMeleeDamage(ItemStack stack) { return BASE_MELEE_DAMAGE.get(); @@ -137,7 +152,7 @@ public class Seedler extends MeleeWeapon { if(entityHitResult != null) { Entity target = entityHitResult.getEntity(); if(summon.getOwner() instanceof Player player) { - if(DamageUtil.meleeAttack(summon, target, summon.getEntityData().get(StaticSummon.STACK_SOURCE), (float) THORN_DAMAGE.get(), 1.0f, 2)) { + if(DamageUtil.meleeAttack(summon, target, summon.getEntityData().get(StaticSummon.STACK_SOURCE), (float) THORN_DAMAGE.get(), 1.0f, 10)) { } } onDied(summon); @@ -247,7 +262,7 @@ public class Seedler extends MeleeWeapon { Entity owner = projectile.getOwner(); if(owner == null) return; if(!FilterUtil.createTargetFilter(owner).test(target) || !(owner instanceof Player player)) return; - if(DamageUtil.meleeAttack(projectile, target, projectile.getEntityData().get(StaticProjectile.STACK_SOURCE), (float) THORN_DAMAGE.get(), 1.0f, 2)) { + if(DamageUtil.meleeAttack(projectile, target, projectile.getEntityData().get(StaticProjectile.STACK_SOURCE), (float) THORN_DAMAGE.get(), 1.0f, 10)) { onDied(projectile); } } diff --git a/src/main/java/com/lzxnone/terraria/item/weapon/melee/StarWrath.java b/src/main/java/com/lzxnone/terraria/item/weapon/melee/StarWrath.java index 01f7c1f..f523275 100644 --- a/src/main/java/com/lzxnone/terraria/item/weapon/melee/StarWrath.java +++ b/src/main/java/com/lzxnone/terraria/item/weapon/melee/StarWrath.java @@ -29,6 +29,7 @@ import net.minecraft.world.item.component.CustomData; import net.minecraft.world.level.Level; import net.minecraft.world.phys.*; import org.joml.Vector3f; +import net.minecraft.world.item.enchantment.Enchantments; public class StarWrath extends MeleeWeapon { public static final String ID = "star_wrath"; @@ -59,6 +60,20 @@ public class StarWrath extends MeleeWeapon { super(Tiers.DIAMOND, new Item.Properties().rarity(Rarity.RARE)); } + @Override + public float getTooltipDamage(ItemStack weaponStack, LivingEntity entity) { + float damage = DAMAGE.get(); + //锋利附魔 + int sharpnessLevel = getEnchantmentLevel(entity, weaponStack, Enchantments.SHARPNESS); + if(sharpnessLevel > 0) { + damage += 1.0F + Math.max(0, sharpnessLevel - 1) * 0.5F; + } + //药水 + if(entity instanceof Player player) damage = DamageUtil.applyPlayerDamageEffects(player, damage); + //近战加成 + return MeleeWeapon.applyMeleeDamageBonus(weaponStack, entity, damage); + } + @Override protected float getBaseMeleeDamage(ItemStack stack) { return BASE_MELEE_DAMAGE.get(); @@ -123,7 +138,7 @@ public class StarWrath extends MeleeWeapon { Entity target = result.getEntity(); Entity owner = projectile.getOwner(); if(!FilterUtil.createTargetFilter(owner).test(target) || !(owner instanceof Player player)) return; - if(DamageUtil.meleeAttack(projectile, target, projectile.getEntityData().get(StaticProjectile.STACK_SOURCE), (float) DAMAGE.get(), 0.2f, 2)) { + if(DamageUtil.meleeAttack(projectile, target, projectile.getEntityData().get(StaticProjectile.STACK_SOURCE), (float) DAMAGE.get(), 0.2f, 10)) { } } } diff --git a/src/main/java/com/lzxnone/terraria/item/weapon/melee/Starfury.java b/src/main/java/com/lzxnone/terraria/item/weapon/melee/Starfury.java index 9fc3880..4dda719 100644 --- a/src/main/java/com/lzxnone/terraria/item/weapon/melee/Starfury.java +++ b/src/main/java/com/lzxnone/terraria/item/weapon/melee/Starfury.java @@ -32,6 +32,7 @@ import net.minecraft.world.level.ClipContext; import net.minecraft.world.level.Level; import net.minecraft.world.phys.*; import org.joml.Vector3f; +import net.minecraft.world.item.enchantment.Enchantments; public class Starfury extends MeleeWeapon { public static final String ID = "starfury"; @@ -62,6 +63,20 @@ public class Starfury extends MeleeWeapon { super(Tiers.IRON, new Item.Properties()); } + @Override + public float getTooltipDamage(ItemStack weaponStack, LivingEntity entity) { + float damage = DAMAGE.get(); + //锋利附魔 + int sharpnessLevel = getEnchantmentLevel(entity, weaponStack, Enchantments.SHARPNESS); + if(sharpnessLevel > 0) { + damage += 1.0F + Math.max(0, sharpnessLevel - 1) * 0.5F; + } + //药水 + if(entity instanceof Player player) damage = DamageUtil.applyPlayerDamageEffects(player, damage); + //近战加成 + return MeleeWeapon.applyMeleeDamageBonus(weaponStack, entity, damage); + } + @Override protected float getBaseMeleeDamage(ItemStack stack) { return BASE_MELEE_DAMAGE.get(); @@ -103,7 +118,7 @@ public class Starfury extends MeleeWeapon { Entity owner = projectile.getOwner(); if(owner == null) return; if(!FilterUtil.createTargetFilter(owner).test(target) || !(owner instanceof Player player)) return; - if(DamageUtil.meleeAttack(projectile, target, projectile.getEntityData().get(StaticProjectile.STACK_SOURCE), (float) DAMAGE.get(), 1.0f, 5)) { + if(DamageUtil.meleeAttack(projectile, target, projectile.getEntityData().get(StaticProjectile.STACK_SOURCE), (float) DAMAGE.get(), 1.0f, 10)) { } } } diff --git a/src/main/java/com/lzxnone/terraria/item/weapon/melee/TerraBlade.java b/src/main/java/com/lzxnone/terraria/item/weapon/melee/TerraBlade.java index 40c1853..efded27 100644 --- a/src/main/java/com/lzxnone/terraria/item/weapon/melee/TerraBlade.java +++ b/src/main/java/com/lzxnone/terraria/item/weapon/melee/TerraBlade.java @@ -6,6 +6,7 @@ import com.lzxnone.terraria.entity.ModEntities; import com.lzxnone.terraria.entity.beam.ISwordBeamBehavior; import com.lzxnone.terraria.entity.beam.SwordBeam; import com.lzxnone.terraria.entity.beam.SwordBeamBehaviors; +import com.lzxnone.terraria.item.ModItems; import com.lzxnone.terraria.entity.summon.IStaticSummonBehavior; import com.lzxnone.terraria.entity.summon.StaticSummon; import com.lzxnone.terraria.entity.summon.StaticSummonBehaviors; @@ -28,12 +29,14 @@ import net.minecraft.resources.ResourceLocation; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResultHolder; +import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.*; import net.minecraft.world.level.ClipContext; import net.minecraft.world.level.Level; import net.minecraft.world.phys.*; +import org.jspecify.annotations.NonNull; import net.neoforged.neoforge.event.entity.player.AttackEntityEvent; import net.neoforged.neoforge.event.entity.player.PlayerInteractEvent; import net.neoforged.neoforge.network.PacketDistributor; @@ -41,16 +44,12 @@ import org.joml.Quaternionf; import org.joml.Vector3f; import java.util.List; +import net.minecraft.world.item.enchantment.Enchantments; public class TerraBlade extends MeleeWeapon { public static final String ID = "terra_blade"; public static final ConfigFloat BASE_MELEE_DAMAGE = createBaseMeleeDamageConfig(ID, 10F); public static final ConfigFloat BASE_MELEE_ATTACK_SPEED = createBaseMeleeAttackSpeedConfig(ID, -1.0F); - public static final ConfigBoolean PROJECTILE_ALIGN_TO_SWORD_BEAM = new ConfigBoolean( - "weapon.terra_blade.projectile_align_to_sword_beam", - "terra_projectile_align_to_blade", - true - ); public static final ConfigInt SWORD_BEAM_ROTATE_RANGE = new ConfigInt( "weapon.terra_blade.sword_beam_rotate_range", "terra_blade_rotate_range", @@ -58,13 +57,6 @@ public class TerraBlade extends MeleeWeapon { 0, 90 ); - public static final ConfigInt PROJECTILE_ROTATE_RANGE = new ConfigInt( - "weapon.terra_blade.projectile_rotate_range", - "terra_projectile_rotate_range", - 45, - 0, - 90 - ); public static final ConfigInt SWORD_BEAM_MAX_HIT_COUNT = new ConfigInt( "weapon.terra_blade.sword_beam_max_hit_count", "terra_blade_max_hit_count", @@ -112,6 +104,20 @@ public class TerraBlade extends MeleeWeapon { super(Tiers.DIAMOND, new Item.Properties().rarity(Rarity.RARE)); } + @Override + public float getTooltipDamage(ItemStack weaponStack, LivingEntity entity) { + float damage = PROJECTILE_DAMAGE.get(); + //锋利附魔 + int sharpnessLevel = getEnchantmentLevel(entity, weaponStack, Enchantments.SHARPNESS); + if(sharpnessLevel > 0) { + damage += 1.0F + Math.max(0, sharpnessLevel - 1) * 0.5F; + } + //药水 + if(entity instanceof Player player) damage = DamageUtil.applyPlayerDamageEffects(player, damage); + //近战加成 + return MeleeWeapon.applyMeleeDamageBonus(weaponStack, entity, damage); + } + @Override protected float getBaseMeleeDamage(ItemStack stack) { return BASE_MELEE_DAMAGE.get(); @@ -128,9 +134,7 @@ public class TerraBlade extends MeleeWeapon { ConfigStruct.loadAll( BASE_MELEE_DAMAGE, BASE_MELEE_ATTACK_SPEED, - PROJECTILE_ALIGN_TO_SWORD_BEAM, SWORD_BEAM_ROTATE_RANGE, - PROJECTILE_ROTATE_RANGE, SWORD_BEAM_MAX_HIT_COUNT, SWORD_BEAM_DAMAGE, PROJECTILE_DAMAGE, @@ -144,9 +148,7 @@ public class TerraBlade extends MeleeWeapon { public static final ConfigListItem CONFIG_LIST_ITEM = createConfigListItem(ID, CONFIG_DATA); public static final CompoundTag BEAM_DATA = Util.make(new CompoundTag(), tag -> { - tag.putString("behavior", "terra_blade"); - tag.putInt("lifetime", 5); - tag.putInt("cooldown", 5); + tag.putString("behavior", SwordBeamBehaviors.TERRA_BLADE); tag.putFloat("color0R", 0.173f); tag.putFloat("color0G", 0.482f); tag.putFloat("color0B", 0.796f); @@ -190,7 +192,7 @@ public class TerraBlade extends MeleeWeapon { if(custom_data.contains("hitEntityCount")) { int count = custom_data.getInt("hitEntityCount"); if(count < SWORD_BEAM_MAX_HIT_COUNT.get()) { - if(DamageUtil.meleeAttack(beam, target, beam.getEntityData().get(SwordBeam.STACK_SOURCE), SWORD_BEAM_DAMAGE.get(), 0.1f, 20)) { + if(DamageUtil.meleeAttack(beam, target, beam.getEntityData().get(SwordBeam.STACK_SOURCE), SWORD_BEAM_DAMAGE.get(), 0.1f, 10)) { count++; custom_data.putInt("hitEntityCount", count); beam.getEntityData().set(SwordBeam.CUSTOM_DATA, custom_data); @@ -205,20 +207,15 @@ public class TerraBlade extends MeleeWeapon { public void generate(Entity entity, CompoundTag beamData) { int randomAngle = (int) (SWORD_BEAM_ROTATE_RANGE.get() * (Math.random() * 2 - 1)); beamData.putInt("rotate", randomAngle); + beamData.putInt("lifetime", Math.max(1, getUseTime() / 3)); ISwordBeamBehavior.super.generate(entity, beamData); - if(entity instanceof Player player) summon(player, randomAngle); + if(entity instanceof Player player) { + summon(player, randomAngle); + player.getCooldowns().addCooldown(ModItems.TERRA_BLADE.get(), Math.max(1, getUseTime() / 3)); + } } }; - public static final Vector3f COLOR0 = new Vector3f(0.255f, 0.420f, 0.302f); - public static final Vector3f COLOR1 = new Vector3f(0.173f, 0.482f, 0.796f); - public static final Vector3f COLOR2 = new Vector3f(0.431f, 0.729f, 0.396f); - - public static final ResourceLocation RES0 = ResourceLocation.parse("lzxnoneterraria:textures/vfx/terra_beam0.png"); - public static final ResourceLocation RES1 = ResourceLocation.parse("lzxnoneterraria:textures/vfx/terra_beam3.png"); - public static final ResourceLocation RES2 = ResourceLocation.parse("lzxnoneterraria:textures/vfx/terra_beam4.png"); - public static final ResourceLocation RES3 = ResourceLocation.parse("lzxnoneterraria:textures/vfx/beam_sparkle.png"); - public static final float FADE_IN = 0.33f; public static final float FADE_OUT = 0.67f; @@ -257,7 +254,7 @@ public class TerraBlade extends MeleeWeapon { int count = customData.getInt("hitCount"); List targets = summon.level().getEntitiesOfClass(Entity.class, summon.getBoundingBox(), FilterUtil.createTargetFilter(summon, summon.getOwner())); for(Entity target : targets) { - if(DamageUtil.meleeAttack(summon, target, summon.getEntityData().get(StaticSummon.STACK_SOURCE), PROJECTILE_DAMAGE.get() * (float)Math.pow(PROJECTILE_DAMAGE_DECAY.get(), count), 0.1f, 12)) { + if(DamageUtil.meleeAttack(summon, target, summon.getEntityData().get(StaticSummon.STACK_SOURCE), PROJECTILE_DAMAGE.get() * (float)Math.pow(PROJECTILE_DAMAGE_DECAY.get(), count), 0.1f, 10)) { count++; ParticleUtil.addParticles( (ServerLevel) summon.level(), ModParticles.TERRA_BEAM_HIT_PARTICLE.get(), @@ -315,8 +312,6 @@ public class TerraBlade extends MeleeWeapon { Vec3 pos = new Vec3(player.getX(), player.getEyeY() - 0.1, player.getZ()); summon.setPos(pos); - if(!PROJECTILE_ALIGN_TO_SWORD_BEAM.get()) randomAngle = (int) (PROJECTILE_ROTATE_RANGE.get() * (Math.random() * 2 - 1)); - Vector3f[] dirs = MathUtil.computeCoordinateSystem(player); dirs = MathUtil.rotateCoordinateSystem(dirs[0], dirs[2], randomAngle); float[] xyRot = MathUtil.computeXYRot(dirs[0], dirs[1]); @@ -402,13 +397,60 @@ public class TerraBlade extends MeleeWeapon { @Override public InteractionResultHolder use(Level level, Player player, InteractionHand hand) { ItemStack stack = player.getItemInHand(hand); - if(!level.isClientSide()) { - SwordBeamBehaviors.getBehavior("terra_blade").generate(player, BEAM_DATA); - }else { - SoundUtil.playClientSound(player, ModSounds.WAVE.get()); - SoundUtil.playClientSound(player, ModSounds.WAVE3.get()); + if(player.getCooldowns().isOnCooldown(stack.getItem()) || !tryShoot(level, player, hand, stack)) return InteractionResultHolder.fail(stack); + player.startUsingItem(hand); + player.getCooldowns().addCooldown(stack.getItem(), Math.max(1, getUseTime() / 3)); + return InteractionResultHolder.consume(stack); + } + + @Override + public void onUseTick(Level level, LivingEntity livingEntity, ItemStack stack, int count) { + if(!(livingEntity instanceof Player player)) return; + if(!shouldShootThisTick(stack, livingEntity, count)) return; + + if(!tryShoot(level, player, player.getUsedItemHand(), stack)) { + player.stopUsingItem(); } - return InteractionResultHolder.sidedSuccess(stack, level.isClientSide()); + } + + public boolean shouldShootThisTick(ItemStack weaponStack, LivingEntity entity, int remainingUseTicks) { + int useTime = Math.max(1, getUseTime()); + int elapsedMinecraftTicks = getUseDuration(weaponStack, entity) - remainingUseTicks; + if(elapsedMinecraftTicks <= 0) return false; + + int currentShot = elapsedMinecraftTicks * 3 / useTime; + int previousShot = (elapsedMinecraftTicks - 1) * 3 / useTime; + return currentShot > previousShot; + } + + public boolean tryShoot(Level level, Player player, InteractionHand hand, ItemStack stack) { + shoot(level, player, hand, stack); + return true; + } + + public void shoot(Level level, Player player, InteractionHand hand, ItemStack stack) { + SoundUtil.playClientSound(player, ModSounds.WAVE.get()); + SoundUtil.playClientSound(player, ModSounds.WAVE3.get()); + int randomAngle = (int) (SWORD_BEAM_ROTATE_RANGE.get() * (Math.random() * 2 - 1)); + CompoundTag beamData = BEAM_DATA.copy(); + beamData.putInt("rotate", randomAngle); + beamData.putInt("lifetime", Math.max(1, getUseTime() / 3)); + SwordBeamBehaviors.getBehavior(SwordBeamBehaviors.DEFAULT).generate(player, beamData); + summon(player, randomAngle); + } + + public static int getUseTime() { + return 18; + } + + @Override + public int getUseDuration(ItemStack stack, LivingEntity entity) { + return 72000; + } + + @Override + public @NonNull UseAnim getUseAnimation(ItemStack stack) { + return UseAnim.NONE; } } diff --git a/src/main/java/com/lzxnone/terraria/item/weapon/melee/Terragrim.java b/src/main/java/com/lzxnone/terraria/item/weapon/melee/Terragrim.java index 08484d0..0454cd6 100644 --- a/src/main/java/com/lzxnone/terraria/item/weapon/melee/Terragrim.java +++ b/src/main/java/com/lzxnone/terraria/item/weapon/melee/Terragrim.java @@ -36,6 +36,7 @@ import org.joml.Vector3f; import org.jspecify.annotations.NonNull; import java.util.List; +import net.minecraft.world.item.enchantment.Enchantments; public class Terragrim extends MeleeWeapon { public static final String ID = "terragrim"; @@ -51,7 +52,7 @@ public class Terragrim extends MeleeWeapon { public static final ConfigFloat DAMAGE = new ConfigFloat( "weapon.terragrim.damage", "terragrim_damage", - 0.25f, + 0.75f, 0.0f, 8388600.0f ); @@ -66,6 +67,20 @@ public class Terragrim extends MeleeWeapon { super(Tiers.DIAMOND, new Item.Properties().rarity(Rarity.RARE)); } + @Override + public float getTooltipDamage(ItemStack weaponStack, LivingEntity entity) { + float damage = DAMAGE.get(); + //锋利附魔 + int sharpnessLevel = getEnchantmentLevel(entity, weaponStack, Enchantments.SHARPNESS); + if(sharpnessLevel > 0) { + damage += 1.0F + Math.max(0, sharpnessLevel - 1) * 0.5F; + } + //药水 + if(entity instanceof Player player) damage = DamageUtil.applyPlayerDamageEffects(player, damage); + //近战加成 + return MeleeWeapon.applyMeleeDamageBonus(weaponStack, entity, damage); + } + @Override protected float getBaseMeleeDamage(ItemStack stack) { return BASE_MELEE_DAMAGE.get(); @@ -148,7 +163,7 @@ public class Terragrim extends MeleeWeapon { ); for(Entity target : targets) { if(target instanceof LivingEntity livingEntity) { - DamageUtil.meleeAttack(summon, target, summon.getEntityData().get(StaticSummon.STACK_SOURCE), (float) DAMAGE.get(), 0.05f, 0); + DamageUtil.meleeAttack(summon, target, summon.getEntityData().get(StaticSummon.STACK_SOURCE), (float) DAMAGE.get(), 0.05f, 10); } } } diff --git a/src/main/java/com/lzxnone/terraria/item/weapon/melee/TheHorsemansBlade.java b/src/main/java/com/lzxnone/terraria/item/weapon/melee/TheHorsemansBlade.java index 4a829b6..9ec2f2f 100644 --- a/src/main/java/com/lzxnone/terraria/item/weapon/melee/TheHorsemansBlade.java +++ b/src/main/java/com/lzxnone/terraria/item/weapon/melee/TheHorsemansBlade.java @@ -42,8 +42,11 @@ import com.lzxnone.terraria.ui.config.struct.ConfigDouble; import com.lzxnone.terraria.ui.config.struct.ConfigFloat; import com.lzxnone.terraria.ui.config.struct.ConfigInt; import com.lzxnone.terraria.ui.config.struct.ConfigStruct; +import com.lzxnone.terraria.item.ModItems; import java.util.List; +import net.minecraft.world.item.enchantment.Enchantments; +import org.jspecify.annotations.NonNull; public class TheHorsemansBlade extends MeleeWeapon { public static final String ID = "the_horsemans_blade"; @@ -121,6 +124,20 @@ public class TheHorsemansBlade extends MeleeWeapon { super(Tiers.DIAMOND, new Item.Properties().rarity(Rarity.RARE)); } + @Override + public float getTooltipDamage(ItemStack weaponStack, LivingEntity entity) { + float damage = BLADE_DAMAGE.get(); + //锋利附魔 + int sharpnessLevel = getEnchantmentLevel(entity, weaponStack, Enchantments.SHARPNESS); + if(sharpnessLevel > 0) { + damage += 1.0F + Math.max(0, sharpnessLevel - 1) * 0.5F; + } + //药水 + if(entity instanceof Player player) damage = DamageUtil.applyPlayerDamageEffects(player, damage); + //近战加成 + return MeleeWeapon.applyMeleeDamageBonus(weaponStack, entity, damage); + } + @Override protected float getBaseMeleeDamage(ItemStack stack) { return BASE_MELEE_DAMAGE.get(); @@ -133,7 +150,6 @@ public class TheHorsemansBlade extends MeleeWeapon { public static final CompoundTag BEAM_DATA = Util.make(new CompoundTag(), tag -> { tag.putString("behavior", "the_horsemans_blade"); - tag.putInt("cooldown", 10); tag.putFloat("color0R", 0.741f); tag.putFloat("color0G", 0.133f); tag.putFloat("color0B", 0.133f); @@ -177,7 +193,7 @@ public class TheHorsemansBlade extends MeleeWeapon { if(custom_data.contains("hitEntityCount")) { int count = custom_data.getInt("hitEntityCount"); if(count < BLADE_MAX_HIT_COUNT.get()) { - if(DamageUtil.meleeAttack(beam, target, beam.getEntityData().get(SwordBeam.STACK_SOURCE), (float) BLADE_DAMAGE.get(), 1.0f, 20)) { + if(DamageUtil.meleeAttack(beam, target, beam.getEntityData().get(SwordBeam.STACK_SOURCE), (float) BLADE_DAMAGE.get(), 1.0f, 10)) { count++; custom_data.putInt("hitEntityCount", count); beam.getEntityData().set(SwordBeam.CUSTOM_DATA, custom_data); @@ -223,8 +239,11 @@ public class TheHorsemansBlade extends MeleeWeapon { @Override public void generate(Entity entity, CompoundTag beamData) { beamData.putInt("rotate", (int) (BLADE_ROTATE_RANGE.get() * (Math.random() * 2 - 1))); - //beamData.putBoolean("right", entity.getRandom().nextInt(2) == 0); + beamData.putInt("lifetime", Math.max(1, getUseTime() / 3)); ISwordBeamBehavior.super.generate(entity, beamData); + if(entity instanceof Player player) { + player.getCooldowns().addCooldown(ModItems.THE_HORSEMANS_BLADE.get(), Math.max(1, getUseTime() / 3)); + } } }; @@ -258,12 +277,58 @@ public class TheHorsemansBlade extends MeleeWeapon { @Override public InteractionResultHolder use(Level level, Player player, InteractionHand hand) { ItemStack stack = player.getItemInHand(hand); - if(!level.isClientSide()) { - SwordBeamBehaviors.getBehavior("the_horsemans_blade").generate(player, BEAM_DATA); - }else { - SoundUtil.playClientSound(player, ModSounds.WAVE.get()); + if(player.getCooldowns().isOnCooldown(stack.getItem()) || !tryShoot(level, player, hand, stack)) return InteractionResultHolder.fail(stack); + player.startUsingItem(hand); + player.getCooldowns().addCooldown(stack.getItem(), Math.max(1, getUseTime() / 3)); + return InteractionResultHolder.consume(stack); + } + + @Override + public void onUseTick(Level level, LivingEntity livingEntity, ItemStack stack, int count) { + if(!(livingEntity instanceof Player player)) return; + if(!shouldShootThisTick(stack, livingEntity, count)) return; + + if(!tryShoot(level, player, player.getUsedItemHand(), stack)) { + player.stopUsingItem(); } - return InteractionResultHolder.sidedSuccess(stack, level.isClientSide()); + } + + public boolean shouldShootThisTick(ItemStack weaponStack, LivingEntity entity, int remainingUseTicks) { + int useTime = Math.max(1, getUseTime()); + int elapsedMinecraftTicks = getUseDuration(weaponStack, entity) - remainingUseTicks; + if(elapsedMinecraftTicks <= 0) return false; + + int currentShot = elapsedMinecraftTicks * 3 / useTime; + int previousShot = (elapsedMinecraftTicks - 1) * 3 / useTime; + return currentShot > previousShot; + } + + public boolean tryShoot(Level level, Player player, InteractionHand hand, ItemStack stack) { + shoot(level, player, hand, stack); + return true; + } + + public void shoot(Level level, Player player, InteractionHand hand, ItemStack stack) { + SoundUtil.playClientSound(player, ModSounds.WAVE.get()); + int randomAngle = (int) (BLADE_ROTATE_RANGE.get() * (Math.random() * 2 - 1)); + CompoundTag beamData = BEAM_DATA.copy(); + beamData.putInt("rotate", randomAngle); + beamData.putInt("lifetime", Math.max(1, getUseTime() / 3)); + SwordBeamBehaviors.getBehavior(SwordBeamBehaviors.DEFAULT).generate(player, beamData); + } + + public static int getUseTime() { + return 26; + } + + @Override + public int getUseDuration(ItemStack stack, LivingEntity entity) { + return 72000; + } + + @Override + public @NonNull UseAnim getUseAnimation(ItemStack stack) { + return UseAnim.NONE; } public static final IStaticSummonBehavior SUMMON_BEHAVIOR = new IStaticSummonBehavior() { @@ -304,7 +369,7 @@ public class TheHorsemansBlade extends MeleeWeapon { summon.setYRot(xyRot[1]); if(selfPos.distanceToSqr(targetPos) < 2.0D) { - if(summon.getOwner() instanceof Player player && FilterUtil.createTargetFilter(player).test(target) && DamageUtil.meleeAttack(summon, target, summon.getEntityData().get(StaticSummon.STACK_SOURCE), (float) PUMPKIN_DAMAGE.get(), 1.0f, -1)) onDied(summon); + if(summon.getOwner() instanceof Player player && FilterUtil.createTargetFilter(player).test(target) && DamageUtil.meleeAttack(summon, target, summon.getEntityData().get(StaticSummon.STACK_SOURCE), (float) PUMPKIN_DAMAGE.get(), 1.0f, 10)) onDied(summon); } }else { Vec3 dir = summon.getLookAngle().normalize(); @@ -325,7 +390,7 @@ public class TheHorsemansBlade extends MeleeWeapon { for(Entity hitEntity : hitEntities) { if(target != null && hitEntity.getUUID() == target.getUUID()) continue; if(summon.getOwner() instanceof Player player) { - if(DamageUtil.meleeAttack(summon, hitEntity, summon.getEntityData().get(StaticSummon.STACK_SOURCE), (float) PUMPKIN_DAMAGE.get(), 1.0f, 2)) { + if(DamageUtil.meleeAttack(summon, hitEntity, summon.getEntityData().get(StaticSummon.STACK_SOURCE), (float) PUMPKIN_DAMAGE.get(), 1.0f, 10)) { } } } diff --git a/src/main/java/com/lzxnone/terraria/item/weapon/melee/TrueCopperShortsword.java b/src/main/java/com/lzxnone/terraria/item/weapon/melee/TrueCopperShortsword.java index f097e76..93298e2 100644 --- a/src/main/java/com/lzxnone/terraria/item/weapon/melee/TrueCopperShortsword.java +++ b/src/main/java/com/lzxnone/terraria/item/weapon/melee/TrueCopperShortsword.java @@ -11,6 +11,7 @@ import com.lzxnone.terraria.entity.projectile.StaticProjectileBehaviors; import com.lzxnone.terraria.item.ModItems; import com.lzxnone.terraria.utils.MathUtil; import com.lzxnone.terraria.utils.SoundUtil; +import com.lzxnone.terraria.utils.DamageUtil; import net.minecraft.core.component.DataComponents; import net.minecraft.nbt.CompoundTag; import net.minecraft.resources.ResourceLocation; @@ -24,6 +25,7 @@ import net.minecraft.world.level.Level; import net.minecraft.world.phys.Vec3; import org.joml.Vector3f; import org.jspecify.annotations.NonNull; +import net.minecraft.world.item.enchantment.Enchantments; public class TrueCopperShortsword extends MeleeWeapon { public static final String ID = "true_copper_shortsword"; @@ -36,6 +38,20 @@ public class TrueCopperShortsword extends MeleeWeapon { super(Tiers.NETHERITE, new Item.Properties().fireResistant().rarity(Rarity.EPIC)); } + @Override + public float getTooltipDamage(ItemStack weaponStack, LivingEntity entity) { + float damage = Zenith.DAMAGE.get(); + //锋利附魔 + int sharpnessLevel = getEnchantmentLevel(entity, weaponStack, Enchantments.SHARPNESS); + if(sharpnessLevel > 0) { + damage += 1.0F + Math.max(0, sharpnessLevel - 1) * 0.5F; + } + //药水 + if(entity instanceof Player player) damage = DamageUtil.applyPlayerDamageEffects(player, damage); + //近战加成 + return MeleeWeapon.applyMeleeDamageBonus(weaponStack, entity, damage); + } + @Override protected float getBaseMeleeDamage(ItemStack stack) { return BASE_MELEE_DAMAGE.get(); @@ -138,21 +154,49 @@ public class TrueCopperShortsword extends MeleeWeapon { @Override public InteractionResultHolder use(Level level, Player player, InteractionHand hand) { ItemStack stack = player.getItemInHand(hand); + if(player.getCooldowns().isOnCooldown(stack.getItem()) || !tryShoot(level, player, hand, stack)) return InteractionResultHolder.fail(stack); player.startUsingItem(hand); - return InteractionResultHolder.consume(stack); + player.getCooldowns().addCooldown(stack.getItem(), Math.max(1, getUseTime() / 3)); + return InteractionResultHolder.sidedSuccess(stack, level.isClientSide()); } @Override public void onUseTick(Level level, LivingEntity livingEntity, ItemStack stack, int count) { if(!(livingEntity instanceof Player player)) return; - if(player.tickCount % 3 == 0) { - double deltaDist = stack.getOrDefault(DataComponents.CUSTOM_DATA, CustomData.EMPTY) - .copyTag().getDouble("deltaDist"); - summon(player, deltaDist); - SoundUtil.playClientSound(player, ModSounds.WAVE.get()); + if(!shouldShootThisTick(stack, livingEntity, count)) return; + + if(!tryShoot(level, player, player.getUsedItemHand(), stack)) { + player.stopUsingItem(); } } + public boolean shouldShootThisTick(ItemStack weaponStack, LivingEntity entity, int remainingUseTicks) { + int useTime = Math.max(1, getUseTime()); + int elapsedMinecraftTicks = getUseDuration(weaponStack, entity) - remainingUseTicks; + if(elapsedMinecraftTicks <= 0) return false; + + int currentShot = elapsedMinecraftTicks * 3 / useTime; + int previousShot = (elapsedMinecraftTicks - 1) * 3 / useTime; + return currentShot > previousShot; + } + + public boolean tryShoot(Level level, Player player, InteractionHand hand, ItemStack stack) { + shoot(level, player, hand, stack); + return true; + } + + public void shoot(Level level, Player player, InteractionHand hand, ItemStack stack) { + SoundUtil.playClientSound(player, ModSounds.WAVE.get()); + if(level.isClientSide()) return; + double deltaDist = stack.getOrDefault(DataComponents.CUSTOM_DATA, CustomData.EMPTY) + .copyTag().getDouble("deltaDist"); + summon(player, deltaDist); + } + + public int getUseTime() { + return 10; + } + @Override public int getUseDuration(ItemStack stack, LivingEntity entity) { return 72000; diff --git a/src/main/java/com/lzxnone/terraria/item/weapon/melee/TrueExcalibur.java b/src/main/java/com/lzxnone/terraria/item/weapon/melee/TrueExcalibur.java index 7a18dbc..ab6bb4e 100644 --- a/src/main/java/com/lzxnone/terraria/item/weapon/melee/TrueExcalibur.java +++ b/src/main/java/com/lzxnone/terraria/item/weapon/melee/TrueExcalibur.java @@ -18,6 +18,7 @@ import net.minecraft.server.level.ServerLevel; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResultHolder; import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.*; import net.minecraft.world.level.Level; @@ -32,6 +33,9 @@ import com.lzxnone.terraria.ui.config.IConfigData; import com.lzxnone.terraria.ui.config.struct.ConfigFloat; import com.lzxnone.terraria.ui.config.struct.ConfigInt; import com.lzxnone.terraria.ui.config.struct.ConfigStruct; +import com.lzxnone.terraria.item.ModItems; +import net.minecraft.world.item.enchantment.Enchantments; +import org.jspecify.annotations.NonNull; public class TrueExcalibur extends MeleeWeapon { public static final String ID = "true_excalibur"; @@ -77,6 +81,20 @@ public class TrueExcalibur extends MeleeWeapon { super(Tiers.DIAMOND, new Item.Properties().rarity(Rarity.RARE)); } + @Override + public float getTooltipDamage(ItemStack weaponStack, LivingEntity entity) { + float damage = DAMAGE.get(); + //锋利附魔 + int sharpnessLevel = getEnchantmentLevel(entity, weaponStack, Enchantments.SHARPNESS); + if(sharpnessLevel > 0) { + damage += 1.0F + Math.max(0, sharpnessLevel - 1) * 0.5F; + } + //药水 + if(entity instanceof Player player) damage = DamageUtil.applyPlayerDamageEffects(player, damage); + //近战加成 + return MeleeWeapon.applyMeleeDamageBonus(weaponStack, entity, damage); + } + @Override protected float getBaseMeleeDamage(ItemStack stack) { return BASE_MELEE_DAMAGE.get(); @@ -89,8 +107,6 @@ public class TrueExcalibur extends MeleeWeapon { public static final CompoundTag BEAM_DATA = Util.make(new CompoundTag(), tag -> { tag.putString("behavior", "true_excalibur"); - tag.putInt("lifetime", 5); - tag.putInt("cooldown", 5); tag.putFloat("inflate", 2.0f); tag.putFloat("color0R", 0.745f); tag.putFloat("color0G", 0.620f); @@ -136,7 +152,7 @@ public class TrueExcalibur extends MeleeWeapon { if(custom_data.contains("hitEntityCount")) { int count = custom_data.getInt("hitEntityCount"); if(count < MAX_HIT_COUNT.get()) { - if(DamageUtil.meleeAttack(beam, target, beam.getEntityData().get(SwordBeam.STACK_SOURCE), (float) DAMAGE.get(), 1.0f, 20)) { + if(DamageUtil.meleeAttack(beam, target, beam.getEntityData().get(SwordBeam.STACK_SOURCE), (float) DAMAGE.get(), 1.0f, 10)) { count++; custom_data.putInt("hitEntityCount", count); beam.getEntityData().set(SwordBeam.CUSTOM_DATA, custom_data); @@ -160,7 +176,11 @@ public class TrueExcalibur extends MeleeWeapon { @Override public void generate(Entity entity, CompoundTag beamData) { beamData.putInt("rotate", (int) (ROTATE_RANGE.get() * (Math.random() * 2 - 1))); + beamData.putInt("lifetime", Math.max(1, getUseTime() / 3)); ISwordBeamBehavior.super.generate(entity, beamData); + if(entity instanceof Player player) { + player.getCooldowns().addCooldown(ModItems.TRUE_EXCALIBUR.get(), Math.max(1, getUseTime() / 3)); + } } }; @@ -194,12 +214,58 @@ public class TrueExcalibur extends MeleeWeapon { @Override public InteractionResultHolder use(Level level, Player player, InteractionHand hand) { ItemStack stack = player.getItemInHand(hand); - if(!level.isClientSide()) { - SwordBeamBehaviors.getBehavior("true_excalibur").generate(player, BEAM_DATA); - }else { - SoundUtil.playClientSound(player, ModSounds.WAVE.get()); + if(player.getCooldowns().isOnCooldown(stack.getItem()) || !tryShoot(level, player, hand, stack)) return InteractionResultHolder.fail(stack); + player.startUsingItem(hand); + player.getCooldowns().addCooldown(stack.getItem(), Math.max(1, getUseTime() / 3)); + return InteractionResultHolder.consume(stack); + } + + @Override + public void onUseTick(Level level, LivingEntity livingEntity, ItemStack stack, int count) { + if(!(livingEntity instanceof Player player)) return; + if(!shouldShootThisTick(stack, livingEntity, count)) return; + + if(!tryShoot(level, player, player.getUsedItemHand(), stack)) { + player.stopUsingItem(); } - return InteractionResultHolder.sidedSuccess(stack, level.isClientSide()); + } + + public boolean shouldShootThisTick(ItemStack weaponStack, LivingEntity entity, int remainingUseTicks) { + int useTime = Math.max(1, getUseTime()); + int elapsedMinecraftTicks = getUseDuration(weaponStack, entity) - remainingUseTicks; + if(elapsedMinecraftTicks <= 0) return false; + + int currentShot = elapsedMinecraftTicks * 3 / useTime; + int previousShot = (elapsedMinecraftTicks - 1) * 3 / useTime; + return currentShot > previousShot; + } + + public boolean tryShoot(Level level, Player player, InteractionHand hand, ItemStack stack) { + shoot(level, player, hand, stack); + return true; + } + + public void shoot(Level level, Player player, InteractionHand hand, ItemStack stack) { + SoundUtil.playClientSound(player, ModSounds.WAVE.get()); + int randomAngle = (int) (ROTATE_RANGE.get() * (Math.random() * 2 - 1)); + CompoundTag beamData = BEAM_DATA.copy(); + beamData.putInt("rotate", randomAngle); + beamData.putInt("lifetime", Math.max(1, getUseTime() / 3)); + SwordBeamBehaviors.getBehavior(SwordBeamBehaviors.DEFAULT).generate(player, beamData); + } + + public static int getUseTime() { + return 18; + } + + @Override + public int getUseDuration(ItemStack stack, LivingEntity entity) { + return 72000; + } + + @Override + public @NonNull UseAnim getUseAnimation(ItemStack stack) { + return UseAnim.NONE; } } diff --git a/src/main/java/com/lzxnone/terraria/item/weapon/melee/TrueNightsEdge.java b/src/main/java/com/lzxnone/terraria/item/weapon/melee/TrueNightsEdge.java index 1338a23..127cac6 100644 --- a/src/main/java/com/lzxnone/terraria/item/weapon/melee/TrueNightsEdge.java +++ b/src/main/java/com/lzxnone/terraria/item/weapon/melee/TrueNightsEdge.java @@ -40,18 +40,16 @@ import com.lzxnone.terraria.ui.config.struct.ConfigDouble; import com.lzxnone.terraria.ui.config.struct.ConfigFloat; import com.lzxnone.terraria.ui.config.struct.ConfigInt; import com.lzxnone.terraria.ui.config.struct.ConfigStruct; +import com.lzxnone.terraria.item.ModItems; import java.util.List; +import net.minecraft.world.item.enchantment.Enchantments; +import org.jspecify.annotations.NonNull; public class TrueNightsEdge extends MeleeWeapon { public static final String ID = "true_nights_edge"; public static final ConfigFloat BASE_MELEE_DAMAGE = createBaseMeleeDamageConfig(ID, 7.0F); public static final ConfigFloat BASE_MELEE_ATTACK_SPEED = createBaseMeleeAttackSpeedConfig(ID, -2.4F); - public static final ConfigBoolean PROJECTILE_ALIGN_TO_BLADE = new ConfigBoolean( - "weapon.true_nights_edge.projectile_align_to_blade", - "true_nights_edge_projectile_align_to_blade", - true - ); public static final ConfigInt ROTATE_RANGE = new ConfigInt( "weapon.true_nights_edge.rotate_range", "true_nights_edge_rotate_range", @@ -59,13 +57,6 @@ public class TrueNightsEdge extends MeleeWeapon { 0, 90 ); - public static final ConfigInt PROJECTILE_ROTATE_RANGE = new ConfigInt( - "weapon.true_nights_edge.projectile_rotate_range", - "true_nights_edge_projectile_rotate_range", - 45, - 0, - 90 - ); public static final ConfigInt MAX_HIT_COUNT = new ConfigInt( "weapon.true_nights_edge.max_hit_count", "true_nights_edge_max_hit_count", @@ -90,7 +81,7 @@ public class TrueNightsEdge extends MeleeWeapon { public static final ConfigFloat PROJECTILE_DAMAGE = new ConfigFloat( "weapon.true_nights_edge.projectile_damage", "true_nights_edge_projectile_damage", - 4.0f, + 6.0f, 0.0f, 8388600.0f ); @@ -128,9 +119,7 @@ public class TrueNightsEdge extends MeleeWeapon { ConfigStruct.loadAll( BASE_MELEE_DAMAGE, BASE_MELEE_ATTACK_SPEED, - PROJECTILE_ALIGN_TO_BLADE, ROTATE_RANGE, - PROJECTILE_ROTATE_RANGE, MAX_HIT_COUNT, PROJECTILE_MAX_HIT_COUNT, DAMAGE, @@ -149,6 +138,20 @@ public class TrueNightsEdge extends MeleeWeapon { super(Tiers.DIAMOND, new Item.Properties().rarity(Rarity.RARE)); } + @Override + public float getTooltipDamage(ItemStack weaponStack, LivingEntity entity) { + float damage = DAMAGE.get(); + //锋利附魔 + int sharpnessLevel = getEnchantmentLevel(entity, weaponStack, Enchantments.SHARPNESS); + if(sharpnessLevel > 0) { + damage += 1.0F + Math.max(0, sharpnessLevel - 1) * 0.5F; + } + //药水 + if(entity instanceof Player player) damage = DamageUtil.applyPlayerDamageEffects(player, damage); + //近战加成 + return MeleeWeapon.applyMeleeDamageBonus(weaponStack, entity, damage); + } + @Override protected float getBaseMeleeDamage(ItemStack stack) { return BASE_MELEE_DAMAGE.get(); @@ -161,8 +164,6 @@ public class TrueNightsEdge extends MeleeWeapon { public static final CompoundTag BEAM_DATA = Util.make(new CompoundTag(), tag -> { tag.putString("behavior", "true_nights_edge"); - tag.putInt("lifetime", 10); - tag.putInt("cooldown", 10); tag.putFloat("color0R", 0.165f); tag.putFloat("color0G", 0.098f); tag.putFloat("color0B", 0.247f); @@ -212,7 +213,7 @@ public class TrueNightsEdge extends MeleeWeapon { if(custom_data.contains("hitEntityCount")) { int count = custom_data.getInt("hitEntityCount"); if(count < MAX_HIT_COUNT.get()) { - if(DamageUtil.meleeAttack(beam, target, beam.getEntityData().get(SwordBeam.STACK_SOURCE), (float) DAMAGE.get(), 1.0f, 20)) { + if(DamageUtil.meleeAttack(beam, target, beam.getEntityData().get(SwordBeam.STACK_SOURCE), (float) DAMAGE.get(), 1.0f, 10)) { ParticleUtil.addParticles( (ServerLevel) target.level(), ModParticles.NIGHTS_EDGE_HIT_PARTICLE.get(), new Vec3(target.getX(), target.getY() + target.getBbHeight() / 2.0, target.getZ()), new Vec3(0, 0, 0), @@ -232,25 +233,16 @@ public class TrueNightsEdge extends MeleeWeapon { public void generate(Entity entity, CompoundTag beamData) { int randomAngle = (int) (ROTATE_RANGE.get() * (Math.random() * 2 - 1)); beamData.putInt("rotate", randomAngle); + beamData.putInt("lifetime", Math.max(1, getUseTime() / 3)); ISwordBeamBehavior.super.generate(entity, beamData); + if(entity instanceof Player player) { + player.getCooldowns().addCooldown(ModItems.TRUE_NIGHTS_EDGE.get(), Math.max(1, getUseTime() / 3)); + } if(entity instanceof Player player) summon(player, randomAngle); } }; - public static final Vector3f COLOR0 = new Vector3f(0.400f, 0.659f, 0.290f); - public static final Vector3f COLOR1 = new Vector3f(0.475f, 0.612f, 0.247f); - public static final Vector3f COLOR2 = new Vector3f(0.631f, 0.871f, 0.192f); - - public static final ResourceLocation RES0 = ResourceLocation.parse("lzxnoneterraria:textures/vfx/terra_beam0.png"); - public static final ResourceLocation RES1 = ResourceLocation.parse("lzxnoneterraria:textures/vfx/terra_beam3.png"); - public static final ResourceLocation RES2 = ResourceLocation.parse("lzxnoneterraria:textures/vfx/beam_sparkle.png"); - - public static final float FADE_IN = 0.33f; - public static final float FADE_OUT = 0.67f; - public static final IStaticSummonBehavior SUMMON_BEHAVIOR = new IStaticSummonBehavior() { - - @Override public void tick(StaticSummon summon) { this.checkBeforeTick(summon); @@ -284,7 +276,7 @@ public class TrueNightsEdge extends MeleeWeapon { List targets = summon.level().getEntitiesOfClass(Entity.class, summon.getBoundingBox(), FilterUtil.createTargetFilter(summon, summon.getOwner())); for(Entity target : targets) { if(count >= PROJECTILE_MAX_HIT_COUNT.get()) break; - if(DamageUtil.meleeAttack(summon, target, summon.getEntityData().get(StaticSummon.STACK_SOURCE), (float) PROJECTILE_DAMAGE.get(), 1.0f, 20)) { + if(DamageUtil.meleeAttack(summon, target, summon.getEntityData().get(StaticSummon.STACK_SOURCE), (float) PROJECTILE_DAMAGE.get(), 1.0f, 10)) { count++; ParticleUtil.addParticles( (ServerLevel) target.level(), ModParticles.TRUE_NIGHTS_EDGE_HIT_PARTICLE.get(), @@ -328,8 +320,7 @@ public class TrueNightsEdge extends MeleeWeapon { Vec3 pos = new Vec3(player.getX(), player.getEyeY() - 0.1, player.getZ()); summon.setPos(pos); - if(!PROJECTILE_ALIGN_TO_BLADE.get()) randomAngle = (int) (PROJECTILE_ROTATE_RANGE.get() * (Math.random() * 2 - 1)); - + //弹射方向始终与刀光对齐(硬编码) Vector3f[] dirs = MathUtil.computeCoordinateSystem(player); dirs = MathUtil.rotateCoordinateSystem(dirs[0], dirs[2], randomAngle); float[] xyRot = MathUtil.computeXYRot(dirs[0], dirs[1]); @@ -414,12 +405,59 @@ public class TrueNightsEdge extends MeleeWeapon { @Override public InteractionResultHolder use(Level level, Player player, InteractionHand hand) { ItemStack stack = player.getItemInHand(hand); - if(!level.isClientSide()) { - SwordBeamBehaviors.getBehavior("true_nights_edge").generate(player, BEAM_DATA); - }else { - SoundUtil.playClientSound(player, ModSounds.WAVE.get()); + if(player.getCooldowns().isOnCooldown(stack.getItem()) || !tryShoot(level, player, hand, stack)) return InteractionResultHolder.fail(stack); + player.startUsingItem(hand); + player.getCooldowns().addCooldown(stack.getItem(), Math.max(1, getUseTime() / 3)); + return InteractionResultHolder.consume(stack); + } + + @Override + public void onUseTick(Level level, LivingEntity livingEntity, ItemStack stack, int count) { + if(!(livingEntity instanceof Player player)) return; + if(!shouldShootThisTick(stack, livingEntity, count)) return; + + if(!tryShoot(level, player, player.getUsedItemHand(), stack)) { + player.stopUsingItem(); } - return InteractionResultHolder.sidedSuccess(stack, level.isClientSide()); + } + + public boolean shouldShootThisTick(ItemStack weaponStack, LivingEntity entity, int remainingUseTicks) { + int useTime = Math.max(1, getUseTime()); + int elapsedMinecraftTicks = getUseDuration(weaponStack, entity) - remainingUseTicks; + if(elapsedMinecraftTicks <= 0) return false; + + int currentShot = elapsedMinecraftTicks * 3 / useTime; + int previousShot = (elapsedMinecraftTicks - 1) * 3 / useTime; + return currentShot > previousShot; + } + + public boolean tryShoot(Level level, Player player, InteractionHand hand, ItemStack stack) { + shoot(level, player, hand, stack); + return true; + } + + public void shoot(Level level, Player player, InteractionHand hand, ItemStack stack) { + SoundUtil.playClientSound(player, ModSounds.WAVE.get()); + int randomAngle = (int) (ROTATE_RANGE.get() * (Math.random() * 2 - 1)); + CompoundTag beamData = BEAM_DATA.copy(); + beamData.putInt("rotate", randomAngle); + beamData.putInt("lifetime", Math.max(1, getUseTime() / 3)); + SwordBeamBehaviors.getBehavior(SwordBeamBehaviors.DEFAULT).generate(player, beamData); + summon(player, randomAngle); + } + + public static int getUseTime() { + return 32; + } + + @Override + public int getUseDuration(ItemStack stack, LivingEntity entity) { + return 72000; + } + + @Override + public @NonNull UseAnim getUseAnimation(ItemStack stack) { + return UseAnim.NONE; } } diff --git a/src/main/java/com/lzxnone/terraria/item/weapon/melee/Volcano.java b/src/main/java/com/lzxnone/terraria/item/weapon/melee/Volcano.java index f57497d..30f31df 100644 --- a/src/main/java/com/lzxnone/terraria/item/weapon/melee/Volcano.java +++ b/src/main/java/com/lzxnone/terraria/item/weapon/melee/Volcano.java @@ -35,6 +35,7 @@ import org.joml.Vector3f; import java.util.Comparator; import java.util.List; +import net.minecraft.world.item.enchantment.Enchantments; public class Volcano extends MeleeWeapon { public static final String ID = "volcano"; @@ -72,6 +73,20 @@ public class Volcano extends MeleeWeapon { super(Tiers.IRON, new Item.Properties()); } + @Override + public float getTooltipDamage(ItemStack weaponStack, LivingEntity entity) { + float damage = EXPLOSION_DAMAGE.get(); + //锋利附魔 + int sharpnessLevel = getEnchantmentLevel(entity, weaponStack, Enchantments.SHARPNESS); + if(sharpnessLevel > 0) { + damage += 1.0F + Math.max(0, sharpnessLevel - 1) * 0.5F; + } + //药水 + if(entity instanceof Player player) damage = DamageUtil.applyPlayerDamageEffects(player, damage); + //近战加成 + return MeleeWeapon.applyMeleeDamageBonus(weaponStack, entity, damage); + } + @Override protected float getBaseMeleeDamage(ItemStack stack) { return BASE_MELEE_DAMAGE.get(); @@ -166,7 +181,7 @@ public class Volcano extends MeleeWeapon { for(LivingEntity livingEntity : targets) { if(livingEntity.getUUID() == target.getUUID()) continue; if(hitCount >= EXPLOSION_MAX_HIT_COUNT.get()) break; - if(DamageUtil.meleeAttack(player, livingEntity, player.getWeaponItem(), (float) EXPLOSION_DAMAGE.get(), 1.0f, -1)) { + if(DamageUtil.meleeAttack(player, livingEntity, player.getWeaponItem(), (float) EXPLOSION_DAMAGE.get(), 1.0f, 10)) { livingTarget.igniteForSeconds(IGNITE_SECONDS.get()); hitCount++; } diff --git a/src/main/java/com/lzxnone/terraria/item/weapon/melee/Zenith.java b/src/main/java/com/lzxnone/terraria/item/weapon/melee/Zenith.java index 1f52c6a..f979f82 100644 --- a/src/main/java/com/lzxnone/terraria/item/weapon/melee/Zenith.java +++ b/src/main/java/com/lzxnone/terraria/item/weapon/melee/Zenith.java @@ -20,6 +20,7 @@ import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.*; import net.minecraft.world.item.component.CustomData; +import net.minecraft.world.item.enchantment.Enchantments; import net.minecraft.world.level.Level; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.EntityHitResult; @@ -44,8 +45,8 @@ public class Zenith extends MeleeWeapon { public static final ConfigFloat DAMAGE = new ConfigFloat( "weapon.zenith.damage", "zenith_damage", - 4.0f, - 1.0f, + 10.0f, + 0.0f, 8388600.0f ); public static final ConfigDouble MAX_RANGE = new ConfigDouble( @@ -127,6 +128,20 @@ public class Zenith extends MeleeWeapon { return DAMAGE.get(); } + @Override + public float getTooltipDamage(ItemStack weaponStack, LivingEntity entity) { + float damage = DAMAGE.get(); + //锋利附魔 + int sharpnessLevel = getEnchantmentLevel(entity, weaponStack, Enchantments.SHARPNESS); + if(sharpnessLevel > 0) { + damage += 1.0F + Math.max(0, sharpnessLevel - 1) * 0.5F; + } + //药水 + if(entity instanceof Player player) damage = DamageUtil.applyPlayerDamageEffects(player, damage); + //近战加成 + return MeleeWeapon.applyMeleeDamageBonus(weaponStack, entity, damage); + } + public static double getMaxRange() { return MAX_RANGE.get(); } @@ -311,7 +326,7 @@ public class Zenith extends MeleeWeapon { if(!projectile.level().isClientSide()) { Entity target = result.getEntity(); if(projectile.getOwner() instanceof Player player && FilterUtil.createTargetFilter(projectile, projectile.getOwner()).test(target)) { - if(DamageUtil.meleeAttack(projectile, target, projectile.getEntityData().get(StaticProjectile.STACK_SOURCE), (float) (DAMAGE.get() + Math.random() * DAMAGE.get()), 0.2f, 2)) { + if(DamageUtil.meleeAttack(projectile, target, projectile.getEntityData().get(StaticProjectile.STACK_SOURCE), (float) (DAMAGE.get() + Math.random() * DAMAGE.get()), 0.2f, 10)) { } } } @@ -414,27 +429,55 @@ public class Zenith extends MeleeWeapon { ItemStack stack = player.getItemInHand(hand); CustomData.update(DataComponents.CUSTOM_DATA, stack, tag -> tag.putBoolean("isFirst", true)); + if(player.getCooldowns().isOnCooldown(stack.getItem()) || !tryShoot(level, player, hand, stack)) return InteractionResultHolder.fail(stack); player.startUsingItem(hand); - return InteractionResultHolder.consume(stack); + player.getCooldowns().addCooldown(stack.getItem(), Math.max(1, getUseTime() / 3)); + return InteractionResultHolder.sidedSuccess(stack, level.isClientSide()); } @Override public void onUseTick(Level level, LivingEntity livingEntity, ItemStack stack, int count) { if(!(livingEntity instanceof Player player)) return; - if(player.tickCount % 3 == 0) { - double deltaDist = stack.getOrDefault(DataComponents.CUSTOM_DATA, CustomData.EMPTY) - .copyTag().getDouble("deltaDist"); - boolean isFirst = stack.getOrDefault(DataComponents.CUSTOM_DATA, CustomData.EMPTY) - .copyTag().getBoolean("isFirst"); - if(isFirst) { - CustomData.update(DataComponents.CUSTOM_DATA, stack, - tag -> tag.putBoolean("isFirst", false)); - } - summon(player, deltaDist, isFirst); - SoundUtil.playClientSound(player, ModSounds.WAVE.get()); + if(!shouldShootThisTick(stack, livingEntity, count)) return; + + if(!tryShoot(level, player, player.getUsedItemHand(), stack)) { + player.stopUsingItem(); } } + public boolean shouldShootThisTick(ItemStack weaponStack, LivingEntity entity, int remainingUseTicks) { + int useTime = Math.max(1, getUseTime()); + int elapsedMinecraftTicks = getUseDuration(weaponStack, entity) - remainingUseTicks; + if(elapsedMinecraftTicks <= 0) return false; + + int currentShot = elapsedMinecraftTicks * 3 / useTime; + int previousShot = (elapsedMinecraftTicks - 1) * 3 / useTime; + return currentShot > previousShot; + } + + public boolean tryShoot(Level level, Player player, InteractionHand hand, ItemStack stack) { + shoot(level, player, hand, stack); + return true; + } + + public void shoot(Level level, Player player, InteractionHand hand, ItemStack stack) { + SoundUtil.playClientSound(player, ModSounds.WAVE.get()); + if(level.isClientSide()) return; + double deltaDist = stack.getOrDefault(DataComponents.CUSTOM_DATA, CustomData.EMPTY) + .copyTag().getDouble("deltaDist"); + boolean isFirst = stack.getOrDefault(DataComponents.CUSTOM_DATA, CustomData.EMPTY) + .copyTag().getBoolean("isFirst"); + if(isFirst) { + CustomData.update(DataComponents.CUSTOM_DATA, stack, + tag -> tag.putBoolean("isFirst", false)); + } + summon(player, deltaDist, isFirst); + } + + public int getUseTime() { + return 10; + } + @Override public int getUseDuration(ItemStack stack, LivingEntity entity) { return 72000; diff --git a/src/main/java/com/lzxnone/terraria/item/weapon/ranged/ElfMelter.java b/src/main/java/com/lzxnone/terraria/item/weapon/ranged/ElfMelter.java index 25cd968..8636b20 100644 --- a/src/main/java/com/lzxnone/terraria/item/weapon/ranged/ElfMelter.java +++ b/src/main/java/com/lzxnone/terraria/item/weapon/ranged/ElfMelter.java @@ -38,7 +38,7 @@ public class ElfMelter extends RangedWeapon { public static final ConfigFloat DAMAGE = new ConfigFloat("weapon.elf_melter.damage", "elf_melter_damage", 4.0f, 0.0f, 8388600.0f); public static final ConfigDouble SPEED = new ConfigDouble("weapon.elf_melter.speed", "elf_melter_speed", 4.0D, 0.1D, 24.0D); public static final ConfigDouble RANGE = new ConfigDouble("weapon.elf_melter.range", "elf_melter_range", 32.0D, 1.0D, 128.0D); - public static final ConfigInt FREEZE_TICKS = new ConfigInt("weapon.elf_melter.freeze_ticks", "elf_melter_freeze_ticks", 400, 0, 72000); + public static final ConfigInt FREEZE_TICKS = new ConfigInt("weapon.elf_melter.freeze_ticks", "elf_melter_freeze_ticks", 1800, 0, 72000); public static final Vector3f OFFSET = new Vector3f(-0.3f, -0.1f, 1.5f); public static final float FLAME_RED = 0.35f; public static final float FLAME_GREEN = 0.85f; @@ -85,9 +85,14 @@ public class ElfMelter extends RangedWeapon { FilterUtil.createTargetFilter(summon, summon.getOwner()) ); for(Entity target : targets) { - if(target.getBoundingBox().inflate(1.0).clip(collisionStart, end).isEmpty()) continue; + AABB targetBox = target.getBoundingBox().inflate(1.0); + if(!targetBox.contains(collisionStart) && targetBox.clip(collisionStart, end).isEmpty()) continue; ItemStack sourceStack = summon.getEntityData().get(StaticSummon.STACK_SOURCE); - if(DamageUtil.rangedAttack(summon, target, sourceStack, DAMAGE.get(), -0.25f, 12)) { + //25% 原版冰冻伤害(先结算,避免被 75% 远程伤害的短无敌帧吞掉),并附带 0.8~1.2 伤害浮动 + float freezeDamage = DAMAGE.get() * 0.25F * (0.8F + (float) Math.random() * 0.4F); + target.hurt(target.damageSources().freeze(), freezeDamage); + //75% 远程伤害 + if(DamageUtil.rangedAttack(summon, target, sourceStack, DAMAGE.get() * 0.75F, -0.25f, 4)) { if(target instanceof LivingEntity livingTarget) { livingTarget.setTicksFrozen(Math.max(livingTarget.getTicksFrozen(), FREEZE_TICKS.get())); } @@ -140,8 +145,11 @@ public class ElfMelter extends RangedWeapon { @Override public float getTooltipDamage(ItemStack weaponStack, LivingEntity entity) { - float damage = entity instanceof Player player ? DamageUtil.applyPlayerDamageEffects(player, DAMAGE.get()) : DAMAGE.get(); - return applyRangedDamageBonus(weaponStack, entity, damage); + //75% 远程伤害走完整加成流程 + float damage = entity instanceof Player player ? DamageUtil.applyPlayerDamageEffects(player, DAMAGE.get() * 0.75F) : DAMAGE.get() * 0.75F; + damage = applyRangedDamageBonus(weaponStack, entity, damage); + //加上 25% 原版冰冻伤害 + return damage + DAMAGE.get() * 0.25F; } @Override diff --git a/src/main/java/com/lzxnone/terraria/item/weapon/ranged/Flamethrower.java b/src/main/java/com/lzxnone/terraria/item/weapon/ranged/Flamethrower.java index 412f8b6..adc3ce8 100644 --- a/src/main/java/com/lzxnone/terraria/item/weapon/ranged/Flamethrower.java +++ b/src/main/java/com/lzxnone/terraria/item/weapon/ranged/Flamethrower.java @@ -111,9 +111,14 @@ public class Flamethrower extends RangedWeapon { FilterUtil.createTargetFilter(summon, summon.getOwner()) ); for(Entity target : targets) { - if(target.getBoundingBox().inflate(1.0).clip(collisionStart, end).isEmpty()) continue; + AABB targetBox = target.getBoundingBox().inflate(1.0); + if(!targetBox.contains(collisionStart) && targetBox.clip(collisionStart, end).isEmpty()) continue; ItemStack sourceStack = summon.getEntityData().get(StaticSummon.STACK_SOURCE); - if(DamageUtil.rangedAttack(summon, target, sourceStack, DAMAGE.get(), -0.25f, 12)) { + //25% 原版火焰伤害(先结算,避免被 75% 远程伤害的短无敌帧吞掉),并附带 0.8~1.2 伤害浮动 + float flameDamage = DAMAGE.get() * 0.25F * (0.8F + (float) Math.random() * 0.4F); + target.hurt(target.damageSources().onFire(), flameDamage); + //75% 远程伤害 + if(DamageUtil.rangedAttack(summon, target, sourceStack, DAMAGE.get() * 0.75F, -0.25f, 4)) { if(target instanceof LivingEntity livingTarget) { livingTarget.igniteForTicks(IGNITE_TICKS.get()); } @@ -162,8 +167,11 @@ public class Flamethrower extends RangedWeapon { @Override public float getTooltipDamage(ItemStack weaponStack, LivingEntity entity) { - float damage = entity instanceof Player player ? DamageUtil.applyPlayerDamageEffects(player, DAMAGE.get()) : DAMAGE.get(); - return applyRangedDamageBonus(weaponStack, entity, damage); + //75% 远程伤害走完整加成流程 + float damage = entity instanceof Player player ? DamageUtil.applyPlayerDamageEffects(player, DAMAGE.get() * 0.75F) : DAMAGE.get() * 0.75F; + damage = applyRangedDamageBonus(weaponStack, entity, damage); + //加上 25% 原版火焰伤害 + return damage + DAMAGE.get() * 0.25F; } @Override diff --git a/src/main/java/com/lzxnone/terraria/item/weapon/ranged/StarCannon.java b/src/main/java/com/lzxnone/terraria/item/weapon/ranged/StarCannon.java index 7b0ca24..303c9ac 100644 --- a/src/main/java/com/lzxnone/terraria/item/weapon/ranged/StarCannon.java +++ b/src/main/java/com/lzxnone/terraria/item/weapon/ranged/StarCannon.java @@ -81,7 +81,7 @@ public class StarCannon extends RangedWeapon { ); for(Entity target : targets) { ItemStack sourceStack = summon.getEntityData().get(StaticSummon.STACK_SOURCE); - if(DamageUtil.rangedAttack(summon, target, sourceStack, DAMAGE.get(), 0.25f, 5)) { + if(DamageUtil.rangedAttack(summon, target, sourceStack, DAMAGE.get(), 0.25f, 10)) { } } diff --git a/src/main/java/com/lzxnone/terraria/item/weapon/ranged/SuperStarShooter.java b/src/main/java/com/lzxnone/terraria/item/weapon/ranged/SuperStarShooter.java index 725e3f0..de4c427 100644 --- a/src/main/java/com/lzxnone/terraria/item/weapon/ranged/SuperStarShooter.java +++ b/src/main/java/com/lzxnone/terraria/item/weapon/ranged/SuperStarShooter.java @@ -129,7 +129,7 @@ public class SuperStarShooter extends RangedWeapon { public void onHitEntity(StaticProjectile projectile, EntityHitResult result) { if(!projectile.level().isClientSide()) { Entity target = result.getEntity(); - if(DamageUtil.rangedAttack(projectile, target, projectile.getEntityData().get(StaticProjectile.STACK_SOURCE), BOLT_DAMAGE.get(), 0.3f, 5)) { + if(DamageUtil.rangedAttack(projectile, target, projectile.getEntityData().get(StaticProjectile.STACK_SOURCE), BOLT_DAMAGE.get(), 0.3f, 10)) { } } } diff --git a/src/main/java/com/lzxnone/terraria/item/weapon/ranged/bow/Bow.java b/src/main/java/com/lzxnone/terraria/item/weapon/ranged/bow/Bow.java index 9a86e3c..c3e4212 100644 --- a/src/main/java/com/lzxnone/terraria/item/weapon/ranged/bow/Bow.java +++ b/src/main/java/com/lzxnone/terraria/item/weapon/ranged/bow/Bow.java @@ -87,7 +87,7 @@ public class Bow extends RangedWeapon { } protected int getInvulnerableTime(ItemStack weaponStack, LivingEntity entity, ItemStack ammoStack) { - return 20; + return 10; } protected boolean hasInfinity(ItemStack weaponStack, LivingEntity entity) { diff --git a/src/main/java/com/lzxnone/terraria/item/weapon/ranged/gun/ChainGun.java b/src/main/java/com/lzxnone/terraria/item/weapon/ranged/gun/ChainGun.java index 2156701..50e0dcb 100644 --- a/src/main/java/com/lzxnone/terraria/item/weapon/ranged/gun/ChainGun.java +++ b/src/main/java/com/lzxnone/terraria/item/weapon/ranged/gun/ChainGun.java @@ -47,7 +47,7 @@ public class ChainGun extends Gun { } @Override protected int getInvulnerableTime(ItemStack stack, Player player) { - return 4; + return 10; } @Override diff --git a/src/main/java/com/lzxnone/terraria/item/weapon/ranged/gun/ClockworkAssaultRifle.java b/src/main/java/com/lzxnone/terraria/item/weapon/ranged/gun/ClockworkAssaultRifle.java index 1c552c2..10fbbba 100644 --- a/src/main/java/com/lzxnone/terraria/item/weapon/ranged/gun/ClockworkAssaultRifle.java +++ b/src/main/java/com/lzxnone/terraria/item/weapon/ranged/gun/ClockworkAssaultRifle.java @@ -57,7 +57,7 @@ public class ClockworkAssaultRifle extends Gun { @Override protected int getInvulnerableTime(ItemStack stack, Player player) { - return 5; + return 10; } @Override diff --git a/src/main/java/com/lzxnone/terraria/item/weapon/ranged/gun/Gatligator.java b/src/main/java/com/lzxnone/terraria/item/weapon/ranged/gun/Gatligator.java index 0384f51..60598b2 100644 --- a/src/main/java/com/lzxnone/terraria/item/weapon/ranged/gun/Gatligator.java +++ b/src/main/java/com/lzxnone/terraria/item/weapon/ranged/gun/Gatligator.java @@ -54,7 +54,7 @@ public class Gatligator extends Gun { @Override protected int getInvulnerableTime(ItemStack stack, Player player) { - return 5; + return 10; } @Override diff --git a/src/main/java/com/lzxnone/terraria/item/weapon/ranged/gun/Megashark.java b/src/main/java/com/lzxnone/terraria/item/weapon/ranged/gun/Megashark.java index 01d900a..6464367 100644 --- a/src/main/java/com/lzxnone/terraria/item/weapon/ranged/gun/Megashark.java +++ b/src/main/java/com/lzxnone/terraria/item/weapon/ranged/gun/Megashark.java @@ -45,7 +45,7 @@ public class Megashark extends Gun { } @Override protected int getInvulnerableTime(ItemStack stack, Player player) { - return 5; + return 10; } @Override diff --git a/src/main/java/com/lzxnone/terraria/item/weapon/ranged/gun/Minishark.java b/src/main/java/com/lzxnone/terraria/item/weapon/ranged/gun/Minishark.java index 9c1003b..1e07b58 100644 --- a/src/main/java/com/lzxnone/terraria/item/weapon/ranged/gun/Minishark.java +++ b/src/main/java/com/lzxnone/terraria/item/weapon/ranged/gun/Minishark.java @@ -45,7 +45,7 @@ public class Minishark extends Gun { } @Override protected int getInvulnerableTime(ItemStack stack, Player player) { - return 5; + return 10; } @Override diff --git a/src/main/java/com/lzxnone/terraria/item/weapon/ranged/gun/SDMG.java b/src/main/java/com/lzxnone/terraria/item/weapon/ranged/gun/SDMG.java index 1e3a012..3724280 100644 --- a/src/main/java/com/lzxnone/terraria/item/weapon/ranged/gun/SDMG.java +++ b/src/main/java/com/lzxnone/terraria/item/weapon/ranged/gun/SDMG.java @@ -45,7 +45,7 @@ public class SDMG extends Gun { } @Override protected int getInvulnerableTime(ItemStack stack, Player player) { - return 5; + return 10; } @Override diff --git a/src/main/java/com/lzxnone/terraria/item/weapon/ranged/gun/SniperRifle.java b/src/main/java/com/lzxnone/terraria/item/weapon/ranged/gun/SniperRifle.java index 44a6801..0327957 100644 --- a/src/main/java/com/lzxnone/terraria/item/weapon/ranged/gun/SniperRifle.java +++ b/src/main/java/com/lzxnone/terraria/item/weapon/ranged/gun/SniperRifle.java @@ -82,7 +82,7 @@ public class SniperRifle extends Gun implements ScopeZoomModifier { @Override protected int getInvulnerableTime(ItemStack stack, Player player) { - return 20; + return 10; } @Override diff --git a/src/main/java/com/lzxnone/terraria/item/weapon/ranged/gun/Uzi.java b/src/main/java/com/lzxnone/terraria/item/weapon/ranged/gun/Uzi.java index a0bf56b..eeaba42 100644 --- a/src/main/java/com/lzxnone/terraria/item/weapon/ranged/gun/Uzi.java +++ b/src/main/java/com/lzxnone/terraria/item/weapon/ranged/gun/Uzi.java @@ -48,7 +48,7 @@ public class Uzi extends Gun { } @Override protected int getInvulnerableTime(ItemStack stack, Player player) { - return 5; + return 10; } @Override diff --git a/src/main/java/com/lzxnone/terraria/item/weapon/ranged/gun/VenusMagnum.java b/src/main/java/com/lzxnone/terraria/item/weapon/ranged/gun/VenusMagnum.java index 876fbcc..f174ff3 100644 --- a/src/main/java/com/lzxnone/terraria/item/weapon/ranged/gun/VenusMagnum.java +++ b/src/main/java/com/lzxnone/terraria/item/weapon/ranged/gun/VenusMagnum.java @@ -48,7 +48,7 @@ public class VenusMagnum extends Gun { } @Override protected int getInvulnerableTime(ItemStack stack, Player player) { - return 5; + return 10; } @Override diff --git a/src/main/java/com/lzxnone/terraria/item/weapon/summon/minion/StardustCellStaff.java b/src/main/java/com/lzxnone/terraria/item/weapon/summon/minion/StardustCellStaff.java new file mode 100644 index 0000000..361a920 --- /dev/null +++ b/src/main/java/com/lzxnone/terraria/item/weapon/summon/minion/StardustCellStaff.java @@ -0,0 +1,477 @@ +package com.lzxnone.terraria.item.weapon.summon.minion; + +import com.lzxnone.terraria.LzxnoneTerraria; +import com.lzxnone.terraria.ModSounds; +import com.lzxnone.terraria.effect.ModEffects; +import com.lzxnone.terraria.entity.ModEntities; +import com.lzxnone.terraria.entity.projectile.IStaticProjectileBehavior; +import com.lzxnone.terraria.entity.projectile.StaticProjectile; +import com.lzxnone.terraria.entity.projectile.StaticProjectileBehaviors; +import com.lzxnone.terraria.entity.summon.IStaticSummonBehavior; +import com.lzxnone.terraria.entity.summon.StaticSummon; +import com.lzxnone.terraria.entity.summon.StaticSummonBehaviors; +import com.lzxnone.terraria.item.ModItems; +import com.lzxnone.terraria.particle.CircleParticleOptions; +import com.lzxnone.terraria.particle.DustParticleOptions; +import com.lzxnone.terraria.ui.config.ConfigListItem; +import com.lzxnone.terraria.ui.config.IConfigData; +import com.lzxnone.terraria.ui.config.struct.ConfigDouble; +import com.lzxnone.terraria.ui.config.struct.ConfigFloat; +import com.lzxnone.terraria.ui.config.struct.ConfigInt; +import com.lzxnone.terraria.ui.config.struct.ConfigStruct; +import com.lzxnone.terraria.utils.CollisionUtil; +import com.lzxnone.terraria.utils.DamageUtil; +import com.lzxnone.terraria.utils.FilterUtil; +import com.lzxnone.terraria.utils.MathUtil; +import com.lzxnone.terraria.utils.ParticleUtil; +import com.lzxnone.terraria.utils.SoundUtil; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.sounds.SoundEvents; +import net.minecraft.util.Mth; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResultHolder; +import net.minecraft.world.effect.MobEffectInstance; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Rarity; +import net.minecraft.world.item.Tiers; +import net.minecraft.world.level.Level; +import net.minecraft.world.phys.EntityHitResult; +import net.minecraft.world.phys.Vec3; +import org.joml.Vector3f; + +import java.util.List; + +public class StardustCellStaff extends MinionWeapon { + public static final ConfigDouble TARGET_RANGE = new ConfigDouble( + "weapon.stardust_cell_staff.target_range", "stardust_cell_staff_target_range", 64.0D, 1.0D, 256.0D + ); + public static final ConfigDouble SHOOT_RANGE = new ConfigDouble( + "weapon.stardust_cell_staff.shoot_range", "stardust_cell_staff_shoot_range", 12.0D, 1.0D, 256.0D + ); + public static final ConfigFloat DAMAGE = new ConfigFloat( + "weapon.stardust_cell_staff.damage", "stardust_cell_staff_damage", 5.0F, 0.0F, 8388600.0F + ); + public static final ConfigInt CELLED_DURATION = new ConfigInt( + "weapon.stardust_cell_staff.celled_duration", "stardust_cell_staff_celled_duration", 100, 1, 72000 + ); + + public static final ConfigDouble MIN_SHOOT_DISTANCE = new ConfigDouble( + "weapon.stardust_cell_staff.min_shoot_distance", "stardust_cell_staff_min_shoot_distance", 8.0D, 0.1D, 256.0D + ); + public static final ConfigDouble PROJECTILE_SPEED = new ConfigDouble( + "weapon.stardust_cell_staff.projectile_speed", "stardust_cell_staff_projectile_speed", 1.5D, 0.01D, 32.0D + ); + public static final ConfigInt PROJECTILE_LIFETIME = new ConfigInt( + "weapon.stardust_cell_staff.projectile_lifetime", "stardust_cell_staff_projectile_lifetime", 100, 1, 72000 + ); + + public static final ConfigDouble WANDER_SPEED = new ConfigDouble( + "weapon.stardust_cell_staff.wander_speed", "stardust_cell_staff_wander_speed", 0.6D, 0.01D, 32.0D + ); + public static final ConfigDouble CHASE_SPEED = new ConfigDouble( + "weapon.stardust_cell_staff.chase_speed", "stardust_cell_staff_chase_speed", 1.0D, 0.01D, 32.0D + ); + public static final ConfigDouble BACK_AWAY_SPEED = new ConfigDouble( + "weapon.stardust_cell_staff.back_away_speed", "stardust_cell_staff_back_away_speed", 0.45D, 0.01D, 32.0D + ); + public static final ConfigDouble RECOIL_SPEED = new ConfigDouble( + "weapon.stardust_cell_staff.recoil_speed", "stardust_cell_staff_recoil_speed", 0.5D, 0.01D, 32.0D + ); + public static final ConfigDouble PRE_SHOOT_FRICTION = new ConfigDouble( + "weapon.stardust_cell_staff.pre_shoot_friction", "stardust_cell_staff_pre_shoot_friction", 0.35D, 0.0D, 1.0D + ); + public static final ConfigDouble RECOIL_BRAKE = new ConfigDouble( + "weapon.stardust_cell_staff.recoil_brake", "stardust_cell_staff_recoil_brake", 0.12D, 0.0D, 1.0D + ); + + private static final double WANDER_RADIUS = 12.0D; + private static final double WANDER_TELEPORT_DISTANCE = WANDER_RADIUS * 1.5D; + private static final int TELEPORT_CHASE_TICKS = 20; + private static final double TELEPORT_RADIUS = 4.0D; + private static final float ROTATION_LERP = 0.25F; + + private static final int TELEPORT_PARTICLE_COUNT = 100; + private static final DustParticleOptions TELEPORT_PARTICLE = new DustParticleOptions( + 0.05f, 0.5f, 40, true, new Vector3f[]{ + new Vector3f(0.0F, 0.5F, 1.0F), + new Vector3f(0.0F, 1.0F, 1.0F), + } + ); + + public static final CircleParticleOptions CELL_CIRCLE_BLUE = new CircleParticleOptions(0.08F, 40, new Vector3f(0.0F, 0.5F, 1.0F)); + public static final CircleParticleOptions CELL_CIRCLE_CYAN = new CircleParticleOptions(0.08F, 40, new Vector3f(0.0F, 1.0F, 1.0F)); + + public enum State { + IDLE, + WANDER, + FIGHT, + CHASE, + PRE_SHOOT, + SHOOT, + DONE + } + + public StardustCellStaff() { + super(Tiers.NETHERITE, new Properties().stacksTo(1).fireResistant().rarity(Rarity.EPIC)); + } + + public static final IConfigData CONFIG_DATA = new IConfigData() { + @Override + public void onConfigLoad() { + ConfigStruct.loadAll( + TARGET_RANGE, + SHOOT_RANGE, + DAMAGE, + CELLED_DURATION, + MIN_SHOOT_DISTANCE, + PROJECTILE_SPEED, + PROJECTILE_LIFETIME, + WANDER_SPEED, + CHASE_SPEED, + BACK_AWAY_SPEED, + RECOIL_SPEED, + PRE_SHOOT_FRICTION, + RECOIL_BRAKE + ); + } + }; + + public static final ConfigListItem CONFIG_LIST_ITEM = new ConfigListItem( + "stardust_cell_staff", + ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "textures/item/stardust_cell_staff.png"), + Component.translatable("item.lzxnoneterraria.stardust_cell_staff"), + CONFIG_DATA + ); + + @Override + public float getTooltipDamage(ItemStack weaponStack, LivingEntity entity) { + float damage = entity instanceof Player player + ? DamageUtil.applyPlayerDamageEffects(player, DAMAGE.get()) + : DAMAGE.get(); + return applySummonDamageBonus(weaponStack, entity, damage); + } + + public static final IStaticSummonBehavior SUMMON_BEHAVIOR = new IStaticSummonBehavior() { + @Override + public void tick(StaticSummon summon) { + checkBeforeTick(summon); + Entity owner = summon.getOwner(); + if(owner != null && owner.position().subtract(summon.position()).length() > MinionWeapon.MAX_RANGE) { + summon.setPos(owner.getBoundingBox().getCenter()); + summon.setDeltaMovement(Vec3.ZERO); + } + if(!summon.level().isClientSide() && owner instanceof Player player && summon.isAlive()) { + onState(summon, player); + } + } + }; + + public static void onState(StaticSummon summon, Player player) { + CompoundTag customData = summon.getEntityData().get(StaticSummon.CUSTOM_DATA).copy(); + int state = customData.contains("state") ? customData.getInt("state") : State.IDLE.ordinal(); + + if(state == State.IDLE.ordinal()) { + storeSummonTarget(summon, findSummonTarget(summon, player, TARGET_RANGE.get())); + if(getStoredSummonTarget(summon) == null) changeState(summon, State.WANDER); + else changeState(summon, State.FIGHT); + return; + } + + if(state == State.WANDER.ordinal()) { + storeSummonTarget(summon, findSummonTarget(summon, player, TARGET_RANGE.get())); + if(getStoredSummonTarget(summon) != null) { + changeState(summon, State.FIGHT); + return; + } + + customData = summon.getEntityData().get(StaticSummon.CUSTOM_DATA).copy(); + if(!customData.contains("wanderX") || !customData.contains("wanderY") || !customData.contains("wanderZ")) { + changeState(summon, State.IDLE); + return; + } + Vec3 wanderPos = new Vec3(customData.getDouble("wanderX"), customData.getDouble("wanderY"), customData.getDouble("wanderZ")); + Vec3 distance = wanderPos.subtract(summon.position()); + customData.putInt("wanderTicks", customData.getInt("wanderTicks") + 1); + summon.getEntityData().set(StaticSummon.CUSTOM_DATA, customData); + if(distance.length() > WANDER_TELEPORT_DISTANCE && customData.getInt("wanderTicks") > TELEPORT_CHASE_TICKS) { + teleportSummon(summon, wanderPos, State.IDLE); + return; + } + if(distance.length() > 0.25D) { + summon.setDeltaMovement(distance.normalize().scale(Math.min(WANDER_SPEED.get(), distance.length()))); + float[] xyRot = MathUtil.computeXYRot(summon.getDeltaMovement().toVector3f()); + summon.setXRot(Mth.rotLerp(ROTATION_LERP, summon.getXRot(), xyRot[0])); + summon.setYRot(Mth.rotLerp(ROTATION_LERP, summon.getYRot(), xyRot[1])); + }else { + summon.setDeltaMovement(summon.getDeltaMovement().scale(0.35D)); + if(summon.getDeltaMovement().length() < 0.05D) { + summon.setDeltaMovement(Vec3.ZERO); + changeState(summon, State.IDLE); + } + } + return; + } + + if(state == State.FIGHT.ordinal()) { + storeSummonTarget(summon, findSummonTarget(summon, player, TARGET_RANGE.get())); + Entity target = getStoredSummonTarget(summon); + if(target == null) { + changeState(summon, State.IDLE); + return; + } + + Vec3 targetDirection = target.getBoundingBox().getCenter().subtract(summon.position()); + float[] xyRot = MathUtil.computeXYRot(targetDirection.toVector3f()); + summon.setXRot(Mth.rotLerp(ROTATION_LERP, summon.getXRot(), xyRot[0])); + summon.setYRot(Mth.rotLerp(ROTATION_LERP, summon.getYRot(), xyRot[1])); + if(targetDirection.length() > SHOOT_RANGE.get()) changeState(summon, State.CHASE); + else changeState(summon, State.PRE_SHOOT); + return; + } + + if(state == State.CHASE.ordinal()) { + Entity target = getStoredSummonTarget(summon); + if(target == null || !target.isAlive() + || target.distanceToSqr(summon) > TARGET_RANGE.get() * TARGET_RANGE.get() + || !FilterUtil.createTargetFilter(summon, player).test(target)) { + changeState(summon, State.FIGHT); + return; + } + + Vec3 targetDirection = target.getBoundingBox().getCenter().subtract(summon.position()); + if(targetDirection.length() <= SHOOT_RANGE.get()) { + changeState(summon, State.FIGHT); + return; + } + + summon.setDeltaMovement(targetDirection.normalize().scale(CHASE_SPEED.get())); + float[] xyRot = MathUtil.computeXYRot(summon.getDeltaMovement().toVector3f()); + summon.setXRot(Mth.rotLerp(ROTATION_LERP, summon.getXRot(), xyRot[0])); + summon.setYRot(Mth.rotLerp(ROTATION_LERP, summon.getYRot(), xyRot[1])); + + customData.putInt("chaseTicks", customData.getInt("chaseTicks") + 1); + summon.getEntityData().set(StaticSummon.CUSTOM_DATA, customData); + if(customData.getInt("chaseTicks") > TELEPORT_CHASE_TICKS) { + teleportSummon(summon, target.getBoundingBox().getCenter(), State.FIGHT); + } + return; + } + + if(state == State.PRE_SHOOT.ordinal()) { + Entity target = getStoredSummonTarget(summon); + if(target == null || !target.isAlive() || !FilterUtil.createTargetFilter(summon, player).test(target)) { + changeState(summon, State.FIGHT); + return; + } + + Vec3 targetDirection = target.getBoundingBox().getCenter().subtract(summon.position()); + double distance = targetDirection.length(); + if(distance > SHOOT_RANGE.get()) { + changeState(summon, State.FIGHT); + }else if(distance < MIN_SHOOT_DISTANCE.get()) { + summon.setDeltaMovement(targetDirection.normalize().scale(-BACK_AWAY_SPEED.get())); + }else { + summon.setDeltaMovement(summon.getDeltaMovement().scale(PRE_SHOOT_FRICTION.get())); + if(summon.getDeltaMovement().length() < 0.05D) { + summon.setDeltaMovement(Vec3.ZERO); + changeState(summon, State.SHOOT); + } + } + return; + } + + if(state == State.SHOOT.ordinal()) { + Entity target = getStoredSummonTarget(summon); + if(target == null || !target.isAlive() || !FilterUtil.createTargetFilter(summon, player).test(target)) { + changeState(summon, State.FIGHT); + return; + } + + Vec3 direction = target.getBoundingBox().getCenter().subtract(summon.position()).normalize(); + Vector3f[] directions = MathUtil.computeCoordinateSystem(direction.toVector3f(), summon.getYRot()); + StaticProjectile projectile = new StaticProjectile(ModEntities.STATIC_PROJECTILE.get(), summon.level()); + projectile.setOwner(player); + projectile.setPos(summon.position()); + projectile.getEntityData().set(StaticProjectile.STACK_SOURCE, summon.getEntityData().get(StaticSummon.STACK_SOURCE).copy()); + projectile.getEntityData().set(StaticProjectile.BEHAVIOR, StaticProjectileBehaviors.STARDUST_CELL_PROJECTILE); + projectile.getEntityData().set(StaticProjectile.RENDER_MODE, "custom"); + projectile.getEntityData().set(StaticProjectile.ORIGIN, summon.position().toVector3f()); + projectile.getEntityData().set(StaticProjectile.DIRECTION, directions[0]); + projectile.getEntityData().set(StaticProjectile.UP, directions[1]); + projectile.getEntityData().set(StaticProjectile.RIGHT, directions[2]); + projectile.getEntityData().set(StaticProjectile.EXPRESSION_Z, PROJECTILE_SPEED.get() + "*t"); + projectile.getEntityData().set(StaticProjectile.LIFETIME, PROJECTILE_LIFETIME.get()); + projectile.getEntityData().set(StaticProjectile.SCALE_X, 0.5F); + projectile.getEntityData().set(StaticProjectile.SCALE_Y, 0.5F); + projectile.getEntityData().set(StaticProjectile.SCALE_Z, 0.5F); + projectile.getEntityData().set(StaticProjectile.GLOW, true); + projectile.setDeltaMovement(direction.scale(PROJECTILE_SPEED.get())); + summon.level().addFreshEntity(projectile); + + ParticleUtil.addParticles((ServerLevel) summon.level(), CELL_CIRCLE_BLUE, summon.position(), Vec3.ZERO, 0.2D, 12); + ParticleUtil.addParticles((ServerLevel) summon.level(), CELL_CIRCLE_CYAN, summon.position(), Vec3.ZERO, 0.2D, 12); + + customData = summon.getEntityData().get(StaticSummon.CUSTOM_DATA).copy(); + customData.putInt("state", State.DONE.ordinal()); + customData.putDouble("shootDirX", direction.x); + customData.putDouble("shootDirY", direction.y); + customData.putDouble("shootDirZ", direction.z); + summon.getEntityData().set(StaticSummon.CUSTOM_DATA, customData); + summon.setDeltaMovement(direction.scale(-RECOIL_SPEED.get())); + return; + } + + if(state == State.DONE.ordinal()) { + Vec3 shootDirection = new Vec3( + customData.getDouble("shootDirX"), + customData.getDouble("shootDirY"), + customData.getDouble("shootDirZ") + ); + Vec3 velocity = summon.getDeltaMovement(); + if(shootDirection.lengthSqr() < 1.0E-6D || velocity.length() < 0.05D || velocity.dot(shootDirection) >= -0.05D) { + summon.setDeltaMovement(Vec3.ZERO); + changeState(summon, State.FIGHT); + }else { + summon.setDeltaMovement(velocity.add(shootDirection.normalize().scale(RECOIL_BRAKE.get()))); + } + } + } + + private static void teleportSummon(StaticSummon summon, Vec3 targetCenter, State nextState) { + Vec3 from = summon.position(); + Vec3 to = MathUtil.getRandomPosInRadius(targetCenter, TELEPORT_RADIUS); + SoundUtil.playServerSound(summon.level(), SoundEvents.ENDERMAN_TELEPORT, from); + summon.setPos(to); + summon.setDeltaMovement(Vec3.ZERO); + for(int i = 0; i < TELEPORT_PARTICLE_COUNT; i++) { + Vec3 pos = from.lerp(to, i / (double) (TELEPORT_PARTICLE_COUNT - 1)); + ParticleUtil.addParticles((ServerLevel) summon.level(), TELEPORT_PARTICLE, pos, Vec3.ZERO, 0.0D, 1); + } + ParticleUtil.addParticles((ServerLevel) summon.level(), CELL_CIRCLE_BLUE, from, Vec3.ZERO, 0.2D, 12); + ParticleUtil.addParticles((ServerLevel) summon.level(), CELL_CIRCLE_CYAN, from, Vec3.ZERO, 0.2D, 12); + ParticleUtil.addParticles((ServerLevel) summon.level(), CELL_CIRCLE_BLUE, to, Vec3.ZERO, 0.2D, 12); + ParticleUtil.addParticles((ServerLevel) summon.level(), CELL_CIRCLE_CYAN, to, Vec3.ZERO, 0.2D, 12); + changeState(summon, nextState); + } + + public static void changeState(StaticSummon summon, State state) { + CompoundTag customData = summon.getEntityData().get(StaticSummon.CUSTOM_DATA).copy(); + customData.putInt("state", state.ordinal()); + if(state == State.IDLE) { + summon.setDeltaMovement(Vec3.ZERO); + }else if(state == State.WANDER && summon.getOwner() != null) { + Vec3 wanderPos = MathUtil.getRandomPosInRadius(summon.getOwner().getBoundingBox().getCenter(), WANDER_RADIUS); + customData.putDouble("wanderX", wanderPos.x); + customData.putDouble("wanderY", wanderPos.y); + customData.putDouble("wanderZ", wanderPos.z); + customData.putInt("wanderTicks", 0); + }else if(state == State.CHASE) { + customData.putInt("chaseTicks", 0); + } + summon.getEntityData().set(StaticSummon.CUSTOM_DATA, customData); + } + + public static final IStaticSummonBehavior SUMMON_BEHAVIOR2 = new IStaticSummonBehavior() { + @Override + public void tick(StaticSummon summon) { + this.checkBeforeTick(summon); + Entity target = summon.getOwner(); + CompoundTag customData = summon.getEntityData().get(StaticSummon.CUSTOM_DATA); + if(target == null || !target.isAlive() + || !customData.contains("offsetX") || !customData.contains("offsetY") || !customData.contains("offsetZ")) { + onDied(summon); + return; + } + Vec3 position = target.getBoundingBox().getCenter().add( + customData.getDouble("offsetX"), + customData.getDouble("offsetY"), + customData.getDouble("offsetZ") + ); + summon.setPos(position); + } + }; + + public static final IStaticProjectileBehavior PROJECTILE_BEHAVIOR = new IStaticProjectileBehavior() { + @Override + public void onMoving(StaticProjectile projectile) { + if(projectile.level().isClientSide() || projectile.prevPos == null || !projectile.isAlive()) return; + EntityHitResult entityHit = CollisionUtil.checkEntityHit(projectile, projectile.prevPos, projectile.position(), 0.35D); + if(entityHit != null) { + onHitEntity(projectile, entityHit); + } + } + + @Override + public void onHitEntity(StaticProjectile projectile, EntityHitResult result) { + if(projectile.level().isClientSide()) return; + Entity target = result.getEntity(); + Entity owner = projectile.getOwner(); + if(owner == null) return; + if(!FilterUtil.createTargetFilter(owner).test(target) || !(owner instanceof Player)) return; + if(DamageUtil.summonAttack(projectile, target, projectile.getEntityData().get(StaticProjectile.STACK_SOURCE), (float) DAMAGE.get(), 0.5f, 10)) { + if(target instanceof LivingEntity livingEntity) { + MobEffectInstance effectInstance = new MobEffectInstance(ModEffects.CELLED, CELLED_DURATION.get(), 0); + livingEntity.addEffect(effectInstance); + } + Vec3 pos = projectile.position(); + Vec3 offset = pos.subtract(target.getBoundingBox().getCenter()); + StaticSummon summon = new StaticSummon(ModEntities.STATIC_SUMMON.get(), projectile.level()); + summon.setOwner(target); + summon.setPos(pos.add(offset)); + summon.getEntityData().set(StaticSummon.BEHAVIOR, StaticSummonBehaviors.STARDUST_CELL_STUCK_PROJECTILE); + summon.getEntityData().set(StaticSummon.RENDER_MODE, "custom"); + summon.getEntityData().set(StaticSummon.LIFETIME, CELLED_DURATION.get()); + summon.getEntityData().set(StaticSummon.SCALE_X, 0.5F); + summon.getEntityData().set(StaticSummon.SCALE_Y, 0.5F); + summon.getEntityData().set(StaticSummon.SCALE_Z, 0.5F); + summon.getEntityData().set(StaticSummon.GLOW, true); + + CompoundTag customData = new CompoundTag(); + customData.putDouble("offsetX", offset.x); + customData.putDouble("offsetY", offset.y); + customData.putDouble("offsetZ", offset.z); + summon.getEntityData().set(StaticSummon.CUSTOM_DATA, customData); + + summon.setNoGravity(true); + summon.noPhysics = true; + + projectile.level().addFreshEntity(summon); + ParticleUtil.addParticles((ServerLevel) projectile.level(), CELL_CIRCLE_BLUE, target.getBoundingBox().getCenter(), Vec3.ZERO, 0.2D, 12); + ParticleUtil.addParticles((ServerLevel) projectile.level(), CELL_CIRCLE_CYAN, target.getBoundingBox().getCenter(), Vec3.ZERO, 0.2D, 12); + projectile.discard(); + } + } + }; + + @Override + public InteractionResultHolder use(Level level, Player player, InteractionHand hand) { + ItemStack stack = player.getItemInHand(hand); + if(stack.is(ModItems.STARDUST_CELL_STAFF.get()) && level instanceof ServerLevel) { + StaticSummon summon = new StaticSummon(ModEntities.STATIC_SUMMON.get(), level); + summon.setOwner(player); + summon.setPos(player.getBoundingBox().getCenter()); + summon.getEntityData().set(StaticSummon.STACK_SOURCE, stack.copy()); + summon.getEntityData().set(StaticSummon.BEHAVIOR, StaticSummonBehaviors.STARDUST_CELL_STAFF); + summon.getEntityData().set(StaticSummon.RENDER_MODE, "custom"); + summon.getEntityData().set(StaticSummon.LIFETIME, StaticSummon.INFINITE_LIFETIME); + summon.getEntityData().set(StaticSummon.SCALE_X, 1.0F); + summon.getEntityData().set(StaticSummon.SCALE_Y, 1.0F); + summon.getEntityData().set(StaticSummon.SCALE_Z, 1.0F); + summon.getEntityData().set(StaticSummon.GLOW, true); + CompoundTag customData = new CompoundTag(); + customData.putInt("state", State.IDLE.ordinal()); + summon.getEntityData().set(StaticSummon.CUSTOM_DATA, customData); + summon.setNoGravity(true); + summon.noPhysics = true; + MinionWeapon.addFreshSummon(player, StaticSummonBehaviors.STARDUST_CELL_STAFF, List.of(summon)); + } + SoundUtil.playClientSound(player, ModSounds.SUMMON.get()); + return InteractionResultHolder.consume(stack); + } +} diff --git a/src/main/java/com/lzxnone/terraria/item/weapon/summon/minion/StardustDragonStaff.java b/src/main/java/com/lzxnone/terraria/item/weapon/summon/minion/StardustDragonStaff.java index a838c61..f485c22 100644 --- a/src/main/java/com/lzxnone/terraria/item/weapon/summon/minion/StardustDragonStaff.java +++ b/src/main/java/com/lzxnone/terraria/item/weapon/summon/minion/StardustDragonStaff.java @@ -173,8 +173,17 @@ public class StardustDragonStaff extends MinionWeapon { } float damage = DAMAGE.get() + ADD_DAMAGE.get() * Math.max(0, stardustDragonSlotCount - 1); + //以头部 UUID 作为伤害来源:各节命中统一走头部结算,配合 per-source 冷却避免同 tick 多次命中瞬间爆炸 + StaticSummon head = summon; + if(customData.contains("headUUID")) { + Entity headEntity = serverLevel.getEntity(customData.getUUID("headUUID")); + if(headEntity instanceof StaticSummon headSummon && headSummon.isAlive() + && headSummon.getEntityData().get(StaticSummon.BEHAVIOR).equals(StaticSummonBehaviors.STARDUST_DRAGON_STAFF)) { + head = headSummon; + } + } for(Entity target : targets) { - DamageUtil.minionAttack(summon, target, sourceStack, damage, 1.0f, 15); + DamageUtil.minionAttack(head, target, sourceStack, damage, 1.0f, 10); } } } @@ -520,21 +529,25 @@ public class StardustDragonStaff extends MinionWeapon { CompoundTag headCustomData = new CompoundTag(); headCustomData.putBoolean("head", true); headCustomData.putInt("state", State.IDLE.ordinal()); + headCustomData.putUUID("headUUID", headSummon.getUUID()); headSummon.getEntityData().set(StaticSummon.CUSTOM_DATA, headCustomData); CompoundTag bodyACustomData = new CompoundTag(); bodyACustomData.putBoolean("bodyA", true); bodyACustomData.putUUID("uuid", headSummon.getUUID()); + bodyACustomData.putUUID("headUUID", headSummon.getUUID()); bodySummonA.getEntityData().set(StaticSummon.CUSTOM_DATA, bodyACustomData); CompoundTag bodyBCustomData = new CompoundTag(); bodyBCustomData.putBoolean("bodyB", true); bodyBCustomData.putUUID("uuid", bodySummonA.getUUID()); + bodyBCustomData.putUUID("headUUID", headSummon.getUUID()); bodySummonB.getEntityData().set(StaticSummon.CUSTOM_DATA, bodyBCustomData); CompoundTag tailCustomData = new CompoundTag(); tailCustomData.putBoolean("tail", true); tailCustomData.putUUID("uuid", bodySummonB.getUUID()); + tailCustomData.putUUID("headUUID", headSummon.getUUID()); tailSummon.getEntityData().set(StaticSummon.CUSTOM_DATA, tailCustomData); MinionWeapon.addFreshSummon(player, StaticSummonBehaviors.STARDUST_DRAGON_STAFF, List.of(headSummon, bodySummonA, bodySummonB, tailSummon)); @@ -606,18 +619,28 @@ public class StardustDragonStaff extends MinionWeapon { StaticSummon bodySummonA = createSummon(level, player, hand); StaticSummon bodySummonB = createSummon(level, player, hand); + UUID headUUID = null; + Entity previousEntity = serverLevel.getEntity(previousUUID); + if(previousEntity instanceof StaticSummon previousSummon) { + CompoundTag previousData = previousSummon.getEntityData().get(StaticSummon.CUSTOM_DATA); + if(previousData.contains("headUUID")) headUUID = previousData.getUUID("headUUID"); + } + CompoundTag bodyACustomData = new CompoundTag(); bodyACustomData.putBoolean("bodyA", true); bodyACustomData.putUUID("uuid", previousUUID); + if(headUUID != null) bodyACustomData.putUUID("headUUID", headUUID); bodySummonA.getEntityData().set(StaticSummon.CUSTOM_DATA, bodyACustomData); CompoundTag bodyBCustomData = new CompoundTag(); bodyBCustomData.putBoolean("bodyB", true); bodyBCustomData.putUUID("uuid", bodySummonA.getUUID()); + if(headUUID != null) bodyBCustomData.putUUID("headUUID", headUUID); bodySummonB.getEntityData().set(StaticSummon.CUSTOM_DATA, bodyBCustomData); tailCustomData.putBoolean("tail", true); tailCustomData.putUUID("uuid", bodySummonB.getUUID()); + if(headUUID != null) tailCustomData.putUUID("headUUID", headUUID); tailSummon.getEntityData().set(StaticSummon.CUSTOM_DATA, tailCustomData); stardustDragonSlots.addFirst(new PlayerSummon.SummonSlot(StaticSummonBehaviors.STARDUST_DRAGON_STAFF, List.of(bodySummonA.getUUID(), bodySummonB.getUUID()))); diff --git a/src/main/java/com/lzxnone/terraria/item/weapon/summon/minion/Terraprisma.java b/src/main/java/com/lzxnone/terraria/item/weapon/summon/minion/Terraprisma.java index cf21986..19573d9 100644 --- a/src/main/java/com/lzxnone/terraria/item/weapon/summon/minion/Terraprisma.java +++ b/src/main/java/com/lzxnone/terraria/item/weapon/summon/minion/Terraprisma.java @@ -92,7 +92,7 @@ public class Terraprisma extends MinionWeapon { public static final ConfigFloat DAMAGE = new ConfigFloat( "weapon.terraprisma.damage", "terraprisma_damage", - 20.0F, + 12.0F, 0.0F, 8388600.0F ); @@ -234,7 +234,7 @@ public class Terraprisma extends MinionWeapon { ); ItemStack sourceStack = summon.getEntityData().get(StaticSummon.STACK_SOURCE); for(Entity target : targets) { - DamageUtil.minionAttack(summon, target, sourceStack, customData.contains("damage") ? customData.getFloat("damage") : DAMAGE.get(), 1.0f, 15); + DamageUtil.minionAttack(summon, target, sourceStack, customData.contains("damage") ? customData.getFloat("damage") : DAMAGE.get(), 1.0f, 10); } }else if(state == State.ROTATE.ordinal()) { int time = customData.contains("rotateTime") ? customData.getInt("rotateTime") : 0; @@ -285,7 +285,7 @@ public class Terraprisma extends MinionWeapon { ItemStack sourceStack = summon.getEntityData().get(StaticSummon.STACK_SOURCE); for(Entity target : targets) { - DamageUtil.minionAttack(summon, target, sourceStack, customData.contains("damage") ? customData.getFloat("damage") : DAMAGE.get(), 1.0f, 15); + DamageUtil.minionAttack(summon, target, sourceStack, customData.contains("damage") ? customData.getFloat("damage") : DAMAGE.get(), 1.0f, 10); } customData.putInt("rotateTime", time + 1); diff --git a/src/main/java/com/lzxnone/terraria/item/weapon/summon/whip/Possession.java b/src/main/java/com/lzxnone/terraria/item/weapon/summon/whip/Possession.java index 22fcdd7..0f69d5d 100644 --- a/src/main/java/com/lzxnone/terraria/item/weapon/summon/whip/Possession.java +++ b/src/main/java/com/lzxnone/terraria/item/weapon/summon/whip/Possession.java @@ -86,7 +86,7 @@ public class Possession extends Whip { @Override protected int getInvulnerableTime() { - return 12; + return 10; } public static final IConfigData CONFIG_DATA = new IConfigData() { @@ -154,7 +154,7 @@ public class Possession extends Whip { public void onHitEntity(StaticProjectile projectile, EntityHitResult result) { if(!projectile.level().isClientSide()) { Entity target = result.getEntity(); - DamageUtil.meleeAttack(projectile, target, projectile.getEntityData().get(StaticProjectile.STACK_SOURCE), BEAM_DAMAGE.get(), 0, 5); + DamageUtil.meleeAttack(projectile, target, projectile.getEntityData().get(StaticProjectile.STACK_SOURCE), BEAM_DAMAGE.get(), 0, 10); } } }; diff --git a/src/main/java/com/lzxnone/terraria/item/weapon/summon/whip/Whip.java b/src/main/java/com/lzxnone/terraria/item/weapon/summon/whip/Whip.java index c83ac0e..2b5578f 100644 --- a/src/main/java/com/lzxnone/terraria/item/weapon/summon/whip/Whip.java +++ b/src/main/java/com/lzxnone/terraria/item/weapon/summon/whip/Whip.java @@ -15,6 +15,7 @@ import net.minecraft.util.Mth; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResultHolder; import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.HumanoidArm; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.Item; @@ -70,7 +71,7 @@ public abstract class Whip extends SummonWeapon { } protected int getInvulnerableTime() { - return 20; + return 10; } protected int getRotateAngle() { @@ -153,7 +154,6 @@ public abstract class Whip extends SummonWeapon { @Override public void onUseTick(Level level, LivingEntity entity, ItemStack stack, int count) { - if(level.isClientSide()) return; if(!(entity instanceof Player player)) return; if(!shouldShootThisTick(stack, entity, count)) return; @@ -176,7 +176,7 @@ public abstract class Whip extends SummonWeapon { summon.setOwner(player); summon.getEntityData().set(StaticSummon.STACK_SOURCE, stack.copy()); Vector3f offset = new Vector3f( - hand == InteractionHand.OFF_HAND ? -OFFSET.x : OFFSET.x, + hand == (player.getMainArm() == HumanoidArm.RIGHT ? InteractionHand.OFF_HAND : InteractionHand.MAIN_HAND) ? -OFFSET.x : OFFSET.x, OFFSET.y, OFFSET.z ); diff --git a/src/main/java/com/lzxnone/terraria/mixin/HumanoidModelMixin.java b/src/main/java/com/lzxnone/terraria/mixin/HumanoidModelMixin.java index 8cbde8b..deaa6c7 100644 --- a/src/main/java/com/lzxnone/terraria/mixin/HumanoidModelMixin.java +++ b/src/main/java/com/lzxnone/terraria/mixin/HumanoidModelMixin.java @@ -1,14 +1,17 @@ package com.lzxnone.terraria.mixin; import com.lzxnone.terraria.client.config.RenderConfigs; +import com.lzxnone.terraria.entity.beam.SwordBeam; import com.lzxnone.terraria.item.weapon.RangedWeapon; import com.lzxnone.terraria.item.weapon.ranged.bow.Bow; import net.minecraft.client.model.HumanoidModel; import net.minecraft.client.model.geom.ModelPart; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.world.InteractionHand; import net.minecraft.world.entity.HumanoidArm; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -21,11 +24,40 @@ public abstract class HumanoidModelMixin { @Shadow @Final public ModelPart rightArm; @Shadow @Final public ModelPart leftArm; + private static String behaviorOf(ItemStack stack) { + return stack.isEmpty() ? "" : BuiltInRegistries.ITEM.getKey(stack.getItem()).getPath(); + } + @Inject(method = "setupAnim", at = @At("RETURN")) private void setupAnim(T entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, CallbackInfo ci) { if(!RenderConfigs.ENABLE_SETUP_ANIM.get()) return; if(!(entity instanceof Player player)) return; + + SwordBeam beam = SwordBeam.getActiveBeam(player, behaviorOf(player.getMainHandItem())); + HumanoidArm beamArm = player.getMainArm(); + if(beam == null) { + beam = SwordBeam.getActiveBeam(player, behaviorOf(player.getOffhandItem())); + if(beam != null) beamArm = player.getMainArm().getOpposite(); + } + if(beam != null) { + float partialTick = ageInTicks - (float) entity.tickCount; + int age = beam.getEntityData().get(SwordBeam.AGE); + int lifetime = Math.max(1, beam.getEntityData().get(SwordBeam.LIFETIME)); + float progress = (age + partialTick) / (float) lifetime; + if(progress > 1.0f) progress = 1.0f; + if(beam.getEntityData().get(SwordBeam.RIGHT)) progress = 1.0f - progress; + + float angleDeg = (0.5f - progress) * 180.0f; + if(beamArm == player.getMainArm()) angleDeg = -angleDeg; + ModelPart arm = beamArm == HumanoidArm.RIGHT ? rightArm : leftArm; + if(arm == leftArm) angleDeg = -angleDeg; + if(player.getMainArm() == HumanoidArm.LEFT) angleDeg = -angleDeg; + arm.xRot += (float) Math.toRadians(-75); + arm.zRot += (float) Math.toRadians(-beam.getEntityData().get(SwordBeam.ROTATE)); + arm.yRot += (float) Math.toRadians(angleDeg); + } + if(!player.isUsingItem()) return; HumanoidArm usedArm = player.getUsedItemHand() == InteractionHand.MAIN_HAND diff --git a/src/main/java/com/lzxnone/terraria/mixin/ItemInHandRenderMixin.java b/src/main/java/com/lzxnone/terraria/mixin/ItemInHandRenderMixin.java index 064c7f4..abc4daf 100644 --- a/src/main/java/com/lzxnone/terraria/mixin/ItemInHandRenderMixin.java +++ b/src/main/java/com/lzxnone/terraria/mixin/ItemInHandRenderMixin.java @@ -5,6 +5,8 @@ import com.lzxnone.terraria.client.config.RenderConfigs; import com.lzxnone.terraria.client.item.magic.ClientNebulaBlaze; import com.lzxnone.terraria.client.item.melee.ClientDevilsDevastation; import com.lzxnone.terraria.entity.ModRenderTypes; +import com.lzxnone.terraria.entity.beam.SwordBeam; +import com.lzxnone.terraria.entity.beam.SwordBeamBehaviors; import com.lzxnone.terraria.item.ModItems; import com.lzxnone.terraria.item.weapon.melee.DevilsDevastation; import com.lzxnone.terraria.item.weapon.melee.Mace; @@ -149,6 +151,30 @@ public class ItemInHandRenderMixin { ci.cancel(); } } + }else if(itemStack.is(ModItems.TERRA_BLADE.get()) && entity instanceof Player player) { + if(SwordBeam.hasActiveBeam(player, SwordBeamBehaviors.TERRA_BLADE)) { + ci.cancel(); + } + }else if(itemStack.is(ModItems.THE_HORSEMANS_BLADE.get()) && entity instanceof Player player) { + if(SwordBeam.hasActiveBeam(player, SwordBeamBehaviors.THE_HORSEMANS_BLADE)) { + ci.cancel(); + } + }else if(itemStack.is(ModItems.EXCALIBUR.get()) && entity instanceof Player player) { + if(SwordBeam.hasActiveBeam(player, SwordBeamBehaviors.EXCALIBUR)) { + ci.cancel(); + } + }else if(itemStack.is(ModItems.TRUE_EXCALIBUR.get()) && entity instanceof Player player) { + if(SwordBeam.hasActiveBeam(player, SwordBeamBehaviors.TRUE_EXCALIBUR)) { + ci.cancel(); + } + }else if(itemStack.is(ModItems.NIGHTS_EDGE.get()) && entity instanceof Player player) { + if (SwordBeam.hasActiveBeam(player, SwordBeamBehaviors.NIGHTS_EDGE)) { + ci.cancel(); + } + }else if(itemStack.is(ModItems.TRUE_NIGHTS_EDGE.get()) && entity instanceof Player player) { + if (SwordBeam.hasActiveBeam(player, SwordBeamBehaviors.TRUE_NIGHTS_EDGE)) { + ci.cancel(); + } } } diff --git a/src/main/java/com/lzxnone/terraria/mixin/UseSpeedMixin.java b/src/main/java/com/lzxnone/terraria/mixin/UseSpeedMixin.java index 614c26e..984a739 100644 --- a/src/main/java/com/lzxnone/terraria/mixin/UseSpeedMixin.java +++ b/src/main/java/com/lzxnone/terraria/mixin/UseSpeedMixin.java @@ -22,6 +22,12 @@ public abstract class UseSpeedMixin { || usingItem.is(ModItems.FIRST_FRACTAL.get()) || usingItem.is(ModItems.TERRAGRIM.get()) || usingItem.is(ModItems.MACE.get()) + || usingItem.is(ModItems.TERRA_BLADE.get()) + || usingItem.is(ModItems.THE_HORSEMANS_BLADE.get()) + || usingItem.is(ModItems.EXCALIBUR.get()) + || usingItem.is(ModItems.TRUE_EXCALIBUR.get()) + || usingItem.is(ModItems.NIGHTS_EDGE.get()) + || usingItem.is(ModItems.TRUE_NIGHTS_EDGE.get()) || usingItem.getItem() instanceof MagicWeapon || usingItem.getItem() instanceof RangedWeapon || usingItem.getItem() instanceof Whip; diff --git a/src/main/java/com/lzxnone/terraria/network/handler/ClearSummonHandler.java b/src/main/java/com/lzxnone/terraria/network/handler/ClearSummonHandler.java index 25d5dbe..da332d1 100644 --- a/src/main/java/com/lzxnone/terraria/network/handler/ClearSummonHandler.java +++ b/src/main/java/com/lzxnone/terraria/network/handler/ClearSummonHandler.java @@ -73,6 +73,9 @@ public class ClearSummonHandler { if(StaticSummonBehaviors.STARDUST_DRAGON_STAFF.equals(id)) { return Component.translatable("item.lzxnoneterraria.stardust_dragon_staff"); } + if(StaticSummonBehaviors.STARDUST_CELL_STAFF.equals(id)) { + return Component.translatable("item.lzxnoneterraria.stardust_cell_staff"); + } return Component.literal(id); } } diff --git a/src/main/java/com/lzxnone/terraria/ui/config/ConfigFactory.java b/src/main/java/com/lzxnone/terraria/ui/config/ConfigFactory.java index c5ecbcc..b83b5bd 100644 --- a/src/main/java/com/lzxnone/terraria/ui/config/ConfigFactory.java +++ b/src/main/java/com/lzxnone/terraria/ui/config/ConfigFactory.java @@ -71,7 +71,7 @@ public class ConfigFactory { scroller.setOnValueChanged(floatValue -> setIntConfigValue(path, scroller, valueField, Math.round(floatValue), minValue, maxValue)); valueField.setTextResponder(textValue -> setIntConfigValue(path, scroller, valueField, parseInt(textValue, defaultValue), minValue, maxValue)); - resetButton.setOnClick(event -> setIntConfigValue(path, scroller, valueField, resetValue, minValue, maxValue)); + resetButton.setOnClick(event -> resetIntConfigValue(path, scroller, valueField, resetValue, minValue, maxValue)); container.addChildren(label, scroller, valueField, resetButton); configContainer.addChild(container); @@ -120,7 +120,7 @@ public class ConfigFactory { scroller.setOnValueChanged(floatValue -> setFloatConfigValue(path, scroller, valueField, floatValue, minValue, maxValue)); valueField.setTextResponder(textValue -> setFloatConfigValue(path, scroller, valueField, parseFloat(textValue, defaultValue), minValue, maxValue)); - resetButton.setOnClick(event -> setFloatConfigValue(path, scroller, valueField, resetValue, minValue, maxValue)); + resetButton.setOnClick(event -> resetFloatConfigValue(path, scroller, valueField, resetValue, minValue, maxValue)); container.addChildren(label, scroller, valueField, resetButton); configContainer.addChild(container); @@ -169,7 +169,7 @@ public class ConfigFactory { scroller.setOnValueChanged(floatValue -> setDoubleConfigValue(path, scroller, valueField, floatValue, minValue, maxValue)); valueField.setTextResponder(textValue -> setDoubleConfigValue(path, scroller, valueField, parseDouble(textValue, defaultValue), minValue, maxValue)); - resetButton.setOnClick(event -> setDoubleConfigValue(path, scroller, valueField, resetValue, minValue, maxValue)); + resetButton.setOnClick(event -> resetDoubleConfigValue(path, scroller, valueField, resetValue, minValue, maxValue)); container.addChildren(label, scroller, valueField, resetButton); configContainer.addChild(container); @@ -208,7 +208,7 @@ public class ConfigFactory { resetButton.setText(Component.translatable(RESET_BUTTON_TRANSLATION_KEY)); textField.setTextResponder(textValue -> ConfigUtil.setString(path, textValue)); - resetButton.setOnClick(event -> setStringConfigValue(path, textField, defaultValue)); + resetButton.setOnClick(event -> resetStringConfigValue(path, textField, defaultValue)); container.addChildren(label, textField, resetButton); configContainer.addChild(container); @@ -247,7 +247,7 @@ public class ConfigFactory { resetButton.setText(Component.translatable(RESET_BUTTON_TRANSLATION_KEY)); configSwitch.setOnSwitchChanged(switchValue -> ConfigUtil.setBoolean(path, switchValue)); - resetButton.setOnClick(event -> setBooleanConfigValue(path, configSwitch, defaultValue)); + resetButton.setOnClick(event -> resetBooleanConfigValue(path, configSwitch, defaultValue)); container.addChildren(label, configSwitch, resetButton); configContainer.addChild(container); @@ -291,6 +291,43 @@ public class ConfigFactory { ConfigUtil.setBoolean(path, value); } + private static void resetIntConfigValue(String path, Scroller scroller, TextField valueField, int resetValue, int minValue, int maxValue) { + ConfigUtil.remove(path); + int intValue = Math.clamp(resetValue, minValue, maxValue); + if(scroller.getValue() != intValue) { + scroller.setValue((float)intValue, false); + } + valueField.setText(Integer.toString(intValue), false); + } + + private static void resetFloatConfigValue(String path, Scroller scroller, TextField valueField, float resetValue, float minValue, float maxValue) { + ConfigUtil.remove(path); + float floatValue = Math.clamp(resetValue, minValue, maxValue); + if(scroller.getValue() != floatValue) { + scroller.setValue(floatValue, false); + } + valueField.setText(formatFloat(floatValue), false); + } + + private static void resetDoubleConfigValue(String path, Scroller scroller, TextField valueField, double resetValue, double minValue, double maxValue) { + ConfigUtil.remove(path); + double doubleValue = Math.clamp(resetValue, minValue, maxValue); + if(scroller.getValue() != (float)doubleValue) { + scroller.setValue((float)doubleValue, false); + } + valueField.setText(formatDouble(doubleValue), false); + } + + private static void resetStringConfigValue(String path, TextField textField, String defaultValue) { + ConfigUtil.remove(path); + textField.setText(defaultValue, false); + } + + private static void resetBooleanConfigValue(String path, Switch configSwitch, boolean defaultValue) { + ConfigUtil.remove(path); + configSwitch.setOn(defaultValue, false); + } + private static void disableScrollerWheel(Scroller scroller) { scroller.scrollerStyle(style -> style.scrollDelta(0)); } diff --git a/src/main/java/com/lzxnone/terraria/ui/config/ConfigList.java b/src/main/java/com/lzxnone/terraria/ui/config/ConfigList.java index 79e3961..3c99ee4 100644 --- a/src/main/java/com/lzxnone/terraria/ui/config/ConfigList.java +++ b/src/main/java/com/lzxnone/terraria/ui/config/ConfigList.java @@ -5,6 +5,7 @@ import com.lzxnone.terraria.effect.AcidVenomEffect; import com.lzxnone.terraria.effect.CursedInfernoEffect; import com.lzxnone.terraria.effect.DemonicFlamesEffect; import com.lzxnone.terraria.effect.BetsysCurseEffect; +import com.lzxnone.terraria.effect.CelledEffect; import com.lzxnone.terraria.effect.IchorEffect; import com.lzxnone.terraria.effect.ManaSicknessEffect; import com.lzxnone.terraria.effect.MidasEffect; @@ -133,6 +134,7 @@ import com.lzxnone.terraria.item.weapon.ranged.SuperStarShooter; import com.lzxnone.terraria.item.weapon.ranged.bow.DaedalusStormbow; import com.lzxnone.terraria.item.weapon.ranged.gun.*; import com.lzxnone.terraria.item.weapon.summon.minion.StardustDragonStaff; +import com.lzxnone.terraria.item.weapon.summon.minion.StardustCellStaff; import com.lzxnone.terraria.item.weapon.summon.minion.Terraprisma; import com.lzxnone.terraria.item.weapon.summon.whip.Possession; @@ -178,6 +180,7 @@ public class ConfigList { DevilsDevastation.CONFIG_LIST_ITEM, Terraprisma.CONFIG_LIST_ITEM, StardustDragonStaff.CONFIG_LIST_ITEM, + StardustCellStaff.CONFIG_LIST_ITEM, Possession.CONFIG_LIST_ITEM, LastPrism.CONFIG_LIST_ITEM, BetsyWrath.CONFIG_LIST_ITEM, @@ -220,6 +223,7 @@ public class ConfigList { IchorEffect.CONFIG_LIST_ITEM, BetsysCurseEffect.CONFIG_LIST_ITEM, AcidVenomEffect.CONFIG_LIST_ITEM, + CelledEffect.CONFIG_LIST_ITEM, MidasEffect.CONFIG_LIST_ITEM, ManaSicknessEffect.CONFIG_LIST_ITEM, SummonEffect.CONFIG_LIST_ITEM, diff --git a/src/main/java/com/lzxnone/terraria/ui/config/ConfigUtil.java b/src/main/java/com/lzxnone/terraria/ui/config/ConfigUtil.java index bfd8418..f6ed2bc 100644 --- a/src/main/java/com/lzxnone/terraria/ui/config/ConfigUtil.java +++ b/src/main/java/com/lzxnone/terraria/ui/config/ConfigUtil.java @@ -85,6 +85,29 @@ public final class ConfigUtil { set(path, new JsonPrimitive(value)); } + public static void remove(String path) { + ensureLoaded(); + + String[] parts = splitPath(path); + if(parts.length == 0) { + return; + } + + JsonObject current = configCache; + for(int i = 0; i < parts.length - 1; i++) { + JsonElement child = current.get(parts[i]); + if(child == null || !child.isJsonObject()) { + return; + } + current = child.getAsJsonObject(); + } + + if(current.has(parts[parts.length - 1])) { + current.remove(parts[parts.length - 1]); + dirty = true; + } + } + public static void save() { save(false); } diff --git a/src/main/java/com/lzxnone/terraria/utils/AmmoUtil.java b/src/main/java/com/lzxnone/terraria/utils/AmmoUtil.java index ca68103..cc671ad 100644 --- a/src/main/java/com/lzxnone/terraria/utils/AmmoUtil.java +++ b/src/main/java/com/lzxnone/terraria/utils/AmmoUtil.java @@ -9,6 +9,7 @@ import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.nbt.CompoundTag; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.InteractionHand; +import net.minecraft.world.entity.HumanoidArm; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; @@ -27,7 +28,7 @@ public class AmmoUtil { ItemStack ammoStack, Vector3f offset) { Vector3f[] dirs = MathUtil.computeCoordinateSystem(player); Vec3 eyePos = player.getEyePosition(); - offset = getOffset(hand, offset); + offset = getOffset(player, hand, offset); Vec3 pos = new Vec3( eyePos.x + dirs[0].x * offset.z + dirs[1].x * offset.y + dirs[2].x * offset.x, eyePos.y + dirs[0].y * offset.z + dirs[1].y * offset.y + dirs[2].y * offset.x, @@ -71,9 +72,9 @@ public class AmmoUtil { return summon; } - public static Vector3f getOffset(InteractionHand hand, Vector3f offset) { + public static Vector3f getOffset(Player player, InteractionHand hand, Vector3f offset) { return new Vector3f( - hand == InteractionHand.OFF_HAND ? -offset.x : offset.x, + hand == (player.getMainArm() == HumanoidArm.RIGHT ? InteractionHand.OFF_HAND : InteractionHand.MAIN_HAND) ? -offset.x : offset.x, offset.y, offset.z ); diff --git a/src/main/java/com/lzxnone/terraria/utils/DamageUtil.java b/src/main/java/com/lzxnone/terraria/utils/DamageUtil.java index fa38cf4..5a9e913 100644 --- a/src/main/java/com/lzxnone/terraria/utils/DamageUtil.java +++ b/src/main/java/com/lzxnone/terraria/utils/DamageUtil.java @@ -1,5 +1,7 @@ package com.lzxnone.terraria.utils; +import com.lzxnone.terraria.LzxnoneTerraria; +import com.lzxnone.terraria.attachment.ModAttachments; import com.lzxnone.terraria.damage.ModDamageTypes; import com.lzxnone.terraria.entity.beam.SwordBeam; import com.lzxnone.terraria.entity.projectile.StaticProjectile; @@ -31,6 +33,8 @@ import java.util.UUID; public class DamageUtil { private static final Map DRAGON_INVULNERABLE_UNTIL = new HashMap<>(); + private static final int SHORT_INVULNERABLE_TIME = 2; + private static final int MAX_SOURCE_COOLDOWNS = 64; public enum DamageCategory { NORMAL, @@ -126,8 +130,21 @@ public class DamageUtil { } } + //伤害浮动:最终伤害乘以 0.8~1.2 随机系数 + finalDamage *= 0.8F + (float) Math.random() * 0.4F; + Vec3 beforeHurtMovement = target instanceof LivingEntity livingTarget ? livingTarget.getDeltaMovement() : Vec3.ZERO; String dragonInvulnerableKey = getDragonInvulnerableKey(target); + //按来源隔离的冷却:同一来源(UUID)在 invulnerableTime 内不重复命中同一目标 + if(invulnerableTime > 0 && target instanceof LivingEntity livingTarget) { + long gameTime = serverLevel.getGameTime(); + Map sourceCooldowns = livingTarget.getData(ModAttachments.SOURCE_HIT_COOLDOWNS); + if(sourceCooldowns.size() > MAX_SOURCE_COOLDOWNS) { + sourceCooldowns.entrySet().removeIf(entry -> entry.getValue() <= gameTime); + } + Long nextAllowed = sourceCooldowns.get(attackEntity.getUUID()); + if(nextAllowed != null && gameTime < nextAllowed) return false; + } if(dragonInvulnerableKey != null && invulnerableTime > 0) { long gameTime = serverLevel.getGameTime(); Long invulnerableUntil = DRAGON_INVULNERABLE_UNTIL.get(dragonInvulnerableKey); @@ -136,6 +153,10 @@ public class DamageUtil { boolean hasHurt = target.hurt(source, finalDamage); if(hasHurt) { + if(invulnerableTime > 0 && target instanceof LivingEntity livingTarget) { + livingTarget.getData(ModAttachments.SOURCE_HIT_COOLDOWNS) + .put(attackEntity.getUUID(), serverLevel.getGameTime() + invulnerableTime); + } applyInvulnerableTime(serverLevel, target, invulnerableTime, dragonInvulnerableKey); if(category != DamageCategory.MINION && category != DamageCategory.SENTRY && target instanceof LivingEntity livingTarget) { player.setLastHurtMob(livingTarget); @@ -171,9 +192,10 @@ public class DamageUtil { private static void applyInvulnerableTime(ServerLevel serverLevel, Entity target, int invulnerableTime, String dragonInvulnerableKey) { if(invulnerableTime < 0) return; - target.invulnerableTime = invulnerableTime; + //实体全局无敌帧固定缩短;同来源防刷已由 SOURCE_HIT_COOLDOWNS 承担 + target.invulnerableTime = SHORT_INVULNERABLE_TIME; if(target instanceof EnderDragonPart dragonPart) { - dragonPart.parentMob.invulnerableTime = invulnerableTime; + dragonPart.parentMob.invulnerableTime = SHORT_INVULNERABLE_TIME; } if(dragonInvulnerableKey != null && invulnerableTime > 0) { DRAGON_INVULNERABLE_UNTIL.put(dragonInvulnerableKey, serverLevel.getGameTime() + invulnerableTime); diff --git a/src/main/java/com/lzxnone/terraria/utils/ParticleUtil.java b/src/main/java/com/lzxnone/terraria/utils/ParticleUtil.java index 894eea0..5a6eaa1 100644 --- a/src/main/java/com/lzxnone/terraria/utils/ParticleUtil.java +++ b/src/main/java/com/lzxnone/terraria/utils/ParticleUtil.java @@ -1,12 +1,15 @@ package com.lzxnone.terraria.utils; import net.minecraft.core.particles.ParticleOptions; +import net.minecraft.network.protocol.game.ClientboundLevelParticlesPacket; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.level.Level; import net.minecraft.world.phys.Vec3; public class ParticleUtil { + private static final double DEFAULT_PARTICLE_BROADCAST_RADIUS = 128.0D; + public static void addParticle(Level level, ParticleOptions particleData, Vec3 pos, double randomRadius, Vec3 speed, double randomSpeed) { if(level.isClientSide()) { level.addParticle(particleData, true, @@ -22,6 +25,14 @@ public class ParticleUtil { } public static void addParticles(ServerLevel level, ParticleOptions particleData, Vec3 pos, Vec3 offset, double speed, int count) { - level.sendParticles(particleData, pos.x, pos.y, pos.z, count, offset.x, offset.y, offset.z, speed); + addParticles(level, particleData, pos, offset, speed, count, DEFAULT_PARTICLE_BROADCAST_RADIUS); + } + + public static void addParticles(ServerLevel level, ParticleOptions particleData, Vec3 pos, Vec3 offset, double speed, int count, double radius) { + ClientboundLevelParticlesPacket packet = new ClientboundLevelParticlesPacket( + particleData, false, pos.x, pos.y, pos.z, + (float) offset.x, (float) offset.y, (float) offset.z, (float) speed, count + ); + level.getServer().getPlayerList().broadcast(null, pos.x, pos.y, pos.z, radius, level.dimension(), packet); } } diff --git a/src/main/java/com/lzxnone/terraria/utils/RenderUtil.java b/src/main/java/com/lzxnone/terraria/utils/RenderUtil.java index fbf126c..ece8434 100644 --- a/src/main/java/com/lzxnone/terraria/utils/RenderUtil.java +++ b/src/main/java/com/lzxnone/terraria/utils/RenderUtil.java @@ -5,6 +5,8 @@ import com.mojang.blaze3d.vertex.VertexConsumer; import com.mojang.math.Axis; import net.minecraft.client.renderer.LightTexture; import net.minecraft.client.renderer.texture.OverlayTexture; +import net.minecraft.world.entity.HumanoidArm; +import net.minecraft.world.entity.player.Player; import org.joml.Matrix4f; import org.joml.Quaternionf; import org.joml.Vector3f; @@ -29,6 +31,7 @@ public class RenderUtil { public static void applyTranslate(PoseStack poseStack, Vector3f dir, Vector3f right, double angle, double dist) { float cos = (float) Math.cos(Math.toRadians(angle)); float sin = (float) Math.sin(Math.toRadians(angle)); + //dist += 0.3; Vector3f current = new Vector3f( cos * right.x + sin * dir.x, cos * right.y + sin * dir.y, diff --git a/src/main/resources/assets/lzxnoneterraria/lang/en_us.json b/src/main/resources/assets/lzxnoneterraria/lang/en_us.json index 5307f33..1e4b934 100644 --- a/src/main/resources/assets/lzxnoneterraria/lang/en_us.json +++ b/src/main/resources/assets/lzxnoneterraria/lang/en_us.json @@ -7,13 +7,11 @@ "itemGroup.lzxnoneterraria.block": "Terraria Block", "itemGroup.lzxnoneterraria.calamity_melee": "Terraria Calamity Melee", "curios.identifier.terraria_accessory": "Terraria Accessory", - "block.lzxnoneterraria.vision": "Vision", "block.lzxnoneterraria.stardust_dragon_head": "Stardust Dragon Head", "block.lzxnoneterraria.stardust_dragon_body_a": "Stardust Dragon Body A", "block.lzxnoneterraria.stardust_dragon_body_b": "Stardust Dragon Body B", "block.lzxnoneterraria.stardust_dragon_tail": "Stardust Dragon Tail", - "item.lzxnoneterraria.copper_shortsword": "Copper Shortsword", "item.lzxnoneterraria.enchanted_sword": "Enchanted Sword", "item.lzxnoneterraria.bee_keeper": "Bee Keeper", @@ -50,6 +48,7 @@ "item.lzxnoneterraria.vortex_rocket": "Vortex Rocket", "item.lzxnoneterraria.terraprisma": "Terraprisma", "item.lzxnoneterraria.stardust_dragon_staff": "Stardust Dragon Staff", + "item.lzxnoneterraria.stardust_cell_staff": "Stardust Cell Staff", "item.lzxnoneterraria.possession": "Possession", "item.lzxnoneterraria.musket": "Musket", "item.lzxnoneterraria.minishark": "Minishark", @@ -196,7 +195,6 @@ "item.lzxnoneterraria.mana_potion": "Mana Potion", "item.lzxnoneterraria.greater_mana_potion": "Greater Mana Potion", "item.lzxnoneterraria.super_mana_potion": "Super Mana Potion", - "enchantment.lzxnoneterraria.mana_leak": "Mana Leak", "enchantment.lzxnoneterraria.mana_efficiency": "Mana Efficiency", "enchantment.lzxnoneterraria.arcane_amplification": "Arcane Amplification", @@ -215,27 +213,22 @@ "tooltip.lzxnoneterraria.enchantment.gunpowder": "Increases damage dealt by ranged weapons", "tooltip.lzxnoneterraria.enchantment.steady_breath": "Reduces ranged weapon spread", "tooltip.lzxnoneterraria.enchantment.barren_land": "Allows minions to seek enemies through blocks", - "death.attack.lzxnoneterraria.player_normal": "%1$s was slain by %2$s", "death.attack.lzxnoneterraria.player_normal.item": "%1$s was slain by %2$s using %3$s", "death.attack.lzxnoneterraria.player_real": "%1$s was slain by %2$s's true damage", "death.attack.lzxnoneterraria.player_real.item": "%1$s was slain by %2$s's true damage using %3$s", - "tooltip.lzxnoneterraria.relative_distance": "Relative Distance", "tooltip.lzxnoneterraria.absolute_distance": "Absolute Distance", "tooltip.lzxnoneterraria.zoom": "Zoom", "tooltip.lzxnoneterraria.ammo": "Ammo: %s", "tooltip.lzxnoneterraria.minion_weapon_minion_count": "Minion Count: %s", "tooltip.lzxnoneterraria.devils_devastation_kill_mode": "Kill Mode", - "tooltip.lzxnoneterraria.devils_devastation.0": "The perfect blade of the Underworld, wielding the power of Brimstone directly.", "tooltip.lzxnoneterraria.devils_devastation.1": "Humans understand this force as Havoc, the inevitable sundering of all order in fire.", "tooltip.lzxnoneterraria.devils_devastation.2": "Perhaps this is why the Brimstone Elemental had strength unrivaled by her sisters.", "tooltip.lzxnoneterraria.mana_crystal": "Permanently increases maximum mana by 20, up to 200", - "tooltip.lzxnoneterraria.summoning_potion": "Increases minion capacity by %s for 8 minutes", "tooltip.lzxnoneterraria.mana_potion": "Restores %s mana", - "curios.modifiers.terraria_accessory": "Accessory Attribute Bonus", "tooltip.lzxnoneterraria.poison_immunity": "Poison Immunity", "tooltip.lzxnoneterraria.active_at_night": "At night:", @@ -285,8 +278,8 @@ "lzxnoneterraria.configuration.item_pickup_range.tooltip": "Pickup range of all dropped items while equipped", "lzxnoneterraria.configuration.block_interaction_range": "Block Interaction Range", "lzxnoneterraria.configuration.block_interaction_range.tooltip": "Extra block interaction range in blocks while equipped", - "lzxnoneterraria.configuration.mining_speed": "Mining Speed Multiplier", - "lzxnoneterraria.configuration.mining_speed.tooltip": "Mining speed is multiplied by this value while equipped (1.25 = +25%)", + "lzxnoneterraria.configuration.mining_speed": "Mining Speed", + "lzxnoneterraria.configuration.mining_speed.tooltip": "Block breaking speed multiplier while equipped", "lzxnoneterraria.configuration.emerald_pickup_range.tooltip": "Pickup range for emerald item entities while equipped, in blocks", "lzxnoneterraria.configuration.star_pickup_range": "Star Pickup Range", "lzxnoneterraria.configuration.star_pickup_range.tooltip": "Pickup range for mana stars and fallen stars while equipped, in blocks", @@ -294,10 +287,9 @@ "lzxnoneterraria.configuration.lava_damage_reduction.tooltip": "Reduces lava damage taken while equipped", "lzxnoneterraria.configuration.panic_duration": "Panic Duration", "lzxnoneterraria.configuration.panic_duration.tooltip": "Duration of the speed boost after taking damage while equipped, in ticks", - "tooltip.lzxnoneterraria.damage_increase": "Damage +%s%%", "tooltip.lzxnoneterraria.crit_chance_bonus": "Critical Strike Chance +%s%%", - "tooltip.lzxnoneterraria.mining_speed_bonus": "Mining Speed +%s%%", + "tooltip.lzxnoneterraria.mining_speed_bonus": "Mining speed +%s%%", "tooltip.lzxnoneterraria.move_speed_bonus": "Movement Speed +%s%%", "tooltip.lzxnoneterraria.water_breathing": "Breathe underwater", "tooltip.lzxnoneterraria.jump_boost": "Slightly increases jump height and speed", @@ -317,13 +309,10 @@ "lzxnoneterraria.configuration.armor_pierce.tooltip": "Attacks ignore this much target armor while equipped", "lzxnoneterraria.configuration.crit_chance": "Critical Strike Chance", "lzxnoneterraria.configuration.crit_chance.tooltip": "Critical strike chance granted while equipped", - "lzxnoneterraria.configuration.mining_speed": "Mining Speed", - "lzxnoneterraria.configuration.mining_speed.tooltip": "Block breaking speed multiplier while equipped", "lzxnoneterraria.configuration.move_speed": "Movement Speed", "lzxnoneterraria.configuration.move_speed.tooltip": "Movement speed multiplier while equipped", "lzxnoneterraria.configuration.jump_height": "Jump Height", "lzxnoneterraria.configuration.jump_height.tooltip": "Vertical jump velocity multiplier while equipped", - "tooltip.lzxnoneterraria.fallen_star_summon": "Summons falling stars when damaged", "tooltip.lzxnoneterraria.invulnerable_time_bonus": "Extends invulnerability time after being hit x%s", "tooltip.lzxnoneterraria.bee_summon": "Releases bees when damaged", @@ -347,7 +336,6 @@ "lzxnoneterraria.configuration.max_health_ratio.tooltip": "Triggers while health is below this ratio (0 disables)", "lzxnoneterraria.configuration.min_health_ratio": "Min Health Threshold", "lzxnoneterraria.configuration.min_health_ratio.tooltip": "Triggers while health is above this ratio (0 disables)", - "tooltip.lzxnoneterraria.melee_damage_increase": "+%s%% melee damage", "tooltip.lzxnoneterraria.melee_crit_chance_bonus": "Melee Critical Strike Chance +%s%%", "tooltip.lzxnoneterraria.melee_damage_decrease": "-%s%% melee damage", @@ -366,7 +354,6 @@ "lzxnoneterraria.configuration.melee_crit_chance.tooltip": "Critical strike chance granted to melee attacks while equipped", "lzxnoneterraria.configuration.attack_speed": "Attack Speed", "lzxnoneterraria.configuration.attack_speed.tooltip": "Attack speed is multiplied by this value while equipped (1.12 = +12%)", - "tooltip.lzxnoneterraria.ranged_damage_increase": "+%s%% ranged damage", "tooltip.lzxnoneterraria.ranged_damage_decrease": "-%s%% ranged damage", "tooltip.lzxnoneterraria.ranged_weapon_damage": "Ranged Damage: %s", @@ -375,9 +362,9 @@ "tooltip.lzxnoneterraria.sniper_rifle": "Scroll wheel adjusts zoom", "lzxnoneterraria.configuration.ranged_damage_multiplier": "Ranged Damage Multiplier", "lzxnoneterraria.configuration.ranged_damage_multiplier.tooltip": "Ranged damage is multiplied by this value while equipped", - "tooltip.lzxnoneterraria.magic_weapon_mana": "Mana: %s", "tooltip.lzxnoneterraria.magic_weapon_damage": "Magic Damage: %s", + "tooltip.lzxnoneterraria.melee_weapon_damage": "Melee Damage: %s", "tooltip.lzxnoneterraria.magic_damage_increase": "+%s%% magic damage", "tooltip.lzxnoneterraria.magic_damage_decrease": "-%s%% magic damage", "tooltip.lzxnoneterraria.mana_cost_increase": "+%s%% mana cost", @@ -392,7 +379,6 @@ "tooltip.lzxnoneterraria.emerald_pickup_range": "Extends emerald pickup range to %s blocks", "tooltip.lzxnoneterraria.item_pickup_range": "Extends item pickup range to %s blocks", "tooltip.lzxnoneterraria.block_interaction_range": "Block interaction range +%s", - "tooltip.lzxnoneterraria.mining_speed_bonus": "Mining speed +%s%%", "tooltip.lzxnoneterraria.merchant_discount": "Provides %s trade discount", "tooltip.lzxnoneterraria.star_pickup_range": "Extends star pickup range to %s blocks", "tooltip.lzxnoneterraria.auto_mana_potion_use": "Automatically uses mana potions when mana runs out", @@ -400,7 +386,6 @@ "lzxnoneterraria.configuration.magic_damage_multiplier.tooltip": "Magic damage is multiplied by this value while equipped", "lzxnoneterraria.configuration.mana_cost_multiplier": "Mana Cost Multiplier", "lzxnoneterraria.configuration.mana_cost_multiplier.tooltip": "Mana cost is multiplied by this value while equipped", - "tooltip.lzxnoneterraria.summon_damage_increase": "+%s%% summon damage", "tooltip.lzxnoneterraria.summon_damage_decrease": "-%s%% summon damage", "tooltip.lzxnoneterraria.summon_weapon_damage": "Summon Damage: %s", @@ -414,7 +399,6 @@ "lzxnoneterraria.configuration.minion_knockback_multiplier.tooltip": "Minion knockback is multiplied by this value while equipped", "lzxnoneterraria.configuration.minion_count_bonus": "Minion Count Bonus", "lzxnoneterraria.configuration.minion_count_bonus.tooltip": "Extra minion capacity granted while equipped", - "jei.lzxnoneterraria.info.fallen_star": "Has a chance to fall from the sky at night. Fallen Stars spawn in open areas near players and can be picked up after landing.", "jei.lzxnoneterraria.info.lesser_mana_potion": "Can be obtained by trading with Cleric villagers or from chests.", "jei.lzxnoneterraria.info.mana_potion": "Can be obtained by trading with Cleric villagers, brewing, or from chests.", @@ -459,7 +443,6 @@ "jei.lzxnoneterraria.info.ranger_emblem": "Obtained by defeating the Wither.", "jei.lzxnoneterraria.info.sorcerer_emblem": "Obtained by defeating the Wither.", "jei.lzxnoneterraria.info.daedalus_stormbow": "Can be obtained by defeating the Ender Dragon.", - "entity.lzxnoneterraria.static_projectile": "Projectile", "entity.lzxnoneterraria.static_summon": "Summon", "entity.lzxnoneterraria.bee_summon": "Bee", @@ -472,13 +455,13 @@ "effect.lzxnoneterraria.ichor": "Ichor", "effect.lzxnoneterraria.betsys_curse": "Betsy's Curse", "effect.lzxnoneterraria.acid_venom": "Acid Venom", + "effect.lzxnoneterraria.celled": "Celled", "effect.lzxnoneterraria.midas": "Midas", "effect.lzxnoneterraria.paladins_shield": "Paladin's Shield", "effect.lzxnoneterraria.ice_barrier": "Ice Barrier", "effect.lzxnoneterraria.panic": "Panic", "effect.lzxnoneterraria.summon": "Summon", "effect.lzxnoneterraria.mana_sickness": "Mana Sickness", - "key.categories.lzxnoneterraria": "lzxnoneterraria", "key.lzxnoneterraria.kill_mode": "Kill Mode", "key.lzxnoneterraria.clear_summon": "Clear Selected Summons", @@ -492,7 +475,6 @@ "message.lzxnoneterraria.summon_attack_mode.neutral": "Neutral", "message.lzxnoneterraria.summon_attack_mode.aggressive": "Aggressive", "message.lzxnoneterraria.summon_attack_mode.attack_target": "Attack Player Target", - "lzxnoneterraria.configuration.title": "LzxnoneTerraria Config", "lzxnoneterraria.configuration.nav_weapon": "Weapon", "lzxnoneterraria.configuration.nav_ammo": "Ammo", @@ -544,6 +526,8 @@ "lzxnoneterraria.configuration.betsys_curse_armor_reduction_per_level.tooltip": "Armor reduced per Betsy's Curse level on the target", "lzxnoneterraria.configuration.acid_venom_damage_per_level": "Damage Per Level", "lzxnoneterraria.configuration.acid_venom_damage_per_level.tooltip": "Acid Venom checks damage once per second; damage dealt per effect level", + "lzxnoneterraria.configuration.celled_damage_per_level": "Damage Per Level", + "lzxnoneterraria.configuration.celled_damage_per_level.tooltip": "Celled checks damage once per second; damage dealt per effect level", "lzxnoneterraria.configuration.midas_drop_chance": "Emerald Drop Chance", "lzxnoneterraria.configuration.midas_drop_chance.tooltip": "Chance for an entity with Midas to drop one emerald on death, from 0 to 1", "lzxnoneterraria.configuration.mana_sickness_duration_per_use": "Duration Added Per Use", @@ -626,12 +610,8 @@ "lzxnoneterraria.configuration.meowmere_gravity.tooltip": "Gravity applied to projectile", "lzxnoneterraria.configuration.meowmere_initial_speed": "Initial Speed", "lzxnoneterraria.configuration.meowmere_initial_speed.tooltip": "Projectile initial speed", - "lzxnoneterraria.configuration.terra_projectile_align_to_blade": "Projectile Align To Blade", - "lzxnoneterraria.configuration.terra_projectile_align_to_blade.tooltip": "Whether projectile direction follows blade direction", "lzxnoneterraria.configuration.terra_blade_rotate_range": "Blade Rotate Range", "lzxnoneterraria.configuration.terra_blade_rotate_range.tooltip": "Blade rotation angle range", - "lzxnoneterraria.configuration.terra_projectile_rotate_range": "Projectile Rotate Range", - "lzxnoneterraria.configuration.terra_projectile_rotate_range.tooltip": "Projectile rotation angle range", "lzxnoneterraria.configuration.terra_blade_max_hit_count": "Blade Max Hit Count", "lzxnoneterraria.configuration.terra_blade_max_hit_count.tooltip": "Maximum entities hit per blade swing", "lzxnoneterraria.configuration.terra_blade_damage": "Blade Damage", @@ -668,12 +648,8 @@ "lzxnoneterraria.configuration.excalibur_max_hit_count.tooltip": "Maximum entities hit per blade swing", "lzxnoneterraria.configuration.excalibur_damage": "Blade Damage", "lzxnoneterraria.configuration.excalibur_damage.tooltip": "Damage dealt by blade", - "lzxnoneterraria.configuration.nights_edge_projectile_align_to_blade": "Projectile Align To Blade", - "lzxnoneterraria.configuration.nights_edge_projectile_align_to_blade.tooltip": "Whether projectile direction follows blade direction", "lzxnoneterraria.configuration.nights_edge_rotate_range": "Blade Rotate Range", "lzxnoneterraria.configuration.nights_edge_rotate_range.tooltip": "Blade rotation angle range", - "lzxnoneterraria.configuration.nights_edge_projectile_rotate_range": "Projectile Rotate Range", - "lzxnoneterraria.configuration.nights_edge_projectile_rotate_range.tooltip": "Projectile rotation angle range", "lzxnoneterraria.configuration.nights_edge_max_hit_count": "Blade Max Hit Count", "lzxnoneterraria.configuration.nights_edge_max_hit_count.tooltip": "Maximum entities hit per blade swing", "lzxnoneterraria.configuration.nights_edge_projectile_max_hit_count": "Projectile Max Hit Count", @@ -694,12 +670,8 @@ "lzxnoneterraria.configuration.true_excalibur_max_hit_count.tooltip": "Maximum entities hit per blade swing", "lzxnoneterraria.configuration.true_excalibur_damage": "Blade Damage", "lzxnoneterraria.configuration.true_excalibur_damage.tooltip": "Damage dealt by blade", - "lzxnoneterraria.configuration.true_nights_edge_projectile_align_to_blade": "Projectile Align To Blade", - "lzxnoneterraria.configuration.true_nights_edge_projectile_align_to_blade.tooltip": "Whether projectile direction follows blade direction", "lzxnoneterraria.configuration.true_nights_edge_rotate_range": "Blade Rotate Range", "lzxnoneterraria.configuration.true_nights_edge_rotate_range.tooltip": "Blade rotation angle range", - "lzxnoneterraria.configuration.true_nights_edge_projectile_rotate_range": "Projectile Rotate Range", - "lzxnoneterraria.configuration.true_nights_edge_projectile_rotate_range.tooltip": "Projectile rotation angle range", "lzxnoneterraria.configuration.true_nights_edge_max_hit_count": "Blade Max Hit Count", "lzxnoneterraria.configuration.true_nights_edge_max_hit_count.tooltip": "Maximum entities hit per blade swing", "lzxnoneterraria.configuration.true_nights_edge_projectile_max_hit_count": "Projectile Max Hit Count", @@ -814,6 +786,32 @@ "lzxnoneterraria.configuration.stardust_dragon_staff_wander_fri.tooltip": "Velocity retention per tick while slowing down from wander", "lzxnoneterraria.configuration.stardust_dragon_staff_dash_fri": "Dash Friction", "lzxnoneterraria.configuration.stardust_dragon_staff_dash_fri.tooltip": "Velocity retention per tick while slowing down from dash", + "lzxnoneterraria.configuration.stardust_cell_staff_target_range": "Target Range", + "lzxnoneterraria.configuration.stardust_cell_staff_target_range.tooltip": "Maximum range for the Stardust Cell to search for and keep targets", + "lzxnoneterraria.configuration.stardust_cell_staff_shoot_range": "Shoot Range", + "lzxnoneterraria.configuration.stardust_cell_staff_shoot_range.tooltip": "Maximum distance at which the Stardust Cell begins its shooting sequence", + "lzxnoneterraria.configuration.stardust_cell_staff_celled_duration": "Celled Duration", + "lzxnoneterraria.configuration.stardust_cell_staff_celled_duration.tooltip": "Attached cell and Celled duration after a shot hits, in ticks", + "lzxnoneterraria.configuration.stardust_cell_staff_damage": "Damage", + "lzxnoneterraria.configuration.stardust_cell_staff_damage.tooltip": "Damage dealt by the cell projectile hit", + "lzxnoneterraria.configuration.stardust_cell_staff_min_shoot_distance": "Minimum Shoot Distance", + "lzxnoneterraria.configuration.stardust_cell_staff_min_shoot_distance.tooltip": "Minimum distance to the target at which the Stardust Cell starts shooting", + "lzxnoneterraria.configuration.stardust_cell_staff_projectile_speed": "Projectile Speed", + "lzxnoneterraria.configuration.stardust_cell_staff_projectile_speed.tooltip": "Movement speed of the cell projectile", + "lzxnoneterraria.configuration.stardust_cell_staff_projectile_lifetime": "Projectile Lifetime", + "lzxnoneterraria.configuration.stardust_cell_staff_projectile_lifetime.tooltip": "Lifetime of the cell projectile, in ticks", + "lzxnoneterraria.configuration.stardust_cell_staff_wander_speed": "Wander Speed", + "lzxnoneterraria.configuration.stardust_cell_staff_wander_speed.tooltip": "Movement speed while wandering", + "lzxnoneterraria.configuration.stardust_cell_staff_chase_speed": "Chase Speed", + "lzxnoneterraria.configuration.stardust_cell_staff_chase_speed.tooltip": "Movement speed while chasing a target", + "lzxnoneterraria.configuration.stardust_cell_staff_back_away_speed": "Back Away Speed", + "lzxnoneterraria.configuration.stardust_cell_staff_back_away_speed.tooltip": "Movement speed while backing away from a target that is too close", + "lzxnoneterraria.configuration.stardust_cell_staff_recoil_speed": "Recoil Speed", + "lzxnoneterraria.configuration.stardust_cell_staff_recoil_speed.tooltip": "Initial knockback speed of the Stardust Cell when it fires", + "lzxnoneterraria.configuration.stardust_cell_staff_pre_shoot_friction": "Pre-Shoot Friction", + "lzxnoneterraria.configuration.stardust_cell_staff_pre_shoot_friction.tooltip": "Velocity retention per tick while slowing down before shooting", + "lzxnoneterraria.configuration.stardust_cell_staff_recoil_brake": "Recoil Brake", + "lzxnoneterraria.configuration.stardust_cell_staff_recoil_brake.tooltip": "Velocity retention per tick while braking from recoil", "lzxnoneterraria.configuration.possession_range": "Range", "lzxnoneterraria.configuration.possession_range.tooltip": "Maximum whip strike distance", "lzxnoneterraria.configuration.possession_damage": "Damage", @@ -1138,4 +1136,4 @@ "lzxnoneterraria.configuration.devils_devastation_stuck_projectile_effect_duration.tooltip": "Effect duration applied by popped-out projectile in ticks", "lzxnoneterraria.configuration.devils_devastation_kill_mode_projectile_effect_duration": "Kill Mode Projectile Effect Duration", "lzxnoneterraria.configuration.devils_devastation_kill_mode_projectile_effect_duration.tooltip": "Effect duration applied by kill mode projectile in ticks" -} +} \ No newline at end of file diff --git a/src/main/resources/assets/lzxnoneterraria/lang/zh_cn.json b/src/main/resources/assets/lzxnoneterraria/lang/zh_cn.json index 9bdd08b..0e3dd3b 100644 --- a/src/main/resources/assets/lzxnoneterraria/lang/zh_cn.json +++ b/src/main/resources/assets/lzxnoneterraria/lang/zh_cn.json @@ -7,13 +7,11 @@ "itemGroup.lzxnoneterraria.block": "泰拉瑞亚 方块", "itemGroup.lzxnoneterraria.calamity_melee": "泰拉瑞亚灾厄 近战武器", "curios.identifier.terraria_accessory": "泰拉瑞亚饰品", - "block.lzxnoneterraria.vision": "幻象", "block.lzxnoneterraria.stardust_dragon_head": "星尘龙头部", "block.lzxnoneterraria.stardust_dragon_body_a": "星尘龙身体A", "block.lzxnoneterraria.stardust_dragon_body_b": "星尘龙身体B", "block.lzxnoneterraria.stardust_dragon_tail": "星尘龙尾部", - "item.lzxnoneterraria.copper_shortsword": "铜短剑", "item.lzxnoneterraria.enchanted_sword": "附魔剑", "item.lzxnoneterraria.bee_keeper": "养蜂人", @@ -50,6 +48,7 @@ "item.lzxnoneterraria.vortex_rocket": "星旋火箭", "item.lzxnoneterraria.terraprisma": "泰拉棱镜", "item.lzxnoneterraria.stardust_dragon_staff": "星尘之龙法杖", + "item.lzxnoneterraria.stardust_cell_staff": "星尘细胞法杖", "item.lzxnoneterraria.possession": "支配之鞭", "item.lzxnoneterraria.musket": "火枪", "item.lzxnoneterraria.minishark": "迷你鲨", @@ -196,7 +195,6 @@ "item.lzxnoneterraria.mana_potion": "魔力药水", "item.lzxnoneterraria.greater_mana_potion": "强效魔力药水", "item.lzxnoneterraria.super_mana_potion": "超级魔力药水", - "enchantment.lzxnoneterraria.mana_leak": "魔力泄漏", "enchantment.lzxnoneterraria.mana_efficiency": "魔力效率", "enchantment.lzxnoneterraria.arcane_amplification": "奥术增幅", @@ -215,27 +213,22 @@ "tooltip.lzxnoneterraria.enchantment.gunpowder": "提高远程武器造成的伤害", "tooltip.lzxnoneterraria.enchantment.steady_breath": "降低远程武器的散射", "tooltip.lzxnoneterraria.enchantment.barren_land": "召唤物可以隔着方块寻找敌人", - "death.attack.lzxnoneterraria.player_normal": "%1$s 被 %2$s 击杀", "death.attack.lzxnoneterraria.player_normal.item": "%1$s 被 %2$s 用 %3$s 击杀", "death.attack.lzxnoneterraria.player_real": "%1$s 被 %2$s 的真实伤害击杀", "death.attack.lzxnoneterraria.player_real.item": "%1$s 被 %2$s 用 %3$s 的真实伤害击杀", - "tooltip.lzxnoneterraria.relative_distance": "相对距离", "tooltip.lzxnoneterraria.absolute_distance": "绝对距离", "tooltip.lzxnoneterraria.zoom": "倍率", "tooltip.lzxnoneterraria.ammo": "弹药: %s", "tooltip.lzxnoneterraria.minion_weapon_minion_count": "仆从数量: %s", "tooltip.lzxnoneterraria.devils_devastation_kill_mode": "杀戮模式", - "tooltip.lzxnoneterraria.devils_devastation.0": "完美的地狱之剑,直接掌握着硫磺火之力。", "tooltip.lzxnoneterraria.devils_devastation.1": "人类将这种力量理解为浩劫,即一切秩序在火焰之中的必然毁灭。", "tooltip.lzxnoneterraria.devils_devastation.2": "或许这就是硫磺火元素掌握着她的姐妹所不能匹敌之力量的原因。", "tooltip.lzxnoneterraria.mana_crystal": "永久提升 20 点最大魔力,最高提升到 200", - "tooltip.lzxnoneterraria.summoning_potion": "增加 %s 个仆从栏位,持续 8 分钟", "tooltip.lzxnoneterraria.mana_potion": "恢复 %s 点魔力", - "curios.modifiers.terraria_accessory": "饰品属性加成", "tooltip.lzxnoneterraria.poison_immunity": "免疫中毒", "tooltip.lzxnoneterraria.active_at_night": "在夜晚时:", @@ -286,15 +279,14 @@ "lzxnoneterraria.configuration.item_pickup_range.tooltip": "佩戴后所有掉落物的吸附范围(格)", "lzxnoneterraria.configuration.block_interaction_range": "方块交互距离", "lzxnoneterraria.configuration.block_interaction_range.tooltip": "佩戴后方块交互距离的增加值(格)", - "lzxnoneterraria.configuration.mining_speed": "挖掘速度倍率", - "lzxnoneterraria.configuration.mining_speed.tooltip": "佩戴后挖掘速度乘以该倍率(1.25 = +25%)", + "lzxnoneterraria.configuration.mining_speed": "挖矿速度", + "lzxnoneterraria.configuration.mining_speed.tooltip": "佩戴后挖掘方块的速度倍率", "lzxnoneterraria.configuration.star_pickup_range": "星星拾取范围", "lzxnoneterraria.configuration.star_pickup_range.tooltip": "佩戴后魔力星和坠落之星的拾取范围(格)", "lzxnoneterraria.configuration.lava_damage_reduction": "岩浆伤害减免", "lzxnoneterraria.configuration.lava_damage_reduction.tooltip": "佩戴后受到的岩浆伤害减免比例", "lzxnoneterraria.configuration.panic_duration": "恐慌持续时间", "lzxnoneterraria.configuration.panic_duration.tooltip": "佩戴后受到伤害时加速持续的时间(刻)", - "tooltip.lzxnoneterraria.damage_increase": "伤害 +%s%%", "tooltip.lzxnoneterraria.crit_chance_bonus": "暴击率 +%s%%", "tooltip.lzxnoneterraria.mining_speed_bonus": "挖掘速度 +%s%%", @@ -317,13 +309,10 @@ "lzxnoneterraria.configuration.armor_pierce.tooltip": "佩戴后攻击无视目标该数值的护甲", "lzxnoneterraria.configuration.crit_chance": "暴击率", "lzxnoneterraria.configuration.crit_chance.tooltip": "佩戴后攻击时增加暴击率", - "lzxnoneterraria.configuration.mining_speed": "挖矿速度", - "lzxnoneterraria.configuration.mining_speed.tooltip": "佩戴后挖掘方块的速度倍率", "lzxnoneterraria.configuration.move_speed": "移动速度", "lzxnoneterraria.configuration.move_speed.tooltip": "佩戴后移动速度的倍率", "lzxnoneterraria.configuration.jump_height": "跳跃高度", "lzxnoneterraria.configuration.jump_height.tooltip": "佩戴后跳跃垂直初速度的倍率", - "tooltip.lzxnoneterraria.fallen_star_summon": "受到伤害后会使星星坠落", "tooltip.lzxnoneterraria.invulnerable_time_bonus": "延长受伤后的无敌状态时间 x%s", "tooltip.lzxnoneterraria.bee_summon": "受到伤害后释放蜜蜂", @@ -347,7 +336,6 @@ "lzxnoneterraria.configuration.max_health_ratio.tooltip": "生命低于该比例时触发(0 禁用)", "lzxnoneterraria.configuration.min_health_ratio": "最低生命阈值", "lzxnoneterraria.configuration.min_health_ratio.tooltip": "生命高于该比例时触发(0 禁用)", - "tooltip.lzxnoneterraria.melee_damage_increase": "近战伤害 +%s%%", "tooltip.lzxnoneterraria.melee_crit_chance_bonus": "近战暴击率 +%s%%", "tooltip.lzxnoneterraria.melee_damage_decrease": "近战伤害 -%s%%", @@ -366,7 +354,6 @@ "lzxnoneterraria.configuration.melee_crit_chance.tooltip": "佩戴后近战攻击时增加暴击率", "lzxnoneterraria.configuration.attack_speed": "攻击速度", "lzxnoneterraria.configuration.attack_speed.tooltip": "佩戴后攻击速度乘以该倍率", - "tooltip.lzxnoneterraria.ranged_damage_increase": "远程伤害 +%s%%", "tooltip.lzxnoneterraria.ranged_damage_decrease": "远程伤害 -%s%%", "tooltip.lzxnoneterraria.ranged_weapon_damage": "远程伤害: %s", @@ -375,9 +362,9 @@ "tooltip.lzxnoneterraria.sniper_rifle": "滚轮可以调节放大倍率", "lzxnoneterraria.configuration.ranged_damage_multiplier": "远程伤害倍率", "lzxnoneterraria.configuration.ranged_damage_multiplier.tooltip": "佩戴后远程伤害乘以该倍率", - "tooltip.lzxnoneterraria.magic_weapon_mana": "魔力: %s", "tooltip.lzxnoneterraria.magic_weapon_damage": "魔法伤害: %s", + "tooltip.lzxnoneterraria.melee_weapon_damage": "近战伤害: %s", "tooltip.lzxnoneterraria.magic_damage_increase": "魔法伤害 +%s%%", "tooltip.lzxnoneterraria.magic_damage_decrease": "魔法伤害 -%s%%", "tooltip.lzxnoneterraria.mana_cost_increase": "魔力花费 +%s%%", @@ -392,7 +379,6 @@ "tooltip.lzxnoneterraria.emerald_pickup_range": "扩大绿宝石吸附范围 %s 格", "tooltip.lzxnoneterraria.item_pickup_range": "扩大物品吸附范围 %s 格", "tooltip.lzxnoneterraria.block_interaction_range": "方块交互距离 +%s", - "tooltip.lzxnoneterraria.mining_speed_bonus": "挖掘速度 +%s%%", "tooltip.lzxnoneterraria.merchant_discount": "提供 %s 交易折扣", "tooltip.lzxnoneterraria.star_pickup_range": "扩大星星拾取范围 %s 格", "tooltip.lzxnoneterraria.auto_mana_potion_use": "需要时自动使用魔力药水", @@ -400,7 +386,6 @@ "lzxnoneterraria.configuration.magic_damage_multiplier.tooltip": "佩戴后魔法伤害乘以该倍率", "lzxnoneterraria.configuration.mana_cost_multiplier": "魔力消耗倍率", "lzxnoneterraria.configuration.mana_cost_multiplier.tooltip": "佩戴后魔力消耗乘以该倍率", - "tooltip.lzxnoneterraria.summon_damage_increase": "召唤伤害 +%s%%", "tooltip.lzxnoneterraria.summon_damage_decrease": "召唤伤害 -%s%%", "tooltip.lzxnoneterraria.summon_weapon_damage": "召唤伤害: %s", @@ -414,7 +399,6 @@ "lzxnoneterraria.configuration.minion_knockback_multiplier.tooltip": "佩戴后仆从击退乘以该倍率", "lzxnoneterraria.configuration.minion_count_bonus": "仆从数量加成", "lzxnoneterraria.configuration.minion_count_bonus.tooltip": "佩戴后额外增加的仆从数量", - "jei.lzxnoneterraria.info.fallen_star": "夜晚时有概率从天空坠落。坠落之星会在玩家附近的露天区域生成,落地后可以拾取。", "jei.lzxnoneterraria.info.lesser_mana_potion": "可以在牧师处交易或者在宝箱中获取。", "jei.lzxnoneterraria.info.mana_potion": "可以在牧师处交易、酿造或者宝箱中获取。", @@ -459,7 +443,6 @@ "jei.lzxnoneterraria.info.ranger_emblem": "通过击杀凋零获取。", "jei.lzxnoneterraria.info.sorcerer_emblem": "通过击杀凋零获取。", "jei.lzxnoneterraria.info.daedalus_stormbow": "可以通过击杀末影龙获得。", - "entity.lzxnoneterraria.static_projectile": "弹射物", "entity.lzxnoneterraria.static_summon": "召唤物", "entity.lzxnoneterraria.bee_summon": "蜜蜂", @@ -472,13 +455,13 @@ "effect.lzxnoneterraria.ichor": "灵液", "effect.lzxnoneterraria.betsys_curse": "双足翼龙诅咒", "effect.lzxnoneterraria.acid_venom": "酸性毒液", + "effect.lzxnoneterraria.celled": "细胞附着", "effect.lzxnoneterraria.midas": "迈达斯", "effect.lzxnoneterraria.paladins_shield": "圣骑士护盾", "effect.lzxnoneterraria.ice_barrier": "冰障", "effect.lzxnoneterraria.panic": "恐慌", "effect.lzxnoneterraria.summon": "召唤", "effect.lzxnoneterraria.mana_sickness": "耐魔性", - "key.categories.lzxnoneterraria": "lzxnoneterraria", "key.lzxnoneterraria.kill_mode": "进入杀戮模式", "key.lzxnoneterraria.clear_summon": "清除指定召唤物", @@ -492,7 +475,6 @@ "message.lzxnoneterraria.summon_attack_mode.neutral": "中立", "message.lzxnoneterraria.summon_attack_mode.aggressive": "主动", "message.lzxnoneterraria.summon_attack_mode.attack_target": "攻击玩家目标", - "lzxnoneterraria.configuration.title": "LzxnoneTerraria 配置", "lzxnoneterraria.configuration.nav_weapon": "武器", "lzxnoneterraria.configuration.nav_ammo": "弹药", @@ -544,6 +526,8 @@ "lzxnoneterraria.configuration.betsys_curse_armor_reduction_per_level.tooltip": "目标拥有双足翼龙诅咒效果时,每级降低的护甲值", "lzxnoneterraria.configuration.acid_venom_damage_per_level": "每级伤害", "lzxnoneterraria.configuration.acid_venom_damage_per_level.tooltip": "酸性毒液每秒进行一次伤害判定,每级造成的伤害", + "lzxnoneterraria.configuration.celled_damage_per_level": "每级伤害", + "lzxnoneterraria.configuration.celled_damage_per_level.tooltip": "细胞附着每秒进行一次伤害判定,每级造成的伤害", "lzxnoneterraria.configuration.midas_drop_chance": "绿宝石掉落概率", "lzxnoneterraria.configuration.midas_drop_chance.tooltip": "拥有迈达斯效果的生物死亡时掉落一颗绿宝石的概率,范围 0~1", "lzxnoneterraria.configuration.mana_sickness_duration_per_use": "每次增加时间", @@ -626,12 +610,8 @@ "lzxnoneterraria.configuration.meowmere_gravity.tooltip": "弹射物受到的重力", "lzxnoneterraria.configuration.meowmere_initial_speed": "弹射初速度", "lzxnoneterraria.configuration.meowmere_initial_speed.tooltip": "弹射物初始速度", - "lzxnoneterraria.configuration.terra_projectile_align_to_blade": "弹射匹配刀光方向", - "lzxnoneterraria.configuration.terra_projectile_align_to_blade.tooltip": "弹射方向是否跟随刀光方向", "lzxnoneterraria.configuration.terra_blade_rotate_range": "刀光偏转角范围", "lzxnoneterraria.configuration.terra_blade_rotate_range.tooltip": "刀光旋转角度范围", - "lzxnoneterraria.configuration.terra_projectile_rotate_range": "弹射偏转角范围", - "lzxnoneterraria.configuration.terra_projectile_rotate_range.tooltip": "弹射物偏转角度范围", "lzxnoneterraria.configuration.terra_blade_max_hit_count": "刀光最大击中数", "lzxnoneterraria.configuration.terra_blade_max_hit_count.tooltip": "刀光单次最大击中生物数量", "lzxnoneterraria.configuration.terra_blade_damage": "刀光伤害", @@ -668,12 +648,8 @@ "lzxnoneterraria.configuration.excalibur_max_hit_count.tooltip": "刀光单次最大击中生物数量", "lzxnoneterraria.configuration.excalibur_damage": "刀光伤害", "lzxnoneterraria.configuration.excalibur_damage.tooltip": "刀光造成的伤害", - "lzxnoneterraria.configuration.nights_edge_projectile_align_to_blade": "弹射匹配刀光方向", - "lzxnoneterraria.configuration.nights_edge_projectile_align_to_blade.tooltip": "弹射方向是否跟随刀光方向", "lzxnoneterraria.configuration.nights_edge_rotate_range": "刀光偏转角范围", "lzxnoneterraria.configuration.nights_edge_rotate_range.tooltip": "刀光旋转角度范围", - "lzxnoneterraria.configuration.nights_edge_projectile_rotate_range": "弹射偏转角范围", - "lzxnoneterraria.configuration.nights_edge_projectile_rotate_range.tooltip": "弹射物偏转角度范围", "lzxnoneterraria.configuration.nights_edge_max_hit_count": "刀光最大击中数", "lzxnoneterraria.configuration.nights_edge_max_hit_count.tooltip": "刀光单次最大击中生物数量", "lzxnoneterraria.configuration.nights_edge_projectile_max_hit_count": "弹射刀光最大击中数", @@ -694,12 +670,8 @@ "lzxnoneterraria.configuration.true_excalibur_max_hit_count.tooltip": "刀光单次最大击中生物数量", "lzxnoneterraria.configuration.true_excalibur_damage": "刀光伤害", "lzxnoneterraria.configuration.true_excalibur_damage.tooltip": "刀光造成的伤害", - "lzxnoneterraria.configuration.true_nights_edge_projectile_align_to_blade": "弹射匹配刀光方向", - "lzxnoneterraria.configuration.true_nights_edge_projectile_align_to_blade.tooltip": "弹射方向是否跟随刀光方向", "lzxnoneterraria.configuration.true_nights_edge_rotate_range": "刀光偏转角范围", "lzxnoneterraria.configuration.true_nights_edge_rotate_range.tooltip": "刀光旋转角度范围", - "lzxnoneterraria.configuration.true_nights_edge_projectile_rotate_range": "弹射偏转角范围", - "lzxnoneterraria.configuration.true_nights_edge_projectile_rotate_range.tooltip": "弹射物偏转角度范围", "lzxnoneterraria.configuration.true_nights_edge_max_hit_count": "刀光最大击中数", "lzxnoneterraria.configuration.true_nights_edge_max_hit_count.tooltip": "刀光单次最大击中生物数量", "lzxnoneterraria.configuration.true_nights_edge_projectile_max_hit_count": "弹射刀光最大击中数", @@ -814,6 +786,32 @@ "lzxnoneterraria.configuration.stardust_dragon_staff_wander_fri.tooltip": "游荡减速时每刻速度保留比例", "lzxnoneterraria.configuration.stardust_dragon_staff_dash_fri": "冲刺阻力", "lzxnoneterraria.configuration.stardust_dragon_staff_dash_fri.tooltip": "冲刺减速时每刻速度保留比例", + "lzxnoneterraria.configuration.stardust_cell_staff_target_range": "寻敌范围", + "lzxnoneterraria.configuration.stardust_cell_staff_target_range.tooltip": "星尘细胞搜索和维持目标的最大距离", + "lzxnoneterraria.configuration.stardust_cell_staff_shoot_range": "射击范围", + "lzxnoneterraria.configuration.stardust_cell_staff_shoot_range.tooltip": "星尘细胞进入射击流程的最大距离", + "lzxnoneterraria.configuration.stardust_cell_staff_celled_duration": "细胞附着持续时间", + "lzxnoneterraria.configuration.stardust_cell_staff_celled_duration.tooltip": "细胞弹命中后附着物和效果的持续时间(刻)", + "lzxnoneterraria.configuration.stardust_cell_staff_damage": "伤害", + "lzxnoneterraria.configuration.stardust_cell_staff_damage.tooltip": "细胞弹命中造成的伤害", + "lzxnoneterraria.configuration.stardust_cell_staff_min_shoot_distance": "最小射击距离", + "lzxnoneterraria.configuration.stardust_cell_staff_min_shoot_distance.tooltip": "星尘细胞开始射击时与目标的最小距离", + "lzxnoneterraria.configuration.stardust_cell_staff_projectile_speed": "弹射物速度", + "lzxnoneterraria.configuration.stardust_cell_staff_projectile_speed.tooltip": "细胞弹的飞行速度", + "lzxnoneterraria.configuration.stardust_cell_staff_projectile_lifetime": "弹射物持续时间", + "lzxnoneterraria.configuration.stardust_cell_staff_projectile_lifetime.tooltip": "细胞弹的持续时间(刻)", + "lzxnoneterraria.configuration.stardust_cell_staff_wander_speed": "游荡速度", + "lzxnoneterraria.configuration.stardust_cell_staff_wander_speed.tooltip": "游荡状态下的移动速度", + "lzxnoneterraria.configuration.stardust_cell_staff_chase_speed": "追击速度", + "lzxnoneterraria.configuration.stardust_cell_staff_chase_speed.tooltip": "追击目标时的移动速度", + "lzxnoneterraria.configuration.stardust_cell_staff_back_away_speed": "后退速度", + "lzxnoneterraria.configuration.stardust_cell_staff_back_away_speed.tooltip": "目标过近时后退的移动速度", + "lzxnoneterraria.configuration.stardust_cell_staff_recoil_speed": "后坐力速度", + "lzxnoneterraria.configuration.stardust_cell_staff_recoil_speed.tooltip": "星尘细胞开火时的初始后坐速度", + "lzxnoneterraria.configuration.stardust_cell_staff_pre_shoot_friction": "射击前阻力", + "lzxnoneterraria.configuration.stardust_cell_staff_pre_shoot_friction.tooltip": "射击前减速时每刻速度保留比例", + "lzxnoneterraria.configuration.stardust_cell_staff_recoil_brake": "后坐制动", + "lzxnoneterraria.configuration.stardust_cell_staff_recoil_brake.tooltip": "后坐减速时每刻速度保留比例", "lzxnoneterraria.configuration.possession_range": "射程", "lzxnoneterraria.configuration.possession_range.tooltip": "鞭子最大抽打距离", "lzxnoneterraria.configuration.possession_damage": "伤害", @@ -1138,4 +1136,4 @@ "lzxnoneterraria.configuration.devils_devastation_stuck_projectile_effect_duration.tooltip": "弹出弹射命中后造成的效果持续时间(刻)", "lzxnoneterraria.configuration.devils_devastation_kill_mode_projectile_effect_duration": "杀戮模式弹射效果持续时间", "lzxnoneterraria.configuration.devils_devastation_kill_mode_projectile_effect_duration.tooltip": "杀戮模式弹射命中后造成的效果持续时间(刻)" -} +} \ No newline at end of file diff --git a/src/main/resources/assets/lzxnoneterraria/models/item/stardust_cell_staff.json b/src/main/resources/assets/lzxnoneterraria/models/item/stardust_cell_staff.json new file mode 100644 index 0000000..ce4ebc2 --- /dev/null +++ b/src/main/resources/assets/lzxnoneterraria/models/item/stardust_cell_staff.json @@ -0,0 +1,6 @@ +{ + "parent": "lzxnoneterraria:item/sword3", + "textures": { + "layer0": "lzxnoneterraria:item/stardust_cell_staff" + } +} diff --git a/src/main/resources/assets/lzxnoneterraria/textures/item/stardust_cell_staff.png b/src/main/resources/assets/lzxnoneterraria/textures/item/stardust_cell_staff.png new file mode 100644 index 0000000..7996809 Binary files /dev/null and b/src/main/resources/assets/lzxnoneterraria/textures/item/stardust_cell_staff.png differ diff --git a/src/main/resources/assets/lzxnoneterraria/textures/mob_effect/celled.png b/src/main/resources/assets/lzxnoneterraria/textures/mob_effect/celled.png new file mode 100644 index 0000000..977f562 Binary files /dev/null and b/src/main/resources/assets/lzxnoneterraria/textures/mob_effect/celled.png differ diff --git a/src/main/resources/assets/lzxnoneterraria/textures/vfx/stardust_cell0.png b/src/main/resources/assets/lzxnoneterraria/textures/vfx/stardust_cell0.png new file mode 100644 index 0000000..ff42f31 Binary files /dev/null and b/src/main/resources/assets/lzxnoneterraria/textures/vfx/stardust_cell0.png differ diff --git a/src/main/resources/assets/lzxnoneterraria/textures/vfx/stardust_cell1.png b/src/main/resources/assets/lzxnoneterraria/textures/vfx/stardust_cell1.png new file mode 100644 index 0000000..8213c40 Binary files /dev/null and b/src/main/resources/assets/lzxnoneterraria/textures/vfx/stardust_cell1.png differ diff --git a/src/main/resources/assets/lzxnoneterraria/textures/vfx/stardust_cell2.png b/src/main/resources/assets/lzxnoneterraria/textures/vfx/stardust_cell2.png new file mode 100644 index 0000000..ff42f31 Binary files /dev/null and b/src/main/resources/assets/lzxnoneterraria/textures/vfx/stardust_cell2.png differ diff --git a/src/main/resources/assets/lzxnoneterraria/textures/vfx/stardust_cell3.png b/src/main/resources/assets/lzxnoneterraria/textures/vfx/stardust_cell3.png new file mode 100644 index 0000000..143daf1 Binary files /dev/null and b/src/main/resources/assets/lzxnoneterraria/textures/vfx/stardust_cell3.png differ diff --git a/src/main/resources/assets/lzxnoneterraria/textures/vfx/stardust_cell_mini0.png b/src/main/resources/assets/lzxnoneterraria/textures/vfx/stardust_cell_mini0.png new file mode 100644 index 0000000..ff42f31 Binary files /dev/null and b/src/main/resources/assets/lzxnoneterraria/textures/vfx/stardust_cell_mini0.png differ diff --git a/src/main/resources/assets/lzxnoneterraria/textures/vfx/stardust_cell_mini1.png b/src/main/resources/assets/lzxnoneterraria/textures/vfx/stardust_cell_mini1.png new file mode 100644 index 0000000..8213c40 Binary files /dev/null and b/src/main/resources/assets/lzxnoneterraria/textures/vfx/stardust_cell_mini1.png differ diff --git a/src/main/resources/assets/lzxnoneterraria/textures/vfx/stardust_cell_mini2.png b/src/main/resources/assets/lzxnoneterraria/textures/vfx/stardust_cell_mini2.png new file mode 100644 index 0000000..ff42f31 Binary files /dev/null and b/src/main/resources/assets/lzxnoneterraria/textures/vfx/stardust_cell_mini2.png differ diff --git a/src/main/resources/assets/lzxnoneterraria/textures/vfx/stardust_cell_mini3.png b/src/main/resources/assets/lzxnoneterraria/textures/vfx/stardust_cell_mini3.png new file mode 100644 index 0000000..143daf1 Binary files /dev/null and b/src/main/resources/assets/lzxnoneterraria/textures/vfx/stardust_cell_mini3.png differ