From e955738812668e0f8a27bf5a495153df373aa34e Mon Sep 17 00:00:00 2001 From: LZX <1820455493@qq.com> Date: Sun, 12 Jul 2026 14:18:39 +0800 Subject: [PATCH] v1.3.0-pre --- gradle.properties | 2 +- .../java/com/lzxnone/terraria/Config.java | 280 ++++++++- .../terraria/LzxnoneTerrariaClient.java | 16 +- .../ModCreativeModeTabs.java | 6 + .../terraria/effect/BloodButcheredEffect.java | 44 ++ .../terraria/effect/EffectLogicHandler.java | 27 +- .../lzxnone/terraria/effect/ModEffects.java | 2 + .../entity/beam/ISwordBeamBehavior.java | 63 +- .../terraria/entity/beam/SwordBeam.java | 19 +- .../entity/beam/SwordBeamBehaviors.java | 11 +- .../terraria/entity/summon/BeeSummon.java | 10 +- .../entity/summon/StaticSummonBehaviors.java | 6 + .../terraria/event_handler/InputHandler.java | 59 ++ .../terraria/item/ItemWaveBehaviors.java | 16 +- .../item/weapon/melee/BloodButcherer.java | 94 ++- .../item/weapon/melee/EnchantedSword.java | 30 +- .../terraria/item/weapon/melee/Excalibur.java | 140 ++++- .../item/weapon/melee/InfluxWaver.java | 11 +- .../item/weapon/melee/LightsBane.java | 192 ++++++- .../terraria/item/weapon/melee/Meowmere.java | 6 +- .../item/weapon/melee/NightsEdge.java | 456 ++++++++++++++- .../terraria/item/weapon/melee/Seedler.java | 21 +- .../terraria/item/weapon/melee/StarWrath.java | 11 +- .../terraria/item/weapon/melee/Starfury.java | 13 +- .../item/weapon/melee/TerraBlade.java | 128 ++--- .../item/weapon/melee/TheHorsemansBlade.java | 14 +- .../weapon/melee/TrueCopperShortsword.java | 15 +- .../item/weapon/melee/TrueExcalibur.java | 270 ++++++++- .../item/weapon/melee/TrueNightsEdge.java | 544 +++++++++++++++++- .../terraria/item/weapon/melee/Zenith.java | 19 +- .../terraria/mixin/ZenithRenderMixin.java | 67 +++ .../lzxnone/terraria/network/ModNetwork.java | 7 + .../network/handler/ZenithScrollHandler.java | 42 ++ .../network/payload/ZenithScrollPayload.java | 23 + .../particle/BloodButcheredParticle.java | 66 +++ .../particle/ExcaliburHitParticle.java | 70 +++ .../terraria/particle/ModParticles.java | 10 + .../particle/NightsEdgeHitParticle.java | 74 +++ .../particle/TrueExcaliburHitParticle.java | 74 +++ .../particle/TrueNightsEdgeHitParticle.java | 74 +++ .../lzxnone/terraria/utils/DamageUtil.java | 40 ++ .../lzxnone/terraria/utils/RenderUtil.java | 59 ++ .../assets/lzxnoneterraria/lang/en_us.json | 83 ++- .../assets/lzxnoneterraria/lang/zh_cn.json | 83 ++- .../models/item/blood_butcherer.json | 2 +- .../models/item/excalibur.json | 2 +- .../models/item/lights_bane.json | 2 +- .../models/item/nights_edge.json | 2 +- .../models/item/true_excalibur.json | 2 +- .../models/item/true_nights_edge.json | 2 +- .../particles/blood_butchered_particle.json | 5 + .../particles/excalibur_hit_particle.json | 5 + .../particles/nights_edge_hit_particle.json | 7 + .../true_excalibur_hit_particle.json | 5 + .../true_nights_edge_hit_particle.json | 7 + .../textures/mob_effect/blood_butchered.png | Bin 0 -> 249 bytes .../particle/blood_butchered_particle.png | Bin 0 -> 1420 bytes .../particle/excalibur_hit_particle.png | Bin 0 -> 236 bytes .../particle/nights_edge_hit_particle0.png | Bin 0 -> 264 bytes .../particle/nights_edge_hit_particle1.png | Bin 0 -> 331 bytes .../particle/nights_edge_hit_particle2.png | Bin 0 -> 266 bytes .../particle/true_excalibur_hit_particle.png | Bin 0 -> 249 bytes .../true_nights_edge_hit_particle0.png | Bin 0 -> 257 bytes .../true_nights_edge_hit_particle1.png | Bin 0 -> 311 bytes .../true_nights_edge_hit_particle2.png | Bin 0 -> 250 bytes .../textures/vfx/lights_bane_slash0.png | Bin 0 -> 305 bytes .../textures/vfx/lights_bane_slash1.png | Bin 0 -> 186 bytes .../textures/vfx/lights_bane_slash10.png | Bin 0 -> 165 bytes .../textures/vfx/lights_bane_slash11.png | Bin 0 -> 143 bytes .../textures/vfx/lights_bane_slash2.png | Bin 0 -> 236 bytes .../textures/vfx/lights_bane_slash3.png | Bin 0 -> 251 bytes .../textures/vfx/lights_bane_slash4.png | Bin 0 -> 217 bytes .../textures/vfx/lights_bane_slash5.png | Bin 0 -> 187 bytes .../textures/vfx/lights_bane_slash6.png | Bin 0 -> 226 bytes .../textures/vfx/lights_bane_slash7.png | Bin 0 -> 221 bytes .../textures/vfx/lights_bane_slash8.png | Bin 0 -> 213 bytes .../textures/vfx/lights_bane_slash9.png | Bin 0 -> 199 bytes .../weapon_attributes/blood_butcherer.json | 3 + .../weapon_attributes/excalibur.json | 3 + .../weapon_attributes/lights_bane.json | 3 + .../weapon_attributes/nights_edge.json | 3 + .../weapon_attributes/true_excalibur.json | 3 + .../weapon_attributes/true_nights_edge.json | 3 + .../resources/lzxnoneterraria.mixins.json | 13 + .../templates/META-INF/neoforge.mods.toml | 3 + 85 files changed, 3117 insertions(+), 255 deletions(-) create mode 100644 src/main/java/com/lzxnone/terraria/effect/BloodButcheredEffect.java create mode 100644 src/main/java/com/lzxnone/terraria/event_handler/InputHandler.java create mode 100644 src/main/java/com/lzxnone/terraria/mixin/ZenithRenderMixin.java create mode 100644 src/main/java/com/lzxnone/terraria/network/handler/ZenithScrollHandler.java create mode 100644 src/main/java/com/lzxnone/terraria/network/payload/ZenithScrollPayload.java create mode 100644 src/main/java/com/lzxnone/terraria/particle/BloodButcheredParticle.java create mode 100644 src/main/java/com/lzxnone/terraria/particle/ExcaliburHitParticle.java create mode 100644 src/main/java/com/lzxnone/terraria/particle/NightsEdgeHitParticle.java create mode 100644 src/main/java/com/lzxnone/terraria/particle/TrueExcaliburHitParticle.java create mode 100644 src/main/java/com/lzxnone/terraria/particle/TrueNightsEdgeHitParticle.java create mode 100644 src/main/java/com/lzxnone/terraria/utils/DamageUtil.java create mode 100644 src/main/java/com/lzxnone/terraria/utils/RenderUtil.java create mode 100644 src/main/resources/assets/lzxnoneterraria/particles/blood_butchered_particle.json create mode 100644 src/main/resources/assets/lzxnoneterraria/particles/excalibur_hit_particle.json create mode 100644 src/main/resources/assets/lzxnoneterraria/particles/nights_edge_hit_particle.json create mode 100644 src/main/resources/assets/lzxnoneterraria/particles/true_excalibur_hit_particle.json create mode 100644 src/main/resources/assets/lzxnoneterraria/particles/true_nights_edge_hit_particle.json create mode 100644 src/main/resources/assets/lzxnoneterraria/textures/mob_effect/blood_butchered.png create mode 100644 src/main/resources/assets/lzxnoneterraria/textures/particle/blood_butchered_particle.png create mode 100644 src/main/resources/assets/lzxnoneterraria/textures/particle/excalibur_hit_particle.png create mode 100644 src/main/resources/assets/lzxnoneterraria/textures/particle/nights_edge_hit_particle0.png create mode 100644 src/main/resources/assets/lzxnoneterraria/textures/particle/nights_edge_hit_particle1.png create mode 100644 src/main/resources/assets/lzxnoneterraria/textures/particle/nights_edge_hit_particle2.png create mode 100644 src/main/resources/assets/lzxnoneterraria/textures/particle/true_excalibur_hit_particle.png create mode 100644 src/main/resources/assets/lzxnoneterraria/textures/particle/true_nights_edge_hit_particle0.png create mode 100644 src/main/resources/assets/lzxnoneterraria/textures/particle/true_nights_edge_hit_particle1.png create mode 100644 src/main/resources/assets/lzxnoneterraria/textures/particle/true_nights_edge_hit_particle2.png create mode 100644 src/main/resources/assets/lzxnoneterraria/textures/vfx/lights_bane_slash0.png create mode 100644 src/main/resources/assets/lzxnoneterraria/textures/vfx/lights_bane_slash1.png create mode 100644 src/main/resources/assets/lzxnoneterraria/textures/vfx/lights_bane_slash10.png create mode 100644 src/main/resources/assets/lzxnoneterraria/textures/vfx/lights_bane_slash11.png create mode 100644 src/main/resources/assets/lzxnoneterraria/textures/vfx/lights_bane_slash2.png create mode 100644 src/main/resources/assets/lzxnoneterraria/textures/vfx/lights_bane_slash3.png create mode 100644 src/main/resources/assets/lzxnoneterraria/textures/vfx/lights_bane_slash4.png create mode 100644 src/main/resources/assets/lzxnoneterraria/textures/vfx/lights_bane_slash5.png create mode 100644 src/main/resources/assets/lzxnoneterraria/textures/vfx/lights_bane_slash6.png create mode 100644 src/main/resources/assets/lzxnoneterraria/textures/vfx/lights_bane_slash7.png create mode 100644 src/main/resources/assets/lzxnoneterraria/textures/vfx/lights_bane_slash8.png create mode 100644 src/main/resources/assets/lzxnoneterraria/textures/vfx/lights_bane_slash9.png create mode 100644 src/main/resources/data/lzxnoneterraria/weapon_attributes/blood_butcherer.json create mode 100644 src/main/resources/data/lzxnoneterraria/weapon_attributes/excalibur.json create mode 100644 src/main/resources/data/lzxnoneterraria/weapon_attributes/lights_bane.json create mode 100644 src/main/resources/data/lzxnoneterraria/weapon_attributes/nights_edge.json create mode 100644 src/main/resources/data/lzxnoneterraria/weapon_attributes/true_excalibur.json create mode 100644 src/main/resources/data/lzxnoneterraria/weapon_attributes/true_nights_edge.json create mode 100644 src/main/resources/lzxnoneterraria.mixins.json diff --git a/gradle.properties b/gradle.properties index 17372d2..fc79e50 100644 --- a/gradle.properties +++ b/gradle.properties @@ -32,7 +32,7 @@ mod_name=Lzxnone Terraria # The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default. mod_license=All Rights Reserved # The mod version. See https://semver.org/ -mod_version=1.2.2 +mod_version=1.2.3 # The group ID for the mod. It is only important when publishing as an artifact to a Maven repository. # This should match the base package used for the mod sources. # See https://maven.apache.org/guides/mini/guide-naming-conventions.html diff --git a/src/main/java/com/lzxnone/terraria/Config.java b/src/main/java/com/lzxnone/terraria/Config.java index 4cb9d89..417d677 100644 --- a/src/main/java/com/lzxnone/terraria/Config.java +++ b/src/main/java/com/lzxnone/terraria/Config.java @@ -18,6 +18,10 @@ public class Config { public static final ModConfigSpec.IntValue BEE_KEEPER_CONFUSION_DURATION; public static final ModConfigSpec.DoubleValue BEE_KEEPER_BEE_DAMAGE; + public static final ModConfigSpec.IntValue BLOOD_BUTCHERER_EFFECT_DURATION; + public static final ModConfigSpec.IntValue BLOOD_BUTCHERER_MAX_LEVEL; + public static final ModConfigSpec.DoubleValue BLOOD_BUTCHERER_DAMAGE_PER_LEVEL; + public static final ModConfigSpec.DoubleValue STARFURY_DAMAGE; public static final ModConfigSpec.DoubleValue STARFURY_MAX_RANGE; public static final ModConfigSpec.DoubleValue STARFURY_SPEED; @@ -51,6 +55,25 @@ public class Config { public static final ModConfigSpec.DoubleValue MEOWMERE_GRAVITY; public static final ModConfigSpec.DoubleValue MEOWMERE_INITIAL_SPEED; + public static final ModConfigSpec.DoubleValue LIGHTS_BANE_BIG_DAMAGE; + public static final ModConfigSpec.DoubleValue LIGHTS_BANE_SMALL_DAMAGE; + public static final ModConfigSpec.DoubleValue LIGHTS_BANE_TARGET_RANGE; + + public static final ModConfigSpec.IntValue EXCALIBUR_ROTATE_RANGE; + public static final ModConfigSpec.IntValue EXCALIBUR_MAX_HIT_COUNT; + public static final ModConfigSpec.DoubleValue EXCALIBUR_DAMAGE; + + public static final ModConfigSpec.BooleanValue NIGHTS_EDGE_PROJECTILE_ALIGN_TO_BLADE; + public static final ModConfigSpec.IntValue NIGHTS_EDGE_ROTATE_RANGE; + public static final ModConfigSpec.IntValue NIGHTS_EDGE_PROJECTILE_ROTATE_RANGE; + public static final ModConfigSpec.IntValue NIGHTS_EDGE_MAX_HIT_COUNT; + public static final ModConfigSpec.IntValue NIGHTS_EDGE_PROJECTILE_MAX_HIT_COUNT; + public static final ModConfigSpec.DoubleValue NIGHTS_EDGE_DAMAGE; + public static final ModConfigSpec.DoubleValue NIGHTS_EDGE_PROJECTILE_DAMAGE; + public static final ModConfigSpec.DoubleValue NIGHTS_EDGE_PROJECTILE_SPEED; + public static final ModConfigSpec.IntValue NIGHTS_EDGE_PROJECTILE_LIFETIME; + public static final ModConfigSpec.IntValue NIGHTS_EDGE_PROJECTILE_ROTATION_SPEED; + public static final ModConfigSpec.BooleanValue TERRA_PROJECTILE_ALIGN_TO_BLADE; public static final ModConfigSpec.IntValue TERRA_BLADE_ROTATE_RANGE; public static final ModConfigSpec.IntValue TERRA_PROJECTILE_ROTATE_RANGE; @@ -63,6 +86,8 @@ public class Config { public static final ModConfigSpec.DoubleValue ZENITH_DAMAGE; public static final ModConfigSpec.DoubleValue ZENITH_MAX_RANGE; + public static final ModConfigSpec.BooleanValue ZENITH_DISTANCE_MODE; + public static final ModConfigSpec.IntValue ZENITH_SCROLL_SPEED; public static final ModConfigSpec.DoubleValue ZENITH_TRAIL_B; public static final ModConfigSpec.IntValue ZENITH_TRAIL_OFFSET; public static final ModConfigSpec.IntValue ZENITH_WEAPON_COUNT; @@ -72,6 +97,21 @@ public class Config { public static final ModConfigSpec.DoubleValue ZENITH_TRAIL_ALPHA; public static final ModConfigSpec.IntValue ZENITH_TRAIL_MAX_LENGTH; + public static final ModConfigSpec.IntValue TRUE_EXCALIBUR_ROTATE_RANGE; + public static final ModConfigSpec.IntValue TRUE_EXCALIBUR_MAX_HIT_COUNT; + public static final ModConfigSpec.DoubleValue TRUE_EXCALIBUR_DAMAGE; + + public static final ModConfigSpec.BooleanValue TRUE_NIGHTS_EDGE_PROJECTILE_ALIGN_TO_BLADE; + public static final ModConfigSpec.IntValue TRUE_NIGHTS_EDGE_ROTATE_RANGE; + public static final ModConfigSpec.IntValue TRUE_NIGHTS_EDGE_PROJECTILE_ROTATE_RANGE; + public static final ModConfigSpec.IntValue TRUE_NIGHTS_EDGE_MAX_HIT_COUNT; + public static final ModConfigSpec.IntValue TRUE_NIGHTS_EDGE_PROJECTILE_MAX_HIT_COUNT; + public static final ModConfigSpec.DoubleValue TRUE_NIGHTS_EDGE_DAMAGE; + public static final ModConfigSpec.DoubleValue TRUE_NIGHTS_EDGE_PROJECTILE_DAMAGE; + public static final ModConfigSpec.DoubleValue TRUE_NIGHTS_EDGE_PROJECTILE_SPEED; + public static final ModConfigSpec.IntValue TRUE_NIGHTS_EDGE_PROJECTILE_LIFETIME; + public static final ModConfigSpec.IntValue TRUE_NIGHTS_EDGE_PROJECTILE_ROTATION_SPEED; + public static double enchantedSwordDamage; public static int enchantedSwordLifetime; public static double enchantedSwordSpeed; @@ -80,6 +120,10 @@ public class Config { public static int beeKeeperConfusionDuration; public static double beeKeeperBeeDamage; + public static int bloodButchererEffectDuration; + public static int bloodButchererMaxLevel; + public static double bloodButchererDamagePerLevel; + public static double starfuryDamage; public static double starfuryMaxRange; public static double starfurySpeed; @@ -113,6 +157,25 @@ public class Config { public static double meowmereGravity; public static double meowmereInitialSpeed; + public static double lightsBaneBigDamage; + public static double lightsBaneSmallDamage; + public static double lightsBaneTargetRange; + + public static int excaliburRotateRange; + public static int excaliburMaxHitCount; + public static double excaliburDamage; + + public static boolean nightsEdgeProjectileAlignToBlade; + public static int nightsEdgeRotateRange; + public static int nightsEdgeProjectileRotateRange; + public static int nightsEdgeMaxHitCount; + public static int nightsEdgeProjectileMaxHitCount; + public static double nightsEdgeDamage; + public static double nightsEdgeProjectileDamage; + public static double nightsEdgeProjectileSpeed; + public static int nightsEdgeProjectileLifetime; + public static int nightsEdgeProjectileRotationSpeed; + public static boolean terraProjectileAlignToBlade; public static int terraBladeRotateRange; public static int terraProjectileRotateRange; @@ -125,6 +188,8 @@ public class Config { public static double zenithDamage; public static double zenithMaxRange; + public static boolean zenithDistanceMode; + public static int zenithMouseSpeed; public static double zenithTrailB; public static int zenithTrailOffset; public static int zenithWeaponCount; @@ -134,6 +199,21 @@ public class Config { public static double zenithTrailAlpha; public static int zenithTrailMaxLength; + public static int trueExcaliburRotateRange; + public static int trueExcaliburMaxHitCount; + public static double trueExcaliburDamage; + + public static boolean trueNightsEdgeProjectileAlignToBlade; + public static int trueNightsEdgeRotateRange; + public static int trueNightsEdgeProjectileRotateRange; + public static int trueNightsEdgeMaxHitCount; + public static int trueNightsEdgeProjectileMaxHitCount; + public static double trueNightsEdgeDamage; + public static double trueNightsEdgeProjectileDamage; + public static double trueNightsEdgeProjectileSpeed; + public static int trueNightsEdgeProjectileLifetime; + public static int trueNightsEdgeProjectileRotationSpeed; + static { ModConfigSpec.Builder builder = new ModConfigSpec.Builder(); @@ -170,6 +250,21 @@ public class Config { builder.pop(); + builder.push("blood_butcherer_settings"); + + BLOOD_BUTCHERER_EFFECT_DURATION = builder + .comment("血腥屠宰效果持续时间(刻)") + .defineInRange("blood_butcherer_effect_duration", 180, 0, 72000); + + BLOOD_BUTCHERER_MAX_LEVEL = builder + .comment("血腥屠宰效果最大等级") + .defineInRange("blood_butcherer_max_level", 4, 0, 255); + + BLOOD_BUTCHERER_DAMAGE_PER_LEVEL = builder + .comment("血腥屠宰效果每级伤害") + .defineInRange("blood_butcherer_damage_per_level", 0.5, 0, 8388600); + + builder.pop(); builder.push("starfury_settings"); @@ -309,6 +404,85 @@ public class Config { builder.pop(); + builder.push("lights_bane_settings"); + + LIGHTS_BANE_BIG_DAMAGE = builder + .comment("大斩击伤害") + .defineInRange("lights_bane_big_damage", 4.0, 0, 2147483647.0); + + LIGHTS_BANE_SMALL_DAMAGE = builder + .comment("小斩击伤害") + .defineInRange("lights_bane_small_damage", 2.0, 0, 2147483647.0); + + LIGHTS_BANE_TARGET_RANGE = builder + .comment("寻敌范围") + .defineInRange("lights_bane_target_range", 2.0, 1.0, 64.0); + + builder.pop(); + + + builder.push("excalibur_settings"); + + EXCALIBUR_ROTATE_RANGE = builder + .comment("刀光偏转角范围") + .defineInRange("excalibur_rotate_range", 45, 0, 90); + + EXCALIBUR_MAX_HIT_COUNT = builder + .comment("刀光单次最大击中生物数量") + .defineInRange("excalibur_max_hit_count", 3, 0, 100); + + EXCALIBUR_DAMAGE = builder + .comment("刀光伤害") + .defineInRange("excalibur_damage", 8.0, 0, 2147483647.0); + + builder.pop(); + + + builder.push("nights_edge_settings"); + + NIGHTS_EDGE_PROJECTILE_ALIGN_TO_BLADE = builder + .comment("弹射是否匹配刀光方向") + .define("nights_edge_projectile_align_to_blade", true); + + NIGHTS_EDGE_ROTATE_RANGE = builder + .comment("刀光偏转角范围") + .defineInRange("nights_edge_rotate_range", 45, 0, 90); + + NIGHTS_EDGE_PROJECTILE_ROTATE_RANGE = builder + .comment("弹射偏转角范围") + .defineInRange("nights_edge_projectile_rotate_range", 40, 0, 90); + + NIGHTS_EDGE_MAX_HIT_COUNT = builder + .comment("刀光单次最大击中生物数量") + .defineInRange("nights_edge_max_hit_count", 2, 0, 100); + + NIGHTS_EDGE_PROJECTILE_MAX_HIT_COUNT = builder + .comment("弹射刀光单次最大击中生物数量") + .defineInRange("nights_edge_projectile_max_hit_count", 2, 0, 100); + + NIGHTS_EDGE_DAMAGE = builder + .comment("刀光伤害") + .defineInRange("nights_edge_damage", 7.0, 0, 2147483647.0); + + NIGHTS_EDGE_PROJECTILE_DAMAGE = builder + .comment("弹射伤害") + .defineInRange("nights_edge_projectile_damage", 7.0, 0, 2147483647.0); + + NIGHTS_EDGE_PROJECTILE_SPEED = builder + .comment("弹射速度") + .defineInRange("nights_edge_projectile_speed", 0.25, 0, 10); + + NIGHTS_EDGE_PROJECTILE_LIFETIME = builder + .comment("弹射持续时间") + .defineInRange("nights_edge_projectile_lifetime", 10, 1, 1200); + + NIGHTS_EDGE_PROJECTILE_ROTATION_SPEED = builder + .comment("弹射旋转速度") + .defineInRange("nights_edge_projectile_rotation_speed", 36, 0, 360); + + builder.pop(); + + builder.push("terra_blade_settings"); TERRA_PROJECTILE_ALIGN_TO_BLADE = builder @@ -317,11 +491,11 @@ public class Config { TERRA_BLADE_ROTATE_RANGE = builder .comment("刀光偏转角范围") - .defineInRange("terra_blade_rotate_range", 30, 0, 90); + .defineInRange("terra_blade_rotate_range", 45, 0, 90); TERRA_PROJECTILE_ROTATE_RANGE = builder .comment("弹射偏转角范围") - .defineInRange("terra_projectile_rotate_range", 30, 0, 90); + .defineInRange("terra_projectile_rotate_range", 45, 0, 90); TERRA_BLADE_MAX_HIT_COUNT = builder .comment("刀光单次最大击中生物数量") @@ -360,6 +534,14 @@ public class Config { .comment("最大范围(2a)") .defineInRange("zenith_max_range", 64.0, 1.0, 1024.0); + ZENITH_DISTANCE_MODE = builder + .comment("使用相对距离") + .define("zenith_distance_mode", true); + + ZENITH_SCROLL_SPEED = builder + .comment("滚轮调节距离速度") + .defineInRange("zenith_mouse_speed", 4, 0, 128); + ZENITH_TRAIL_B = builder .comment("椭圆轨道半短轴(b)") .defineInRange("zenith_trail_b", 4.0, 0.1, 512.0); @@ -394,6 +576,66 @@ public class Config { builder.pop(); + builder.push("true_excalibur_settings"); + + TRUE_EXCALIBUR_ROTATE_RANGE = builder + .comment("刀光偏转角范围") + .defineInRange("true_excalibur_rotate_range", 45, 0, 90); + + TRUE_EXCALIBUR_MAX_HIT_COUNT = builder + .comment("刀光单次最大击中生物数量") + .defineInRange("true_excalibur_max_hit_count", 6, 0, 100); + + TRUE_EXCALIBUR_DAMAGE = builder + .comment("刀光伤害") + .defineInRange("true_excalibur_damage", 8.0, 0, 2147483647.0); + + builder.pop(); + + builder.push("true_nights_edge_settings"); + + TRUE_NIGHTS_EDGE_PROJECTILE_ALIGN_TO_BLADE = builder + .comment("弹射是否匹配刀光方向") + .define("true_nights_edge_projectile_align_to_blade", true); + + TRUE_NIGHTS_EDGE_ROTATE_RANGE = builder + .comment("刀光偏转角范围") + .defineInRange("true_nights_edge_rotate_range", 45, 0, 90); + + TRUE_NIGHTS_EDGE_PROJECTILE_ROTATE_RANGE = builder + .comment("弹射偏转角范围") + .defineInRange("true_nights_edge_projectile_rotate_range", 45, 0, 90); + + TRUE_NIGHTS_EDGE_MAX_HIT_COUNT = builder + .comment("刀光单次最大击中生物数量") + .defineInRange("true_nights_edge_max_hit_count", 2, 0, 100); + + TRUE_NIGHTS_EDGE_PROJECTILE_MAX_HIT_COUNT = builder + .comment("弹射刀光单次最大击中生物数量") + .defineInRange("true_nights_edge_projectile_max_hit_count", 3, 0, 100); + + TRUE_NIGHTS_EDGE_DAMAGE = builder + .comment("刀光伤害") + .defineInRange("true_nights_edge_damage", 8.0, 0, 2147483647.0); + + TRUE_NIGHTS_EDGE_PROJECTILE_DAMAGE = builder + .comment("弹射伤害") + .defineInRange("true_nights_edge_projectile_damage", 4.0, 0, 2147483647.0); + + TRUE_NIGHTS_EDGE_PROJECTILE_SPEED = builder + .comment("弹射速度") + .defineInRange("true_nights_edge_projectile_speed", 0.5, 0, 10); + + TRUE_NIGHTS_EDGE_PROJECTILE_LIFETIME = builder + .comment("弹射持续时间") + .defineInRange("true_nights_edge_projectile_lifetime", 60, 1, 1200); + + TRUE_NIGHTS_EDGE_PROJECTILE_ROTATION_SPEED = builder + .comment("弹射旋转速度") + .defineInRange("true_nights_edge_projectile_rotation_speed", 30, 0, 360); + + builder.pop(); + SPEC = builder.build(); } @@ -406,6 +648,9 @@ public class Config { beeKeeperMaxBees = BEE_KEEPER_MAX_BEES.get(); beeKeeperConfusionDuration = BEE_KEEPER_CONFUSION_DURATION.get(); beeKeeperBeeDamage = BEE_KEEPER_BEE_DAMAGE.get(); + bloodButchererEffectDuration = BLOOD_BUTCHERER_EFFECT_DURATION.get(); + bloodButchererMaxLevel = BLOOD_BUTCHERER_MAX_LEVEL.get(); + bloodButchererDamagePerLevel = BLOOD_BUTCHERER_DAMAGE_PER_LEVEL.get(); starfuryDamage = STARFURY_DAMAGE.get(); starfuryMaxRange = STARFURY_MAX_RANGE.get(); starfurySpeed = STARFURY_SPEED.get(); @@ -433,6 +678,22 @@ public class Config { meowmereDamage = MEOWMERE_DAMAGE.get(); meowmereGravity = MEOWMERE_GRAVITY.get(); meowmereInitialSpeed = MEOWMERE_INITIAL_SPEED.get(); + lightsBaneBigDamage = LIGHTS_BANE_BIG_DAMAGE.get(); + lightsBaneSmallDamage = LIGHTS_BANE_SMALL_DAMAGE.get(); + lightsBaneTargetRange = LIGHTS_BANE_TARGET_RANGE.get(); + excaliburRotateRange = EXCALIBUR_ROTATE_RANGE.get(); + excaliburMaxHitCount = EXCALIBUR_MAX_HIT_COUNT.get(); + excaliburDamage = EXCALIBUR_DAMAGE.get(); + nightsEdgeProjectileAlignToBlade = NIGHTS_EDGE_PROJECTILE_ALIGN_TO_BLADE.get(); + nightsEdgeRotateRange = NIGHTS_EDGE_ROTATE_RANGE.get(); + nightsEdgeProjectileRotateRange = NIGHTS_EDGE_PROJECTILE_ROTATE_RANGE.get(); + nightsEdgeMaxHitCount = NIGHTS_EDGE_MAX_HIT_COUNT.get(); + nightsEdgeProjectileMaxHitCount = NIGHTS_EDGE_PROJECTILE_MAX_HIT_COUNT.get(); + nightsEdgeDamage = NIGHTS_EDGE_DAMAGE.get(); + nightsEdgeProjectileDamage = NIGHTS_EDGE_PROJECTILE_DAMAGE.get(); + nightsEdgeProjectileSpeed = NIGHTS_EDGE_PROJECTILE_SPEED.get(); + nightsEdgeProjectileLifetime = NIGHTS_EDGE_PROJECTILE_LIFETIME.get(); + nightsEdgeProjectileRotationSpeed = NIGHTS_EDGE_PROJECTILE_ROTATION_SPEED.get(); terraProjectileAlignToBlade = TERRA_PROJECTILE_ALIGN_TO_BLADE.get(); terraBladeRotateRange = TERRA_BLADE_ROTATE_RANGE.get(); terraProjectileRotateRange = TERRA_PROJECTILE_ROTATE_RANGE.get(); @@ -444,6 +705,8 @@ public class Config { terraProjectileDamageDecay = TERRA_PROJECTILE_DAMAGE_DECAY.get(); zenithDamage = ZENITH_DAMAGE.get(); zenithMaxRange = ZENITH_MAX_RANGE.get(); + zenithDistanceMode = ZENITH_DISTANCE_MODE.get(); + zenithMouseSpeed = ZENITH_SCROLL_SPEED.get(); zenithTrailB = ZENITH_TRAIL_B.get(); zenithTrailOffset = ZENITH_TRAIL_OFFSET.get(); zenithWeaponCount = ZENITH_WEAPON_COUNT.get(); @@ -452,6 +715,19 @@ public class Config { zenithScale = ZENITH_SCALE.get(); zenithTrailAlpha = ZENITH_TRAIL_ALPHA.get(); zenithTrailMaxLength = ZENITH_TRAIL_MAX_LENGTH.get(); + trueExcaliburRotateRange = TRUE_EXCALIBUR_ROTATE_RANGE.get(); + trueExcaliburMaxHitCount = TRUE_EXCALIBUR_MAX_HIT_COUNT.get(); + trueExcaliburDamage = TRUE_EXCALIBUR_DAMAGE.get(); + trueNightsEdgeProjectileAlignToBlade = TRUE_NIGHTS_EDGE_PROJECTILE_ALIGN_TO_BLADE.get(); + trueNightsEdgeRotateRange = TRUE_NIGHTS_EDGE_ROTATE_RANGE.get(); + trueNightsEdgeProjectileRotateRange = TRUE_NIGHTS_EDGE_PROJECTILE_ROTATE_RANGE.get(); + trueNightsEdgeMaxHitCount = TRUE_NIGHTS_EDGE_MAX_HIT_COUNT.get(); + trueNightsEdgeProjectileMaxHitCount = TRUE_NIGHTS_EDGE_PROJECTILE_MAX_HIT_COUNT.get(); + trueNightsEdgeDamage = TRUE_NIGHTS_EDGE_DAMAGE.get(); + trueNightsEdgeProjectileDamage = TRUE_NIGHTS_EDGE_PROJECTILE_DAMAGE.get(); + trueNightsEdgeProjectileSpeed = TRUE_NIGHTS_EDGE_PROJECTILE_SPEED.get(); + trueNightsEdgeProjectileLifetime = TRUE_NIGHTS_EDGE_PROJECTILE_LIFETIME.get(); + trueNightsEdgeProjectileRotationSpeed = TRUE_NIGHTS_EDGE_PROJECTILE_ROTATION_SPEED.get(); } } } diff --git a/src/main/java/com/lzxnone/terraria/LzxnoneTerrariaClient.java b/src/main/java/com/lzxnone/terraria/LzxnoneTerrariaClient.java index 9e51cde..1864e9a 100644 --- a/src/main/java/com/lzxnone/terraria/LzxnoneTerrariaClient.java +++ b/src/main/java/com/lzxnone/terraria/LzxnoneTerrariaClient.java @@ -59,6 +59,20 @@ public class LzxnoneTerrariaClient { modEventBus.addListener(RegisterParticleProvidersEvent.class, event -> { event.registerSpriteSet(ModParticles.TERRA_BEAM_HIT_PARTICLE.get(), TerraBeamHitParticle.Provider::new); }); - + modEventBus.addListener(RegisterParticleProvidersEvent.class, event -> { + event.registerSpriteSet(ModParticles.EXCALIBUR_HIT_PARTICLE.get(), ExcaliburHitParticle.Provider::new); + }); + modEventBus.addListener(RegisterParticleProvidersEvent.class, event -> { + event.registerSpriteSet(ModParticles.TRUE_EXCALIBUR_HIT_PARTICLE.get(), TrueExcaliburHitParticle.Provider::new); + }); + modEventBus.addListener(RegisterParticleProvidersEvent.class, event -> { + event.registerSpriteSet(ModParticles.NIGHTS_EDGE_HIT_PARTICLE.get(), NightsEdgeHitParticle.Provider::new); + }); + modEventBus.addListener(RegisterParticleProvidersEvent.class, event -> { + event.registerSpriteSet(ModParticles.TRUE_NIGHTS_EDGE_HIT_PARTICLE.get(), TrueNightsEdgeHitParticle.Provider::new); + }); + modEventBus.addListener(RegisterParticleProvidersEvent.class, event -> { + event.registerSpriteSet(ModParticles.BLOOD_BUTCHERED_PARTICLE.get(), BloodButcheredParticle.Provider::new); + }); } } 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 bc605cb..4f7a4e1 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 @@ -29,5 +29,11 @@ public class ModCreativeModeTabs { output.accept(ModItems.TERRA_BLADE.get()); output.accept(ModItems.ZENITH.get()); output.accept(ModItems.TRUE_COPPER_SHORTSWORD.get()); + output.accept(ModItems.EXCALIBUR.get()); + output.accept(ModItems.NIGHTS_EDGE.get()); + output.accept(ModItems.TRUE_EXCALIBUR.get()); + output.accept(ModItems.TRUE_NIGHTS_EDGE.get()); + output.accept(ModItems.LIGHTS_BANE.get()); + output.accept(ModItems.BLOOD_BUTCHERER.get()); }).build()); } diff --git a/src/main/java/com/lzxnone/terraria/effect/BloodButcheredEffect.java b/src/main/java/com/lzxnone/terraria/effect/BloodButcheredEffect.java new file mode 100644 index 0000000..40ba6ea --- /dev/null +++ b/src/main/java/com/lzxnone/terraria/effect/BloodButcheredEffect.java @@ -0,0 +1,44 @@ +package com.lzxnone.terraria.effect; + +import com.lzxnone.terraria.Config; +import com.lzxnone.terraria.particle.ModParticles; +import com.lzxnone.terraria.utils.MathUtil; +import com.lzxnone.terraria.utils.ParticleUtil; +import net.minecraft.world.effect.MobEffect; +import net.minecraft.world.effect.MobEffectCategory; +import net.minecraft.world.effect.MobEffectInstance; +import net.minecraft.world.effect.MobEffects; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.phys.Vec3; + +public class BloodButcheredEffect extends MobEffect { + public BloodButcheredEffect() { + super(MobEffectCategory.HARMFUL, 0xFF0000); + } + + @Override + public boolean shouldApplyEffectTickThisTick(int duration, int amplifier) { + return true; + } + + @Override + public boolean applyEffectTick(LivingEntity entity, int amplifier) { + if(entity.level().isClientSide()) { + Vec3 center = entity.getBoundingBox().getCenter(); + ParticleUtil.addParticles( + entity.level(), ModParticles.BLOOD_BUTCHERED_PARTICLE.get(), + center, 0.05, + new Vec3(0, 0, 0), Math.min((amplifier + 1) * 0.1, 0.5), + Math.min(amplifier + 1, 5) + ); + }else { + MobEffectInstance instance = entity.getEffect(ModEffects.BLOOD_BUTCHERED); + if(instance != null) { + if(instance.getDuration() % 20 == 0) { + entity.hurt(entity.damageSources().magic(), (float) Config.bloodButchererDamagePerLevel * (amplifier + 1)); + } + } + } + return true; + } +} diff --git a/src/main/java/com/lzxnone/terraria/effect/EffectLogicHandler.java b/src/main/java/com/lzxnone/terraria/effect/EffectLogicHandler.java index 7ef3117..708a4c8 100644 --- a/src/main/java/com/lzxnone/terraria/effect/EffectLogicHandler.java +++ b/src/main/java/com/lzxnone/terraria/effect/EffectLogicHandler.java @@ -1,9 +1,12 @@ package com.lzxnone.terraria.effect; import com.lzxnone.terraria.LzxnoneTerraria; +import net.minecraft.core.Holder; import net.minecraft.network.protocol.game.ClientboundRemoveMobEffectPacket; import net.minecraft.network.protocol.game.ClientboundUpdateMobEffectPacket; import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.effect.MobEffect; +import net.minecraft.world.effect.MobEffectInstance; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.PathfinderMob; import net.minecraft.world.entity.player.Player; @@ -20,7 +23,9 @@ public class EffectLogicHandler { @SubscribeEvent public static void onEffectAdded(MobEffectEvent.Added event) { LivingEntity entity = event.getEntity(); - if(!entity.level().isClientSide() && !(entity instanceof Player)) { + MobEffectInstance instance = event.getEffectInstance(); + Holder currentEffect = instance.getEffect(); + if(checkEffect(currentEffect) && !entity.level().isClientSide() && !(entity instanceof Player)) { if(entity.level() instanceof ServerLevel serverLevel) { serverLevel.getChunkSource().broadcast(entity, new ClientboundUpdateMobEffectPacket(entity.getId(), event.getEffectInstance(), false)); @@ -31,7 +36,9 @@ public class EffectLogicHandler { @SubscribeEvent public static void onEffectRemoved(MobEffectEvent.Remove event) { LivingEntity entity = event.getEntity(); - if(!entity.level().isClientSide() && !(entity instanceof Player)) { + MobEffectInstance instance = event.getEffectInstance(); + Holder currentEffect = instance.getEffect(); + if(checkEffect(currentEffect) && !entity.level().isClientSide() && !(entity instanceof Player)) { if(entity.level() instanceof ServerLevel serverLevel) { if(event.getEffectInstance() != null) { serverLevel.getChunkSource().broadcast(entity, @@ -44,8 +51,10 @@ public class EffectLogicHandler { @SubscribeEvent public static void onEffectExpired(MobEffectEvent.Expired event) { LivingEntity entity = event.getEntity(); - if (!entity.level().isClientSide() && !(entity instanceof Player)) { - if (entity.level() instanceof ServerLevel serverLevel) { + MobEffectInstance instance = event.getEffectInstance(); + Holder currentEffect = instance.getEffect(); + if(checkEffect(currentEffect) && !entity.level().isClientSide() && !(entity instanceof Player)) { + if(entity.level() instanceof ServerLevel serverLevel) { if(event.getEffectInstance() != null) { serverLevel.getChunkSource().broadcast(entity, new ClientboundRemoveMobEffectPacket(entity.getId(), event.getEffectInstance().getEffect())); @@ -54,11 +63,9 @@ public class EffectLogicHandler { } } - @SubscribeEvent - public static void onLivingTick(EntityTickEvent.Post event) { - if(!event.getEntity().level().isClientSide() && event.getEntity() instanceof PathfinderMob mob) { - - } + public static boolean checkEffect(Holder effect) { + return + effect == ModEffects.CONFUSED || + effect == ModEffects.BLOOD_BUTCHERED; } - } diff --git a/src/main/java/com/lzxnone/terraria/effect/ModEffects.java b/src/main/java/com/lzxnone/terraria/effect/ModEffects.java index ee750af..1024489 100644 --- a/src/main/java/com/lzxnone/terraria/effect/ModEffects.java +++ b/src/main/java/com/lzxnone/terraria/effect/ModEffects.java @@ -12,4 +12,6 @@ public class ModEffects { public static final DeferredHolder CONFUSED = MOB_EFFECTS.register("confused", ConfusedEffect::new); + public static final DeferredHolder BLOOD_BUTCHERED = + MOB_EFFECTS.register("blood_butchered", BloodButcheredEffect::new); } 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 c0984dd..b4ebd9c 100644 --- a/src/main/java/com/lzxnone/terraria/entity/beam/ISwordBeamBehavior.java +++ b/src/main/java/com/lzxnone/terraria/entity/beam/ISwordBeamBehavior.java @@ -4,6 +4,7 @@ import com.lzxnone.terraria.LzxnoneTerraria; import com.lzxnone.terraria.entity.ModEntities; import com.lzxnone.terraria.entity.summon.StaticSummon; import com.lzxnone.terraria.utils.MathUtil; +import com.lzxnone.terraria.utils.RenderUtil; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; import com.mojang.math.Axis; @@ -15,7 +16,6 @@ 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.LivingEntity; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.Item; import net.minecraft.world.item.Items; @@ -75,24 +75,24 @@ public interface ISwordBeamBehavior { //左边 poseStack.pushPose(); - this.applyTranslate(poseStack, dirs[0], dirs[2], progress - 0.1f * (1.0f - progress), SwordBeam.DIST); - this.applyRotate(poseStack, dirs[0], dirs[1], progress - 0.1f * (1.0f - progress), rotate); + RenderUtil.applyTranslate(poseStack, dirs[0], dirs[2], (progress - 0.1f * (1.0f - progress)) * 180, SwordBeam.DIST); + RenderUtil.applyRotate(poseStack, dirs[0], dirs[1], (0.5f - (progress - 0.1f * (1.0f - progress))) * 180, rotate); renderQuad(poseStack.last().pose(), vertexConsumer0, color0.x(), color0.y(), color0.z(), alpha, halfWidth, halfHeight, 0f, 0, -0.01f); poseStack.popPose(); //右边 poseStack.pushPose(); - this.applyTranslate(poseStack, dirs[0], dirs[2], progress + 0.1f, SwordBeam.DIST); - this.applyRotate(poseStack, dirs[0], dirs[1], progress + 0.05f, rotate); + RenderUtil.applyTranslate(poseStack, dirs[0], dirs[2], (progress + 0.1f) * 180, SwordBeam.DIST); + RenderUtil.applyRotate(poseStack, dirs[0], dirs[1], (0.5f - (progress + 0.05f)) * 180, rotate); renderQuad(poseStack.last().pose(), vertexConsumer0, color2.x(), color2.y(), color2.z(), alpha, halfWidth, halfHeight, 0f, 0, -0.02f); poseStack.popPose(); //中间 poseStack.pushPose(); - this.applyTranslate(poseStack, dirs[0], dirs[2], progress, SwordBeam.DIST); - this.applyRotate(poseStack, dirs[0], dirs[1], progress, rotate); + RenderUtil.applyTranslate(poseStack, dirs[0], dirs[2], progress * 180, SwordBeam.DIST); + RenderUtil.applyRotate(poseStack, dirs[0], dirs[1], (0.5f - progress) * 180, rotate); renderQuad(poseStack.last().pose(), vertexConsumer0, color1.x(), color1.y(), color1.z(), alpha, halfWidth, halfHeight, 0f, 0f, 0f); poseStack.popPose(); @@ -101,24 +101,24 @@ public interface ISwordBeamBehavior { //三线 poseStack.pushPose(); - this.applyTranslate(poseStack, dirs[0], dirs[2], progress + 0.05f, SwordBeam.DIST / 1.5f); - this.applyRotate(poseStack, dirs[0], dirs[1], progress, rotate); + RenderUtil.applyTranslate(poseStack, dirs[0], dirs[2], (progress + 0.05f) * 180, SwordBeam.DIST / 1.5f); + RenderUtil.applyRotate(poseStack, dirs[0], dirs[1], (0.5f - progress) * 180, rotate); poseStack.scale(0.5f, 0.5f, 0.5f); renderQuad(poseStack.last().pose(), vertexConsumer1, color3.x(), color3.y(), color3.z(), alpha, halfWidth, halfHeight, 0f, 0f, 0.02f); poseStack.popPose(); poseStack.pushPose(); - this.applyTranslate(poseStack, dirs[0], dirs[2], progress + 0.05f, SwordBeam.DIST / 1.25f); - this.applyRotate(poseStack, dirs[0], dirs[1], progress, rotate); + RenderUtil.applyTranslate(poseStack, dirs[0], dirs[2], (progress + 0.05f) * 180, SwordBeam.DIST / 1.25f); + RenderUtil.applyRotate(poseStack, dirs[0], dirs[1], (0.5f - progress) * 180, rotate); poseStack.scale(0.75f, 0.75f, 0.75f); renderQuad(poseStack.last().pose(), vertexConsumer1, color3.x(), color3.y(), color3.z(), alpha, halfWidth, halfHeight, 0f, 0f, 0.02f); poseStack.popPose(); poseStack.pushPose(); - this.applyTranslate(poseStack, dirs[0], dirs[2], progress, SwordBeam.DIST * 1.15f); - this.applyRotate(poseStack, dirs[0], dirs[1], progress, rotate); + RenderUtil.applyTranslate(poseStack, dirs[0], dirs[2], progress * 180, SwordBeam.DIST * 1.15f); + RenderUtil.applyRotate(poseStack, dirs[0], dirs[1], (0.5f - progress) * 180, rotate); poseStack.scale(0.95f, 0.95f, 0.95f); renderQuad(poseStack.last().pose(), vertexConsumer1, color3.x(), color3.y(), color3.z(), alpha, halfWidth, halfHeight, 0f, 0f, 0.02f); @@ -128,8 +128,8 @@ public interface ISwordBeamBehavior { //边缘高光 poseStack.pushPose(); - this.applyTranslate(poseStack, dirs[0], dirs[2], progress + 0.05f, SwordBeam.DIST * 1.15f); - this.applyRotate(poseStack, dirs[0], dirs[1], progress + 0.05f, rotate); + 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++) { renderQuad(poseStack.last().pose(), vertexConsumer2, @@ -141,8 +141,8 @@ public interface ISwordBeamBehavior { //闪烁 poseStack.pushPose(); - this.applyTranslate(poseStack, dirs[0], dirs[2], progress + 0.25f, SwordBeam.DIST * 2.25f); - this.applyRotate(poseStack, dirs[0], dirs[1], progress + 0.25f, rotate); + RenderUtil.applyTranslate(poseStack, dirs[0], dirs[2], (progress + 0.25f) * 180, SwordBeam.DIST * 2.25f); + RenderUtil.applyRotate(poseStack, dirs[0], dirs[1], (0.5f - progress - 0.25f) * 180, rotate); poseStack.mulPose(Axis.ZP.rotationDegrees(45.0F)); poseStack.scale(1.0f, 1.0f, 1.0f); for(int i = 0;i < 20;i++) { @@ -152,34 +152,6 @@ public interface ISwordBeamBehavior { poseStack.popPose(); } - default void applyRotate(PoseStack poseStack, Vector3f dir, Vector3f up, double progress, double rotate) { - float angle = (float) ((0.5 - progress) * Math.PI); - Quaternionf rotation = new Quaternionf() - .fromAxisAngleRad(up, angle); - Quaternionf rotation2 = new Quaternionf() - .fromAxisAngleRad(dir, (float) Math.toRadians(Math.abs(dir.y) > 0.999 ? 0 : rotate)); - poseStack.mulPose(rotation); - poseStack.mulPose(rotation2); - - float[] xyRot = MathUtil.computeXYRot(dir, up); - poseStack.mulPose(Axis.YP.rotationDegrees(-xyRot[1])); - poseStack.mulPose(Axis.XP.rotationDegrees(xyRot[0])); - - poseStack.mulPose(Axis.XP.rotationDegrees(-90.0F)); - poseStack.mulPose(Axis.ZP.rotationDegrees(-90.0F)); - } - - default void applyTranslate(PoseStack poseStack, Vector3f dir, Vector3f right, float progress, float dist) { - float cos = (float) Math.cos(progress * Math.PI); - float sin = (float) Math.sin(progress * Math.PI); - Vector3f current = new Vector3f( - cos * right.x + sin * dir.x, - cos * right.y + sin * dir.y, - cos * right.z + sin * dir.z - ); - poseStack.translate(current.x * dist, current.y * dist, current.z * dist); - } - 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) { int ir = (int) (r * 255.0F); int ig = (int) (g * 255.0F); @@ -209,6 +181,7 @@ public interface ISwordBeamBehavior { if(beamData.contains("behavior")) beam.getEntityData().set(SwordBeam.BEHAVIOR, beamData.getString("behavior")); 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")); if(beamData.contains("color0R") && beamData.contains("color0G") && beamData.contains("color0B")) { beam.getEntityData().set(SwordBeam.COLOR0, new Vector3f(beamData.getFloat("color0R"), beamData.getFloat("color0G"), beamData.getFloat("color0B"))); } 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 d32f570..f57fdc4 100644 --- a/src/main/java/com/lzxnone/terraria/entity/beam/SwordBeam.java +++ b/src/main/java/com/lzxnone/terraria/entity/beam/SwordBeam.java @@ -40,6 +40,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 INFLATE = + SynchedEntityData.defineId(SwordBeam.class, EntityDataSerializers.FLOAT); public static final EntityDataAccessor AGE = SynchedEntityData.defineId(SwordBeam.class, EntityDataSerializers.INT); public static final EntityDataAccessor LIFETIME = @@ -147,18 +149,6 @@ public class SwordBeam extends Entity { Quaternionf rotation2 = new Quaternionf() .fromAxisAngleRad(up, angle); - - /*float xzLen = (float) Math.sqrt(current.x() * current.x() + current.z() * current.z()); - float pitch = (float) (Math.atan2(-current.y(), xzLen) * (180.0 / Math.PI)); - float yaw = (float) (Math.atan2(-current.x(), current.z()) * (180.0 / Math.PI)); - - Quaternionf rotation = new Quaternionf() - .fromAxisAngleRad(up, angle) - .rotateY((float) Math.toRadians(-yaw)) - .rotateX((float) Math.toRadians(pitch)) - .rotateX((float) Math.toRadians(-90.0)) - .rotateZ((float) Math.toRadians(-90.0));*/ - Vector3f axisX = new Vector3f(1, 0, 0).rotate(rotation).rotate(rotation2); Vector3f axisY = new Vector3f(0, 1, 0).rotate(rotation).rotate(rotation2); Vector3f axisZ = new Vector3f(0, 0, 1).rotate(rotation).rotate(rotation2); @@ -170,7 +160,7 @@ public class SwordBeam extends Entity { AABB hitBox = new AABB( centerX - extX, centerY - extY, centerZ - extZ, centerX + extX, centerY + extY, centerZ + extZ - ); + ).inflate(this.getEntityData().get(SwordBeam.INFLATE)); this.setBoundingBox(hitBox); List targets = this.level().getEntities(this, hitBox, FilterUtil.createTargetFilter(this, this.getOwner())); @@ -201,6 +191,7 @@ public class SwordBeam extends Entity { builder.define(BEHAVIOR, "default"); builder.define(ROTATE, 0); builder.define(RIGHT, false); + builder.define(INFLATE, 0.0f); builder.define(COLOR0, new Vector3f(1.0f, 1.0f, 1.0f)); builder.define(COLOR1, new Vector3f(1.0f, 1.0f, 1.0f)); builder.define(COLOR2, new Vector3f(1.0f, 1.0f, 1.0f)); @@ -216,6 +207,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.putFloat("inflate", this.entityData.get(INFLATE)); Vector3f c0 = this.entityData.get(COLOR0); tag.putFloat("color0R", c0.x); tag.putFloat("color0G", c0.y); @@ -243,6 +235,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("inflate")) this.entityData.set(INFLATE, tag.getFloat("inflate")); if(tag.contains("color0R")) { this.entityData.set(COLOR0, new Vector3f( tag.getFloat("color0R"), tag.getFloat("color0G"), tag.getFloat("color0B") diff --git a/src/main/java/com/lzxnone/terraria/entity/beam/SwordBeamBehaviors.java b/src/main/java/com/lzxnone/terraria/entity/beam/SwordBeamBehaviors.java index 1638630..4f7b081 100644 --- a/src/main/java/com/lzxnone/terraria/entity/beam/SwordBeamBehaviors.java +++ b/src/main/java/com/lzxnone/terraria/entity/beam/SwordBeamBehaviors.java @@ -1,7 +1,6 @@ package com.lzxnone.terraria.entity.beam; -import com.lzxnone.terraria.item.weapon.melee.TerraBlade; -import com.lzxnone.terraria.item.weapon.melee.TheHorsemansBlade; +import com.lzxnone.terraria.item.weapon.melee.*; import java.util.HashMap; import java.util.Map; @@ -12,11 +11,19 @@ public class SwordBeamBehaviors { public static final String DEFAULT = "default"; public static final String THE_HORSEMANS_BLADE = "the_horsemans_blade"; public static final String TERRA_BLADE = "terra_blade"; + public static final String TRUE_EXCALIBUR = "true_excalibur"; + public static final String TRUE_NIGHTS_EDGE = "true_nights_edge"; + public static final String EXCALIBUR = "excalibur"; + public static final String NIGHTS_EDGE = "nights_edge"; static { BEHAVIORS.put(DEFAULT, new ISwordBeamBehavior() {}); BEHAVIORS.put(THE_HORSEMANS_BLADE, TheHorsemansBlade.SWORD_BEAM_BEHAVIOR); BEHAVIORS.put(TERRA_BLADE, TerraBlade.SWORD_BEAM_BEHAVIOR); + BEHAVIORS.put(TRUE_EXCALIBUR, TrueExcalibur.SWORD_BEAM_BEHAVIOR); + BEHAVIORS.put(TRUE_NIGHTS_EDGE, TrueNightsEdge.SWORD_BEAM_BEHAVIOR); + BEHAVIORS.put(EXCALIBUR, Excalibur.SWORD_BEAM_BEHAVIOR); + BEHAVIORS.put(NIGHTS_EDGE, NightsEdge.SWORD_BEAM_BEHAVIOR); } public static ISwordBeamBehavior 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 c7116d2..12e8d26 100644 --- a/src/main/java/com/lzxnone/terraria/entity/summon/BeeSummon.java +++ b/src/main/java/com/lzxnone/terraria/entity/summon/BeeSummon.java @@ -1,6 +1,7 @@ package com.lzxnone.terraria.entity.summon; import com.lzxnone.terraria.Config; +import com.lzxnone.terraria.utils.DamageUtil; import com.lzxnone.terraria.utils.MathUtil; import net.minecraft.nbt.CompoundTag; import net.minecraft.server.level.ServerLevel; @@ -121,8 +122,13 @@ public class BeeSummon extends Bee { @Override public boolean doHurtTarget(Entity target) { if(owner == null) return false; - DamageSource damageSource = this.damageSources().mobAttack(owner); - boolean isHurt = target.hurt(damageSource, (float) Config.beeKeeperBeeDamage); + boolean isHurt; + if(owner instanceof Player player) { + isHurt = DamageUtil.attack(player, target, (float) Config.beeKeeperBeeDamage); + }else { + DamageSource damageSource = this.damageSources().mobAttack(owner); + isHurt = target.hurt(damageSource, (float) Config.beeKeeperBeeDamage); + } if(isHurt) { this.customAttackCount++; 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 d17c0d5..636308c 100644 --- a/src/main/java/com/lzxnone/terraria/entity/summon/StaticSummonBehaviors.java +++ b/src/main/java/com/lzxnone/terraria/entity/summon/StaticSummonBehaviors.java @@ -14,6 +14,9 @@ public class StaticSummonBehaviors { public static final String INFLUX_WAVER_BEAM = "influx_waver_beam"; public static final String MEOWMERE_PROJECTILE = "meowmere_projectile"; public static final String TERRA_BLADE_BEAM = "terra_blade_beam"; + public static final String TRUE_NIGHTS_EDGE_BEAM = "true_nights_edge_beam"; + public static final String NIGHTS_EDGE_BEAM = "nights_edge_beam"; + public static final String LIGHTS_BANE_SLASH = "lights_bane_slash"; static { BEHAVIORS.put(DEFAULT, new IStaticSummonBehavior() {}); @@ -22,6 +25,9 @@ public class StaticSummonBehaviors { BEHAVIORS.put(INFLUX_WAVER_BEAM, InfluxWaver.SUMMON_BEHAVIOR); BEHAVIORS.put(MEOWMERE_PROJECTILE, Meowmere.SUMMON_BEHAVIOR); BEHAVIORS.put(TERRA_BLADE_BEAM, TerraBlade.SUMMON_BEHAVIOR); + BEHAVIORS.put(TRUE_NIGHTS_EDGE_BEAM, TrueNightsEdge.SUMMON_BEHAVIOR); + BEHAVIORS.put(NIGHTS_EDGE_BEAM, NightsEdge.SUMMON_BEHAVIOR); + BEHAVIORS.put(LIGHTS_BANE_SLASH, LightsBane.SUMMON_BEHAVIOR); } public static IStaticSummonBehavior getBehavior(String id) { diff --git a/src/main/java/com/lzxnone/terraria/event_handler/InputHandler.java b/src/main/java/com/lzxnone/terraria/event_handler/InputHandler.java new file mode 100644 index 0000000..d6f10c4 --- /dev/null +++ b/src/main/java/com/lzxnone/terraria/event_handler/InputHandler.java @@ -0,0 +1,59 @@ +package com.lzxnone.terraria.event_handler; + +import com.lzxnone.terraria.Config; +import com.lzxnone.terraria.LzxnoneTerraria; +import com.lzxnone.terraria.item.weapon.melee.TrueCopperShortsword; +import com.lzxnone.terraria.item.weapon.melee.Zenith; +import com.lzxnone.terraria.network.payload.ZenithScrollPayload; +import net.minecraft.ChatFormatting; +import net.minecraft.client.Minecraft; +import net.minecraft.client.player.LocalPlayer; +import net.minecraft.core.component.DataComponents; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.MutableComponent; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.component.CustomData; +import net.neoforged.api.distmarker.Dist; +import net.neoforged.bus.api.SubscribeEvent; +import net.neoforged.fml.common.EventBusSubscriber; +import net.neoforged.neoforge.client.event.InputEvent; +import net.neoforged.neoforge.network.PacketDistributor; + +@EventBusSubscriber(modid = LzxnoneTerraria.MODID, value = Dist.CLIENT) +public class InputHandler { + @SubscribeEvent + public static void onMouseScroll(InputEvent.MouseScrollingEvent event) { + Minecraft mc = Minecraft.getInstance(); + LocalPlayer player = mc.player; + if(player == null) return; + + ItemStack mainHand = player.getMainHandItem(); + if(mainHand.getItem() instanceof Zenith || mainHand.getItem() instanceof TrueCopperShortsword) { + int count = mainHand.getOrDefault(DataComponents.CUSTOM_DATA, CustomData.EMPTY) + .copyTag().getInt("attackCount"); + double scrollDelta = event.getScrollDeltaY(); + if(scrollDelta != 0 && count > 0) { + event.setCanceled(true); + double deltaDist = mainHand.getOrDefault(DataComponents.CUSTOM_DATA, CustomData.EMPTY) + .copyTag().getDouble("deltaDist"); + + double finalDelta = deltaDist + scrollDelta * Config.zenithMouseSpeed; + + if(Config.zenithDistanceMode) { + if(finalDelta > Config.zenithMaxRange) finalDelta = Config.zenithMaxRange; + else if(finalDelta < -Config.zenithMaxRange) finalDelta = -Config.zenithMaxRange; + }else { + if(finalDelta > Config.zenithMaxRange) finalDelta = Config.zenithMaxRange; + else if(finalDelta < 0) finalDelta = 0; + } + + MutableComponent displayText = Component.empty(); + displayText.append(Component.literal(String.format("%s", Config.zenithDistanceMode ? "相对距离: " : "绝对距离: ")).withStyle(ChatFormatting.WHITE)) + .append(Component.literal(String.format("%.1f", finalDelta)).withStyle(ChatFormatting.GREEN, ChatFormatting.BOLD)); + player.displayClientMessage(displayText, true); + + PacketDistributor.sendToServer(new ZenithScrollPayload(scrollDelta)); + } + } + } +} diff --git a/src/main/java/com/lzxnone/terraria/item/ItemWaveBehaviors.java b/src/main/java/com/lzxnone/terraria/item/ItemWaveBehaviors.java index c174222..d99c526 100644 --- a/src/main/java/com/lzxnone/terraria/item/ItemWaveBehaviors.java +++ b/src/main/java/com/lzxnone/terraria/item/ItemWaveBehaviors.java @@ -1,8 +1,6 @@ package com.lzxnone.terraria.item; -import com.lzxnone.terraria.item.weapon.melee.BeeKeeper; -import com.lzxnone.terraria.item.weapon.melee.TerraBlade; -import com.lzxnone.terraria.item.weapon.melee.TheHorsemansBlade; +import com.lzxnone.terraria.item.weapon.melee.*; import java.util.HashMap; import java.util.Map; @@ -14,12 +12,24 @@ public class ItemWaveBehaviors { public static final String BEE_KEEPER = "bee_keeper"; public static final String THE_HORSEMANS_BLADE = "the_horsemans_blade"; public static final String TERRA_BLADE = "terra_blade"; + public static final String TRUE_EXCALIBUR = "true_excalibur"; + public static final String TRUE_NIGHTS_EDGE = "true_nights_edge"; + public static final String EXCALIBUR = "excalibur"; + public static final String NIGHTS_EDGE = "nights_edge"; + public static final String LIGHTS_BANE = "lights_bane"; + public static final String BLOOD_BUTCHERER = "blood_butcherer"; static { BEHAVIORS.put(DEFAULT, new IItemWaveBehavior() {}); BEHAVIORS.put(BEE_KEEPER, BeeKeeper.ITEM_WAVE_BEHAVIOR); BEHAVIORS.put(THE_HORSEMANS_BLADE, TheHorsemansBlade.ITEM_WAVE_BEHAVIOR); BEHAVIORS.put(TERRA_BLADE, TerraBlade.ITEM_WAVE_BEHAVIOR); + BEHAVIORS.put(TRUE_EXCALIBUR, TrueExcalibur.ITEM_WAVE_BEHAVIOR); + BEHAVIORS.put(TRUE_NIGHTS_EDGE, TrueNightsEdge.ITEM_WAVE_BEHAVIOR); + BEHAVIORS.put(EXCALIBUR, Excalibur.ITEM_WAVE_BEHAVIOR); + BEHAVIORS.put(NIGHTS_EDGE, NightsEdge.ITEM_WAVE_BEHAVIOR); + BEHAVIORS.put(LIGHTS_BANE, LightsBane.ITEM_WAVE_BEHAVIOR); + BEHAVIORS.put(BLOOD_BUTCHERER, BloodButcherer.ITEM_WAVE_BEHAVIOR); } public static IItemWaveBehavior getBehavior(String id) { diff --git a/src/main/java/com/lzxnone/terraria/item/weapon/melee/BloodButcherer.java b/src/main/java/com/lzxnone/terraria/item/weapon/melee/BloodButcherer.java index 8a2f1e8..8e62b69 100644 --- a/src/main/java/com/lzxnone/terraria/item/weapon/melee/BloodButcherer.java +++ b/src/main/java/com/lzxnone/terraria/item/weapon/melee/BloodButcherer.java @@ -1,25 +1,115 @@ package com.lzxnone.terraria.item.weapon.melee; +import com.lzxnone.terraria.Config; import com.lzxnone.terraria.LzxnoneTerraria; +import com.lzxnone.terraria.effect.ModEffects; +import com.lzxnone.terraria.item.IItemWaveBehavior; +import com.lzxnone.terraria.particle.ModParticles; +import com.lzxnone.terraria.utils.FilterUtil; +import com.lzxnone.terraria.utils.ParticleUtil; import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.effect.MobEffectInstance; +import net.minecraft.world.entity.Entity; 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.Item; +import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.SwordItem; import net.minecraft.world.item.Tiers; import net.minecraft.world.item.component.ItemAttributeModifiers; +import net.minecraft.world.phys.Vec3; +import net.neoforged.neoforge.event.entity.player.AttackEntityEvent; +import net.neoforged.neoforge.event.entity.player.PlayerInteractEvent; public class BloodButcherer extends SwordItem { public BloodButcherer() { super(Tiers.IRON, new Item.Properties().attributes(ItemAttributeModifiers.builder() .add(Attributes.ATTACK_DAMAGE, - new AttributeModifier(ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "base_attack_damage"), 4, AttributeModifier.Operation.ADD_VALUE), + new AttributeModifier(ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "base_attack_damage"), 3.5, AttributeModifier.Operation.ADD_VALUE), EquipmentSlotGroup.MAINHAND) .add(Attributes.ATTACK_SPEED, - new AttributeModifier(ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "base_attack_speed"), -2.4, AttributeModifier.Operation.ADD_VALUE), + new AttributeModifier(ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "base_attack_speed"), -1.5, AttributeModifier.Operation.ADD_VALUE), EquipmentSlotGroup.MAINHAND) .build() )); } + + public static final IItemWaveBehavior ITEM_WAVE_BEHAVIOR = new IItemWaveBehavior() { + @Override + public void onLeftClickAir(PlayerInteractEvent.LeftClickEmpty event) { + Player player = event.getEntity(); + if(player.level().isClientSide()) { + ItemStack itemStack = player.getMainHandItem(); + if(itemStack.isEmpty()) return; + Item item = itemStack.getItem(); + if(item instanceof BloodButcherer) { + ParticleUtil.addParticles( + player.level(), ModParticles.BLOOD_BUTCHERED_PARTICLE.get(), + player.getBoundingBox().getCenter(), 0.2, + new Vec3(0, 0, 0), 0.2, + 20 + ); + } + } + } + + @Override + public void onLeftClickBlock(PlayerInteractEvent.LeftClickBlock event) { + Player player = event.getEntity(); + if(player.level().isClientSide()) { + ItemStack itemStack = player.getMainHandItem(); + if(itemStack.isEmpty()) return; + Item item = itemStack.getItem(); + if(item instanceof BloodButcherer) { + ParticleUtil.addParticles( + player.level(), ModParticles.BLOOD_BUTCHERED_PARTICLE.get(), + player.getBoundingBox().getCenter(), 0.2, + new Vec3(0, 0, 0), 0.2, + 20 + ); + } + } + } + + @Override + public void onAttackEntity(AttackEntityEvent event) { + Player player = event.getEntity(); + ItemStack itemStack = player.getMainHandItem(); + if(itemStack.isEmpty()) return; + Item item = itemStack.getItem(); + if(item instanceof BloodButcherer) { + if(!player.level().isClientSide()) { + if(!player.getCooldowns().isOnCooldown(item)) { + Entity target = event.getTarget(); + if(target instanceof LivingEntity livingTarget && FilterUtil.createLivingTargetFilter(player).test(livingTarget)) { + int currentLevel = -1; + if(livingTarget.hasEffect(ModEffects.BLOOD_BUTCHERED)) { + MobEffectInstance instance = livingTarget.getEffect(ModEffects.BLOOD_BUTCHERED); + if(instance != null) { + currentLevel = instance.getAmplifier(); + } + } + if(currentLevel >= Config.bloodButchererMaxLevel) currentLevel = Config.bloodButchererMaxLevel - 1; + livingTarget.addEffect(new MobEffectInstance( + ModEffects.BLOOD_BUTCHERED, + Config.bloodButchererEffectDuration, + currentLevel + 1 + )); + } + player.getCooldowns().addCooldown(item, 7); + } + }else { + ParticleUtil.addParticles( + player.level(), ModParticles.BLOOD_BUTCHERED_PARTICLE.get(), + player.getBoundingBox().getCenter(), 0.2, + new Vec3(0, 0, 0), 0.2, + 20 + ); + } + } + } + }; } 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 c261d68..345bc36 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 @@ -9,10 +9,7 @@ import com.lzxnone.terraria.entity.projectile.StaticProjectileBehaviors; import com.lzxnone.terraria.entity.projectile.StaticProjectile; import com.lzxnone.terraria.item.ModItems; import com.lzxnone.terraria.particle.ModParticles; -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 com.lzxnone.terraria.utils.*; import net.minecraft.core.component.DataComponents; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.level.ServerLevel; @@ -66,19 +63,18 @@ public class EnchantedSword extends SwordItem { @Override public void onHitEntity(StaticProjectile projectile, EntityHitResult result) { if(!projectile.level().isClientSide()) { - if(result.getEntity() instanceof LivingEntity target) { - Entity owner = projectile.getOwner(); - if(owner == null) return; - if(!FilterUtil.createLivingTargetFilter(owner).test(target) || !(owner instanceof Player player)) return; - if(target.hurt(projectile.damageSources().playerAttack(player), (float) Config.enchantedSwordDamage)) { - target.invulnerableTime = 5; - ParticleUtil.addParticles( - (ServerLevel) projectile.level(), ModParticles.COLORFUL_PARTICLE, - projectile.position(), new Vec3(0.2, 0.2, 0.2), - 0.2, 25 - ); - onDied(projectile); - } + Entity target = result.getEntity(); + Entity owner = projectile.getOwner(); + if(owner == null) return; + if(!FilterUtil.createTargetFilter(owner).test(target) || !(owner instanceof Player player)) return; + if(DamageUtil.attack(player, target, (float) Config.enchantedSwordDamage)) { + target.invulnerableTime = 5; + ParticleUtil.addParticles( + (ServerLevel) projectile.level(), ModParticles.COLORFUL_PARTICLE, + projectile.position(), new Vec3(0.2, 0.2, 0.2), + 0.2, 25 + ); + onDied(projectile); } } } 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 0b0857e..6fdb597 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 @@ -1,25 +1,161 @@ package com.lzxnone.terraria.item.weapon.melee; +import com.lzxnone.terraria.Config; import com.lzxnone.terraria.LzxnoneTerraria; +import com.lzxnone.terraria.ModSounds; +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.IItemWaveBehavior; +import com.lzxnone.terraria.network.payload.SwordBeamPayload; +import com.lzxnone.terraria.particle.DustParticleOptions; +import com.lzxnone.terraria.particle.ModParticles; +import com.lzxnone.terraria.utils.DamageUtil; +import com.lzxnone.terraria.utils.FilterUtil; +import com.lzxnone.terraria.utils.ParticleUtil; +import com.lzxnone.terraria.utils.SoundUtil; +import net.minecraft.Util; +import net.minecraft.nbt.CompoundTag; 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.Entity; import net.minecraft.world.entity.EquipmentSlotGroup; 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.Item; +import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.SwordItem; import net.minecraft.world.item.Tiers; import net.minecraft.world.item.component.ItemAttributeModifiers; +import net.minecraft.world.level.Level; +import net.minecraft.world.phys.EntityHitResult; +import net.minecraft.world.phys.Vec3; +import net.neoforged.neoforge.event.entity.player.AttackEntityEvent; +import net.neoforged.neoforge.event.entity.player.PlayerInteractEvent; +import net.neoforged.neoforge.network.PacketDistributor; +import org.joml.Vector3f; public class Excalibur extends SwordItem { public Excalibur() { super(Tiers.DIAMOND, new Item.Properties().attributes(ItemAttributeModifiers.builder() .add(Attributes.ATTACK_DAMAGE, - new AttributeModifier(ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "base_attack_damage"), 10, AttributeModifier.Operation.ADD_VALUE), + new AttributeModifier(ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "base_attack_damage"), 7.0, AttributeModifier.Operation.ADD_VALUE), EquipmentSlotGroup.MAINHAND) .add(Attributes.ATTACK_SPEED, - new AttributeModifier(ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "base_attack_speed"), -2.4, AttributeModifier.Operation.ADD_VALUE), + new AttributeModifier(ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "base_attack_speed"), -1.0, AttributeModifier.Operation.ADD_VALUE), EquipmentSlotGroup.MAINHAND) .build() )); } + + 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); + tag.putFloat("color1R", 0.949f); + tag.putFloat("color1G", 0.863f); + tag.putFloat("color1B", 0.431f); + tag.putFloat("color2R", 0.898f); + tag.putFloat("color2G", 0.725f); + tag.putFloat("color2B", 0.484f); + + CompoundTag customData = new CompoundTag(); + customData.putInt("hitEntityCount", 0); + tag.put("customData", customData); + }); + + public static final DustParticleOptions PARTICLE = new DustParticleOptions( + 0.075f, 0.5f, 40, true, new Vector3f[]{ + new Vector3f(1.0F, 1.0F, 1.0F), + new Vector3f(1.0F, 0.9F, 0.0F) + } + ); + + public static final ISwordBeamBehavior SWORD_BEAM_BEHAVIOR = new ISwordBeamBehavior() { + @Override + public void onMoving(SwordBeam beam) { + if(beam.currentPosition == null) return; + ParticleUtil.addParticle( + beam.level(), PARTICLE, + beam.currentPosition, 0.2, + new Vec3(0, 0, 0), 0.2 + ); + } + + @Override + public void onHitEntity(SwordBeam beam, EntityHitResult result) { + if(!beam.level().isClientSide()) { + Entity target = result.getEntity(); + if(beam.getOwner() instanceof Player player && FilterUtil.createTargetFilter(player).test(target)) { + CompoundTag custom_data = beam.getEntityData().get(SwordBeam.CUSTOM_DATA); + if(custom_data.contains("hitEntityCount")) { + int count = custom_data.getInt("hitEntityCount"); + if(count < Config.excaliburMaxHitCount) { + if(DamageUtil.attack(player, target, (float) Config.excaliburDamage)) { + target.invulnerableTime = 20; + count++; + custom_data.putInt("hitEntityCount", count); + beam.getEntityData().set(SwordBeam.CUSTOM_DATA, custom_data); + ParticleUtil.addParticles( + (ServerLevel) target.level(), ModParticles.EXCALIBUR_HIT_PARTICLE.get(), + new Vec3(target.getX(), target.getY() + target.getBbHeight() / 2.0, target.getZ()), new Vec3(0, 0, 0), + 0, 1 + ); + } + } + } + } + } + } + + @Override + public void generate(Entity entity, CompoundTag beamData) { + beamData.putInt("rotate", (int) (Config.excaliburRotateRange * (Math.random() * 2 - 1))); + ISwordBeamBehavior.super.generate(entity, beamData); + } + }; + + public static final IItemWaveBehavior ITEM_WAVE_BEHAVIOR = new IItemWaveBehavior() { + public void onLeftClickAir(PlayerInteractEvent.LeftClickEmpty event) { + Player player = event.getEntity(); + ItemStack itemStack = player.getMainHandItem(); + if(itemStack.isEmpty()) return; + Item item = itemStack.getItem(); + if(item instanceof Excalibur && !player.getCooldowns().isOnCooldown(item)) { + PacketDistributor.sendToServer(new SwordBeamPayload("excalibur", BEAM_DATA)); + SoundUtil.playClientSound(player, ModSounds.WAVE.get()); + } + } + public void onAttackEntity(AttackEntityEvent event) { + Player player = event.getEntity(); + ItemStack itemStack = player.getMainHandItem(); + if(itemStack.isEmpty()) return; + Item item = itemStack.getItem(); + if(item instanceof Excalibur && !player.getCooldowns().isOnCooldown(item)) { + if(!player.level().isClientSide()) { + SwordBeamBehaviors.getBehavior("excalibur").generate(player, BEAM_DATA); + }else { + SoundUtil.playClientSound(player, ModSounds.WAVE.get()); + } + } + event.setCanceled(true); + } + }; + + @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()); + } + return InteractionResultHolder.sidedSuccess(stack, level.isClientSide()); + } } 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 405b8d0..71108e2 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 @@ -12,10 +12,7 @@ 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.ModParticles; -import com.lzxnone.terraria.utils.CollisionUtil; -import com.lzxnone.terraria.utils.FilterUtil; -import com.lzxnone.terraria.utils.MathUtil; -import com.lzxnone.terraria.utils.ParticleUtil; +import com.lzxnone.terraria.utils.*; import net.minecraft.nbt.CompoundTag; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.level.ServerLevel; @@ -151,9 +148,9 @@ public class InfluxWaver extends SwordItem { Entity hitTarget = entityHitResult.getEntity(); Entity target = customData.contains("target") ? summon.level().getEntity(customData.getInt("target")) : null; if(target != null && !hitTarget.getUUID().equals(target.getUUID())) return; - if(hitTarget instanceof LivingEntity livingEntity && summon.getOwner() instanceof Player player && FilterUtil.createLivingTargetFilter(player).test(livingEntity)) { - if(livingEntity.hurt(summon.damageSources().playerAttack(player), (float) Config.influxWaverDamage)) { - livingEntity.invulnerableTime = 2; + if(summon.getOwner() instanceof Player player && FilterUtil.createTargetFilter(player).test(hitTarget)) { + if(DamageUtil.attack(player, hitTarget, (float) Config.influxWaverDamage)) { + hitTarget.invulnerableTime = 2; } 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 a4c80ec..e2e988b 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 @@ -1,25 +1,213 @@ package com.lzxnone.terraria.item.weapon.melee; +import com.lzxnone.terraria.Config; import com.lzxnone.terraria.LzxnoneTerraria; +import com.lzxnone.terraria.entity.ModEntities; +import com.lzxnone.terraria.entity.beam.SwordBeam; +import com.lzxnone.terraria.entity.projectile.StaticProjectile; +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.IItemWaveBehavior; +import com.lzxnone.terraria.particle.DustParticleOptions; +import com.lzxnone.terraria.utils.DamageUtil; +import com.lzxnone.terraria.utils.FilterUtil; +import com.lzxnone.terraria.utils.ParticleUtil; +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.RenderType; +import net.minecraft.client.renderer.texture.OverlayTexture; +import net.minecraft.nbt.CompoundTag; import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.entity.Entity; 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.monster.Monster; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.entity.projectile.Projectile; import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.SwordItem; import net.minecraft.world.item.Tiers; import net.minecraft.world.item.component.ItemAttributeModifiers; +import net.minecraft.world.phys.AABB; +import net.minecraft.world.phys.Vec3; +import net.neoforged.neoforge.event.entity.player.AttackEntityEvent; +import org.joml.Matrix4f; +import org.joml.Vector3f; + +import java.util.Comparator; +import java.util.List; public class LightsBane extends SwordItem { public LightsBane() { super(Tiers.IRON, new Item.Properties().attributes(ItemAttributeModifiers.builder() .add(Attributes.ATTACK_DAMAGE, - new AttributeModifier(ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "base_attack_damage"), 4, AttributeModifier.Operation.ADD_VALUE), + new AttributeModifier(ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "base_attack_damage"), 3, AttributeModifier.Operation.ADD_VALUE), EquipmentSlotGroup.MAINHAND) .add(Attributes.ATTACK_SPEED, - new AttributeModifier(ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "base_attack_speed"), -2.4, AttributeModifier.Operation.ADD_VALUE), + new AttributeModifier(ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "base_attack_speed"), -1.0, AttributeModifier.Operation.ADD_VALUE), EquipmentSlotGroup.MAINHAND) .build() )); } + + public static final DustParticleOptions PARTICLE = new DustParticleOptions( + 0.075f, 0.5f, 40, true, new Vector3f[]{ + new Vector3f(0.463F, 0.196F, 0.918F), + new Vector3f(0.408F, 0.373F, 0.494F) + } + ); + + public static final float SCALE_SMALL = 0.025f; + public static final float SCALE_BIG = 0.05f; + public static final int HALF_WIDTH = 85; + public static final int HALF_HEIGHT = 27; + + public static final ResourceLocation[] RES = { + ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "textures/vfx/lights_bane_slash0.png"), + ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "textures/vfx/lights_bane_slash1.png"), + ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "textures/vfx/lights_bane_slash2.png"), + ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "textures/vfx/lights_bane_slash3.png"), + ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "textures/vfx/lights_bane_slash4.png"), + ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "textures/vfx/lights_bane_slash5.png"), + ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "textures/vfx/lights_bane_slash6.png"), + ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "textures/vfx/lights_bane_slash7.png"), + ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "textures/vfx/lights_bane_slash8.png"), + ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "textures/vfx/lights_bane_slash9.png"), + ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "textures/vfx/lights_bane_slash10.png"), + ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "textures/vfx/lights_bane_slash11.png"), + }; + + public static final IStaticSummonBehavior SUMMON_BEHAVIOR = new IStaticSummonBehavior() { + @Override + public void render(Entity entity, float entityYaw, float partialTick, + PoseStack poseStack, MultiBufferSource bufferSource, int packedLight) { + if(!(entity instanceof StaticSummon summon)) return; + + float lifeRatio = (summon.getEntityData().get(StaticSummon.AGE) + partialTick) / summon.getEntityData().get(StaticSummon.LIFETIME); + if(lifeRatio > 1.0f) return; + + int frame = Math.min((int) (lifeRatio * 12.0f), 11); + + poseStack.pushPose(); + poseStack.mulPose(Minecraft.getInstance().getEntityRenderDispatcher().cameraOrientation()); + + VertexConsumer consumer = bufferSource.getBuffer(RenderType.entityTranslucentEmissive(RES[frame])); + Matrix4f matrix = poseStack.last().pose(); + + CompoundTag customData = summon.getEntityData().get(StaticSummon.CUSTOM_DATA); + float scale; + if(customData.contains("big") && customData.getBoolean("big")) scale = SCALE_BIG; + else scale = SCALE_SMALL; + + poseStack.mulPose(Axis.ZP.rotationDegrees(summon.getEntityData().get(StaticSummon.RZP))); + + consumer.addVertex(matrix, -HALF_WIDTH * scale, -HALF_HEIGHT * scale, 0) + .setColor(255, 255, 255, 255).setUv(0.0f, 1.0f) + .setOverlay(OverlayTexture.NO_OVERLAY).setLight(LightTexture.FULL_BRIGHT).setNormal(0.0f, 1.0f, 0.0f); + consumer.addVertex(matrix, HALF_WIDTH * scale, -HALF_HEIGHT * scale, 0) + .setColor(255, 255, 255, 255).setUv(1.0f, 1.0f) + .setOverlay(OverlayTexture.NO_OVERLAY).setLight(LightTexture.FULL_BRIGHT).setNormal(0.0f, 1.0f, 0.0f); + consumer.addVertex(matrix, HALF_WIDTH * scale, HALF_HEIGHT * scale, 0) + .setColor(255, 255, 255, 255).setUv(1.0f, 0.0f) + .setOverlay(OverlayTexture.NO_OVERLAY).setLight(LightTexture.FULL_BRIGHT).setNormal(0.0f, 1.0f, 0.0f); + consumer.addVertex(matrix, -HALF_WIDTH * scale, HALF_HEIGHT * scale, 0) + .setColor(255, 255, 255, 255).setUv(0.0f, 0.0f) + .setOverlay(OverlayTexture.NO_OVERLAY).setLight(LightTexture.FULL_BRIGHT).setNormal(0.0f, 1.0f, 0.0f); + + poseStack.popPose(); + } + + @Override + public void tick(StaticSummon summon) { + //Vec3 center = summon.position().add(summon.getLookAngle().normalize().scale(SwordBeam.DIST)); + this.checkBeforeTick(summon); + Vec3 pos = summon.position(); + CompoundTag customData = summon.getEntityData().get(StaticSummon.CUSTOM_DATA); + float scale; + if(customData.contains("big") && customData.getBoolean("big")) scale = SCALE_BIG; + else scale = SCALE_SMALL; + float width = HALF_WIDTH * scale; + float height = HALF_HEIGHT * scale; + + summon.setBoundingBox(new AABB( + pos.x - height, pos.y - width, pos.z - height, + pos.x + height, pos.y + width, pos.z + height + )); + + if(!summon.level().isClientSide() && summon.getOwner() instanceof Player player) { + List targets = summon.level().getEntitiesOfClass(LivingEntity.class, summon.getBoundingBox(), FilterUtil.createTargetFilter(summon, summon.getOwner())); + for(LivingEntity target : targets) { + float damage = customData.contains("big") && customData.getBoolean("big") ? (float) Config.lightsBaneBigDamage : (float) Config.lightsBaneSmallDamage; + if(DamageUtil.attack(player, target, damage)) { + + } + } + } + } + }; + + public static final IItemWaveBehavior ITEM_WAVE_BEHAVIOR = new IItemWaveBehavior() { + @Override + public void onAttackEntity(AttackEntityEvent event) { + Player player = event.getEntity(); + ItemStack itemStack = player.getMainHandItem(); + if(itemStack.isEmpty()) return; + Item item = itemStack.getItem(); + if(item instanceof LightsBane) { + if(!player.level().isClientSide()) { + if(!player.getCooldowns().isOnCooldown(item)) { + Entity target = event.getTarget(); + Vec3 pos = target.position(); + AABB searchBox = new AABB( + pos.x - Config.lightsBaneTargetRange, pos.y - Config.lightsBaneTargetRange, pos.z - Config.lightsBaneTargetRange, + pos.x + Config.lightsBaneTargetRange, pos.y + Config.lightsBaneTargetRange, pos.z + Config.lightsBaneTargetRange + ); + List entities = target.level().getEntitiesOfClass( + Monster.class, + searchBox, + FilterUtil.createMonsterFilter(player) + ); + Monster summonTarget = null; + entities.sort(Comparator.comparingDouble(e -> e.distanceToSqr(pos))); + if(!entities.isEmpty()) summonTarget = entities.getFirst(); + if(summonTarget != null) { + StaticSummon summon = new StaticSummon(ModEntities.STATIC_SUMMON.get(), player.level()); + summon.setOwner(player); + summon.setPos(new Vec3(summonTarget.getX(), summonTarget.getY() + summonTarget.getBbHeight(), summonTarget.getZ())); + summon.getEntityData().set(StaticSummon.BEHAVIOR, StaticSummonBehaviors.LIGHTS_BANE_SLASH); + summon.getEntityData().set(StaticSummon.RENDER_MODE, "custom"); + summon.getEntityData().set(StaticSummon.RXP, -90); + summon.getEntityData().set(StaticSummon.RZP, -90); + summon.getEntityData().set(StaticSummon.GLOW, true); + summon.getEntityData().set(StaticSummon.LIFETIME, 10); + summon.setNoGravity(true); + summon.noPhysics = true; + + CompoundTag customData = new CompoundTag(); + customData.putBoolean("big", summon.getRandom().nextInt(5) == 0); + summon.getEntityData().set(StaticSummon.CUSTOM_DATA, customData); + + target.level().addFreshEntity(summon); + player.getCooldowns().addCooldown(item, 5); + } + } + }else { + ParticleUtil.addParticles( + player.level(), PARTICLE, + player.position(), 0.2, + new Vec3(0, 0, 0), 0.2, + 5 + ); + } + } + } + }; } 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 48ceb1e..f9905e8 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 @@ -146,8 +146,8 @@ public class Meowmere extends SwordItem { EntityHitResult entityHitResult = CollisionUtil.checkEntityHit(summon, summon.position().add(motion)); if(entityHitResult != null) { Entity target = entityHitResult.getEntity(); - if(summon.getOwner() instanceof Player player && target instanceof LivingEntity livingEntity) { - if(livingEntity.hurt(summon.damageSources().playerAttack(player), (float) Config.meowmereDamage)) { + if(summon.getOwner() instanceof Player player) { + if(DamageUtil.attack(player, target, (float) Config.meowmereDamage)) { if(customData.contains("hitEntity") && customData.getInt("hitEntity") < 4) { customData.putInt("hitEntity", customData.getInt("hitEntity") + 1); summon.getEntityData().set(StaticSummon.CUSTOM_DATA, customData); @@ -155,7 +155,7 @@ public class Meowmere extends SwordItem { onDied(summon); return; } - livingEntity.invulnerableTime = 2; + target.invulnerableTime = 2; } } return; 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 02168bf..2fbcfda 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 @@ -1,25 +1,477 @@ package com.lzxnone.terraria.item.weapon.melee; +import com.lzxnone.terraria.Config; import com.lzxnone.terraria.LzxnoneTerraria; +import com.lzxnone.terraria.ModSounds; +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.entity.summon.IStaticSummonBehavior; +import com.lzxnone.terraria.entity.summon.StaticSummon; +import com.lzxnone.terraria.entity.summon.StaticSummonBehaviors; +import com.lzxnone.terraria.item.IItemWaveBehavior; +import com.lzxnone.terraria.network.payload.SwordBeamPayload; +import com.lzxnone.terraria.particle.DustParticleOptions; +import com.lzxnone.terraria.particle.ModParticles; +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.Util; +import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.client.renderer.RenderType; +import net.minecraft.nbt.CompoundTag; 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.Entity; 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.Item; +import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.SwordItem; import net.minecraft.world.item.Tiers; import net.minecraft.world.item.component.ItemAttributeModifiers; +import net.minecraft.world.level.ClipContext; +import net.minecraft.world.level.Level; +import net.minecraft.world.phys.*; +import net.neoforged.neoforge.event.entity.player.AttackEntityEvent; +import net.neoforged.neoforge.event.entity.player.PlayerInteractEvent; +import net.neoforged.neoforge.network.PacketDistributor; +import org.joml.Quaternionf; +import org.joml.Vector3f; + +import java.util.List; public class NightsEdge extends SwordItem { public NightsEdge() { super(Tiers.DIAMOND, new Item.Properties().attributes(ItemAttributeModifiers.builder() .add(Attributes.ATTACK_DAMAGE, - new AttributeModifier(ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "base_attack_damage"), 9, AttributeModifier.Operation.ADD_VALUE), + new AttributeModifier(ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "base_attack_damage"), 6.0, AttributeModifier.Operation.ADD_VALUE), EquipmentSlotGroup.MAINHAND) .add(Attributes.ATTACK_SPEED, - new AttributeModifier(ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "base_attack_speed"), -2.6, AttributeModifier.Operation.ADD_VALUE), + new AttributeModifier(ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "base_attack_speed"), -1.5, AttributeModifier.Operation.ADD_VALUE), EquipmentSlotGroup.MAINHAND) .build() )); } + + 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); + tag.putFloat("color1R", 0.278f); + tag.putFloat("color1G", 0.141f); + tag.putFloat("color1B", 0.588f); + tag.putFloat("color2R", 0.325f); + tag.putFloat("color2G", 0.212f); + tag.putFloat("color2B", 0.553f); + + CompoundTag customData = new CompoundTag(); + customData.putInt("hitEntityCount", 0); + tag.put("customData", customData); + }); + + public static final DustParticleOptions PARTICLE = new DustParticleOptions( + 0.075f, 0.5f, 40, true, new Vector3f[]{ + new Vector3f(0.463F, 0.196F, 0.918F), + new Vector3f(0.408F, 0.373F, 0.494F) + } + ); + + public static final ISwordBeamBehavior SWORD_BEAM_BEHAVIOR = new ISwordBeamBehavior() { + @Override + public void render(Entity entity, float entityYaw, float partialTick, + PoseStack poseStack, MultiBufferSource bufferSource, int packedLight) { + if (!(entity instanceof SwordBeam beam)) 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; + + Vector3f[] dirs = MathUtil.computeCoordinateSystem(beam.getOwner()); + dirs = MathUtil.rotateCoordinateSystem(dirs[0], dirs[2], beam.getEntityData().get(SwordBeam.ROTATE)); + float rotate = beam.getEntityData().get(SwordBeam.ROTATE); + + Vector3f color0 = entity.getEntityData().get(SwordBeam.COLOR0); + Vector3f color1 = entity.getEntityData().get(SwordBeam.COLOR1); + Vector3f color2 = entity.getEntityData().get(SwordBeam.COLOR2); + Vector3f color3 = entity.getEntityData().get(SwordBeam.COLOR3); + 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); + } else { + alpha = 1.0f; + } + if (beam.getEntityData().get(SwordBeam.RIGHT)) progress = 1.0f - progress; + + float halfWidth = SwordBeam.HALF_WIDTH * SwordBeam.SCALE; + float halfHeight = SwordBeam.HALF_HEIGHT * SwordBeam.SCALE; + + VertexConsumer vertexConsumer0 = bufferSource.getBuffer(RenderType.entityTranslucentEmissive(RES0)); + + //左边 + poseStack.pushPose(); + RenderUtil.applyTranslate(poseStack, dirs[0], dirs[2], (progress - 0.1f * (1.0f - progress)) * 180, SwordBeam.DIST); + RenderUtil.applyRotate(poseStack, dirs[0], dirs[1], (0.5f - (progress - 0.1f * (1.0f - progress))) * 180, rotate); + renderQuad(poseStack.last().pose(), vertexConsumer0, + color0.x(), color0.y(), color0.z(), alpha, halfWidth, halfHeight, 0f, 0, -0.01f); + poseStack.popPose(); + + //右边 + poseStack.pushPose(); + RenderUtil.applyTranslate(poseStack, dirs[0], dirs[2], (progress + 0.1f) * 180, SwordBeam.DIST); + RenderUtil.applyRotate(poseStack, dirs[0], dirs[1], (0.5f - (progress + 0.05f)) * 180, rotate); + renderQuad(poseStack.last().pose(), vertexConsumer0, + color2.x(), color2.y(), color2.z(), alpha, halfWidth, halfHeight, 0f, 0, -0.02f); + poseStack.popPose(); + + //中间 + poseStack.pushPose(); + RenderUtil.applyTranslate(poseStack, dirs[0], dirs[2], progress * 180, SwordBeam.DIST); + RenderUtil.applyRotate(poseStack, dirs[0], dirs[1], (0.5f - progress) * 180, rotate); + renderQuad(poseStack.last().pose(), vertexConsumer0, + color1.x(), color1.y(), color1.z(), alpha, halfWidth, halfHeight, 0f, 0f, 0f); + poseStack.popPose(); + + VertexConsumer vertexConsumer1 = bufferSource.getBuffer(RenderType.entityTranslucentEmissive(RES3)); + + //外线 + poseStack.pushPose(); + RenderUtil.applyTranslate(poseStack, dirs[0], dirs[2], progress * 180, SwordBeam.DIST * 1.15f); + RenderUtil.applyRotate(poseStack, dirs[0], dirs[1], (0.5f - progress) * 180, rotate); + poseStack.scale(0.95f, 0.95f, 0.95f); + renderQuad(poseStack.last().pose(), vertexConsumer1, + color3.x(), color3.y(), color3.z(), alpha, halfWidth, halfHeight, 0f, 0f, 0.02f); + poseStack.popPose(); + + VertexConsumer vertexConsumer2 = bufferSource.getBuffer(RenderType.entityTranslucentEmissive(RES5)); + + //闪烁 + poseStack.pushPose(); + RenderUtil.applyTranslate(poseStack, dirs[0], dirs[2], (progress + 0.25f) * 180, SwordBeam.DIST * 2.25f); + RenderUtil.applyRotate(poseStack, dirs[0], dirs[1], (0.5f - progress - 0.25f) * 180, rotate); + poseStack.mulPose(Axis.ZP.rotationDegrees(45.0F)); + poseStack.scale(1.0f, 1.0f, 1.0f); + for (int i = 0; i < 20; i++) { + renderQuad(poseStack.last().pose(), vertexConsumer2, + color1.x(), color1.y(), color1.z(), alpha, 32 * SwordBeam.SCALE, 32 * SwordBeam.SCALE, 0f, 0f, 0.03f); + } + poseStack.popPose(); + } + + @Override + public void onMoving(SwordBeam beam) { + if(beam.currentPosition == null) return; + ParticleUtil.addParticle( + beam.level(), PARTICLE, + beam.currentPosition, 0.2, + new Vec3(0, 0, 0), 0.2 + ); + } + + @Override + public void onHitEntity(SwordBeam beam, EntityHitResult result) { + if(!beam.level().isClientSide()) { + Entity target = result.getEntity(); + if(beam.getOwner() instanceof Player player && FilterUtil.createTargetFilter(player).test(target)) { + CompoundTag custom_data = beam.getEntityData().get(SwordBeam.CUSTOM_DATA); + if(custom_data.contains("hitEntityCount")) { + int count = custom_data.getInt("hitEntityCount"); + if(count < Config.nightsEdgeMaxHitCount) { + if(DamageUtil.attack(player, target, (float) Config.nightsEdgeDamage)) { + 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), + 0, 1 + ); + target.invulnerableTime = 20; + count++; + custom_data.putInt("hitEntityCount", count); + beam.getEntityData().set(SwordBeam.CUSTOM_DATA, custom_data); + } + } + } + } + } + } + + @Override + public void generate(Entity entity, CompoundTag beamData) { + int randomAngle = (int) (Config.nightsEdgeRotateRange * (Math.random() * 2 - 1)); + beamData.putInt("rotate", randomAngle); + ISwordBeamBehavior.super.generate(entity, beamData); + 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 + public void render(Entity entity, float entityYaw, float partialTick, + PoseStack poseStack, MultiBufferSource bufferSource, int packedLight) { + if(!(entity instanceof StaticSummon summon)) return; + + float halfWidth = SwordBeam.HALF_WIDTH * SwordBeam.SCALE; + float halfHeight = SwordBeam.HALF_HEIGHT * SwordBeam.SCALE; + + 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); + }else { + alpha = 1.0f; + } + + if(alpha < 0.01f) return; + + CompoundTag customData = summon.getEntityData().get(StaticSummon.CUSTOM_DATA); + + Vector3f dir = new Vector3f(); + if (customData.contains("dirX")) dir.x = customData.getFloat("dirX"); + if (customData.contains("dirY")) dir.y = customData.getFloat("dirY"); + if (customData.contains("dirZ")) dir.z = customData.getFloat("dirZ"); + Vector3f up = new Vector3f(); + if (customData.contains("upX")) up.x = customData.getFloat("upX"); + if (customData.contains("upY")) up.y = customData.getFloat("upY"); + if (customData.contains("upZ")) up.z = customData.getFloat("upZ"); + Vector3f right = new Vector3f(); + if (customData.contains("rightX")) right.x = customData.getFloat("rightX"); + if (customData.contains("rightY")) right.y = customData.getFloat("rightY"); + if (customData.contains("rightZ")) right.z = customData.getFloat("rightZ"); + + Vector3f[] dirs = new Vector3f[]{dir, up, right}; + double rotate = summon.getEntityData().get(StaticSummon.RZP); + double rotateSpeed = summon.getEntityData().get(StaticSummon.RZPS); + float rotateAngle = (float) ((summon.getEntityData().get(StaticSummon.AGE) + partialTick) * rotateSpeed); + + Quaternionf rotation = new Quaternionf().fromAxisAngleRad( + up, (float) Math.toRadians(-rotateAngle) + ); + poseStack.mulPose(rotation); + + VertexConsumer vertexConsumer0 = bufferSource.getBuffer(RenderType.entityTranslucentEmissive(RES0)); + + //外层(亮) + poseStack.pushPose(); + poseStack.mulPose(rotation); + RenderUtil.applyTranslate(poseStack, dirs[0], dirs[2], 90, SwordBeam.DIST); + RenderUtil.applyRotate(poseStack, dirs[0], dirs[1], 0, rotate); + //poseStack.scale(1.0f + progress, 1.0f + progress, 1.0f + progress); + RenderUtil.renderQuad(poseStack.last().pose(), vertexConsumer0, + COLOR0.x(), COLOR0.y(), COLOR0.z(), alpha, halfWidth, halfHeight, 0f, 0f, 0f); + poseStack.popPose(); + + VertexConsumer vertexConsumer1 = bufferSource.getBuffer(RenderType.entityTranslucentEmissive(RES1)); + + //外线 + poseStack.pushPose(); + poseStack.mulPose(rotation); + RenderUtil.applyTranslate(poseStack, dirs[0], dirs[2], 90, SwordBeam.DIST * 1.15f); + RenderUtil.applyRotate(poseStack, dirs[0], dirs[1], 0, rotate); + //poseStack.scale(0.95f * (1 + progress), 0.95f * (1 + progress), 0.95f * (1 + progress)); + RenderUtil.renderQuad(poseStack.last().pose(), vertexConsumer1, + 1.0f, 1.0f, 1.0f, alpha, halfWidth, halfHeight, 0f, 0f, 0.02f); + poseStack.popPose(); + + VertexConsumer vertexConsumer2 = bufferSource.getBuffer(RenderType.entityTranslucentEmissive(RES2)); + + //闪烁 + poseStack.pushPose(); + poseStack.mulPose(rotation); + RenderUtil.applyTranslate(poseStack, dirs[0], dirs[2], 135, SwordBeam.DIST * 2.25f); + RenderUtil.applyRotate(poseStack, dirs[0], dirs[1], 0, rotate); + //poseStack.scale(1.0f + progress, 1.0f + progress, 1.0f + progress); + RenderUtil.renderQuad(poseStack.last().pose(), vertexConsumer2, + COLOR0.x(), COLOR0.y(), COLOR0.z(), alpha, 32 * SwordBeam.SCALE, 32 * SwordBeam.SCALE, 0f, 0f, 0.04f); + poseStack.popPose(); + + } + + @Override + public void tick(StaticSummon summon) { + this.checkBeforeTick(summon); + CompoundTag customData = summon.getEntityData().get(StaticSummon.CUSTOM_DATA); + + //碰撞箱计算 + Vec3 center = summon.position().add(summon.getLookAngle().normalize().scale(SwordBeam.DIST)); + if(customData.contains("extX") && customData.contains("extY") && customData.contains("extZ")) { + summon.setBoundingBox(new AABB( + center.x - customData.getFloat("extX"), center.y - customData.getFloat("extY"), center.z - customData.getFloat("extZ"), + center.x + customData.getFloat("extX"), center.y + customData.getFloat("extY"), center.z + customData.getFloat("extZ") + )); + } + + //碰撞计算 + if(!summon.level().isClientSide() && customData.contains("hitCount") && summon.getOwner() instanceof Player player) { + int count = customData.getInt("hitCount"); + if(count < Config.nightsEdgeProjectileMaxHitCount) { + List targets = summon.level().getEntitiesOfClass(LivingEntity.class, summon.getBoundingBox(), FilterUtil.createTargetFilter(summon, summon.getOwner())); + for(LivingEntity target : targets) { + if(count >= Config.nightsEdgeProjectileMaxHitCount) break; + if(DamageUtil.attack(player, target, (float) Config.nightsEdgeProjectileDamage)) { + count++; + 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), + 0, 1 + ); + target.invulnerableTime = 20; + } + } + if(!targets.isEmpty()) customData.putInt("hitCount", count); + } + if(count >= Config.nightsEdgeProjectileMaxHitCount) this.onDied(summon); + } + + ClipContext context = new ClipContext( + summon.position(), + summon.position().add(summon.getDeltaMovement()), + ClipContext.Block.COLLIDER, + ClipContext.Fluid.NONE, + summon + ); + BlockHitResult blockHit = summon.level().clip(context); + if(blockHit.getType() != HitResult.Type.MISS) { + + } + + //粒子 + if(summon.level().isClientSide()) { + ParticleUtil.addParticle( + summon.level(), PARTICLE, + summon.position(), 2.5, + new Vec3(0, 0, 0), 0.5 + ); + } + } + }; + + public static void summon(Player player, int randomAngle) { + StaticSummon summon = new StaticSummon(ModEntities.STATIC_SUMMON.get(), player.level()); + summon.setOwner(player); + Vec3 pos = new Vec3(player.getX(), player.getEyeY() - 0.1, player.getZ()); + summon.setPos(pos); + + if(!Config.nightsEdgeProjectileAlignToBlade) randomAngle = (int) (Config.nightsEdgeProjectileRotateRange * (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]); + summon.setXRot(xyRot[0]); + summon.xRotO = xyRot[0]; + summon.setYRot(xyRot[1]); + summon.yRotO = xyRot[1]; + + summon.getEntityData().set(StaticSummon.BEHAVIOR, StaticSummonBehaviors.NIGHTS_EDGE_BEAM); + summon.getEntityData().set(StaticSummon.RENDER_MODE, "custom"); + summon.getEntityData().set(StaticSummon.LIFETIME, Config.nightsEdgeProjectileLifetime); + summon.getEntityData().set(StaticSummon.RZP, randomAngle); + summon.getEntityData().set(StaticSummon.RZPS, Config.nightsEdgeProjectileRotationSpeed); + summon.getEntityData().set(StaticSummon.GLOW, true); + summon.setNoGravity(true); + summon.noPhysics = true; + + CompoundTag customData = new CompoundTag(); + + Quaternionf rotation = new Quaternionf() + .fromAxisAngleRad(dirs[0], (float) Math.toRadians(Math.abs(dirs[0].y) > 0.999 ? 0 : randomAngle)) + .rotateY((float) Math.toRadians(-xyRot[1])) + .rotateX((float) Math.toRadians(xyRot[0])) + .rotateX((float) Math.toRadians(-90.0)) + .rotateZ((float) Math.toRadians(-90.0)); + + Vector3f axisX = new Vector3f(1, 0, 0).rotate(rotation); + Vector3f axisY = new Vector3f(0, 1, 0).rotate(rotation); + Vector3f axisZ = new Vector3f(0, 0, 1).rotate(rotation); + + float extX = SwordBeam.HALF_WIDTH * SwordBeam.SCALE * Math.abs(axisX.x()) + SwordBeam.HALF_HEIGHT * SwordBeam.SCALE * Math.abs(axisY.x()) + SwordBeam.HALF_THICKNESS * SwordBeam.SCALE * Math.abs(axisZ.x()); + float extY = SwordBeam.HALF_WIDTH * SwordBeam.SCALE * Math.abs(axisX.y()) + SwordBeam.HALF_HEIGHT * SwordBeam.SCALE * Math.abs(axisY.y()) + SwordBeam.HALF_THICKNESS * SwordBeam.SCALE * Math.abs(axisZ.y()); + float extZ = SwordBeam.HALF_WIDTH * SwordBeam.SCALE * Math.abs(axisX.z()) + SwordBeam.HALF_HEIGHT * SwordBeam.SCALE * Math.abs(axisY.z()) + SwordBeam.HALF_THICKNESS * SwordBeam.SCALE * Math.abs(axisZ.z()); + + customData.putInt("hitCount", 0); + customData.putFloat("extX", extX); + customData.putFloat("extY", extY); + customData.putFloat("extZ", extZ); + customData.putFloat("dirX", dirs[0].x); + customData.putFloat("dirY", dirs[0].y); + customData.putFloat("dirZ", dirs[0].z); + customData.putFloat("upX", dirs[1].x); + customData.putFloat("upY", dirs[1].y); + customData.putFloat("upZ", dirs[1].z); + customData.putFloat("rightX", dirs[2].x); + customData.putFloat("rightY", dirs[2].y); + customData.putFloat("rightZ", dirs[2].z); + summon.getEntityData().set(StaticSummon.CUSTOM_DATA, customData); + + summon.setDeltaMovement(player.getLookAngle().normalize().scale(Config.nightsEdgeProjectileSpeed)); + + player.level().addFreshEntity(summon); + } + + public static final IItemWaveBehavior ITEM_WAVE_BEHAVIOR = new IItemWaveBehavior() { + public void onLeftClickAir(PlayerInteractEvent.LeftClickEmpty event) { + Player player = event.getEntity(); + ItemStack itemStack = player.getMainHandItem(); + if(itemStack.isEmpty()) return; + Item item = itemStack.getItem(); + if(item instanceof NightsEdge && !player.getCooldowns().isOnCooldown(item)) { + PacketDistributor.sendToServer(new SwordBeamPayload("nights_edge", BEAM_DATA)); + SoundUtil.playClientSound(player, ModSounds.WAVE.get()); + } + } + public void onAttackEntity(AttackEntityEvent event) { + Player player = event.getEntity(); + ItemStack itemStack = player.getMainHandItem(); + if(itemStack.isEmpty()) return; + Item item = itemStack.getItem(); + if(item instanceof NightsEdge && !player.getCooldowns().isOnCooldown(item)) { + if(!player.level().isClientSide()) { + SwordBeamBehaviors.getBehavior("nights_edge").generate(player, BEAM_DATA); + }else { + SoundUtil.playClientSound(player, ModSounds.WAVE.get()); + } + } + event.setCanceled(true); + } + }; + + @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()); + SoundUtil.playClientSound(player, ModSounds.WAVE3.get()); + } + return InteractionResultHolder.sidedSuccess(stack, level.isClientSide()); + } + } 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 cda1684..919ac05 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 @@ -60,9 +60,9 @@ public class Seedler extends SwordItem { EntityHitResult entityHitResult = CollisionUtil.checkEntityHit(summon, summon.position().add(motion)); if(entityHitResult != null) { Entity target = entityHitResult.getEntity(); - if(summon.getOwner() instanceof Player player && target instanceof LivingEntity livingEntity) { - if(livingEntity.hurt(summon.damageSources().playerAttack(player), (float) Config.seedlerThornDamage)) { - livingEntity.invulnerableTime = 2; + if(summon.getOwner() instanceof Player player) { + if(DamageUtil.attack(player, target, (float) Config.seedlerThornDamage)) { + target.invulnerableTime = 2; } } onDied(summon); @@ -173,14 +173,13 @@ public class Seedler extends SwordItem { @Override public void onHitEntity(StaticProjectile projectile, EntityHitResult result) { if(!projectile.level().isClientSide()) { - if(result.getEntity() instanceof LivingEntity target) { - Entity owner = projectile.getOwner(); - if(owner == null) return; - if(!FilterUtil.createLivingTargetFilter(owner).test(target) || !(owner instanceof Player player)) return; - if(target.hurt(projectile.damageSources().playerAttack(player), (float) Config.seedlerThornDamage)) { - target.invulnerableTime = 2; - onDied(projectile); - } + Entity target = result.getEntity(); + Entity owner = projectile.getOwner(); + if(owner == null) return; + if(!FilterUtil.createTargetFilter(owner).test(target) || !(owner instanceof Player player)) return; + if(DamageUtil.attack(player, target, (float) Config.seedlerThornDamage)) { + target.invulnerableTime = 2; + 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 e98e25f..1835d42 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 @@ -82,12 +82,11 @@ public class StarWrath extends SwordItem { @Override public void onHitEntity(StaticProjectile projectile, EntityHitResult result) { if(!projectile.level().isClientSide()) { - if(result.getEntity() instanceof LivingEntity target) { - Entity owner = projectile.getOwner(); - if(!FilterUtil.createLivingTargetFilter(owner).test(target) || !(owner instanceof Player player)) return; - if(target.hurt(projectile.damageSources().playerAttack(player), (float) Config.starWrathDamage)) { - target.invulnerableTime = 2; - } + Entity target = result.getEntity(); + Entity owner = projectile.getOwner(); + if(!FilterUtil.createTargetFilter(owner).test(target) || !(owner instanceof Player player)) return; + if(DamageUtil.attack(player, target, (float) Config.starWrathDamage)) { + target.invulnerableTime = 2; } } } 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 33853fe..52e41a2 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 @@ -61,13 +61,12 @@ public class Starfury extends SwordItem { @Override public void onHitEntity(StaticProjectile projectile, EntityHitResult result) { if(!projectile.level().isClientSide()) { - if(result.getEntity() instanceof LivingEntity target) { - Entity owner = projectile.getOwner(); - if(owner == null) return; - if(!FilterUtil.createLivingTargetFilter(owner).test(target) || !(owner instanceof Player player)) return; - if(target.hurt(projectile.damageSources().playerAttack(player), (float) Config.starfuryDamage)) { - target.invulnerableTime = 5; - } + Entity target = result.getEntity(); + Entity owner = projectile.getOwner(); + if(owner == null) return; + if(!FilterUtil.createTargetFilter(owner).test(target) || !(owner instanceof Player player)) return; + if(DamageUtil.attack(player, target, (float) Config.starfuryDamage)) { + target.invulnerableTime = 5; } } } 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 8503d61..6cadb79 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 @@ -106,12 +106,13 @@ public class TerraBlade extends SwordItem { @Override public void onHitEntity(SwordBeam beam, EntityHitResult result) { if(!beam.level().isClientSide()) { - if(result.getEntity() instanceof LivingEntity target && beam.getOwner() instanceof Player player && FilterUtil.createLivingTargetFilter(player).test(target)) { + Entity target = result.getEntity(); + if(beam.getOwner() instanceof Player player && FilterUtil.createTargetFilter(player).test(target)) { CompoundTag custom_data = beam.getEntityData().get(SwordBeam.CUSTOM_DATA); if(custom_data.contains("hitEntityCount")) { int count = custom_data.getInt("hitEntityCount"); if(count < Config.terraBladeMaxHitCount) { - if(target.hurt(beam.level().damageSources().playerAttack(player), (float) Config.terraBladeDamage)) { + if(DamageUtil.attack(player, target, (float) Config.terraBladeDamage)) { target.invulnerableTime = 20; count++; custom_data.putInt("hitEntityCount", count); @@ -125,7 +126,6 @@ public class TerraBlade extends SwordItem { @Override public void generate(Entity entity, CompoundTag beamData) { - //beamData.putBoolean("right", entity.getRandom().nextInt(2) == 0); int randomAngle = (int) (Config.terraBladeRotateRange * (Math.random() * 2 - 1)); beamData.putInt("rotate", randomAngle); ISwordBeamBehavior.super.generate(entity, beamData); @@ -194,26 +194,26 @@ public class TerraBlade extends SwordItem { //左边 poseStack.pushPose(); - this.applyTranslate(poseStack, dirs[0], dirs[2], 90 - 18 * (1.0f - progress), SwordBeam.DIST); - this.applyRotate(poseStack, dirs[0], dirs[1], 18 * (1.0f - progress), rotate); - renderQuad(poseStack.last().pose(), vertexConsumer0, + RenderUtil.applyTranslate(poseStack, dirs[0], dirs[2], 90 - 18 * (1.0f - progress), SwordBeam.DIST); + RenderUtil.applyRotate(poseStack, dirs[0], dirs[1], 18 * (1.0f - progress), rotate); + RenderUtil.renderQuad(poseStack.last().pose(), vertexConsumer0, COLOR0.x(), COLOR0.y(), COLOR0.z(), alpha, halfWidth, halfHeight, 0f, 0, -0.01f); poseStack.popPose(); //中间 poseStack.pushPose(); - this.applyTranslate(poseStack, dirs[0], dirs[2], 90, SwordBeam.DIST); - this.applyRotate(poseStack, dirs[0], dirs[1], 0, rotate); - renderQuad(poseStack.last().pose(), vertexConsumer0, + RenderUtil.applyTranslate(poseStack, dirs[0], dirs[2], 90, SwordBeam.DIST); + RenderUtil.applyRotate(poseStack, dirs[0], dirs[1], 0, rotate); + RenderUtil.renderQuad(poseStack.last().pose(), vertexConsumer0, COLOR1.x(), COLOR1.y(), COLOR1.z(), alpha, halfWidth, halfHeight, 0f, 0f, 0f); poseStack.popPose(); //右边 poseStack.pushPose(); - this.applyTranslate(poseStack, dirs[0], dirs[2], 108, SwordBeam.DIST); - this.applyRotate(poseStack, dirs[0], dirs[1], -9 * (1.0f - progress), rotate); - renderQuad(poseStack.last().pose(), vertexConsumer0, + RenderUtil.applyTranslate(poseStack, dirs[0], dirs[2], 108, SwordBeam.DIST); + RenderUtil.applyRotate(poseStack, dirs[0], dirs[1], -9 * (1.0f - progress), rotate); + RenderUtil.renderQuad(poseStack.last().pose(), vertexConsumer0, COLOR2.x(), COLOR2.y(), COLOR2.z(), alpha, halfWidth, halfHeight, 0f, 0, 0.01f); poseStack.popPose(); @@ -221,26 +221,26 @@ public class TerraBlade extends SwordItem { //三线 poseStack.pushPose(); - this.applyTranslate(poseStack, dirs[0], dirs[2], 90, SwordBeam.DIST / 1.5f); - this.applyRotate(poseStack, dirs[0], dirs[1], 0, rotate); + RenderUtil.applyTranslate(poseStack, dirs[0], dirs[2], 90, SwordBeam.DIST / 1.5f); + RenderUtil.applyRotate(poseStack, dirs[0], dirs[1], 0, rotate); poseStack.scale(0.5f, 0.5f, 0.5f); - renderQuad(poseStack.last().pose(), vertexConsumer1, + RenderUtil.renderQuad(poseStack.last().pose(), vertexConsumer1, 1.0f, 1.0f, 1.0f, alpha, halfWidth, halfHeight, 0f, 0f, 0.02f); poseStack.popPose(); poseStack.pushPose(); - this.applyTranslate(poseStack, dirs[0], dirs[2], 90, SwordBeam.DIST / 1.25f); - this.applyRotate(poseStack, dirs[0], dirs[1], 0, rotate); + RenderUtil.applyTranslate(poseStack, dirs[0], dirs[2], 90, SwordBeam.DIST / 1.25f); + RenderUtil.applyRotate(poseStack, dirs[0], dirs[1], 0, rotate); poseStack.scale(0.75f, 0.75f, 0.75f); - renderQuad(poseStack.last().pose(), vertexConsumer1, + RenderUtil.renderQuad(poseStack.last().pose(), vertexConsumer1, 1.0f, 1.0f, 1.0f, alpha, halfWidth, halfHeight, 0f, 0f, 0.02f); poseStack.popPose(); poseStack.pushPose(); - this.applyTranslate(poseStack, dirs[0], dirs[2], 90, SwordBeam.DIST * 1.15f); - this.applyRotate(poseStack, dirs[0], dirs[1], 0, rotate); + RenderUtil.applyTranslate(poseStack, dirs[0], dirs[2], 90, SwordBeam.DIST * 1.15f); + RenderUtil.applyRotate(poseStack, dirs[0], dirs[1], 0, rotate); poseStack.scale(0.95f, 0.95f, 0.95f); - renderQuad(poseStack.last().pose(), vertexConsumer1, + RenderUtil.renderQuad(poseStack.last().pose(), vertexConsumer1, 1.0f, 1.0f, 1.0f, alpha, halfWidth, halfHeight, 0f, 0f, 0.02f); poseStack.popPose(); @@ -248,11 +248,11 @@ public class TerraBlade extends SwordItem { //边缘高光 poseStack.pushPose(); - this.applyTranslate(poseStack, dirs[0], dirs[2], 100, SwordBeam.DIST * 1.15f); - this.applyRotate(poseStack, dirs[0], dirs[1], 0, rotate); + RenderUtil.applyTranslate(poseStack, dirs[0], dirs[2], 100, SwordBeam.DIST * 1.15f); + RenderUtil.applyRotate(poseStack, dirs[0], dirs[1], 0, rotate); poseStack.scale(1.0f, 1.0f, 1.0f); for(int i = 0;i < 5;i++) { - renderQuad(poseStack.last().pose(), vertexConsumer2, + RenderUtil.renderQuad(poseStack.last().pose(), vertexConsumer2, COLOR2.x(), COLOR2.y(), COLOR2.z(), alpha, halfWidth, halfHeight, 0f, 0f, 0.03f); } poseStack.popPose(); @@ -274,11 +274,11 @@ public class TerraBlade extends SwordItem { for(int k = 0;k < 2;k++) { poseStack.pushPose(); if(k == 0) { - this.applyTranslate(poseStack, dirs[0], dirs[2], 90 - 60.0 * progress, SwordBeam.DIST * 2f); - this.applyRotate(poseStack, dirs[0], dirs[1], 60 * progress, rotate); + RenderUtil.applyTranslate(poseStack, dirs[0], dirs[2], 90 - 60.0 * progress, SwordBeam.DIST * 2f); + RenderUtil.applyRotate(poseStack, dirs[0], dirs[1], 60 * progress, rotate); }else { - this.applyTranslate(poseStack, dirs[0], dirs[2], 90 + 60.0 * progress, SwordBeam.DIST * 2f + 0.5f * progress); - this.applyRotate(poseStack, dirs[0], dirs[1], -60 * progress, rotate); + RenderUtil.applyTranslate(poseStack, dirs[0], dirs[2], 90 + 60.0 * progress, SwordBeam.DIST * 2f + 0.5f * progress); + RenderUtil.applyRotate(poseStack, dirs[0], dirs[1], -60 * progress, rotate); } for(int j = 0; j < 2; j++) { poseStack.pushPose(); @@ -286,7 +286,7 @@ public class TerraBlade extends SwordItem { else poseStack.mulPose(Axis.ZP.rotationDegrees(45.0F)); poseStack.scale(0.5f, 0.5f, 0.5f); for(int i = 0; i < 5; i++) { - renderQuad(poseStack.last().pose(), vertexConsumer3, + RenderUtil.renderQuad(poseStack.last().pose(), vertexConsumer3, COLOR2.x(), COLOR2.y(), COLOR2.z(), sparkleAlpha, 32 * SwordBeam.SCALE, 32 * SwordBeam.SCALE, 0f, 0f, 0.03f); } poseStack.popPose(); @@ -300,11 +300,11 @@ public class TerraBlade extends SwordItem { for(int k = 0;k < 2;k++) { poseStack.pushPose(); if(k == 0) { - this.applyTranslate(poseStack, dirs[0], dirs[2], 90 - 30.0 * progress, SwordBeam.DIST * 2f); - this.applyRotate(poseStack, dirs[0], dirs[1], 30 * progress, rotate); + RenderUtil.applyTranslate(poseStack, dirs[0], dirs[2], 90 - 30.0 * progress, SwordBeam.DIST * 2f); + RenderUtil.applyRotate(poseStack, dirs[0], dirs[1], 30 * progress, rotate); }else { - this.applyTranslate(poseStack, dirs[0], dirs[2], 90 + 30.0 * progress, SwordBeam.DIST * 2.1f); - this.applyRotate(poseStack, dirs[0], dirs[1], -30 * progress, rotate); + RenderUtil.applyTranslate(poseStack, dirs[0], dirs[2], 90 + 30.0 * progress, SwordBeam.DIST * 2.1f); + RenderUtil.applyRotate(poseStack, dirs[0], dirs[1], -30 * progress, rotate); } for(int j = 0; j < 2; j++) { poseStack.pushPose(); @@ -312,7 +312,7 @@ public class TerraBlade extends SwordItem { else poseStack.mulPose(Axis.ZP.rotationDegrees(45.0F)); poseStack.scale(0.75f, 0.75f, 0.75f); for(int i = 0; i < 5; i++) { - renderQuad(poseStack.last().pose(), vertexConsumer3, + RenderUtil.renderQuad(poseStack.last().pose(), vertexConsumer3, COLOR2.x(), COLOR2.y(), COLOR2.z(), sparkleAlpha, 32 * SwordBeam.SCALE, 32 * SwordBeam.SCALE, 0f, 0f, 0.03f); } poseStack.popPose(); @@ -323,15 +323,15 @@ public class TerraBlade extends SwordItem { //闪烁(内层) poseStack.pushPose(); - this.applyTranslate(poseStack, dirs[0], dirs[2], 90, SwordBeam.DIST * 2f); - this.applyRotate(poseStack, dirs[0], dirs[1], 0, rotate); + RenderUtil.applyTranslate(poseStack, dirs[0], dirs[2], 90, SwordBeam.DIST * 2f); + RenderUtil.applyRotate(poseStack, dirs[0], dirs[1], 0, rotate); for(int j = 0; j < 2; j++) { poseStack.pushPose(); if(j == 0) poseStack.mulPose(Axis.ZP.rotationDegrees(0.0F)); else poseStack.mulPose(Axis.ZP.rotationDegrees(45.0F)); poseStack.scale(1.0f, 1.0f, 1.0f); for(int i = 0; i < 5; i++) { - renderQuad(poseStack.last().pose(), vertexConsumer3, + RenderUtil.renderQuad(poseStack.last().pose(), vertexConsumer3, COLOR2.x(), COLOR2.y(), COLOR2.z(), sparkleAlpha, 32 * SwordBeam.SCALE, 32 * SwordBeam.SCALE, 0f, 0f, 0.03f); } poseStack.popPose(); @@ -341,54 +341,6 @@ public class TerraBlade extends SwordItem { poseStack.popPose(); } - public void applyRotate(PoseStack poseStack, Vector3f dir, Vector3f up, double angle, double rotate) { - Quaternionf rotation = new Quaternionf() - .fromAxisAngleRad(up, (float) Math.toRadians(angle)); - Quaternionf rotation2 = new Quaternionf() - .fromAxisAngleRad(dir, (float) Math.toRadians(Math.abs(dir.y) > 0.999 ? 0 : rotate)); - poseStack.mulPose(rotation); - poseStack.mulPose(rotation2); - - float[] xyRot = MathUtil.computeXYRot(dir, up); - poseStack.mulPose(Axis.YP.rotationDegrees(-xyRot[1])); - poseStack.mulPose(Axis.XP.rotationDegrees(xyRot[0])); - - poseStack.mulPose(Axis.XP.rotationDegrees(-90.0F)); - poseStack.mulPose(Axis.ZP.rotationDegrees(-90.0F)); - } - - public 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)); - Vector3f current = new Vector3f( - cos * right.x + sin * dir.x, - cos * right.y + sin * dir.y, - cos * right.z + sin * dir.z - ).normalize(); - poseStack.translate(current.x * dist, current.y * dist, current.z * dist); - } - - public void renderQuad(Matrix4f matrix, VertexConsumer consumer, float r, float g, float b, float a, float halfWidth, float halfHeight, float offsetX, float offsetY, float offsetZ) { - int ir = (int) (r * 255.0F); - int ig = (int) (g * 255.0F); - int ib = (int) (b * 255.0F); - int ia = (int) (a * 255.0F); - - consumer.addVertex(matrix, -halfWidth, -halfHeight + offsetY, offsetZ) - .setColor(ir, ig, ib, ia).setUv(0.0f, 1.0f) - .setOverlay(OverlayTexture.NO_OVERLAY).setLight(LightTexture.FULL_BRIGHT).setNormal(0.0f, 1.0f, 0.0f); - consumer.addVertex(matrix, halfWidth, -halfHeight + offsetY, offsetZ) - .setColor(ir, ig, ib, ia).setUv(1.0f, 1.0f) - .setOverlay(OverlayTexture.NO_OVERLAY).setLight(LightTexture.FULL_BRIGHT).setNormal(0.0f, 1.0f, 0.0f); - consumer.addVertex(matrix, halfWidth, halfHeight + offsetY, offsetZ) - .setColor(ir, ig, ib, ia).setUv(1.0f, 0.0f) - .setOverlay(OverlayTexture.NO_OVERLAY).setLight(LightTexture.FULL_BRIGHT).setNormal(0.0f, 1.0f, 0.0f); - consumer.addVertex(matrix, -halfWidth, halfHeight + offsetY, offsetZ) - .setColor(ir, ig, ib, ia).setUv(0.0f, 0.0f) - .setOverlay(OverlayTexture.NO_OVERLAY).setLight(LightTexture.FULL_BRIGHT).setNormal(0.0f, 1.0f, 0.0f); - } - - @Override public void tick(StaticSummon summon) { this.checkBeforeTick(summon); @@ -411,8 +363,8 @@ public class TerraBlade extends SwordItem { Vec3 center = summon.position().add(summon.getLookAngle().normalize().scale(SwordBeam.DIST)); if(customData.contains("extX") && customData.contains("extY") && customData.contains("extZ")) { summon.setBoundingBox(new AABB( - center.x - customData.getInt("extX"), center.y - customData.getInt("extY"), center.z - customData.getInt("extZ"), - center.x + customData.getInt("extX"), center.y + customData.getInt("extY"), center.z + customData.getInt("extZ") + center.x - customData.getFloat("extX"), center.y - customData.getFloat("extY"), center.z - customData.getFloat("extZ"), + center.x + customData.getFloat("extX"), center.y + customData.getFloat("extY"), center.z + customData.getFloat("extZ") )); } @@ -421,7 +373,7 @@ public class TerraBlade extends SwordItem { int count = customData.getInt("hitCount"); List targets = summon.level().getEntitiesOfClass(LivingEntity.class, summon.getBoundingBox(), FilterUtil.createTargetFilter(summon, summon.getOwner())); for(LivingEntity target : targets) { - if(target.hurt(summon.damageSources().playerAttack(player), (float) Config.terraProjectileDamage * (float) Math.pow(Config.terraProjectileDamageDecay, count))) { + if(DamageUtil.attack(player, target, (float) Config.terraProjectileDamage * (float) Math.pow(Config.terraProjectileDamageDecay, count))) { count++; ParticleUtil.addParticles( (ServerLevel) summon.level(), ModParticles.TERRA_BEAM_HIT_PARTICLE.get(), 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 fadcc34..37f8663 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 @@ -14,10 +14,7 @@ import com.lzxnone.terraria.item.IItemWaveBehavior; import com.lzxnone.terraria.network.payload.SwordBeamPayload; import com.lzxnone.terraria.particle.DustParticleOptions; import com.lzxnone.terraria.particle.ModParticles; -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 com.lzxnone.terraria.utils.*; import net.minecraft.Util; import net.minecraft.nbt.CompoundTag; import net.minecraft.resources.ResourceLocation; @@ -105,12 +102,13 @@ public class TheHorsemansBlade extends SwordItem { @Override public void onHitEntity(SwordBeam beam, EntityHitResult result) { if(!beam.level().isClientSide()) { - if(result.getEntity() instanceof LivingEntity target && beam.getOwner() instanceof Player player && FilterUtil.createLivingTargetFilter(player).test(target)) { + Entity target = result.getEntity(); + if(beam.getOwner() instanceof Player player && FilterUtil.createTargetFilter(player).test(target)) { CompoundTag custom_data = beam.getEntityData().get(SwordBeam.CUSTOM_DATA); if(custom_data.contains("hitEntityCount")) { int count = custom_data.getInt("hitEntityCount"); if(count < Config.horsemansBladeMaxHitCount) { - if(target.hurt(beam.level().damageSources().playerAttack(player), (float) Config.horsemansBladeDamage)) { + if(DamageUtil.attack(player, target, (float) Config.horsemansBladeDamage)) { target.invulnerableTime = 20; count++; custom_data.putInt("hitEntityCount", count); @@ -242,7 +240,7 @@ public class TheHorsemansBlade extends SwordItem { summon.setYRot(xyRot[1]); if(selfPos.distanceToSqr(targetPos) < 2.0D) { - if(summon.getOwner() instanceof Player player && FilterUtil.createLivingTargetFilter(player).test(target) && target.hurt(summon.damageSources().playerAttack(player), (float) Config.horsemansPumpkinDamage)) onDied(summon); + if(summon.getOwner() instanceof Player player && FilterUtil.createLivingTargetFilter(player).test(target) && DamageUtil.attack(player, target, (float) Config.horsemansPumpkinDamage)) onDied(summon); } }else { Vec3 dir = summon.getLookAngle().normalize(); @@ -267,7 +265,7 @@ public class TheHorsemansBlade extends SwordItem { for(Entity hitEntity : hitEntities) { if(target != null && hitEntity.getUUID() == target.getUUID()) continue; if(summon.getOwner() instanceof Player player) { - if(hitEntity.hurt(summon.damageSources().playerAttack(player), (float) Config.horsemansPumpkinDamage)) { + if(DamageUtil.attack(player, target, (float) Config.horsemansPumpkinDamage)) { hitEntity.invulnerableTime = 2; } } 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 1920350..4248c76 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 @@ -38,14 +38,19 @@ public class TrueCopperShortsword extends SwordItem { )); } - public static void summon(Player player) { + public static void summon(Player player, double deltaDist) { Vector3f[] dirs = MathUtil.computeCoordinateSystem(player); int randomAngle = (int) ((Math.random() * 2 - 1) * Config.zenithTrailOffset); dirs = MathUtil.rotateCoordinateSystem(dirs[0], dirs[2], randomAngle); Vec3 pos = (player.getBoundingBox().getCenter()).add(MathUtil.toVec3(dirs[0]).scale(-2)); - Vec3 targetPos = MathUtil.getCrosshairPos(player, player.level(), Config.zenithMaxRange); - double dist = targetPos.subtract(pos).length(); + double dist; + if(Config.zenithDistanceMode) { + Vec3 targetPos = MathUtil.getCrosshairPos(player, player.level(), Config.zenithMaxRange); + dist = Math.max(0, Math.min(targetPos.subtract(pos).length() + deltaDist, Config.zenithMaxRange)); + }else { + dist = deltaDist; + } int cycle = (int) Math.max(10, dist / Config.zenithMaxRange * Config.zenithCycle); double a = Math.max(dist / 2, 2); double b = Math.min(Math.random() * Config.zenithTrailB + Config.zenithTrailB, a / 2); @@ -142,10 +147,12 @@ public class TrueCopperShortsword extends SwordItem { if(entity instanceof Player player) { if(isSelected) { if(player.tickCount % 3 == 0) { + double deltaDist = stack.getOrDefault(DataComponents.CUSTOM_DATA, CustomData.EMPTY) + .copyTag().getDouble("deltaDist"); int count = stack.getOrDefault(DataComponents.CUSTOM_DATA, CustomData.EMPTY) .copyTag().getInt("attackCount"); if(count > 0) { - summon(player); + summon(player, deltaDist); CustomData.update(DataComponents.CUSTOM_DATA, stack, tag -> tag.putInt("attackCount", count - 1)); } 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 cf46606..b700a83 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 @@ -1,25 +1,291 @@ package com.lzxnone.terraria.item.weapon.melee; +import com.lzxnone.terraria.Config; import com.lzxnone.terraria.LzxnoneTerraria; +import com.lzxnone.terraria.ModSounds; +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.IItemWaveBehavior; +import com.lzxnone.terraria.network.payload.SwordBeamPayload; +import com.lzxnone.terraria.particle.DustParticleOptions; +import com.lzxnone.terraria.particle.ModParticles; +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.Util; +import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.client.renderer.RenderType; +import net.minecraft.nbt.CompoundTag; 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.Entity; import net.minecraft.world.entity.EquipmentSlotGroup; 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.Item; +import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.SwordItem; import net.minecraft.world.item.Tiers; import net.minecraft.world.item.component.ItemAttributeModifiers; +import net.minecraft.world.level.Level; +import net.minecraft.world.phys.EntityHitResult; +import net.minecraft.world.phys.Vec3; +import net.neoforged.neoforge.event.entity.player.AttackEntityEvent; +import net.neoforged.neoforge.event.entity.player.PlayerInteractEvent; +import net.neoforged.neoforge.network.PacketDistributor; +import org.joml.Vector3f; public class TrueExcalibur extends SwordItem { public TrueExcalibur() { super(Tiers.NETHERITE, new Item.Properties().attributes(ItemAttributeModifiers.builder() .add(Attributes.ATTACK_DAMAGE, - new AttributeModifier(ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "base_attack_damage"), 13, AttributeModifier.Operation.ADD_VALUE), + new AttributeModifier(ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "base_attack_damage"), 7.0f, AttributeModifier.Operation.ADD_VALUE), EquipmentSlotGroup.MAINHAND) .add(Attributes.ATTACK_SPEED, - new AttributeModifier(ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "base_attack_speed"), -2.2, AttributeModifier.Operation.ADD_VALUE), + new AttributeModifier(ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "base_attack_speed"), -1.0, AttributeModifier.Operation.ADD_VALUE), EquipmentSlotGroup.MAINHAND) .build() )); } + + 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); + tag.putFloat("color0B", 0.243f); + tag.putFloat("color1R", 0.949f); + tag.putFloat("color1G", 0.863f); + tag.putFloat("color1B", 0.431f); + tag.putFloat("color2R", 0.898f); + tag.putFloat("color2G", 0.725f); + tag.putFloat("color2B", 0.484f); + + CompoundTag customData = new CompoundTag(); + customData.putInt("hitEntityCount", 0); + tag.put("customData", customData); + }); + + public static final DustParticleOptions PARTICLE = new DustParticleOptions( + 0.075f, 0.5f, 40, true, new Vector3f[]{ + new Vector3f(1.0F, 1.0F, 1.0F), + new Vector3f(1.0F, 0.9F, 0.0F), + new Vector3f(1.0F, 0.6F, 0.8F) + } + ); + + public static final ISwordBeamBehavior SWORD_BEAM_BEHAVIOR = new ISwordBeamBehavior() { + @Override + public void render(Entity entity, float entityYaw, float partialTick, + PoseStack poseStack, MultiBufferSource bufferSource, int packedLight) { + if(!(entity instanceof SwordBeam beam)) 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; + + Vector3f[] dirs = MathUtil.computeCoordinateSystem(beam.getOwner()); + dirs = MathUtil.rotateCoordinateSystem(dirs[0], dirs[2], beam.getEntityData().get(SwordBeam.ROTATE)); + float rotate = beam.getEntityData().get(SwordBeam.ROTATE); + + Vector3f color0 = new Vector3f(0.651f, 0.102f, 0.224f); + Vector3f color1 = new Vector3f(0.945f, 0.286f, 0.525f); + Vector3f color2 = new Vector3f(0.945f, 0.286f, 0.525f); + Vector3f color3 = new Vector3f(1.0f, 1.0f, 1.0f); + 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); + }else { + alpha = 1.0f; + } + if(beam.getEntityData().get(SwordBeam.RIGHT)) progress = 1.0f - progress; + + float halfWidth = SwordBeam.HALF_WIDTH * SwordBeam.SCALE; + float halfHeight = SwordBeam.HALF_HEIGHT * SwordBeam.SCALE; + + VertexConsumer vertexConsumer0 = bufferSource.getBuffer(RenderType.entityTranslucentEmissive(RES0)); + + //左边 + poseStack.pushPose(); + RenderUtil.applyTranslate(poseStack, dirs[0], dirs[2], (progress - 0.1f * (1.0f - progress)) * 180, SwordBeam.DIST * 1.5f); + RenderUtil.applyRotate(poseStack, dirs[0], dirs[1], (0.5f - (progress - 0.1f * (1.0f - progress))) * 180, rotate); + poseStack.scale(1.5f, 1.5f, 1.5f); + renderQuad(poseStack.last().pose(), vertexConsumer0, + color0.x(), color0.y(), color0.z(), alpha, halfWidth, halfHeight, 0f, 0, -0.05f); + poseStack.popPose(); + + //右边 + poseStack.pushPose(); + RenderUtil.applyTranslate(poseStack, dirs[0], dirs[2], (progress + 0.1f) * 180, SwordBeam.DIST * 1.5f); + RenderUtil.applyRotate(poseStack, dirs[0], dirs[1], (0.5f - (progress + 0.05f)) * 180, rotate); + poseStack.scale(1.5f, 1.5f, 1.5f); + renderQuad(poseStack.last().pose(), vertexConsumer0, + color2.x(), color2.y(), color2.z(), alpha, halfWidth, halfHeight, 0f, 0, -0.06f); + poseStack.popPose(); + + //中间 + poseStack.pushPose(); + RenderUtil.applyTranslate(poseStack, dirs[0], dirs[2], progress * 180, SwordBeam.DIST * 1.5f); + RenderUtil.applyRotate(poseStack, dirs[0], dirs[1], (0.5f - progress) * 180, rotate); + poseStack.scale(1.5f, 1.5f, 1.5f); + renderQuad(poseStack.last().pose(), vertexConsumer0, + color1.x(), color1.y(), color1.z(), alpha, halfWidth, halfHeight, 0f, 0f, -0.04f); + poseStack.popPose(); + VertexConsumer vertexConsumer1 = bufferSource.getBuffer(RenderType.entityTranslucentEmissive(RES3)); + + + //三线 + poseStack.pushPose(); + RenderUtil.applyTranslate(poseStack, dirs[0], dirs[2], (progress + 0.05f) * 180, SwordBeam.DIST); + RenderUtil.applyRotate(poseStack, dirs[0], dirs[1], (0.5f - progress) * 180, rotate); + poseStack.scale(0.75f, 0.75f, 0.75f); + renderQuad(poseStack.last().pose(), vertexConsumer1, + color3.x(), color3.y(), color3.z(), alpha, halfWidth, halfHeight, 0f, 0f, -0.045f); + poseStack.popPose(); + + poseStack.pushPose(); + RenderUtil.applyTranslate(poseStack, dirs[0], dirs[2], (progress + 0.05f) * 180, SwordBeam.DIST * 1.2f); + RenderUtil.applyRotate(poseStack, dirs[0], dirs[1], (0.5f - progress) * 180, rotate); + poseStack.scale(1.125f, 1.125f, 1.125f); + renderQuad(poseStack.last().pose(), vertexConsumer1, + color3.x(), color3.y(), color3.z(), alpha, halfWidth, halfHeight, 0f, 0f, -0.045f); + poseStack.popPose(); + + poseStack.pushPose(); + RenderUtil.applyTranslate(poseStack, dirs[0], dirs[2], progress * 180, SwordBeam.DIST * 1.725f); + RenderUtil.applyRotate(poseStack, dirs[0], dirs[1], (0.5f - progress) * 180, rotate); + poseStack.scale(1.425f, 1.425f, 1.425f); + renderQuad(poseStack.last().pose(), vertexConsumer1, + color3.x(), color3.y(), color3.z(), alpha, halfWidth, halfHeight, 0f, 0f, -0.045f); + poseStack.popPose(); + + VertexConsumer vertexConsumer2 = bufferSource.getBuffer(RenderType.entityTranslucentEmissive(RES4)); + + //边缘高光 + poseStack.pushPose(); + 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++) { + renderQuad(poseStack.last().pose(), vertexConsumer2, + color1.x(), color1.y(), color1.z(), alpha, halfWidth, halfHeight, 0f, 0f, -0.03f); + } + poseStack.popPose(); + + VertexConsumer vertexConsumer3 = bufferSource.getBuffer(RenderType.entityTranslucentEmissive(RES5)); + + //闪烁 + poseStack.pushPose(); + RenderUtil.applyTranslate(poseStack, dirs[0], dirs[2], (progress + 0.25f) * 180, SwordBeam.DIST * 3.375f); + RenderUtil.applyRotate(poseStack, dirs[0], dirs[1], (0.5f - (progress + 0.25f)) * 180, rotate); + poseStack.mulPose(Axis.ZP.rotationDegrees(45.0F)); + poseStack.scale(1.5f, 1.5f, 1.5f); + for(int i = 0;i < 20;i++) { + renderQuad(poseStack.last().pose(), vertexConsumer3, + color1.x(), color1.y(), color1.z(), alpha, 32 * SwordBeam.SCALE, 32 * SwordBeam.SCALE, 0f, 0f, -0.03f); + } + poseStack.popPose(); + + ISwordBeamBehavior.super.render(entity, entityYaw, partialTick, poseStack, bufferSource, packedLight); + } + + @Override + public void onMoving(SwordBeam beam) { + if(beam.currentPosition == null) return; + ParticleUtil.addParticle( + beam.level(), PARTICLE, + beam.currentPosition, 0.2, + new Vec3(0, 0, 0), 0.2 + ); + } + + @Override + public void onHitEntity(SwordBeam beam, EntityHitResult result) { + if(!beam.level().isClientSide()) { + Entity target = result.getEntity(); + if(beam.getOwner() instanceof Player player && FilterUtil.createTargetFilter(player).test(target)) { + CompoundTag custom_data = beam.getEntityData().get(SwordBeam.CUSTOM_DATA); + if(custom_data.contains("hitEntityCount")) { + int count = custom_data.getInt("hitEntityCount"); + if(count < Config.trueExcaliburMaxHitCount) { + if(DamageUtil.attack(player, target, (float) Config.trueExcaliburDamage)) { + target.invulnerableTime = 20; + count++; + custom_data.putInt("hitEntityCount", count); + beam.getEntityData().set(SwordBeam.CUSTOM_DATA, custom_data); + ParticleUtil.addParticles( + (ServerLevel) target.level(), ModParticles.EXCALIBUR_HIT_PARTICLE.get(), + new Vec3(target.getX(), target.getY() + target.getBbHeight() / 2.0, target.getZ()), new Vec3(0, 0, 0), + 0, 1 + ); + ParticleUtil.addParticles( + (ServerLevel) target.level(), ModParticles.TRUE_EXCALIBUR_HIT_PARTICLE.get(), + new Vec3(target.getX(), target.getY() + target.getBbHeight() / 2.0, target.getZ()), new Vec3(0, 0, 0), + 0, 1 + ); + } + } + } + } + } + } + + @Override + public void generate(Entity entity, CompoundTag beamData) { + beamData.putInt("rotate", (int) (Config.trueExcaliburRotateRange * (Math.random() * 2 - 1))); + ISwordBeamBehavior.super.generate(entity, beamData); + } + }; + + public static final IItemWaveBehavior ITEM_WAVE_BEHAVIOR = new IItemWaveBehavior() { + public void onLeftClickAir(PlayerInteractEvent.LeftClickEmpty event) { + Player player = event.getEntity(); + ItemStack itemStack = player.getMainHandItem(); + if(itemStack.isEmpty()) return; + Item item = itemStack.getItem(); + if(item instanceof TrueExcalibur && !player.getCooldowns().isOnCooldown(item)) { + PacketDistributor.sendToServer(new SwordBeamPayload("true_excalibur", BEAM_DATA)); + SoundUtil.playClientSound(player, ModSounds.WAVE.get()); + } + } + public void onAttackEntity(AttackEntityEvent event) { + Player player = event.getEntity(); + ItemStack itemStack = player.getMainHandItem(); + if(itemStack.isEmpty()) return; + Item item = itemStack.getItem(); + if(item instanceof TrueExcalibur && !player.getCooldowns().isOnCooldown(item)) { + if(!player.level().isClientSide()) { + SwordBeamBehaviors.getBehavior("true_excalibur").generate(player, BEAM_DATA); + }else { + SoundUtil.playClientSound(player, ModSounds.WAVE.get()); + } + } + event.setCanceled(true); + } + }; + + @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()); + } + return InteractionResultHolder.sidedSuccess(stack, level.isClientSide()); + } } 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 24622a1..ad15dee 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 @@ -1,20 +1,58 @@ package com.lzxnone.terraria.item.weapon.melee; +import com.lzxnone.terraria.Config; import com.lzxnone.terraria.LzxnoneTerraria; +import com.lzxnone.terraria.ModSounds; +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.entity.summon.IStaticSummonBehavior; +import com.lzxnone.terraria.entity.summon.StaticSummon; +import com.lzxnone.terraria.entity.summon.StaticSummonBehaviors; +import com.lzxnone.terraria.item.IItemWaveBehavior; +import com.lzxnone.terraria.network.payload.SwordBeamPayload; +import com.lzxnone.terraria.particle.DustParticleOptions; +import com.lzxnone.terraria.particle.ModParticles; +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.Util; +import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.client.renderer.RenderType; +import net.minecraft.nbt.CompoundTag; 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.Entity; 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.Item; +import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.SwordItem; import net.minecraft.world.item.Tiers; import net.minecraft.world.item.component.ItemAttributeModifiers; +import net.minecraft.world.level.ClipContext; +import net.minecraft.world.level.Level; +import net.minecraft.world.phys.*; +import net.neoforged.neoforge.event.entity.player.AttackEntityEvent; +import net.neoforged.neoforge.event.entity.player.PlayerInteractEvent; +import net.neoforged.neoforge.network.PacketDistributor; +import org.joml.Quaternionf; +import org.joml.Vector3f; + +import java.util.List; public class TrueNightsEdge extends SwordItem { public TrueNightsEdge() { super(Tiers.NETHERITE, new Item.Properties().attributes(ItemAttributeModifiers.builder() .add(Attributes.ATTACK_DAMAGE, - new AttributeModifier(ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "base_attack_damage"), 12, AttributeModifier.Operation.ADD_VALUE), + new AttributeModifier(ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "base_attack_damage"), 7.0f, AttributeModifier.Operation.ADD_VALUE), EquipmentSlotGroup.MAINHAND) .add(Attributes.ATTACK_SPEED, new AttributeModifier(ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "base_attack_speed"), -2.4, AttributeModifier.Operation.ADD_VALUE), @@ -22,4 +60,508 @@ public class TrueNightsEdge extends SwordItem { .build() )); } + + 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); + tag.putFloat("color1R", 0.278f); + tag.putFloat("color1G", 0.141f); + tag.putFloat("color1B", 0.588f); + tag.putFloat("color2R", 0.325f); + tag.putFloat("color2G", 0.212f); + tag.putFloat("color2B", 0.553f); + + CompoundTag customData = new CompoundTag(); + customData.putInt("hitEntityCount", 0); + tag.put("customData", customData); + }); + + public static final DustParticleOptions PARTICLE = new DustParticleOptions( + 0.075f, 0.5f, 40, true, new Vector3f[]{ + new Vector3f(0.463F, 0.196F, 0.918F), + new Vector3f(0.408F, 0.373F, 0.494F) + } + ); + + public static final DustParticleOptions PARTICLE2 = new DustParticleOptions( + 0.075f, 0.5f, 40, true, new Vector3f[]{ + new Vector3f(0.573F, 0.765F, 0.239F) + } + ); + + public static final ISwordBeamBehavior SWORD_BEAM_BEHAVIOR = new ISwordBeamBehavior() { + @Override + public void render(Entity entity, float entityYaw, float partialTick, + PoseStack poseStack, MultiBufferSource bufferSource, int packedLight) { + if (!(entity instanceof SwordBeam beam)) 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; + + Vector3f[] dirs = MathUtil.computeCoordinateSystem(beam.getOwner()); + dirs = MathUtil.rotateCoordinateSystem(dirs[0], dirs[2], beam.getEntityData().get(SwordBeam.ROTATE)); + float rotate = beam.getEntityData().get(SwordBeam.ROTATE); + + Vector3f color0 = entity.getEntityData().get(SwordBeam.COLOR0); + Vector3f color1 = entity.getEntityData().get(SwordBeam.COLOR1); + Vector3f color2 = entity.getEntityData().get(SwordBeam.COLOR2); + Vector3f color3 = entity.getEntityData().get(SwordBeam.COLOR3); + 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); + } else { + alpha = 1.0f; + } + if (beam.getEntityData().get(SwordBeam.RIGHT)) progress = 1.0f - progress; + + float halfWidth = SwordBeam.HALF_WIDTH * SwordBeam.SCALE; + float halfHeight = SwordBeam.HALF_HEIGHT * SwordBeam.SCALE; + + VertexConsumer vertexConsumer0 = bufferSource.getBuffer(RenderType.entityTranslucentEmissive(RES0)); + + //左边 + poseStack.pushPose(); + RenderUtil.applyTranslate(poseStack, dirs[0], dirs[2], (progress - 0.1f * (1.0f - progress)) * 180, SwordBeam.DIST); + RenderUtil.applyRotate(poseStack, dirs[0], dirs[1], (0.5f - (progress - 0.1f * (1.0f - progress))) * 180, rotate); + renderQuad(poseStack.last().pose(), vertexConsumer0, + color0.x(), color0.y(), color0.z(), alpha, halfWidth, halfHeight, 0f, 0, -0.01f); + poseStack.popPose(); + + //右边 + poseStack.pushPose(); + RenderUtil.applyTranslate(poseStack, dirs[0], dirs[2], (progress + 0.1f) * 180, SwordBeam.DIST); + RenderUtil.applyRotate(poseStack, dirs[0], dirs[1], (0.5f - (progress + 0.05f)) * 180, rotate); + renderQuad(poseStack.last().pose(), vertexConsumer0, + color2.x(), color2.y(), color2.z(), alpha, halfWidth, halfHeight, 0f, 0, -0.02f); + poseStack.popPose(); + + //中间 + poseStack.pushPose(); + RenderUtil.applyTranslate(poseStack, dirs[0], dirs[2], progress * 180, SwordBeam.DIST); + RenderUtil.applyRotate(poseStack, dirs[0], dirs[1], (0.5f - progress) * 180, rotate); + renderQuad(poseStack.last().pose(), vertexConsumer0, + color1.x(), color1.y(), color1.z(), alpha, halfWidth, halfHeight, 0f, 0f, 0f); + poseStack.popPose(); + + VertexConsumer vertexConsumer1 = bufferSource.getBuffer(RenderType.entityTranslucentEmissive(RES3)); + + //外线 + poseStack.pushPose(); + RenderUtil.applyTranslate(poseStack, dirs[0], dirs[2], progress * 180, SwordBeam.DIST * 1.15f); + RenderUtil.applyRotate(poseStack, dirs[0], dirs[1], (0.5f - progress) * 180, rotate); + poseStack.scale(0.95f, 0.95f, 0.95f); + renderQuad(poseStack.last().pose(), vertexConsumer1, + color3.x(), color3.y(), color3.z(), alpha, halfWidth, halfHeight, 0f, 0f, 0.02f); + poseStack.popPose(); + + VertexConsumer vertexConsumer2 = bufferSource.getBuffer(RenderType.entityTranslucentEmissive(RES5)); + + //闪烁 + poseStack.pushPose(); + RenderUtil.applyTranslate(poseStack, dirs[0], dirs[2], (progress + 0.25f) * 180, SwordBeam.DIST * 2.25f); + RenderUtil.applyRotate(poseStack, dirs[0], dirs[1], (0.5f - progress - 0.25f) * 180, rotate); + poseStack.mulPose(Axis.ZP.rotationDegrees(45.0F)); + poseStack.scale(1.0f, 1.0f, 1.0f); + for (int i = 0; i < 20; i++) { + renderQuad(poseStack.last().pose(), vertexConsumer2, + color1.x(), color1.y(), color1.z(), alpha, 32 * SwordBeam.SCALE, 32 * SwordBeam.SCALE, 0f, 0f, 0.03f); + } + poseStack.popPose(); + } + + @Override + public void onMoving(SwordBeam beam) { + if(beam.currentPosition == null) return; + ParticleUtil.addParticle( + beam.level(), PARTICLE, + beam.currentPosition, 0.2, + new Vec3(0, 0, 0), 0.2 + ); + } + + @Override + public void onHitEntity(SwordBeam beam, EntityHitResult result) { + if(!beam.level().isClientSide()) { + Entity target = result.getEntity(); + if(beam.getOwner() instanceof Player player && FilterUtil.createTargetFilter(player).test(target)) { + CompoundTag custom_data = beam.getEntityData().get(SwordBeam.CUSTOM_DATA); + if(custom_data.contains("hitEntityCount")) { + int count = custom_data.getInt("hitEntityCount"); + if(count < Config.trueNightsEdgeMaxHitCount) { + if(DamageUtil.attack(player, target, (float) Config.trueNightsEdgeDamage)) { + 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), + 0, 1 + ); + target.invulnerableTime = 20; + count++; + custom_data.putInt("hitEntityCount", count); + beam.getEntityData().set(SwordBeam.CUSTOM_DATA, custom_data); + } + } + } + } + } + } + + @Override + public void generate(Entity entity, CompoundTag beamData) { + int randomAngle = (int) (Config.trueNightsEdgeRotateRange * (Math.random() * 2 - 1)); + beamData.putInt("rotate", randomAngle); + ISwordBeamBehavior.super.generate(entity, beamData); + 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 render(Entity entity, float entityYaw, float partialTick, + PoseStack poseStack, MultiBufferSource bufferSource, int packedLight) { + if(!(entity instanceof StaticSummon summon)) return; + + float halfWidth = SwordBeam.HALF_WIDTH * SwordBeam.SCALE; + float halfHeight = SwordBeam.HALF_HEIGHT * SwordBeam.SCALE; + + 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); + }else { + alpha = 1.0f; + } + + if(alpha < 0.01f) return; + + CompoundTag customData = summon.getEntityData().get(StaticSummon.CUSTOM_DATA); + + Vector3f dir = new Vector3f(); + if (customData.contains("dirX")) dir.x = customData.getFloat("dirX"); + if (customData.contains("dirY")) dir.y = customData.getFloat("dirY"); + if (customData.contains("dirZ")) dir.z = customData.getFloat("dirZ"); + Vector3f up = new Vector3f(); + if (customData.contains("upX")) up.x = customData.getFloat("upX"); + if (customData.contains("upY")) up.y = customData.getFloat("upY"); + if (customData.contains("upZ")) up.z = customData.getFloat("upZ"); + Vector3f right = new Vector3f(); + if (customData.contains("rightX")) right.x = customData.getFloat("rightX"); + if (customData.contains("rightY")) right.y = customData.getFloat("rightY"); + if (customData.contains("rightZ")) right.z = customData.getFloat("rightZ"); + + Vector3f[] dirs = new Vector3f[]{dir, up, right}; + double rotate = summon.getEntityData().get(StaticSummon.RZP); + double rotateSpeed = summon.getEntityData().get(StaticSummon.RZPS); + float rotateAngle = (float) ((summon.getEntityData().get(StaticSummon.AGE) + partialTick) * rotateSpeed); + + VertexConsumer vertexConsumer0 = bufferSource.getBuffer(RenderType.entityTranslucentEmissive(RES0)); + + //外层(亮) + poseStack.pushPose(); + rotateInCenter(poseStack, dirs, rotateAngle); + RenderUtil.applyTranslate(poseStack, dirs[0], dirs[2], 90, SwordBeam.DIST); + RenderUtil.applyRotate(poseStack, dirs[0], dirs[1], 0, rotate); + RenderUtil.renderQuad(poseStack.last().pose(), vertexConsumer0, + COLOR0.x(), COLOR0.y(), COLOR0.z(), alpha, halfWidth, halfHeight, 0f, 0f, 0f); + poseStack.popPose(); + + poseStack.pushPose(); + rotateInCenter(poseStack, dirs, rotateAngle); + RenderUtil.applyTranslate(poseStack, dirs[0], dirs[2], 160, SwordBeam.DIST * 1.5f); + RenderUtil.applyRotate(poseStack, dirs[0], dirs[1], -45, rotate); + RenderUtil.renderQuad(poseStack.last().pose(), vertexConsumer0, + COLOR0.x(), COLOR0.y(), COLOR0.z(), alpha * 0.5f, halfWidth, halfHeight, 0f, 0f, -0.01f); + poseStack.popPose(); + + //外层(淡) + poseStack.pushPose(); + rotateInCenter(poseStack, dirs, rotateAngle); + RenderUtil.applyTranslate(poseStack, dirs[0], dirs[2], 20, SwordBeam.DIST * 1.25f); + RenderUtil.applyRotate(poseStack, dirs[0], dirs[1], 45, rotate); + RenderUtil.renderQuad(poseStack.last().pose(), vertexConsumer0, + COLOR0.x(), COLOR0.y(), COLOR0.z(), alpha * 0.25f, halfWidth, halfHeight, 0f, 0f, -0.02f); + poseStack.popPose(); + + poseStack.pushPose(); + rotateInCenter(poseStack, dirs, rotateAngle); + RenderUtil.applyTranslate(poseStack, dirs[0], dirs[2], -100, SwordBeam.DIST * 2.5f); + RenderUtil.applyRotate(poseStack, dirs[0], dirs[1], 180, rotate); + RenderUtil.renderQuad(poseStack.last().pose(), vertexConsumer0, + COLOR0.x(), COLOR0.y(), COLOR0.z(), alpha * 0.125f, halfWidth, halfHeight, 0f, 0f, -0.03f); + poseStack.popPose(); + + //内层 + poseStack.pushPose(); + rotateInCenter(poseStack, dirs, rotateAngle); + RenderUtil.applyTranslate(poseStack, dirs[0], dirs[2], 160, SwordBeam.DIST); + RenderUtil.applyRotate(poseStack, dirs[0], dirs[1], -45, rotate); + poseStack.scale(0.8f, 0.8f, 0.8f); + RenderUtil.renderQuad(poseStack.last().pose(), vertexConsumer0, + COLOR1.x(), COLOR1.y(), COLOR1.z(), alpha, halfWidth, halfHeight, 0f, 0f, 0.01f); + poseStack.popPose(); + + poseStack.pushPose(); + rotateInCenter(poseStack, dirs, rotateAngle); + RenderUtil.applyTranslate(poseStack, dirs[0], dirs[2], 70, SwordBeam.DIST * 0.5); + RenderUtil.applyRotate(poseStack, dirs[0], dirs[1], 15, rotate); + poseStack.scale(0.8f, 0.8f, 0.8f); + RenderUtil.renderQuad(poseStack.last().pose(), vertexConsumer0, + COLOR1.x(), COLOR1.y(), COLOR1.z(), alpha * 0.5f, halfWidth, halfHeight, 0f, 0f, -0.03f); + poseStack.popPose(); + + poseStack.pushPose(); + rotateInCenter(poseStack, dirs, rotateAngle); + RenderUtil.applyTranslate(poseStack, dirs[0], dirs[2], -30, SwordBeam.DIST); + RenderUtil.applyRotate(poseStack, dirs[0], dirs[1], 75, rotate); + poseStack.scale(0.8f, 0.8f, 0.8f); + RenderUtil.renderQuad(poseStack.last().pose(), vertexConsumer0, + COLOR1.x(), COLOR1.y(), COLOR1.z(), alpha * 0.25f, halfWidth, halfHeight, 0f, 0f, -0.02f); + poseStack.popPose(); + + poseStack.pushPose(); + rotateInCenter(poseStack, dirs, rotateAngle); + RenderUtil.applyTranslate(poseStack, dirs[0], dirs[2], -120, SwordBeam.DIST * 2f); + RenderUtil.applyRotate(poseStack, dirs[0], dirs[1], 210, rotate); + poseStack.scale(0.8f, 0.8f, 0.8f); + RenderUtil.renderQuad(poseStack.last().pose(), vertexConsumer0, + COLOR1.x(), COLOR1.y(), COLOR1.z(), alpha * 0.125f, halfWidth, halfHeight, 0f, 0f, -0.02f); + poseStack.popPose(); + + VertexConsumer vertexConsumer1 = bufferSource.getBuffer(RenderType.entityTranslucentEmissive(RES1)); + + //外线 + poseStack.pushPose(); + rotateInCenter(poseStack, dirs, rotateAngle); + RenderUtil.applyTranslate(poseStack, dirs[0], dirs[2], 90, SwordBeam.DIST * 1.15f); + RenderUtil.applyRotate(poseStack, dirs[0], dirs[1], 0, rotate); + poseStack.scale(0.95f, 0.95f, 0.95f); + RenderUtil.renderQuad(poseStack.last().pose(), vertexConsumer1, + 1.0f, 1.0f, 1.0f, alpha, halfWidth, halfHeight, 0f, 0f, 0.02f); + poseStack.popPose(); + + poseStack.pushPose(); + rotateInCenter(poseStack, dirs, rotateAngle); + RenderUtil.applyTranslate(poseStack, dirs[0], dirs[2], 160, SwordBeam.DIST * 1.725f); + RenderUtil.applyRotate(poseStack, dirs[0], dirs[1], -45, rotate); + poseStack.scale(0.95f, 0.95f, 0.95f); + RenderUtil.renderQuad(poseStack.last().pose(), vertexConsumer1, + 1.0f, 1.0f, 1.0f, alpha, halfWidth, halfHeight, 0f, 0f, 0.02f); + poseStack.popPose(); + + VertexConsumer vertexConsumer2 = bufferSource.getBuffer(RenderType.entityTranslucentEmissive(RES2)); + + //闪烁 + poseStack.pushPose(); + rotateInCenter(poseStack, dirs, rotateAngle); + RenderUtil.applyTranslate(poseStack, dirs[0], dirs[2], 180, SwordBeam.DIST * 1.75f); + RenderUtil.applyRotate(poseStack, dirs[0], dirs[1], -45, rotate); + poseStack.mulPose(Axis.ZP.rotationDegrees(45.0F)); + RenderUtil.renderQuad(poseStack.last().pose(), vertexConsumer2, + COLOR2.x(), COLOR2.y(), COLOR2.z(), alpha, 32 * SwordBeam.SCALE, 32 * SwordBeam.SCALE, 0f, 0f, 0.04f); + poseStack.popPose(); + + } + + public void rotateInCenter(PoseStack poseStack, Vector3f[] dirs, float angle) { + float cos = (float) Math.cos(Math.toRadians(90)); + float sin = (float) Math.sin(Math.toRadians(90)); + Vector3f center = new Vector3f( + cos * dirs[2].x + sin * dirs[0].x, + cos * dirs[2].y + sin * dirs[0].y, + cos * dirs[2].z + sin * dirs[0].z + ).normalize().mul(1.15f); + + Quaternionf rotation = new Quaternionf().fromAxisAngleRad( + dirs[1], (float) Math.toRadians(angle) + ); + + poseStack.translate(-center.x, -center.y, -center.z); + poseStack.mulPose(rotation); + poseStack.translate(center.x, center.y, center.z); + } + + @Override + public void tick(StaticSummon summon) { + this.checkBeforeTick(summon); + CompoundTag customData = summon.getEntityData().get(StaticSummon.CUSTOM_DATA); + + //碰撞箱计算 + Vec3 center = summon.position().add(summon.getLookAngle().normalize().scale(SwordBeam.DIST)); + if(customData.contains("extX") && customData.contains("extY") && customData.contains("extZ")) { + summon.setBoundingBox(new AABB( + center.x - customData.getFloat("extX"), center.y - customData.getFloat("extY"), center.z - customData.getFloat("extZ"), + center.x + customData.getFloat("extX"), center.y + customData.getFloat("extY"), center.z + customData.getFloat("extZ") + )); + } + + //碰撞计算 + if(!summon.level().isClientSide() && customData.contains("hitCount") && summon.getOwner() instanceof Player player) { + int count = customData.getInt("hitCount"); + if(count < Config.trueNightsEdgeProjectileMaxHitCount) { + List targets = summon.level().getEntitiesOfClass(LivingEntity.class, summon.getBoundingBox(), FilterUtil.createTargetFilter(summon, summon.getOwner())); + for(LivingEntity target : targets) { + if(count >= Config.trueNightsEdgeProjectileMaxHitCount) break; + if(DamageUtil.attack(player, target, (float) Config.trueNightsEdgeProjectileDamage)) { + count++; + ParticleUtil.addParticles( + (ServerLevel) target.level(), ModParticles.TRUE_NIGHTS_EDGE_HIT_PARTICLE.get(), + new Vec3(target.getX(), target.getY() + target.getBbHeight() / 2.0, target.getZ()), new Vec3(0, 0, 0), + 0, 1 + ); + target.invulnerableTime = 20; + } + } + if(!targets.isEmpty()) customData.putInt("hitCount", count); + } + if(count >= Config.trueNightsEdgeProjectileMaxHitCount) this.onDied(summon); + } + + ClipContext context = new ClipContext( + summon.position(), + summon.position().add(summon.getDeltaMovement()), + ClipContext.Block.COLLIDER, + ClipContext.Fluid.NONE, + summon + ); + BlockHitResult blockHit = summon.level().clip(context); + if(blockHit.getType() != HitResult.Type.MISS) { + + } + + //粒子 + if(summon.level().isClientSide()) { + ParticleUtil.addParticle( + summon.level(), PARTICLE2, + summon.position(), 5.0, + new Vec3(0, 0, 0), 0.5 + ); + } + } + }; + + public static void summon(Player player, int randomAngle) { + StaticSummon summon = new StaticSummon(ModEntities.STATIC_SUMMON.get(), player.level()); + summon.setOwner(player); + Vec3 pos = new Vec3(player.getX(), player.getEyeY() - 0.1, player.getZ()); + summon.setPos(pos); + + if(!Config.trueNightsEdgeProjectileAlignToBlade) randomAngle = (int) (Config.trueNightsEdgeProjectileRotateRange * (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]); + summon.setXRot(xyRot[0]); + summon.xRotO = xyRot[0]; + summon.setYRot(xyRot[1]); + summon.yRotO = xyRot[1]; + + summon.getEntityData().set(StaticSummon.BEHAVIOR, StaticSummonBehaviors.TRUE_NIGHTS_EDGE_BEAM); + summon.getEntityData().set(StaticSummon.RENDER_MODE, "custom"); + summon.getEntityData().set(StaticSummon.LIFETIME, Config.trueNightsEdgeProjectileLifetime); + summon.getEntityData().set(StaticSummon.RZP, randomAngle); + summon.getEntityData().set(StaticSummon.RZPS, Config.trueNightsEdgeProjectileRotationSpeed); + summon.getEntityData().set(StaticSummon.GLOW, true); + summon.setNoGravity(true); + summon.noPhysics = true; + + CompoundTag customData = new CompoundTag(); + + Quaternionf rotation = new Quaternionf() + .fromAxisAngleRad(dirs[0], (float) Math.toRadians(Math.abs(dirs[0].y) > 0.999 ? 0 : randomAngle)) + .rotateY((float) Math.toRadians(-xyRot[1])) + .rotateX((float) Math.toRadians(xyRot[0])) + .rotateX((float) Math.toRadians(-90.0)) + .rotateZ((float) Math.toRadians(-90.0)); + + Vector3f axisX = new Vector3f(1, 0, 0).rotate(rotation); + Vector3f axisY = new Vector3f(0, 1, 0).rotate(rotation); + Vector3f axisZ = new Vector3f(0, 0, 1).rotate(rotation); + + float extX = SwordBeam.HALF_WIDTH * SwordBeam.SCALE * Math.abs(axisX.x()) + SwordBeam.HALF_HEIGHT * SwordBeam.SCALE * Math.abs(axisY.x()) + SwordBeam.HALF_THICKNESS * SwordBeam.SCALE * Math.abs(axisZ.x()); + float extY = SwordBeam.HALF_WIDTH * SwordBeam.SCALE * Math.abs(axisX.y()) + SwordBeam.HALF_HEIGHT * SwordBeam.SCALE * Math.abs(axisY.y()) + SwordBeam.HALF_THICKNESS * SwordBeam.SCALE * Math.abs(axisZ.y()); + float extZ = SwordBeam.HALF_WIDTH * SwordBeam.SCALE * Math.abs(axisX.z()) + SwordBeam.HALF_HEIGHT * SwordBeam.SCALE * Math.abs(axisY.z()) + SwordBeam.HALF_THICKNESS * SwordBeam.SCALE * Math.abs(axisZ.z()); + + customData.putInt("hitCount", 0); + customData.putFloat("extX", extX); + customData.putFloat("extY", extY); + customData.putFloat("extZ", extZ); + customData.putFloat("dirX", dirs[0].x); + customData.putFloat("dirY", dirs[0].y); + customData.putFloat("dirZ", dirs[0].z); + customData.putFloat("upX", dirs[1].x); + customData.putFloat("upY", dirs[1].y); + customData.putFloat("upZ", dirs[1].z); + customData.putFloat("rightX", dirs[2].x); + customData.putFloat("rightY", dirs[2].y); + customData.putFloat("rightZ", dirs[2].z); + summon.getEntityData().set(StaticSummon.CUSTOM_DATA, customData); + + summon.setDeltaMovement(player.getLookAngle().normalize().scale(Config.trueNightsEdgeProjectileSpeed)); + + player.level().addFreshEntity(summon); + } + + public static final IItemWaveBehavior ITEM_WAVE_BEHAVIOR = new IItemWaveBehavior() { + public void onLeftClickAir(PlayerInteractEvent.LeftClickEmpty event) { + Player player = event.getEntity(); + ItemStack itemStack = player.getMainHandItem(); + if(itemStack.isEmpty()) return; + Item item = itemStack.getItem(); + if(item instanceof TrueNightsEdge && !player.getCooldowns().isOnCooldown(item)) { + PacketDistributor.sendToServer(new SwordBeamPayload("true_nights_edge", BEAM_DATA)); + SoundUtil.playClientSound(player, ModSounds.WAVE.get()); + } + } + public void onAttackEntity(AttackEntityEvent event) { + Player player = event.getEntity(); + ItemStack itemStack = player.getMainHandItem(); + if(itemStack.isEmpty()) return; + Item item = itemStack.getItem(); + if(item instanceof TrueNightsEdge && !player.getCooldowns().isOnCooldown(item)) { + if(!player.level().isClientSide()) { + SwordBeamBehaviors.getBehavior("true_nights_edge").generate(player, BEAM_DATA); + }else { + SoundUtil.playClientSound(player, ModSounds.WAVE.get()); + } + } + event.setCanceled(true); + } + }; + + @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()); + SoundUtil.playClientSound(player, ModSounds.WAVE3.get()); + } + return InteractionResultHolder.sidedSuccess(stack, level.isClientSide()); + } } 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 7049192..20e5109 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 @@ -359,8 +359,8 @@ public class Zenith extends SwordItem { public void onHitEntity(StaticProjectile projectile, EntityHitResult result) { if(!projectile.level().isClientSide()) { Entity target = result.getEntity(); - if(projectile.getOwner() instanceof Player player && target instanceof LivingEntity livingEntity && FilterUtil.createLivingTargetFilter(projectile, projectile.getOwner()).test(livingEntity)) { - if(target.hurt(projectile.damageSources().playerAttack(player), (float) (Config.zenithDamage + Math.random() * Config.zenithDamage))) { + if(projectile.getOwner() instanceof Player player && FilterUtil.createTargetFilter(projectile, projectile.getOwner()).test(target)) { + if(DamageUtil.attack(player, target, (float) (Config.zenithDamage + Math.random() * Config.zenithDamage))) { target.invulnerableTime = 2; } } @@ -368,14 +368,19 @@ public class Zenith extends SwordItem { } }; - public static void summon(Player player, boolean isFirst) { + public static void summon(Player player, double deltaDist, boolean isFirst) { Vector3f[] dirs = MathUtil.computeCoordinateSystem(player); int randomAngle = (int) ((Math.random() * 2 - 1) * Config.zenithTrailOffset); dirs = MathUtil.rotateCoordinateSystem(dirs[0], dirs[2], randomAngle); Vec3 pos = (player.getBoundingBox().getCenter()).add(MathUtil.toVec3(dirs[0]).scale(-2)); - Vec3 targetPos = MathUtil.getCrosshairPos(player, player.level(), Config.zenithMaxRange); - double dist = targetPos.subtract(pos).length(); + double dist; + if(Config.zenithDistanceMode) { + Vec3 targetPos = MathUtil.getCrosshairPos(player, player.level(), Config.zenithMaxRange); + dist = Math.max(0, Math.min(targetPos.subtract(pos).length() + deltaDist, Config.zenithMaxRange)); + }else { + dist = deltaDist; + } int cycle = (int) Math.max(10, dist / Config.zenithMaxRange * Config.zenithCycle); double a = Math.max(dist / 2, 2); double b = Math.min(Math.random() * Config.zenithTrailB + Config.zenithTrailB, a / 2); @@ -480,12 +485,14 @@ public class Zenith extends SwordItem { if(entity instanceof Player player) { if(isSelected) { 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"); int count = stack.getOrDefault(DataComponents.CUSTOM_DATA, CustomData.EMPTY) .copyTag().getInt("attackCount"); if(count > 0) { - summon(player, isFirst); + summon(player, deltaDist, isFirst); CustomData.update(DataComponents.CUSTOM_DATA, stack, tag -> tag.putInt("attackCount", count - 1)); CustomData.update(DataComponents.CUSTOM_DATA, stack, diff --git a/src/main/java/com/lzxnone/terraria/mixin/ZenithRenderMixin.java b/src/main/java/com/lzxnone/terraria/mixin/ZenithRenderMixin.java new file mode 100644 index 0000000..2dfd24e --- /dev/null +++ b/src/main/java/com/lzxnone/terraria/mixin/ZenithRenderMixin.java @@ -0,0 +1,67 @@ +package com.lzxnone.terraria.mixin; + +import com.lzxnone.terraria.item.ModItems; +import com.mojang.blaze3d.vertex.PoseStack; +import net.minecraft.client.player.AbstractClientPlayer; +import net.minecraft.client.renderer.ItemInHandRenderer; +import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.core.component.DataComponents; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.entity.HumanoidArm; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.item.ItemDisplayContext; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.component.CustomData; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(ItemInHandRenderer.class) +public class ZenithRenderMixin { + @Shadow + private void renderPlayerArm(PoseStack poseStack, MultiBufferSource buffer, int packedLight, + float equippedProgress, float swingProgress, HumanoidArm side) {} + + @Inject(method = "renderArmWithItem", at = @At("HEAD"), cancellable = true) + private void renderHand(AbstractClientPlayer player, float partialTicks, float pitch, + InteractionHand hand, float swingProgress, ItemStack stack, + float equippedProgress, PoseStack poseStack, + MultiBufferSource buffer, int combinedLight, CallbackInfo ci) { + + if(!player.isScoping()) { + if(stack.is(ModItems.ZENITH.get()) || stack.is(ModItems.TRUE_COPPER_SHORTSWORD.get())) { + int count = stack.getOrDefault(DataComponents.CUSTOM_DATA, CustomData.EMPTY) + .copyTag().getInt("attackCount"); + if(count > 0) { + boolean isMainHand = hand == InteractionHand.MAIN_HAND; + HumanoidArm humanoidarm = isMainHand ? player.getMainArm() : player.getMainArm().getOpposite(); + + poseStack.pushPose(); + + if(!player.isInvisible()) { + this.renderPlayerArm(poseStack, buffer, combinedLight, equippedProgress, swingProgress, humanoidarm); + } + + poseStack.popPose(); + ci.cancel(); + } + } + } + } + + @Inject(method = "renderItem", at = @At("HEAD"), cancellable = true) + private void renderZenith(LivingEntity entity, ItemStack itemStack, ItemDisplayContext displayContext, + boolean leftHand, PoseStack poseStack, MultiBufferSource buffer, + int seed, CallbackInfo ci) { + + if(itemStack.is(ModItems.ZENITH.get()) || itemStack.is(ModItems.TRUE_COPPER_SHORTSWORD.get())) { + int count = itemStack.getOrDefault(DataComponents.CUSTOM_DATA, CustomData.EMPTY) + .copyTag().getInt("attackCount"); + if(count > 0) { + ci.cancel(); + } + } + } +} diff --git a/src/main/java/com/lzxnone/terraria/network/ModNetwork.java b/src/main/java/com/lzxnone/terraria/network/ModNetwork.java index 7d30a73..4cb7897 100644 --- a/src/main/java/com/lzxnone/terraria/network/ModNetwork.java +++ b/src/main/java/com/lzxnone/terraria/network/ModNetwork.java @@ -2,7 +2,9 @@ package com.lzxnone.terraria.network; import com.lzxnone.terraria.LzxnoneTerraria; import com.lzxnone.terraria.network.handler.SwordBeamHandler; +import com.lzxnone.terraria.network.handler.ZenithScrollHandler; import com.lzxnone.terraria.network.payload.SwordBeamPayload; +import com.lzxnone.terraria.network.payload.ZenithScrollPayload; import net.neoforged.bus.api.SubscribeEvent; import net.neoforged.fml.common.EventBusSubscriber; import net.neoforged.neoforge.network.event.RegisterPayloadHandlersEvent; @@ -18,5 +20,10 @@ public class ModNetwork { SwordBeamPayload.CODEC, SwordBeamHandler::handle ); + registrar.playToServer( + ZenithScrollPayload.TYPE, + ZenithScrollPayload.CODEC, + ZenithScrollHandler::handle + ); } } diff --git a/src/main/java/com/lzxnone/terraria/network/handler/ZenithScrollHandler.java b/src/main/java/com/lzxnone/terraria/network/handler/ZenithScrollHandler.java new file mode 100644 index 0000000..024477a --- /dev/null +++ b/src/main/java/com/lzxnone/terraria/network/handler/ZenithScrollHandler.java @@ -0,0 +1,42 @@ +package com.lzxnone.terraria.network.handler; + +import com.lzxnone.terraria.Config; +import com.lzxnone.terraria.item.weapon.melee.TrueCopperShortsword; +import com.lzxnone.terraria.item.weapon.melee.Zenith; +import com.lzxnone.terraria.network.payload.ZenithScrollPayload; +import net.minecraft.core.component.DataComponents; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.component.CustomData; +import net.minecraft.world.level.Level; +import net.neoforged.neoforge.network.handling.IPayloadContext; + +public class ZenithScrollHandler { + public static void handle(final ZenithScrollPayload payload, final IPayloadContext context) { + context.enqueueWork(() -> { + Level level = context.player().level(); + if(level.isClientSide()) return; + Player player = context.player(); + ItemStack weapon = player.getMainHandItem(); + if(weapon.getItem() instanceof Zenith || weapon.getItem() instanceof TrueCopperShortsword) { + double scrollDelta = payload.scrollDelta(); + double deltaDist = weapon.getOrDefault(DataComponents.CUSTOM_DATA, CustomData.EMPTY) + .copyTag().getDouble("deltaDist"); + double finalDelta = deltaDist + scrollDelta * Config.zenithMouseSpeed; + + if(Config.zenithDistanceMode) { + + if(finalDelta > Config.zenithMaxRange) finalDelta = Config.zenithMaxRange; + else if(finalDelta < -Config.zenithMaxRange) finalDelta = -Config.zenithMaxRange; + }else { + if(finalDelta > Config.zenithMaxRange) finalDelta = Config.zenithMaxRange; + else if(finalDelta < 0) finalDelta = 0; + } + + double finalDelta1 = finalDelta; + CustomData.update(DataComponents.CUSTOM_DATA, weapon, + tag -> tag.putDouble("deltaDist", finalDelta1)); + } + }); + } +} diff --git a/src/main/java/com/lzxnone/terraria/network/payload/ZenithScrollPayload.java b/src/main/java/com/lzxnone/terraria/network/payload/ZenithScrollPayload.java new file mode 100644 index 0000000..25a0bc3 --- /dev/null +++ b/src/main/java/com/lzxnone/terraria/network/payload/ZenithScrollPayload.java @@ -0,0 +1,23 @@ +package com.lzxnone.terraria.network.payload; + +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.network.codec.ByteBufCodecs; +import net.minecraft.network.codec.StreamCodec; +import net.minecraft.network.protocol.common.custom.CustomPacketPayload; +import net.minecraft.resources.ResourceLocation; + +public record ZenithScrollPayload(double scrollDelta) implements CustomPacketPayload { + public static final Type TYPE = new Type<>( + ResourceLocation.fromNamespaceAndPath("lzxnoneterraria", "zenith_scroll_payload") + ); + + public static final StreamCodec CODEC = StreamCodec.composite( + ByteBufCodecs.DOUBLE, ZenithScrollPayload::scrollDelta, + ZenithScrollPayload::new + ); + + @Override + public Type type() { + return TYPE; + } +} diff --git a/src/main/java/com/lzxnone/terraria/particle/BloodButcheredParticle.java b/src/main/java/com/lzxnone/terraria/particle/BloodButcheredParticle.java new file mode 100644 index 0000000..b86c3da --- /dev/null +++ b/src/main/java/com/lzxnone/terraria/particle/BloodButcheredParticle.java @@ -0,0 +1,66 @@ +package com.lzxnone.terraria.particle; + +import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.client.particle.*; +import net.minecraft.core.particles.SimpleParticleType; + +public class BloodButcheredParticle extends TextureSheetParticle { + private final float rotSpeed; + private final float baseSize; + + protected BloodButcheredParticle(ClientLevel level, double x, double y, double z, + double xSpeed, double ySpeed, double zSpeed, SpriteSet spriteSet) { + super(level, x, y, z, xSpeed, ySpeed, zSpeed); + this.hasPhysics = false; + + this.friction = 0.9F; + this.gravity = 0.0F; + this.xd = xSpeed; + this.yd = ySpeed; + this.zd = zSpeed; + + this.baseSize = 0.05F + (this.random.nextFloat() * 0.05F); + this.quadSize = baseSize; + + this.roll = this.random.nextFloat() * ((float)Math.PI * 2F); + this.oRoll = this.roll; + this.rotSpeed = (this.random.nextFloat() - 0.5F) * 0.5F; + + this.lifetime = 20 + this.random.nextInt(10); + + this.pickSprite(spriteSet); + } + + @Override + public void tick() { + super.tick(); + + this.oRoll = this.roll; + this.roll += this.rotSpeed; + + float lifeRatio = (float) this.age / (float) this.lifetime; + + this.quadSize = this.baseSize * (1.0F - lifeRatio); + this.alpha = 1.0F - lifeRatio; + } + + @Override + public ParticleRenderType getRenderType() { + return ModParticleRenderTypes.TRANSLUCENT_EMISSIVE; + } + + public static class Provider implements ParticleProvider { + private final SpriteSet spriteSet; + + public Provider(SpriteSet spriteSet) { + this.spriteSet = spriteSet; + } + + @Override + public Particle createParticle(SimpleParticleType type, ClientLevel level, + double x, double y, double z, + double xSpeed, double ySpeed, double zSpeed) { + return new BloodButcheredParticle(level, x, y, z, xSpeed, ySpeed, zSpeed, this.spriteSet); + } + } +} diff --git a/src/main/java/com/lzxnone/terraria/particle/ExcaliburHitParticle.java b/src/main/java/com/lzxnone/terraria/particle/ExcaliburHitParticle.java new file mode 100644 index 0000000..c22f2a3 --- /dev/null +++ b/src/main/java/com/lzxnone/terraria/particle/ExcaliburHitParticle.java @@ -0,0 +1,70 @@ +package com.lzxnone.terraria.particle; + +import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.client.particle.*; +import net.minecraft.client.renderer.LightTexture; +import net.minecraft.core.particles.SimpleParticleType; + +public class ExcaliburHitParticle extends TextureSheetParticle { + private final float baseSize; + + protected ExcaliburHitParticle(ClientLevel level, double x, double y, double z, + double xSpeed, double ySpeed, double zSpeed, SpriteSet spriteSet) { + super(level, x, y, z, xSpeed, ySpeed, zSpeed); + this.hasPhysics = false; + + this.friction = 0.9F; + this.gravity = 0.0F; + this.xd = xSpeed; + this.yd = ySpeed; + this.zd = zSpeed; + + this.baseSize = 1.0F; + this.quadSize = baseSize; + + this.alpha = 1.0f; + + this.lifetime = 10; + + this.pickSprite(spriteSet); + } + + @Override + public void tick() { + super.tick(); + + float lifeRatio = (float) this.age / (float) this.lifetime; + if(lifeRatio <= 0.25f) { + this.quadSize = (lifeRatio / 0.25f) * this.baseSize; + }else if(lifeRatio >= 0.75f) { + this.quadSize = (1.0f - (lifeRatio - 0.75f) / 0.25f) * this.baseSize; + }else { + this.quadSize = this.baseSize; + } + } + + @Override + public int getLightColor(float partialTick) { + return LightTexture.FULL_BRIGHT; + } + + @Override + public ParticleRenderType getRenderType() { + return ModParticleRenderTypes.TRANSLUCENT_EMISSIVE; + } + + public static class Provider implements ParticleProvider { + private final SpriteSet spriteSet; + + public Provider(SpriteSet spriteSet) { + this.spriteSet = spriteSet; + } + + @Override + public Particle createParticle(SimpleParticleType type, ClientLevel level, + double x, double y, double z, + double xSpeed, double ySpeed, double zSpeed) { + return new ExcaliburHitParticle(level, x, y, z, xSpeed, ySpeed, zSpeed, this.spriteSet); + } + } +} diff --git a/src/main/java/com/lzxnone/terraria/particle/ModParticles.java b/src/main/java/com/lzxnone/terraria/particle/ModParticles.java index 6b98390..5e8105b 100644 --- a/src/main/java/com/lzxnone/terraria/particle/ModParticles.java +++ b/src/main/java/com/lzxnone/terraria/particle/ModParticles.java @@ -84,4 +84,14 @@ public class ModParticles { PARTICLE_TYPES.register("influx_waver_drop_particle", () -> new SimpleParticleType(true)); public static final Supplier TERRA_BEAM_HIT_PARTICLE = PARTICLE_TYPES.register("terra_beam_hit_particle", () -> new SimpleParticleType(true)); + public static final Supplier EXCALIBUR_HIT_PARTICLE = + PARTICLE_TYPES.register("excalibur_hit_particle", () -> new SimpleParticleType(true)); + public static final Supplier TRUE_EXCALIBUR_HIT_PARTICLE = + PARTICLE_TYPES.register("true_excalibur_hit_particle", () -> new SimpleParticleType(true)); + public static final Supplier NIGHTS_EDGE_HIT_PARTICLE = + PARTICLE_TYPES.register("nights_edge_hit_particle", () -> new SimpleParticleType(true)); + public static final Supplier TRUE_NIGHTS_EDGE_HIT_PARTICLE = + PARTICLE_TYPES.register("true_nights_edge_hit_particle", () -> new SimpleParticleType(true)); + public static final Supplier BLOOD_BUTCHERED_PARTICLE = + PARTICLE_TYPES.register("blood_butchered_particle", () -> new SimpleParticleType(true)); } \ No newline at end of file diff --git a/src/main/java/com/lzxnone/terraria/particle/NightsEdgeHitParticle.java b/src/main/java/com/lzxnone/terraria/particle/NightsEdgeHitParticle.java new file mode 100644 index 0000000..93f1ebf --- /dev/null +++ b/src/main/java/com/lzxnone/terraria/particle/NightsEdgeHitParticle.java @@ -0,0 +1,74 @@ +package com.lzxnone.terraria.particle; + +import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.client.particle.*; +import net.minecraft.client.renderer.LightTexture; +import net.minecraft.core.particles.SimpleParticleType; + +public class NightsEdgeHitParticle extends TextureSheetParticle { + private final float baseSize; + private final SpriteSet spriteSet; + + protected NightsEdgeHitParticle(ClientLevel level, double x, double y, double z, + double xSpeed, double ySpeed, double zSpeed, SpriteSet spriteSet) { + super(level, x, y, z, xSpeed, ySpeed, zSpeed); + this.hasPhysics = false; + + this.friction = 0.9F; + this.gravity = 0.0F; + this.xd = xSpeed; + this.yd = ySpeed; + this.zd = zSpeed; + + this.baseSize = 0.8F; + this.quadSize = baseSize; + + this.alpha = 1.0f; + + this.lifetime = 10; + + this.spriteSet = spriteSet; + this.setSpriteFromAge(spriteSet); + } + + @Override + public void tick() { + super.tick(); + + float lifeRatio = (float) this.age / (float) this.lifetime; + if(lifeRatio <= 0.25f) { + this.quadSize = (lifeRatio / 0.25f) * this.baseSize; + }else if(lifeRatio >= 0.75f) { + this.quadSize = (1.0f - (lifeRatio - 0.75f) / 0.25f) * this.baseSize; + }else { + this.quadSize = this.baseSize; + } + + this.setSpriteFromAge(this.spriteSet); + } + + @Override + public int getLightColor(float partialTick) { + return LightTexture.FULL_BRIGHT; + } + + @Override + public ParticleRenderType getRenderType() { + return ModParticleRenderTypes.TRANSLUCENT_EMISSIVE; + } + + public static class Provider implements ParticleProvider { + private final SpriteSet spriteSet; + + public Provider(SpriteSet spriteSet) { + this.spriteSet = spriteSet; + } + + @Override + public Particle createParticle(SimpleParticleType type, ClientLevel level, + double x, double y, double z, + double xSpeed, double ySpeed, double zSpeed) { + return new NightsEdgeHitParticle(level, x, y, z, xSpeed, ySpeed, zSpeed, this.spriteSet); + } + } +} diff --git a/src/main/java/com/lzxnone/terraria/particle/TrueExcaliburHitParticle.java b/src/main/java/com/lzxnone/terraria/particle/TrueExcaliburHitParticle.java new file mode 100644 index 0000000..1d9d1fa --- /dev/null +++ b/src/main/java/com/lzxnone/terraria/particle/TrueExcaliburHitParticle.java @@ -0,0 +1,74 @@ +package com.lzxnone.terraria.particle; + +import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.client.particle.*; +import net.minecraft.client.renderer.LightTexture; +import net.minecraft.core.particles.SimpleParticleType; + +public class TrueExcaliburHitParticle extends TextureSheetParticle { + private final float baseSize; + + protected TrueExcaliburHitParticle(ClientLevel level, double x, double y, double z, + double xSpeed, double ySpeed, double zSpeed, SpriteSet spriteSet) { + super(level, x, y, z, xSpeed, ySpeed, zSpeed); + this.hasPhysics = false; + + this.friction = 0.9F; + this.gravity = 0.0F; + this.xd = xSpeed; + this.yd = ySpeed; + this.zd = zSpeed; + + this.baseSize = 0.8F; + this.quadSize = baseSize; + + this.alpha = 1.0f; + + this.lifetime = 20; + + this.pickSprite(spriteSet); + } + + @Override + public void tick() { + super.tick(); + if(this.age <= 10) { + this.quadSize = 0; + return; + } + + float lifeRatio = (float) this.age / (float) this.lifetime; + if(lifeRatio <= 0.25f) { + this.quadSize = (lifeRatio / 0.25f) * this.baseSize; + }else if(lifeRatio >= 0.75f) { + this.quadSize = (1.0f - (lifeRatio - 0.75f) / 0.25f) * this.baseSize; + }else { + this.quadSize = this.baseSize; + } + } + + @Override + public int getLightColor(float partialTick) { + return LightTexture.FULL_BRIGHT; + } + + @Override + public ParticleRenderType getRenderType() { + return ModParticleRenderTypes.TRANSLUCENT_EMISSIVE; + } + + public static class Provider implements ParticleProvider { + private final SpriteSet spriteSet; + + public Provider(SpriteSet spriteSet) { + this.spriteSet = spriteSet; + } + + @Override + public Particle createParticle(SimpleParticleType type, ClientLevel level, + double x, double y, double z, + double xSpeed, double ySpeed, double zSpeed) { + return new TrueExcaliburHitParticle(level, x, y, z, xSpeed, ySpeed, zSpeed, this.spriteSet); + } + } +} diff --git a/src/main/java/com/lzxnone/terraria/particle/TrueNightsEdgeHitParticle.java b/src/main/java/com/lzxnone/terraria/particle/TrueNightsEdgeHitParticle.java new file mode 100644 index 0000000..be9e64a --- /dev/null +++ b/src/main/java/com/lzxnone/terraria/particle/TrueNightsEdgeHitParticle.java @@ -0,0 +1,74 @@ +package com.lzxnone.terraria.particle; + +import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.client.particle.*; +import net.minecraft.client.renderer.LightTexture; +import net.minecraft.core.particles.SimpleParticleType; + +public class TrueNightsEdgeHitParticle extends TextureSheetParticle { + private final float baseSize; + private final SpriteSet spriteSet; + + protected TrueNightsEdgeHitParticle(ClientLevel level, double x, double y, double z, + double xSpeed, double ySpeed, double zSpeed, SpriteSet spriteSet) { + super(level, x, y, z, xSpeed, ySpeed, zSpeed); + this.hasPhysics = false; + + this.friction = 0.9F; + this.gravity = 0.0F; + this.xd = xSpeed; + this.yd = ySpeed; + this.zd = zSpeed; + + this.baseSize = 0.8F; + this.quadSize = baseSize; + + this.alpha = 1.0f; + + this.lifetime = 10; + + this.spriteSet = spriteSet; + this.setSpriteFromAge(spriteSet); + } + + @Override + public void tick() { + super.tick(); + + float lifeRatio = (float) this.age / (float) this.lifetime; + if(lifeRatio <= 0.25f) { + this.quadSize = (lifeRatio / 0.25f) * this.baseSize; + }else if(lifeRatio >= 0.75f) { + this.quadSize = (1.0f - (lifeRatio - 0.75f) / 0.25f) * this.baseSize; + }else { + this.quadSize = this.baseSize; + } + + this.setSpriteFromAge(this.spriteSet); + } + + @Override + public int getLightColor(float partialTick) { + return LightTexture.FULL_BRIGHT; + } + + @Override + public ParticleRenderType getRenderType() { + return ModParticleRenderTypes.TRANSLUCENT_EMISSIVE; + } + + public static class Provider implements ParticleProvider { + private final SpriteSet spriteSet; + + public Provider(SpriteSet spriteSet) { + this.spriteSet = spriteSet; + } + + @Override + public Particle createParticle(SimpleParticleType type, ClientLevel level, + double x, double y, double z, + double xSpeed, double ySpeed, double zSpeed) { + return new TrueNightsEdgeHitParticle(level, x, y, z, xSpeed, ySpeed, zSpeed, this.spriteSet); + } + } +} diff --git a/src/main/java/com/lzxnone/terraria/utils/DamageUtil.java b/src/main/java/com/lzxnone/terraria/utils/DamageUtil.java new file mode 100644 index 0000000..222492d --- /dev/null +++ b/src/main/java/com/lzxnone/terraria/utils/DamageUtil.java @@ -0,0 +1,40 @@ +package com.lzxnone.terraria.utils; + +import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.damagesource.DamageSource; +import net.minecraft.world.effect.MobEffects; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.enchantment.EnchantmentHelper; + +import java.util.Objects; + +public class DamageUtil { + public static boolean attack(Player player, Entity target, float damage) { + float finalDamage = damage; + if(player.hasEffect(MobEffects.DAMAGE_BOOST) && player.getEffect(MobEffects.DAMAGE_BOOST) != null) { + int amplifier = Objects.requireNonNull(player.getEffect(MobEffects.DAMAGE_BOOST)).getAmplifier(); + finalDamage += (amplifier + 1) * 3.0F; + } + if(player.hasEffect(MobEffects.WEAKNESS) && player.getEffect(MobEffects.WEAKNESS) != null) { + int amplifier = Objects.requireNonNull(player.getEffect(MobEffects.WEAKNESS)).getAmplifier(); + finalDamage -= (amplifier + 1) * 4.0F; + } + finalDamage = Math.max(0.0F, finalDamage); + + DamageSource source = player.level().damageSources().playerAttack(player); + if(player.level() instanceof ServerLevel serverLevel) { + finalDamage = EnchantmentHelper.modifyDamage(serverLevel, player.getWeaponItem(), target, source, finalDamage); + } + finalDamage = Math.max(0.0F, finalDamage); + + boolean hasHurt = target.hurt(source, finalDamage); + + if(hasHurt && player.level() instanceof ServerLevel serverLevel) { + EnchantmentHelper.doPostAttackEffects(serverLevel, target, source); + } + + return hasHurt; + } +} diff --git a/src/main/java/com/lzxnone/terraria/utils/RenderUtil.java b/src/main/java/com/lzxnone/terraria/utils/RenderUtil.java new file mode 100644 index 0000000..f73dec7 --- /dev/null +++ b/src/main/java/com/lzxnone/terraria/utils/RenderUtil.java @@ -0,0 +1,59 @@ +package 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.LightTexture; +import net.minecraft.client.renderer.texture.OverlayTexture; +import org.joml.Matrix4f; +import org.joml.Quaternionf; +import org.joml.Vector3f; + +public class RenderUtil { + public static void applyRotate(PoseStack poseStack, Vector3f dir, Vector3f up, double angle, double rotate) { + Quaternionf rotation = new Quaternionf() + .fromAxisAngleRad(up, (float) Math.toRadians(angle)); + Quaternionf rotation2 = new Quaternionf() + .fromAxisAngleRad(dir, (float) Math.toRadians(Math.abs(dir.y) > 0.999 ? 0 : rotate)); + poseStack.mulPose(rotation); + poseStack.mulPose(rotation2); + + float[] xyRot = MathUtil.computeXYRot(dir, up); + poseStack.mulPose(Axis.YP.rotationDegrees(-xyRot[1])); + poseStack.mulPose(Axis.XP.rotationDegrees(xyRot[0])); + + poseStack.mulPose(Axis.XP.rotationDegrees(-90.0F)); + poseStack.mulPose(Axis.ZP.rotationDegrees(-90.0F)); + } + + 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)); + Vector3f current = new Vector3f( + cos * right.x + sin * dir.x, + cos * right.y + sin * dir.y, + cos * right.z + sin * dir.z + ).normalize(); + poseStack.translate(current.x * dist, current.y * dist, current.z * dist); + } + + public static void renderQuad(Matrix4f matrix, VertexConsumer consumer, float r, float g, float b, float a, float halfWidth, float halfHeight, float offsetX, float offsetY, float offsetZ) { + int ir = (int) (r * 255.0F); + int ig = (int) (g * 255.0F); + int ib = (int) (b * 255.0F); + int ia = (int) (a * 255.0F); + + consumer.addVertex(matrix, -halfWidth, -halfHeight + offsetY, offsetZ) + .setColor(ir, ig, ib, ia).setUv(0.0f, 1.0f) + .setOverlay(OverlayTexture.NO_OVERLAY).setLight(LightTexture.FULL_BRIGHT).setNormal(0.0f, 1.0f, 0.0f); + consumer.addVertex(matrix, halfWidth, -halfHeight + offsetY, offsetZ) + .setColor(ir, ig, ib, ia).setUv(1.0f, 1.0f) + .setOverlay(OverlayTexture.NO_OVERLAY).setLight(LightTexture.FULL_BRIGHT).setNormal(0.0f, 1.0f, 0.0f); + consumer.addVertex(matrix, halfWidth, halfHeight + offsetY, offsetZ) + .setColor(ir, ig, ib, ia).setUv(1.0f, 0.0f) + .setOverlay(OverlayTexture.NO_OVERLAY).setLight(LightTexture.FULL_BRIGHT).setNormal(0.0f, 1.0f, 0.0f); + consumer.addVertex(matrix, -halfWidth, halfHeight + offsetY, offsetZ) + .setColor(ir, ig, ib, ia).setUv(0.0f, 0.0f) + .setOverlay(OverlayTexture.NO_OVERLAY).setLight(LightTexture.FULL_BRIGHT).setNormal(0.0f, 1.0f, 0.0f); + } +} diff --git a/src/main/resources/assets/lzxnoneterraria/lang/en_us.json b/src/main/resources/assets/lzxnoneterraria/lang/en_us.json index bb32f38..ccc8bc9 100644 --- a/src/main/resources/assets/lzxnoneterraria/lang/en_us.json +++ b/src/main/resources/assets/lzxnoneterraria/lang/en_us.json @@ -30,6 +30,7 @@ "entity.lzxnoneterraria.bee_summon": "Bee", "effect.lzxnoneterraria.confused": "Confused", + "effect.lzxnoneterraria.blood_butchered": "Blood Butchered", "lzxnoneterraria.configuration.enchanted_sword_settings": "Enchanted Sword Settings", "lzxnoneterraria.configuration.enchanted_sword_damage": "Projectile Damage", @@ -47,6 +48,14 @@ "lzxnoneterraria.configuration.bee_keeper_bee_damage": "Bee Damage", "lzxnoneterraria.configuration.bee_keeper_bee_damage.tooltip": "Damage dealt by each bee", + "lzxnoneterraria.configuration.blood_butcherer_settings": "Blood Butcherer Settings", + "lzxnoneterraria.configuration.blood_butcherer_effect_duration": "Butchery Effect Duration", + "lzxnoneterraria.configuration.blood_butcherer_effect_duration.tooltip": "Duration of the butchery effect in ticks", + "lzxnoneterraria.configuration.blood_butcherer_max_level": "Max Butchery Level", + "lzxnoneterraria.configuration.blood_butcherer_max_level.tooltip": "Maximum stackable level of the butchery effect", + "lzxnoneterraria.configuration.blood_butcherer_damage_per_level": "Damage Per Level", + "lzxnoneterraria.configuration.blood_butcherer_damage_per_level.tooltip": "Damage dealt per butchery level", + "lzxnoneterraria.configuration.starfury_settings": "Starfury Settings", "lzxnoneterraria.configuration.starfury_damage": "Projectile Damage", "lzxnoneterraria.configuration.starfury_damage.tooltip": "Damage per hit", @@ -113,6 +122,44 @@ "lzxnoneterraria.configuration.meowmere_initial_speed": "Initial Speed", "lzxnoneterraria.configuration.meowmere_initial_speed.tooltip": "Projectile initial speed", + "lzxnoneterraria.configuration.lights_bane_settings": "Lights Bane Settings", + "lzxnoneterraria.configuration.lights_bane_big_damage": "Big Slash Damage", + "lzxnoneterraria.configuration.lights_bane_big_damage.tooltip": "Damage dealt by big slash", + "lzxnoneterraria.configuration.lights_bane_small_damage": "Small Slash Damage", + "lzxnoneterraria.configuration.lights_bane_small_damage.tooltip": "Damage dealt by small slash", + "lzxnoneterraria.configuration.lights_bane_target_range": "Target Acquisition Range", + "lzxnoneterraria.configuration.lights_bane_target_range.tooltip": "Range to search for nearby enemies", + + "lzxnoneterraria.configuration.excalibur_settings": "Excalibur Settings", + "lzxnoneterraria.configuration.excalibur_rotate_range": "Blade Rotate Range", + "lzxnoneterraria.configuration.excalibur_rotate_range.tooltip": "Blade rotation angle range", + "lzxnoneterraria.configuration.excalibur_max_hit_count": "Blade Max Hit Count", + "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_settings": "Night's Edge Settings", + "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", + "lzxnoneterraria.configuration.nights_edge_projectile_max_hit_count.tooltip": "Maximum entities hit per projectile", + "lzxnoneterraria.configuration.nights_edge_damage": "Blade Damage", + "lzxnoneterraria.configuration.nights_edge_damage.tooltip": "Damage dealt by blade", + "lzxnoneterraria.configuration.nights_edge_projectile_damage": "Projectile Damage", + "lzxnoneterraria.configuration.nights_edge_projectile_damage.tooltip": "Damage per hit", + "lzxnoneterraria.configuration.nights_edge_projectile_speed": "Projectile Speed", + "lzxnoneterraria.configuration.nights_edge_projectile_speed.tooltip": "Projectile movement speed", + "lzxnoneterraria.configuration.nights_edge_projectile_lifetime": "Projectile Lifetime", + "lzxnoneterraria.configuration.nights_edge_projectile_lifetime.tooltip": "Projectile duration in ticks", + "lzxnoneterraria.configuration.nights_edge_projectile_rotation_speed": "Projectile Rotation Speed", + "lzxnoneterraria.configuration.nights_edge_projectile_rotation_speed.tooltip": "Projectile rotation speed", + "lzxnoneterraria.configuration.terra_blade_settings": "Terra Blade Settings", "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", @@ -136,6 +183,10 @@ "lzxnoneterraria.configuration.zenith_settings": "Zenith Settings", "lzxnoneterraria.configuration.zenith_damage": "Projectile Damage", "lzxnoneterraria.configuration.zenith_damage.tooltip": "Damage per hit (applied as x~2x this value)", + "lzxnoneterraria.configuration.zenith_distance_mode": "Enable Relative Distance Mode", + "lzxnoneterraria.configuration.zenith_distance_mode.tooltip": "The mode of distance", + "lzxnoneterraria.configuration.zenith_mouse_speed": "Scroll Speed", + "lzxnoneterraria.configuration.zenith_mouse_speed.tooltip": "Scroll Distance Per Tick", "lzxnoneterraria.configuration.zenith_max_range": "Max Range", "lzxnoneterraria.configuration.zenith_max_range.tooltip": "Maximum projectile travel range", "lzxnoneterraria.configuration.zenith_trail_b": "Orbit Semi-Axis (b)", @@ -153,5 +204,35 @@ "lzxnoneterraria.configuration.zenith_trail_alpha": "Trail Opacity", "lzxnoneterraria.configuration.zenith_trail_alpha.tooltip": "Trail rendering opacity", "lzxnoneterraria.configuration.zenith_trail_max_length": "Trail Length", - "lzxnoneterraria.configuration.zenith_trail_max_length.tooltip": "Maximum number of trail segments" + "lzxnoneterraria.configuration.zenith_trail_max_length.tooltip": "Maximum number of trail segments", + + "lzxnoneterraria.configuration.true_excalibur_settings": "True Excalibur Settings", + "lzxnoneterraria.configuration.true_excalibur_rotate_range": "Blade Rotate Range", + "lzxnoneterraria.configuration.true_excalibur_rotate_range.tooltip": "Blade rotation angle range", + "lzxnoneterraria.configuration.true_excalibur_max_hit_count": "Blade Max Hit Count", + "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_settings": "True Night's Edge Settings", + "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", + "lzxnoneterraria.configuration.true_nights_edge_projectile_max_hit_count.tooltip": "Maximum entities hit per projectile", + "lzxnoneterraria.configuration.true_nights_edge_damage": "Blade Damage", + "lzxnoneterraria.configuration.true_nights_edge_damage.tooltip": "Damage dealt by blade", + "lzxnoneterraria.configuration.true_nights_edge_projectile_damage": "Projectile Damage", + "lzxnoneterraria.configuration.true_nights_edge_projectile_damage.tooltip": "Damage per hit", + "lzxnoneterraria.configuration.true_nights_edge_projectile_speed": "Projectile Speed", + "lzxnoneterraria.configuration.true_nights_edge_projectile_speed.tooltip": "Projectile movement speed", + "lzxnoneterraria.configuration.true_nights_edge_projectile_lifetime": "Projectile Lifetime", + "lzxnoneterraria.configuration.true_nights_edge_projectile_lifetime.tooltip": "Projectile duration in ticks", + "lzxnoneterraria.configuration.true_nights_edge_projectile_rotation_speed": "Projectile Rotation Speed", + "lzxnoneterraria.configuration.true_nights_edge_projectile_rotation_speed.tooltip": "Projectile rotation speed" } diff --git a/src/main/resources/assets/lzxnoneterraria/lang/zh_cn.json b/src/main/resources/assets/lzxnoneterraria/lang/zh_cn.json index 45f9898..95898bc 100644 --- a/src/main/resources/assets/lzxnoneterraria/lang/zh_cn.json +++ b/src/main/resources/assets/lzxnoneterraria/lang/zh_cn.json @@ -30,6 +30,7 @@ "entity.lzxnoneterraria.bee_summon": "蜜蜂", "effect.lzxnoneterraria.confused": "困惑", + "effect.lzxnoneterraria.blood_butchered": "血腥屠宰", "lzxnoneterraria.configuration.enchanted_sword_settings": "附魔剑 设置", "lzxnoneterraria.configuration.enchanted_sword_damage": "弹射伤害", @@ -47,6 +48,14 @@ "lzxnoneterraria.configuration.bee_keeper_bee_damage": "蜜蜂伤害", "lzxnoneterraria.configuration.bee_keeper_bee_damage.tooltip": "每只蜜蜂的攻击伤害", + "lzxnoneterraria.configuration.blood_butcherer_settings": "血腥屠刀 设置", + "lzxnoneterraria.configuration.blood_butcherer_effect_duration": "屠宰效果持续时间", + "lzxnoneterraria.configuration.blood_butcherer_effect_duration.tooltip": "血腥屠宰效果的持续时间(刻)", + "lzxnoneterraria.configuration.blood_butcherer_max_level": "屠宰效果最大等级", + "lzxnoneterraria.configuration.blood_butcherer_max_level.tooltip": "血腥屠宰效果的可叠加最大等级", + "lzxnoneterraria.configuration.blood_butcherer_damage_per_level": "每级伤害", + "lzxnoneterraria.configuration.blood_butcherer_damage_per_level.tooltip": "每级血腥屠宰效果造成的伤害", + "lzxnoneterraria.configuration.starfury_settings": "星怒 设置", "lzxnoneterraria.configuration.starfury_damage": "弹射伤害", "lzxnoneterraria.configuration.starfury_damage.tooltip": "每次命中伤害", @@ -113,6 +122,44 @@ "lzxnoneterraria.configuration.meowmere_initial_speed": "弹射初速度", "lzxnoneterraria.configuration.meowmere_initial_speed.tooltip": "弹射物初始速度", + "lzxnoneterraria.configuration.lights_bane_settings": "魔光剑 设置", + "lzxnoneterraria.configuration.lights_bane_big_damage": "大斩击伤害", + "lzxnoneterraria.configuration.lights_bane_big_damage.tooltip": "大斩击造成的伤害", + "lzxnoneterraria.configuration.lights_bane_small_damage": "小斩击伤害", + "lzxnoneterraria.configuration.lights_bane_small_damage.tooltip": "小斩击造成的伤害", + "lzxnoneterraria.configuration.lights_bane_target_range": "寻敌范围", + "lzxnoneterraria.configuration.lights_bane_target_range.tooltip": "搜索附近敌人的距离", + + "lzxnoneterraria.configuration.excalibur_settings": "断钢剑 设置", + "lzxnoneterraria.configuration.excalibur_rotate_range": "刀光偏转角范围", + "lzxnoneterraria.configuration.excalibur_rotate_range.tooltip": "刀光旋转角度范围", + "lzxnoneterraria.configuration.excalibur_max_hit_count": "刀光最大击中数", + "lzxnoneterraria.configuration.excalibur_max_hit_count.tooltip": "刀光单次最大击中生物数量", + "lzxnoneterraria.configuration.excalibur_damage": "刀光伤害", + "lzxnoneterraria.configuration.excalibur_damage.tooltip": "刀光造成的伤害", + + "lzxnoneterraria.configuration.nights_edge_settings": "永夜刃 设置", + "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": "弹射刀光最大击中数", + "lzxnoneterraria.configuration.nights_edge_projectile_max_hit_count.tooltip": "弹射刀光单次最大击中生物数量", + "lzxnoneterraria.configuration.nights_edge_damage": "刀光伤害", + "lzxnoneterraria.configuration.nights_edge_damage.tooltip": "刀光造成的伤害", + "lzxnoneterraria.configuration.nights_edge_projectile_damage": "弹射伤害", + "lzxnoneterraria.configuration.nights_edge_projectile_damage.tooltip": "每次命中伤害", + "lzxnoneterraria.configuration.nights_edge_projectile_speed": "弹射速度", + "lzxnoneterraria.configuration.nights_edge_projectile_speed.tooltip": "弹射物移动速度", + "lzxnoneterraria.configuration.nights_edge_projectile_lifetime": "弹射持续时间", + "lzxnoneterraria.configuration.nights_edge_projectile_lifetime.tooltip": "弹射物持续时间(刻)", + "lzxnoneterraria.configuration.nights_edge_projectile_rotation_speed": "弹射旋转速度", + "lzxnoneterraria.configuration.nights_edge_projectile_rotation_speed.tooltip": "弹射物旋转速度", + "lzxnoneterraria.configuration.terra_blade_settings": "泰拉刃 设置", "lzxnoneterraria.configuration.terra_projectile_align_to_blade": "弹射匹配刀光方向", "lzxnoneterraria.configuration.terra_projectile_align_to_blade.tooltip": "弹射方向是否跟随刀光方向", @@ -136,6 +183,10 @@ "lzxnoneterraria.configuration.zenith_settings": "天顶剑 设置", "lzxnoneterraria.configuration.zenith_damage": "弹射伤害", "lzxnoneterraria.configuration.zenith_damage.tooltip": "每次命中伤害(实际为 x~2x 此值)", + "lzxnoneterraria.configuration.zenith_distance_mode": "使用相对距离模式", + "lzxnoneterraria.configuration.zenith_distance_mode.tooltip": "距离模式", + "lzxnoneterraria.configuration.zenith_mouse_speed": "鼠标滚轮调节距离的速度", + "lzxnoneterraria.configuration.zenith_mouse_speed.tooltip": "鼠标滚轮调节距离的速度", "lzxnoneterraria.configuration.zenith_max_range": "最大范围", "lzxnoneterraria.configuration.zenith_max_range.tooltip": "弹射物最大飞行距离", "lzxnoneterraria.configuration.zenith_trail_b": "轨道半短轴 (b)", @@ -153,5 +204,35 @@ "lzxnoneterraria.configuration.zenith_trail_alpha": "尾迹透明度", "lzxnoneterraria.configuration.zenith_trail_alpha.tooltip": "尾迹渲染透明度", "lzxnoneterraria.configuration.zenith_trail_max_length": "尾迹长度", - "lzxnoneterraria.configuration.zenith_trail_max_length.tooltip": "尾迹最大段数" + "lzxnoneterraria.configuration.zenith_trail_max_length.tooltip": "尾迹最大段数", + + "lzxnoneterraria.configuration.true_excalibur_settings": "真断钢剑 设置", + "lzxnoneterraria.configuration.true_excalibur_rotate_range": "刀光偏转角范围", + "lzxnoneterraria.configuration.true_excalibur_rotate_range.tooltip": "刀光旋转角度范围", + "lzxnoneterraria.configuration.true_excalibur_max_hit_count": "刀光最大击中数", + "lzxnoneterraria.configuration.true_excalibur_max_hit_count.tooltip": "刀光单次最大击中生物数量", + "lzxnoneterraria.configuration.true_excalibur_damage": "刀光伤害", + "lzxnoneterraria.configuration.true_excalibur_damage.tooltip": "刀光造成的伤害", + + "lzxnoneterraria.configuration.true_nights_edge_settings": "真永夜刃 设置", + "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": "弹射刀光最大击中数", + "lzxnoneterraria.configuration.true_nights_edge_projectile_max_hit_count.tooltip": "弹射刀光单次最大击中生物数量", + "lzxnoneterraria.configuration.true_nights_edge_damage": "刀光伤害", + "lzxnoneterraria.configuration.true_nights_edge_damage.tooltip": "刀光造成的伤害", + "lzxnoneterraria.configuration.true_nights_edge_projectile_damage": "弹射伤害", + "lzxnoneterraria.configuration.true_nights_edge_projectile_damage.tooltip": "每次命中伤害", + "lzxnoneterraria.configuration.true_nights_edge_projectile_speed": "弹射速度", + "lzxnoneterraria.configuration.true_nights_edge_projectile_speed.tooltip": "弹射物移动速度", + "lzxnoneterraria.configuration.true_nights_edge_projectile_lifetime": "弹射持续时间", + "lzxnoneterraria.configuration.true_nights_edge_projectile_lifetime.tooltip": "弹射物持续时间(刻)", + "lzxnoneterraria.configuration.true_nights_edge_projectile_rotation_speed": "弹射旋转速度", + "lzxnoneterraria.configuration.true_nights_edge_projectile_rotation_speed.tooltip": "弹射物旋转速度" } diff --git a/src/main/resources/assets/lzxnoneterraria/models/item/blood_butcherer.json b/src/main/resources/assets/lzxnoneterraria/models/item/blood_butcherer.json index f7a7743..e669e0e 100644 --- a/src/main/resources/assets/lzxnoneterraria/models/item/blood_butcherer.json +++ b/src/main/resources/assets/lzxnoneterraria/models/item/blood_butcherer.json @@ -1,5 +1,5 @@ { - "parent": "minecraft:item/generated", + "parent": "lzxnoneterraria:item/weapon3", "textures": { "layer0": "lzxnoneterraria:item/blood_butcherer" } diff --git a/src/main/resources/assets/lzxnoneterraria/models/item/excalibur.json b/src/main/resources/assets/lzxnoneterraria/models/item/excalibur.json index 731e93d..ef3d15e 100644 --- a/src/main/resources/assets/lzxnoneterraria/models/item/excalibur.json +++ b/src/main/resources/assets/lzxnoneterraria/models/item/excalibur.json @@ -1,5 +1,5 @@ { - "parent": "minecraft:item/generated", + "parent": "lzxnoneterraria:item/weapon3", "textures": { "layer0": "lzxnoneterraria:item/excalibur" } diff --git a/src/main/resources/assets/lzxnoneterraria/models/item/lights_bane.json b/src/main/resources/assets/lzxnoneterraria/models/item/lights_bane.json index 77fb334..0a33620 100644 --- a/src/main/resources/assets/lzxnoneterraria/models/item/lights_bane.json +++ b/src/main/resources/assets/lzxnoneterraria/models/item/lights_bane.json @@ -1,5 +1,5 @@ { - "parent": "minecraft:item/generated", + "parent": "lzxnoneterraria:item/weapon2", "textures": { "layer0": "lzxnoneterraria:item/lights_bane" } diff --git a/src/main/resources/assets/lzxnoneterraria/models/item/nights_edge.json b/src/main/resources/assets/lzxnoneterraria/models/item/nights_edge.json index e114aa7..89362d6 100644 --- a/src/main/resources/assets/lzxnoneterraria/models/item/nights_edge.json +++ b/src/main/resources/assets/lzxnoneterraria/models/item/nights_edge.json @@ -1,5 +1,5 @@ { - "parent": "minecraft:item/generated", + "parent": "lzxnoneterraria:item/weapon3", "textures": { "layer0": "lzxnoneterraria:item/nights_edge" } diff --git a/src/main/resources/assets/lzxnoneterraria/models/item/true_excalibur.json b/src/main/resources/assets/lzxnoneterraria/models/item/true_excalibur.json index a153870..111bdc6 100644 --- a/src/main/resources/assets/lzxnoneterraria/models/item/true_excalibur.json +++ b/src/main/resources/assets/lzxnoneterraria/models/item/true_excalibur.json @@ -1,5 +1,5 @@ { - "parent": "minecraft:item/generated", + "parent": "lzxnoneterraria:item/weapon3", "textures": { "layer0": "lzxnoneterraria:item/true_excalibur" } diff --git a/src/main/resources/assets/lzxnoneterraria/models/item/true_nights_edge.json b/src/main/resources/assets/lzxnoneterraria/models/item/true_nights_edge.json index f0539c5..fa2d2e3 100644 --- a/src/main/resources/assets/lzxnoneterraria/models/item/true_nights_edge.json +++ b/src/main/resources/assets/lzxnoneterraria/models/item/true_nights_edge.json @@ -1,5 +1,5 @@ { - "parent": "minecraft:item/generated", + "parent": "lzxnoneterraria:item/weapon3", "textures": { "layer0": "lzxnoneterraria:item/true_nights_edge" } diff --git a/src/main/resources/assets/lzxnoneterraria/particles/blood_butchered_particle.json b/src/main/resources/assets/lzxnoneterraria/particles/blood_butchered_particle.json new file mode 100644 index 0000000..83f65d8 --- /dev/null +++ b/src/main/resources/assets/lzxnoneterraria/particles/blood_butchered_particle.json @@ -0,0 +1,5 @@ +{ + "textures": [ + "lzxnoneterraria:blood_butchered_particle" + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/lzxnoneterraria/particles/excalibur_hit_particle.json b/src/main/resources/assets/lzxnoneterraria/particles/excalibur_hit_particle.json new file mode 100644 index 0000000..c7553d8 --- /dev/null +++ b/src/main/resources/assets/lzxnoneterraria/particles/excalibur_hit_particle.json @@ -0,0 +1,5 @@ +{ + "textures": [ + "lzxnoneterraria:excalibur_hit_particle" + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/lzxnoneterraria/particles/nights_edge_hit_particle.json b/src/main/resources/assets/lzxnoneterraria/particles/nights_edge_hit_particle.json new file mode 100644 index 0000000..a9936b0 --- /dev/null +++ b/src/main/resources/assets/lzxnoneterraria/particles/nights_edge_hit_particle.json @@ -0,0 +1,7 @@ +{ + "textures": [ + "lzxnoneterraria:nights_edge_hit_particle0", + "lzxnoneterraria:nights_edge_hit_particle1", + "lzxnoneterraria:nights_edge_hit_particle2" + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/lzxnoneterraria/particles/true_excalibur_hit_particle.json b/src/main/resources/assets/lzxnoneterraria/particles/true_excalibur_hit_particle.json new file mode 100644 index 0000000..612e453 --- /dev/null +++ b/src/main/resources/assets/lzxnoneterraria/particles/true_excalibur_hit_particle.json @@ -0,0 +1,5 @@ +{ + "textures": [ + "lzxnoneterraria:true_excalibur_hit_particle" + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/lzxnoneterraria/particles/true_nights_edge_hit_particle.json b/src/main/resources/assets/lzxnoneterraria/particles/true_nights_edge_hit_particle.json new file mode 100644 index 0000000..c3c8992 --- /dev/null +++ b/src/main/resources/assets/lzxnoneterraria/particles/true_nights_edge_hit_particle.json @@ -0,0 +1,7 @@ +{ + "textures": [ + "lzxnoneterraria:true_nights_edge_hit_particle0", + "lzxnoneterraria:true_nights_edge_hit_particle1", + "lzxnoneterraria:true_nights_edge_hit_particle2" + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/lzxnoneterraria/textures/mob_effect/blood_butchered.png b/src/main/resources/assets/lzxnoneterraria/textures/mob_effect/blood_butchered.png new file mode 100644 index 0000000000000000000000000000000000000000..bb8d2e714c2f5427dc565eccd5d597b98fe2c6bf GIT binary patch literal 249 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnF3?v&v(vJfvl>na*S0D`n^12F)wsuP{`yTz< zYj=Hx@89PP4F9EB{}+Y-U)piiZYC2@4P!}=UoeBivm0qZPP3qSRi7efw~ z3sEarbrKSFuN>MQz`eDhb)&(vX$LYtrw8--K9g1B?J=xR+mk4y&i=QEi$RHJNj1xY z2Q0afhsus!Ovs*U^N&5@W}?nSh6{ExSBr6VoZ=0+aQ~H`hl67(6PI6kRhU&@i^j*j p+uNIdAFDdaxk8nDN8G!*zxr*9PMVjle-;YzfTydU%Q~loCIB`0T2TN1 literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/lzxnoneterraria/textures/particle/blood_butchered_particle.png b/src/main/resources/assets/lzxnoneterraria/textures/particle/blood_butchered_particle.png new file mode 100644 index 0000000000000000000000000000000000000000..dfd8cb54abae594a81fbf6ec8489ab149c5f0cf8 GIT binary patch literal 1420 zcmbVM&u`R56gE;tX{x9Pkcc>$;Xtcmdu;En;{gLhsyiVL3lp;=>8Az`XFsx$`$3q!{vQIx&70eqP+J!>TJr*;B&%6 ztkY0*xn9I6pcUoJxgw=(n@hFJdr{({zkYjw)F|}OMm@km+T{JHwU_a=y`>J@+h%Tv z&Ye}y6a)xjE~#3?gCr+~heo^v*5z*lsUwKo_RvCUP~8kx)TYR|>guM(Ft%04)!l}R z>AZ7FwXjt;ux;RmX1c_*2<%TT1m?1Ei>&&eO^m^phx$^c#4v`#p+2;Ak@XDIbzK8n zhGl7h(DL0x(n3q}6H^AC=PZj-8Hq$K8EIGSNDqOlV-0ay(I)vMP7pDpps8W%xYRTP zhOEM+JK11lJY)tR@R%nu2dr6P)4q@*?~DJTuC`w>0I>~%%ErFF#BpUJmy1_G#v~y7 zqVvvf%8gZ?i=B+|#Vg?EiBe5Uni;23WE~*}(@d>QT~@7zKCgbf5hbA*=AXQDfcsQ( z4?)%%8g?|(>X zNRu8?t1yzL7>EoEgLn4Giy$EFB$qT{yzP4kH0x0mlA6#1cY^TiZ^nCc1=a;hxT8j?enWt>HvLr|=${|_1la5&9Ur$zpNF7xH zp{%TK53w?>JVcY<(K|eiBM3gKA;uG!Tp5h0n|J@d4&%*l`wN}9TR;E!boLrPa^c(4>!*wNQ_Z_t z|AJjcznm}T9?x95v)o*Mvi48w{I%N;SIkcB#-HD;|4Xvp#UIZ%9{zgtR QRyi-*i%b5!3txTr0^0+*wg3PC literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/lzxnoneterraria/textures/particle/excalibur_hit_particle.png b/src/main/resources/assets/lzxnoneterraria/textures/particle/excalibur_hit_particle.png new file mode 100644 index 0000000000000000000000000000000000000000..961d89b6dc7d60bfb24609a9e6e3fe8935036e71 GIT binary patch literal 236 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz&H|6fVg?3oVGw3ym^DWNC^*m4 z#W5tJ_3br7z6J#z)(c5*URtbQp1dMhST*5RJTG6Wk;Wf(mW3T0Yjtj4`of~3z*x`l zCgbq6zT5IWJH?jFzrbSmdKI;Vst0QF8&)c^nh literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/lzxnoneterraria/textures/particle/nights_edge_hit_particle0.png b/src/main/resources/assets/lzxnoneterraria/textures/particle/nights_edge_hit_particle0.png new file mode 100644 index 0000000000000000000000000000000000000000..e0200f93a9c58b5d053f0bbfa375343298e14913 GIT binary patch literal 264 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz&H|6fVg?3oVGw3ym^DWND7eeh z#W5tJ_3gB~oJSRS+>&=1mu&94m??AkY|NqGDk8mx^Vz%u4<5W- zSg33;@xp;fMs7~s8jTIgjR#yCML9+6L>*MZ9%waAY+;?V!jdz6;?#5WBdRB literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/lzxnoneterraria/textures/particle/nights_edge_hit_particle1.png b/src/main/resources/assets/lzxnoneterraria/textures/particle/nights_edge_hit_particle1.png new file mode 100644 index 0000000000000000000000000000000000000000..f6d7a4dcec5b988469554744289d25ce84ae5fdc GIT binary patch literal 331 zcmV-R0kr;!P);H*G|gciOO@JJwVQNSXB!nXp5gaxh=SV=^{QyMzqE~GPU zfx`l$#PA-5r(_sL5&(sp1fl~L&>TY~9{&l|6&T?+r0Wf)wyhG_jnpm=me>ktn~ZgK zhyrMbvq&rjtnC$*U3&w2`u}0<{ayYnWj9{d%7tIFE8upzxqM&iAw_c~{ujT#P5W5Llj&N< zx~_o#RiCUHQj3iQ_v2VM`{aN7YpUE zZuv07Wf}vMzwAMGPO}b=uRe#JW_`U7_{U9TKfj3h4F=zu52ZFqT(^M!VDNPHb6Mw< G&;$USv|z3P literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/lzxnoneterraria/textures/particle/true_excalibur_hit_particle.png b/src/main/resources/assets/lzxnoneterraria/textures/particle/true_excalibur_hit_particle.png new file mode 100644 index 0000000000000000000000000000000000000000..f112bfc537de9a8f69dc094902640a602a6373f7 GIT binary patch literal 249 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz&H|6fVg?3oVGw3ym^DWND7f0w z#W5tJ_3gAkt_B4Gm+LQXKfW5c$4U0+l6|2ZJ?r`d4?e-fWz$x^ zV@qHFB8ClK?C<~TxG(EJSUY#+Qm+HY1A10S?mcfD)G6%YCeqX#%-A8E;TolWarVwwW8if;I|F1L+XseiY`atZ0#Ankoz39s>gTe~DWM4f7=d2J literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/lzxnoneterraria/textures/particle/true_nights_edge_hit_particle0.png b/src/main/resources/assets/lzxnoneterraria/textures/particle/true_nights_edge_hit_particle0.png new file mode 100644 index 0000000000000000000000000000000000000000..8802bd0f98ce36c691cbc0a54ebef988517a4d30 GIT binary patch literal 257 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz&H|6fVg?3oVGw3ym^DWND7e|v z#W5tJ_3gE@ybTIGY!{LuT0|vIJe24Vm0x^IW z4BPf`oZSC+N36*t$HjYh3-5@1BR7Fdzxw)BMyF4UI;?C|?AfO*p6HbDFgJUnScgK{ zp}+=~B=Z`MA59Bd{266fOlvq7C|Ep^2`8=RLE~(n|n3pTX1B&t;ucLK6U; CTw84b literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/lzxnoneterraria/textures/particle/true_nights_edge_hit_particle1.png b/src/main/resources/assets/lzxnoneterraria/textures/particle/true_nights_edge_hit_particle1.png new file mode 100644 index 0000000000000000000000000000000000000000..4f6535783b0319af32344ab90a62cfa42b63a36b GIT binary patch literal 311 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz&H|6fVg?3oVGw3ym^DWNDEQLT z#W5tJ_3pKUyoVKdSObDnC$2f*AlcWriD~hLU@ewoKcv04eAS&e=|9UsKaHgq&Q<05 z{%1Q77{5fu{&(Tr@((;xdv`}SzTUH&eb1r!<=3w=2KBA$u(Elo!8~v2N2h{^Z?6?a zKWMtpvYCOu#jJ)S!cpO&(t#$2!^;_15;?;eO*pbG1Opw~CYCJIeQ2=2)#Urb0;R(S zlbCcqC;v8SVVsrRaphZoz+R@si?`j{7TR#rGTzaL@s?V$YX`%Y!;u2c4O{mv;t<<# z>2@H?cmEwCeM)ZiF5VA?oLE0_JQs*Lc=^Kax_pVhvJZIUcopm_kD7J@JgTe~ HDWM4flQnv; literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/lzxnoneterraria/textures/particle/true_nights_edge_hit_particle2.png b/src/main/resources/assets/lzxnoneterraria/textures/particle/true_nights_edge_hit_particle2.png new file mode 100644 index 0000000000000000000000000000000000000000..eca85ae2d2089c9e227db688feeb364db66780fc GIT binary patch literal 250 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz&H|6fVg?3oVGw3ym^DWND7ePc z#W5tJ_3gE@ybTIGYysIZEus<~4<$N8C0O;7Os34=rX_c4w$NX>TqP&3%$bp|uavNA zI52VrG%)>RxM9KnGvlK1otX^t8TvNd-r7IytK27!tljU|UggrLcd@qVicl&UQ~1$B>A_Z?9ey zY*yfDNDMo{6?sr}ms9u&u5}kSaxZoI$nlip;|IO}-F7dQi+?OQw@GKUy@$FT&(FuR za+s86G(YOh-ViUkx-;EicIj>A3AvWvI@gLN&*T)C$Pt#XGvC$S;*0wEq@PP&E}lwa zbiZ?-FMQL@@8KrXu5!Mew^rzPxkjSS;n!iEyotLVOYKg-H9IstG%5J^zou2Xx38K; z{J42Z@#VviFYCPCxKC!BzNt{8JW2Po&{wwoTRZ>nH^{jT^a6vYtDnm{r-UW|=)Zaj literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/lzxnoneterraria/textures/vfx/lights_bane_slash1.png b/src/main/resources/assets/lzxnoneterraria/textures/vfx/lights_bane_slash1.png new file mode 100644 index 0000000000000000000000000000000000000000..cb2d0868974f63de3bc51b4593f42647197d744e GIT binary patch literal 186 zcmeAS@N?(olHy`uVBq!ia0vp^tAW^zi5W;9t!oqqQak}ZA+A8$mczu2%Rh`K@$}02 zIY2&RNswPKgTu2MX&_F1kzWYo`9CzFvIdZ&}arvS3j3^P6A&lo2mCpil96VhdLo7}wCrGd|Gw?ZVWDGo%kialaF>FR-Bl~X4 z8HdiC2x4hv=S*vc+Wq&0_F$^>bP0 Hl+XkKliw|T literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/lzxnoneterraria/textures/vfx/lights_bane_slash11.png b/src/main/resources/assets/lzxnoneterraria/textures/vfx/lights_bane_slash11.png new file mode 100644 index 0000000000000000000000000000000000000000..addc701ee6002a80599de763118908154e0d64da GIT binary patch literal 143 zcmeAS@N?(olHy`uVBq!ia0vp^tAW^zkr_xf-TQqUNU;U@gt!7}TMmA&lo2mCpilv^-rLLo7}wCrGd|Gw?ZNGB0X5$z-F#$!~kWXOh9w jUmP>a8!R3MI_NVne5+^f4*AdpGJ?U=)z4*}Q$iB}#6Bm# literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/lzxnoneterraria/textures/vfx/lights_bane_slash2.png b/src/main/resources/assets/lzxnoneterraria/textures/vfx/lights_bane_slash2.png new file mode 100644 index 0000000000000000000000000000000000000000..ba444d177ebe829275f61dddbb27586f2da0bee7 GIT binary patch literal 236 zcmeAS@N?(olHy`uVBq!ia0vp^tAW^zi5W;9t!oqqQk(%kA+A8$jmzJb!$hn)f)&VN zED7=pW^j0RBMrpKFY*gvJin-X7Le28>EamTas2JX-C_+291gKDKdi*W_xBxbU9Y1W zKXtB=`@02lJ7olW0!5zkhMC1Z3yNuC%n26T!TG{S`Nw6}UH5vqDqk|OPk-1{Ty)yx z^{HxeQv7 zN8_L#P>8W4$S;_|;n|He5GTLLFNE>@qViclPOqnnV@Sl|w^MF&9#G(MjeWRog6J-% z@AFso-^gO=*0@-A=W}AfWM(N77AFqHC89MxiuISL3BA5sw>mVrE^oo*C(A_loapQ` zJeJDqIQ?0+U9^^Q v6Sqapp3i@EF5jFjho4T~+9Kd|%#tC)MAQGGUe-~d!x%hW{an^LB{Ts50C!x? literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/lzxnoneterraria/textures/vfx/lights_bane_slash4.png b/src/main/resources/assets/lzxnoneterraria/textures/vfx/lights_bane_slash4.png new file mode 100644 index 0000000000000000000000000000000000000000..366521a92631a57ac3ddc833aa6e622ef51c4d6f GIT binary patch literal 217 zcmeAS@N?(olHy`uVBq!ia0vp^tAW^zi5W;9t!oqqQk(%kA+A8$mczu2%U?!yPA!nb zSQ6wH%;50sMjD8dU*s3Ucz#j&EFh=Q)5S5wGLb9G{h)>f dt1~|X!^I9m%gMjyUIH4=;OXk;vd$@?2>@f1Ggbfq literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/lzxnoneterraria/textures/vfx/lights_bane_slash6.png b/src/main/resources/assets/lzxnoneterraria/textures/vfx/lights_bane_slash6.png new file mode 100644 index 0000000000000000000000000000000000000000..a422e70109da7ef993be869e40167c31da3fe90e GIT binary patch literal 226 zcmeAS@N?(olHy`uVBq!ia0vp^tAW^zi5W;9t!oqqQk(%kA+A8$mczu2%U?!yPA!nb zSQ6wH%;50sMjD8dU*s3Ucz#j&EFh=K)5S5w=2{xs Tca-@8UBTe#>gTe~DWM4fwkAv( literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/lzxnoneterraria/textures/vfx/lights_bane_slash7.png b/src/main/resources/assets/lzxnoneterraria/textures/vfx/lights_bane_slash7.png new file mode 100644 index 0000000000000000000000000000000000000000..9a1f6cd40508fdadbbfeceab08eb7d804f94729b GIT binary patch literal 221 zcmeAS@N?(olHy`uVBq!ia0vp^tAW^zi5W;9t!oqqQk(%kA+A8$mczu2%U?!yPA!nb zSQ6wH%;50sMjD8dU*s3Ucz#j&EFh=U)5S5w)5S5wA&lo2mCpill001;Lo7}wCrGe1%NjIyFgxTp^cYCU7%-d`(Bv^` zWS?zm(IP4Fqj5%i!-l`@#`SzP8#X4|)%@6SF#R9@kJgL2YAR=Vo_tVdXJJfC%lUUq qv1g&|dV|e|Gk!VD`Jk~toPlADkDPf{EPEBuHU>{uKbLh*2~7a$+dwY> literal 0 HcmV?d00001 diff --git a/src/main/resources/data/lzxnoneterraria/weapon_attributes/blood_butcherer.json b/src/main/resources/data/lzxnoneterraria/weapon_attributes/blood_butcherer.json new file mode 100644 index 0000000..11bc472 --- /dev/null +++ b/src/main/resources/data/lzxnoneterraria/weapon_attributes/blood_butcherer.json @@ -0,0 +1,3 @@ +{ + "parent": "bettercombat:claymore" +} \ No newline at end of file diff --git a/src/main/resources/data/lzxnoneterraria/weapon_attributes/excalibur.json b/src/main/resources/data/lzxnoneterraria/weapon_attributes/excalibur.json new file mode 100644 index 0000000..11bc472 --- /dev/null +++ b/src/main/resources/data/lzxnoneterraria/weapon_attributes/excalibur.json @@ -0,0 +1,3 @@ +{ + "parent": "bettercombat:claymore" +} \ No newline at end of file diff --git a/src/main/resources/data/lzxnoneterraria/weapon_attributes/lights_bane.json b/src/main/resources/data/lzxnoneterraria/weapon_attributes/lights_bane.json new file mode 100644 index 0000000..30d5174 --- /dev/null +++ b/src/main/resources/data/lzxnoneterraria/weapon_attributes/lights_bane.json @@ -0,0 +1,3 @@ +{ + "parent": "bettercombat:sword" +} diff --git a/src/main/resources/data/lzxnoneterraria/weapon_attributes/nights_edge.json b/src/main/resources/data/lzxnoneterraria/weapon_attributes/nights_edge.json new file mode 100644 index 0000000..11bc472 --- /dev/null +++ b/src/main/resources/data/lzxnoneterraria/weapon_attributes/nights_edge.json @@ -0,0 +1,3 @@ +{ + "parent": "bettercombat:claymore" +} \ No newline at end of file diff --git a/src/main/resources/data/lzxnoneterraria/weapon_attributes/true_excalibur.json b/src/main/resources/data/lzxnoneterraria/weapon_attributes/true_excalibur.json new file mode 100644 index 0000000..f5917e2 --- /dev/null +++ b/src/main/resources/data/lzxnoneterraria/weapon_attributes/true_excalibur.json @@ -0,0 +1,3 @@ +{ + "parent": "bettercombat:claymore" +} diff --git a/src/main/resources/data/lzxnoneterraria/weapon_attributes/true_nights_edge.json b/src/main/resources/data/lzxnoneterraria/weapon_attributes/true_nights_edge.json new file mode 100644 index 0000000..f5917e2 --- /dev/null +++ b/src/main/resources/data/lzxnoneterraria/weapon_attributes/true_nights_edge.json @@ -0,0 +1,3 @@ +{ + "parent": "bettercombat:claymore" +} diff --git a/src/main/resources/lzxnoneterraria.mixins.json b/src/main/resources/lzxnoneterraria.mixins.json new file mode 100644 index 0000000..77c8a5d --- /dev/null +++ b/src/main/resources/lzxnoneterraria.mixins.json @@ -0,0 +1,13 @@ +{ + "required": true, + "minVersion": "0.8", + "package": "com.lzxnone.terraria.mixin", + "compatibilityLevel": "JAVA_21", + "mixins": [ + "ZenithRenderMixin" + ], + "client": [], + "injectors": { + "defaultRequire": 1 + } +} \ No newline at end of file diff --git a/src/main/templates/META-INF/neoforge.mods.toml b/src/main/templates/META-INF/neoforge.mods.toml index cd6519a..d289a9d 100644 --- a/src/main/templates/META-INF/neoforge.mods.toml +++ b/src/main/templates/META-INF/neoforge.mods.toml @@ -98,6 +98,9 @@ Example mod description. [modproperties."${mod_id}"."yumi:entrypoints"] "lambdynlights:initializer" = "com.lzxnone.terraria.dynamic_lights.MDynamicLightsInitializer" +[[mixins]] +config = "lzxnoneterraria.mixins.json" + # Features are specific properties of the game environment, that you may want to declare you require. This example declares # that your mod requires GL version 3.2 or higher. Other features will be added. They are side aware so declaring this won't # stop your mod loading on the server for example.