v1.3.0-pre

This commit is contained in:
LZX committed 2026-07-12 14:18:39 +08:00
1 parent a99646bcd8
commit e955738812
85 files changed
+3095 -233

No files matched your search

+1 -1
View File
@@ -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. # The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
mod_license=All Rights Reserved mod_license=All Rights Reserved
# The mod version. See https://semver.org/ # 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. # 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. # This should match the base package used for the mod sources.
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html # See https://maven.apache.org/guides/mini/guide-naming-conventions.html
+278 -2
View File
@@ -18,6 +18,10 @@ public class Config {
public static final ModConfigSpec.IntValue BEE_KEEPER_CONFUSION_DURATION; public static final ModConfigSpec.IntValue BEE_KEEPER_CONFUSION_DURATION;
public static final ModConfigSpec.DoubleValue BEE_KEEPER_BEE_DAMAGE; 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_DAMAGE;
public static final ModConfigSpec.DoubleValue STARFURY_MAX_RANGE; public static final ModConfigSpec.DoubleValue STARFURY_MAX_RANGE;
public static final ModConfigSpec.DoubleValue STARFURY_SPEED; 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_GRAVITY;
public static final ModConfigSpec.DoubleValue MEOWMERE_INITIAL_SPEED; 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.BooleanValue TERRA_PROJECTILE_ALIGN_TO_BLADE;
public static final ModConfigSpec.IntValue TERRA_BLADE_ROTATE_RANGE; public static final ModConfigSpec.IntValue TERRA_BLADE_ROTATE_RANGE;
public static final ModConfigSpec.IntValue TERRA_PROJECTILE_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_DAMAGE;
public static final ModConfigSpec.DoubleValue ZENITH_MAX_RANGE; 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.DoubleValue ZENITH_TRAIL_B;
public static final ModConfigSpec.IntValue ZENITH_TRAIL_OFFSET; public static final ModConfigSpec.IntValue ZENITH_TRAIL_OFFSET;
public static final ModConfigSpec.IntValue ZENITH_WEAPON_COUNT; 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.DoubleValue ZENITH_TRAIL_ALPHA;
public static final ModConfigSpec.IntValue ZENITH_TRAIL_MAX_LENGTH; 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 double enchantedSwordDamage;
public static int enchantedSwordLifetime; public static int enchantedSwordLifetime;
public static double enchantedSwordSpeed; public static double enchantedSwordSpeed;
@@ -80,6 +120,10 @@ public class Config {
public static int beeKeeperConfusionDuration; public static int beeKeeperConfusionDuration;
public static double beeKeeperBeeDamage; public static double beeKeeperBeeDamage;
public static int bloodButchererEffectDuration;
public static int bloodButchererMaxLevel;
public static double bloodButchererDamagePerLevel;
public static double starfuryDamage; public static double starfuryDamage;
public static double starfuryMaxRange; public static double starfuryMaxRange;
public static double starfurySpeed; public static double starfurySpeed;
@@ -113,6 +157,25 @@ public class Config {
public static double meowmereGravity; public static double meowmereGravity;
public static double meowmereInitialSpeed; 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 boolean terraProjectileAlignToBlade;
public static int terraBladeRotateRange; public static int terraBladeRotateRange;
public static int terraProjectileRotateRange; public static int terraProjectileRotateRange;
@@ -125,6 +188,8 @@ public class Config {
public static double zenithDamage; public static double zenithDamage;
public static double zenithMaxRange; public static double zenithMaxRange;
public static boolean zenithDistanceMode;
public static int zenithMouseSpeed;
public static double zenithTrailB; public static double zenithTrailB;
public static int zenithTrailOffset; public static int zenithTrailOffset;
public static int zenithWeaponCount; public static int zenithWeaponCount;
@@ -134,6 +199,21 @@ public class Config {
public static double zenithTrailAlpha; public static double zenithTrailAlpha;
public static int zenithTrailMaxLength; 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 { static {
ModConfigSpec.Builder builder = new ModConfigSpec.Builder(); ModConfigSpec.Builder builder = new ModConfigSpec.Builder();
@@ -170,6 +250,21 @@ public class Config {
builder.pop(); 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"); builder.push("starfury_settings");
@@ -309,6 +404,85 @@ public class Config {
builder.pop(); 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"); builder.push("terra_blade_settings");
TERRA_PROJECTILE_ALIGN_TO_BLADE = builder TERRA_PROJECTILE_ALIGN_TO_BLADE = builder
@@ -317,11 +491,11 @@ public class Config {
TERRA_BLADE_ROTATE_RANGE = builder TERRA_BLADE_ROTATE_RANGE = builder
.comment("刀光偏转角范围") .comment("刀光偏转角范围")
.defineInRange("terra_blade_rotate_range", 30, 0, 90); .defineInRange("terra_blade_rotate_range", 45, 0, 90);
TERRA_PROJECTILE_ROTATE_RANGE = builder TERRA_PROJECTILE_ROTATE_RANGE = builder
.comment("弹射偏转角范围") .comment("弹射偏转角范围")
.defineInRange("terra_projectile_rotate_range", 30, 0, 90); .defineInRange("terra_projectile_rotate_range", 45, 0, 90);
TERRA_BLADE_MAX_HIT_COUNT = builder TERRA_BLADE_MAX_HIT_COUNT = builder
.comment("刀光单次最大击中生物数量") .comment("刀光单次最大击中生物数量")
@@ -360,6 +534,14 @@ public class Config {
.comment("最大范围(2a)") .comment("最大范围(2a)")
.defineInRange("zenith_max_range", 64.0, 1.0, 1024.0); .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 ZENITH_TRAIL_B = builder
.comment("椭圆轨道半短轴(b)") .comment("椭圆轨道半短轴(b)")
.defineInRange("zenith_trail_b", 4.0, 0.1, 512.0); .defineInRange("zenith_trail_b", 4.0, 0.1, 512.0);
@@ -394,6 +576,66 @@ public class Config {
builder.pop(); 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(); SPEC = builder.build();
} }
@@ -406,6 +648,9 @@ public class Config {
beeKeeperMaxBees = BEE_KEEPER_MAX_BEES.get(); beeKeeperMaxBees = BEE_KEEPER_MAX_BEES.get();
beeKeeperConfusionDuration = BEE_KEEPER_CONFUSION_DURATION.get(); beeKeeperConfusionDuration = BEE_KEEPER_CONFUSION_DURATION.get();
beeKeeperBeeDamage = BEE_KEEPER_BEE_DAMAGE.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(); starfuryDamage = STARFURY_DAMAGE.get();
starfuryMaxRange = STARFURY_MAX_RANGE.get(); starfuryMaxRange = STARFURY_MAX_RANGE.get();
starfurySpeed = STARFURY_SPEED.get(); starfurySpeed = STARFURY_SPEED.get();
@@ -433,6 +678,22 @@ public class Config {
meowmereDamage = MEOWMERE_DAMAGE.get(); meowmereDamage = MEOWMERE_DAMAGE.get();
meowmereGravity = MEOWMERE_GRAVITY.get(); meowmereGravity = MEOWMERE_GRAVITY.get();
meowmereInitialSpeed = MEOWMERE_INITIAL_SPEED.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(); terraProjectileAlignToBlade = TERRA_PROJECTILE_ALIGN_TO_BLADE.get();
terraBladeRotateRange = TERRA_BLADE_ROTATE_RANGE.get(); terraBladeRotateRange = TERRA_BLADE_ROTATE_RANGE.get();
terraProjectileRotateRange = TERRA_PROJECTILE_ROTATE_RANGE.get(); terraProjectileRotateRange = TERRA_PROJECTILE_ROTATE_RANGE.get();
@@ -444,6 +705,8 @@ public class Config {
terraProjectileDamageDecay = TERRA_PROJECTILE_DAMAGE_DECAY.get(); terraProjectileDamageDecay = TERRA_PROJECTILE_DAMAGE_DECAY.get();
zenithDamage = ZENITH_DAMAGE.get(); zenithDamage = ZENITH_DAMAGE.get();
zenithMaxRange = ZENITH_MAX_RANGE.get(); zenithMaxRange = ZENITH_MAX_RANGE.get();
zenithDistanceMode = ZENITH_DISTANCE_MODE.get();
zenithMouseSpeed = ZENITH_SCROLL_SPEED.get();
zenithTrailB = ZENITH_TRAIL_B.get(); zenithTrailB = ZENITH_TRAIL_B.get();
zenithTrailOffset = ZENITH_TRAIL_OFFSET.get(); zenithTrailOffset = ZENITH_TRAIL_OFFSET.get();
zenithWeaponCount = ZENITH_WEAPON_COUNT.get(); zenithWeaponCount = ZENITH_WEAPON_COUNT.get();
@@ -452,6 +715,19 @@ public class Config {
zenithScale = ZENITH_SCALE.get(); zenithScale = ZENITH_SCALE.get();
zenithTrailAlpha = ZENITH_TRAIL_ALPHA.get(); zenithTrailAlpha = ZENITH_TRAIL_ALPHA.get();
zenithTrailMaxLength = ZENITH_TRAIL_MAX_LENGTH.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();
} }
} }
} }
@@ -59,6 +59,20 @@ public class LzxnoneTerrariaClient {
modEventBus.addListener(RegisterParticleProvidersEvent.class, event -> { modEventBus.addListener(RegisterParticleProvidersEvent.class, event -> {
event.registerSpriteSet(ModParticles.TERRA_BEAM_HIT_PARTICLE.get(), TerraBeamHitParticle.Provider::new); 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);
});
} }
} }
@@ -29,5 +29,11 @@ public class ModCreativeModeTabs {
output.accept(ModItems.TERRA_BLADE.get()); output.accept(ModItems.TERRA_BLADE.get());
output.accept(ModItems.ZENITH.get()); output.accept(ModItems.ZENITH.get());
output.accept(ModItems.TRUE_COPPER_SHORTSWORD.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()); }).build());
} }
@@ -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;
}
}
@@ -1,9 +1,12 @@
package com.lzxnone.terraria.effect; package com.lzxnone.terraria.effect;
import com.lzxnone.terraria.LzxnoneTerraria; import com.lzxnone.terraria.LzxnoneTerraria;
import net.minecraft.core.Holder;
import net.minecraft.network.protocol.game.ClientboundRemoveMobEffectPacket; import net.minecraft.network.protocol.game.ClientboundRemoveMobEffectPacket;
import net.minecraft.network.protocol.game.ClientboundUpdateMobEffectPacket; import net.minecraft.network.protocol.game.ClientboundUpdateMobEffectPacket;
import net.minecraft.server.level.ServerLevel; 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.LivingEntity;
import net.minecraft.world.entity.PathfinderMob; import net.minecraft.world.entity.PathfinderMob;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
@@ -20,7 +23,9 @@ public class EffectLogicHandler {
@SubscribeEvent @SubscribeEvent
public static void onEffectAdded(MobEffectEvent.Added event) { public static void onEffectAdded(MobEffectEvent.Added event) {
LivingEntity entity = event.getEntity(); LivingEntity entity = event.getEntity();
if(!entity.level().isClientSide() && !(entity instanceof Player)) { MobEffectInstance instance = event.getEffectInstance();
Holder<MobEffect> currentEffect = instance.getEffect();
if(checkEffect(currentEffect) && !entity.level().isClientSide() && !(entity instanceof Player)) {
if(entity.level() instanceof ServerLevel serverLevel) { if(entity.level() instanceof ServerLevel serverLevel) {
serverLevel.getChunkSource().broadcast(entity, serverLevel.getChunkSource().broadcast(entity,
new ClientboundUpdateMobEffectPacket(entity.getId(), event.getEffectInstance(), false)); new ClientboundUpdateMobEffectPacket(entity.getId(), event.getEffectInstance(), false));
@@ -31,7 +36,9 @@ public class EffectLogicHandler {
@SubscribeEvent @SubscribeEvent
public static void onEffectRemoved(MobEffectEvent.Remove event) { public static void onEffectRemoved(MobEffectEvent.Remove event) {
LivingEntity entity = event.getEntity(); LivingEntity entity = event.getEntity();
if(!entity.level().isClientSide() && !(entity instanceof Player)) { MobEffectInstance instance = event.getEffectInstance();
Holder<MobEffect> currentEffect = instance.getEffect();
if(checkEffect(currentEffect) && !entity.level().isClientSide() && !(entity instanceof Player)) {
if(entity.level() instanceof ServerLevel serverLevel) { if(entity.level() instanceof ServerLevel serverLevel) {
if(event.getEffectInstance() != null) { if(event.getEffectInstance() != null) {
serverLevel.getChunkSource().broadcast(entity, serverLevel.getChunkSource().broadcast(entity,
@@ -44,7 +51,9 @@ public class EffectLogicHandler {
@SubscribeEvent @SubscribeEvent
public static void onEffectExpired(MobEffectEvent.Expired event) { public static void onEffectExpired(MobEffectEvent.Expired event) {
LivingEntity entity = event.getEntity(); LivingEntity entity = event.getEntity();
if (!entity.level().isClientSide() && !(entity instanceof Player)) { MobEffectInstance instance = event.getEffectInstance();
Holder<MobEffect> currentEffect = instance.getEffect();
if(checkEffect(currentEffect) && !entity.level().isClientSide() && !(entity instanceof Player)) {
if(entity.level() instanceof ServerLevel serverLevel) { if(entity.level() instanceof ServerLevel serverLevel) {
if(event.getEffectInstance() != null) { if(event.getEffectInstance() != null) {
serverLevel.getChunkSource().broadcast(entity, serverLevel.getChunkSource().broadcast(entity,
@@ -54,11 +63,9 @@ public class EffectLogicHandler {
} }
} }
@SubscribeEvent public static boolean checkEffect(Holder<MobEffect> effect) {
public static void onLivingTick(EntityTickEvent.Post event) { return
if(!event.getEntity().level().isClientSide() && event.getEntity() instanceof PathfinderMob mob) { effect == ModEffects.CONFUSED ||
effect == ModEffects.BLOOD_BUTCHERED;
} }
} }
}
@@ -12,4 +12,6 @@ public class ModEffects {
public static final DeferredHolder<MobEffect, ConfusedEffect> CONFUSED = public static final DeferredHolder<MobEffect, ConfusedEffect> CONFUSED =
MOB_EFFECTS.register("confused", ConfusedEffect::new); MOB_EFFECTS.register("confused", ConfusedEffect::new);
public static final DeferredHolder<MobEffect, BloodButcheredEffect> BLOOD_BUTCHERED =
MOB_EFFECTS.register("blood_butchered", BloodButcheredEffect::new);
} }
@@ -4,6 +4,7 @@ import com.lzxnone.terraria.LzxnoneTerraria;
import com.lzxnone.terraria.entity.ModEntities; import com.lzxnone.terraria.entity.ModEntities;
import com.lzxnone.terraria.entity.summon.StaticSummon; import com.lzxnone.terraria.entity.summon.StaticSummon;
import com.lzxnone.terraria.utils.MathUtil; import com.lzxnone.terraria.utils.MathUtil;
import com.lzxnone.terraria.utils.RenderUtil;
import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer; import com.mojang.blaze3d.vertex.VertexConsumer;
import com.mojang.math.Axis; import com.mojang.math.Axis;
@@ -15,7 +16,6 @@ import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Item; import net.minecraft.world.item.Item;
import net.minecraft.world.item.Items; import net.minecraft.world.item.Items;
@@ -75,24 +75,24 @@ public interface ISwordBeamBehavior {
//左边 //左边
poseStack.pushPose(); poseStack.pushPose();
this.applyTranslate(poseStack, dirs[0], dirs[2], progress - 0.1f * (1.0f - progress), SwordBeam.DIST); RenderUtil.applyTranslate(poseStack, dirs[0], dirs[2], (progress - 0.1f * (1.0f - progress)) * 180, SwordBeam.DIST);
this.applyRotate(poseStack, dirs[0], dirs[1], progress - 0.1f * (1.0f - progress), rotate); RenderUtil.applyRotate(poseStack, dirs[0], dirs[1], (0.5f - (progress - 0.1f * (1.0f - progress))) * 180, rotate);
renderQuad(poseStack.last().pose(), vertexConsumer0, renderQuad(poseStack.last().pose(), vertexConsumer0,
color0.x(), color0.y(), color0.z(), alpha, halfWidth, halfHeight, 0f, 0, -0.01f); color0.x(), color0.y(), color0.z(), alpha, halfWidth, halfHeight, 0f, 0, -0.01f);
poseStack.popPose(); poseStack.popPose();
//右边 //右边
poseStack.pushPose(); poseStack.pushPose();
this.applyTranslate(poseStack, dirs[0], dirs[2], progress + 0.1f, SwordBeam.DIST); RenderUtil.applyTranslate(poseStack, dirs[0], dirs[2], (progress + 0.1f) * 180, SwordBeam.DIST);
this.applyRotate(poseStack, dirs[0], dirs[1], progress + 0.05f, rotate); RenderUtil.applyRotate(poseStack, dirs[0], dirs[1], (0.5f - (progress + 0.05f)) * 180, rotate);
renderQuad(poseStack.last().pose(), vertexConsumer0, renderQuad(poseStack.last().pose(), vertexConsumer0,
color2.x(), color2.y(), color2.z(), alpha, halfWidth, halfHeight, 0f, 0, -0.02f); color2.x(), color2.y(), color2.z(), alpha, halfWidth, halfHeight, 0f, 0, -0.02f);
poseStack.popPose(); poseStack.popPose();
//中间 //中间
poseStack.pushPose(); poseStack.pushPose();
this.applyTranslate(poseStack, dirs[0], dirs[2], progress, SwordBeam.DIST); RenderUtil.applyTranslate(poseStack, dirs[0], dirs[2], progress * 180, SwordBeam.DIST);
this.applyRotate(poseStack, dirs[0], dirs[1], progress, rotate); RenderUtil.applyRotate(poseStack, dirs[0], dirs[1], (0.5f - progress) * 180, rotate);
renderQuad(poseStack.last().pose(), vertexConsumer0, renderQuad(poseStack.last().pose(), vertexConsumer0,
color1.x(), color1.y(), color1.z(), alpha, halfWidth, halfHeight, 0f, 0f, 0f); color1.x(), color1.y(), color1.z(), alpha, halfWidth, halfHeight, 0f, 0f, 0f);
poseStack.popPose(); poseStack.popPose();
@@ -101,24 +101,24 @@ public interface ISwordBeamBehavior {
//三线 //三线
poseStack.pushPose(); poseStack.pushPose();
this.applyTranslate(poseStack, dirs[0], dirs[2], progress + 0.05f, SwordBeam.DIST / 1.5f); RenderUtil.applyTranslate(poseStack, dirs[0], dirs[2], (progress + 0.05f) * 180, SwordBeam.DIST / 1.5f);
this.applyRotate(poseStack, dirs[0], dirs[1], progress, rotate); RenderUtil.applyRotate(poseStack, dirs[0], dirs[1], (0.5f - progress) * 180, rotate);
poseStack.scale(0.5f, 0.5f, 0.5f); poseStack.scale(0.5f, 0.5f, 0.5f);
renderQuad(poseStack.last().pose(), vertexConsumer1, renderQuad(poseStack.last().pose(), vertexConsumer1,
color3.x(), color3.y(), color3.z(), alpha, halfWidth, halfHeight, 0f, 0f, 0.02f); color3.x(), color3.y(), color3.z(), alpha, halfWidth, halfHeight, 0f, 0f, 0.02f);
poseStack.popPose(); poseStack.popPose();
poseStack.pushPose(); poseStack.pushPose();
this.applyTranslate(poseStack, dirs[0], dirs[2], progress + 0.05f, SwordBeam.DIST / 1.25f); RenderUtil.applyTranslate(poseStack, dirs[0], dirs[2], (progress + 0.05f) * 180, SwordBeam.DIST / 1.25f);
this.applyRotate(poseStack, dirs[0], dirs[1], progress, rotate); RenderUtil.applyRotate(poseStack, dirs[0], dirs[1], (0.5f - progress) * 180, rotate);
poseStack.scale(0.75f, 0.75f, 0.75f); poseStack.scale(0.75f, 0.75f, 0.75f);
renderQuad(poseStack.last().pose(), vertexConsumer1, renderQuad(poseStack.last().pose(), vertexConsumer1,
color3.x(), color3.y(), color3.z(), alpha, halfWidth, halfHeight, 0f, 0f, 0.02f); color3.x(), color3.y(), color3.z(), alpha, halfWidth, halfHeight, 0f, 0f, 0.02f);
poseStack.popPose(); poseStack.popPose();
poseStack.pushPose(); poseStack.pushPose();
this.applyTranslate(poseStack, dirs[0], dirs[2], progress, SwordBeam.DIST * 1.15f); RenderUtil.applyTranslate(poseStack, dirs[0], dirs[2], progress * 180, SwordBeam.DIST * 1.15f);
this.applyRotate(poseStack, dirs[0], dirs[1], progress, rotate); RenderUtil.applyRotate(poseStack, dirs[0], dirs[1], (0.5f - progress) * 180, rotate);
poseStack.scale(0.95f, 0.95f, 0.95f); poseStack.scale(0.95f, 0.95f, 0.95f);
renderQuad(poseStack.last().pose(), vertexConsumer1, renderQuad(poseStack.last().pose(), vertexConsumer1,
color3.x(), color3.y(), color3.z(), alpha, halfWidth, halfHeight, 0f, 0f, 0.02f); color3.x(), color3.y(), color3.z(), alpha, halfWidth, halfHeight, 0f, 0f, 0.02f);
@@ -128,8 +128,8 @@ public interface ISwordBeamBehavior {
//边缘高光 //边缘高光
poseStack.pushPose(); poseStack.pushPose();
this.applyTranslate(poseStack, dirs[0], dirs[2], progress + 0.05f, SwordBeam.DIST * 1.15f); RenderUtil.applyTranslate(poseStack, dirs[0], dirs[2], (progress + 0.05f) * 180, SwordBeam.DIST * 1.15f);
this.applyRotate(poseStack, dirs[0], dirs[1], progress + 0.05f, rotate); RenderUtil.applyRotate(poseStack, dirs[0], dirs[1], (0.5f - progress - 0.05f) * 180, rotate);
poseStack.scale(1.0f, 1.0f, 1.0f); poseStack.scale(1.0f, 1.0f, 1.0f);
for(int i = 0;i < 20;i++) { for(int i = 0;i < 20;i++) {
renderQuad(poseStack.last().pose(), vertexConsumer2, renderQuad(poseStack.last().pose(), vertexConsumer2,
@@ -141,8 +141,8 @@ public interface ISwordBeamBehavior {
//闪烁 //闪烁
poseStack.pushPose(); poseStack.pushPose();
this.applyTranslate(poseStack, dirs[0], dirs[2], progress + 0.25f, SwordBeam.DIST * 2.25f); RenderUtil.applyTranslate(poseStack, dirs[0], dirs[2], (progress + 0.25f) * 180, SwordBeam.DIST * 2.25f);
this.applyRotate(poseStack, dirs[0], dirs[1], progress + 0.25f, rotate); RenderUtil.applyRotate(poseStack, dirs[0], dirs[1], (0.5f - progress - 0.25f) * 180, rotate);
poseStack.mulPose(Axis.ZP.rotationDegrees(45.0F)); poseStack.mulPose(Axis.ZP.rotationDegrees(45.0F));
poseStack.scale(1.0f, 1.0f, 1.0f); poseStack.scale(1.0f, 1.0f, 1.0f);
for(int i = 0;i < 20;i++) { for(int i = 0;i < 20;i++) {
@@ -152,34 +152,6 @@ public interface ISwordBeamBehavior {
poseStack.popPose(); 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) { 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 ir = (int) (r * 255.0F);
int ig = (int) (g * 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("behavior")) beam.getEntityData().set(SwordBeam.BEHAVIOR, beamData.getString("behavior"));
if(beamData.contains("rotate")) beam.getEntityData().set(SwordBeam.ROTATE, beamData.getInt("rotate")); 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("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")) { 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"))); beam.getEntityData().set(SwordBeam.COLOR0, new Vector3f(beamData.getFloat("color0R"), beamData.getFloat("color0G"), beamData.getFloat("color0B")));
} }
@@ -40,6 +40,8 @@ public class SwordBeam extends Entity {
SynchedEntityData.defineId(SwordBeam.class, EntityDataSerializers.VECTOR3); SynchedEntityData.defineId(SwordBeam.class, EntityDataSerializers.VECTOR3);
public static final EntityDataAccessor<Boolean> RIGHT = public static final EntityDataAccessor<Boolean> RIGHT =
SynchedEntityData.defineId(SwordBeam.class, EntityDataSerializers.BOOLEAN); SynchedEntityData.defineId(SwordBeam.class, EntityDataSerializers.BOOLEAN);
public static final EntityDataAccessor<Float> INFLATE =
SynchedEntityData.defineId(SwordBeam.class, EntityDataSerializers.FLOAT);
public static final EntityDataAccessor<Integer> AGE = public static final EntityDataAccessor<Integer> AGE =
SynchedEntityData.defineId(SwordBeam.class, EntityDataSerializers.INT); SynchedEntityData.defineId(SwordBeam.class, EntityDataSerializers.INT);
public static final EntityDataAccessor<Integer> LIFETIME = public static final EntityDataAccessor<Integer> LIFETIME =
@@ -147,18 +149,6 @@ public class SwordBeam extends Entity {
Quaternionf rotation2 = new Quaternionf() Quaternionf rotation2 = new Quaternionf()
.fromAxisAngleRad(up, angle); .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 axisX = new Vector3f(1, 0, 0).rotate(rotation).rotate(rotation2);
Vector3f axisY = new Vector3f(0, 1, 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); Vector3f axisZ = new Vector3f(0, 0, 1).rotate(rotation).rotate(rotation2);
@@ -170,7 +160,7 @@ public class SwordBeam extends Entity {
AABB hitBox = new AABB( AABB hitBox = new AABB(
centerX - extX, centerY - extY, centerZ - extZ, centerX - extX, centerY - extY, centerZ - extZ,
centerX + extX, centerY + extY, centerZ + extZ centerX + extX, centerY + extY, centerZ + extZ
); ).inflate(this.getEntityData().get(SwordBeam.INFLATE));
this.setBoundingBox(hitBox); this.setBoundingBox(hitBox);
List<Entity> targets = this.level().getEntities(this, hitBox, FilterUtil.createTargetFilter(this, this.getOwner())); List<Entity> 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(BEHAVIOR, "default");
builder.define(ROTATE, 0); builder.define(ROTATE, 0);
builder.define(RIGHT, false); builder.define(RIGHT, false);
builder.define(INFLATE, 0.0f);
builder.define(COLOR0, new Vector3f(1.0f, 1.0f, 1.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(COLOR1, new Vector3f(1.0f, 1.0f, 1.0f));
builder.define(COLOR2, 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.putString("behavior", this.entityData.get(BEHAVIOR));
tag.putInt("rotate", this.entityData.get(ROTATE)); tag.putInt("rotate", this.entityData.get(ROTATE));
tag.putBoolean("right", this.entityData.get(RIGHT)); tag.putBoolean("right", this.entityData.get(RIGHT));
tag.putFloat("inflate", this.entityData.get(INFLATE));
Vector3f c0 = this.entityData.get(COLOR0); Vector3f c0 = this.entityData.get(COLOR0);
tag.putFloat("color0R", c0.x); tag.putFloat("color0R", c0.x);
tag.putFloat("color0G", c0.y); 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("behavior")) this.entityData.set(BEHAVIOR, tag.getString("behavior"));
if(tag.contains("rotate")) this.entityData.set(ROTATE, tag.getInt("rotate")); 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("right")) this.entityData.set(RIGHT, tag.getBoolean("right"));
if(tag.contains("inflate")) this.entityData.set(INFLATE, tag.getFloat("inflate"));
if(tag.contains("color0R")) { if(tag.contains("color0R")) {
this.entityData.set(COLOR0, new Vector3f( this.entityData.set(COLOR0, new Vector3f(
tag.getFloat("color0R"), tag.getFloat("color0G"), tag.getFloat("color0B") tag.getFloat("color0R"), tag.getFloat("color0G"), tag.getFloat("color0B")
@@ -1,7 +1,6 @@
package com.lzxnone.terraria.entity.beam; package com.lzxnone.terraria.entity.beam;
import com.lzxnone.terraria.item.weapon.melee.TerraBlade; import com.lzxnone.terraria.item.weapon.melee.*;
import com.lzxnone.terraria.item.weapon.melee.TheHorsemansBlade;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@@ -12,11 +11,19 @@ public class SwordBeamBehaviors {
public static final String DEFAULT = "default"; public static final String DEFAULT = "default";
public static final String THE_HORSEMANS_BLADE = "the_horsemans_blade"; public static final String THE_HORSEMANS_BLADE = "the_horsemans_blade";
public static final String TERRA_BLADE = "terra_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 { static {
BEHAVIORS.put(DEFAULT, new ISwordBeamBehavior() {}); BEHAVIORS.put(DEFAULT, new ISwordBeamBehavior() {});
BEHAVIORS.put(THE_HORSEMANS_BLADE, TheHorsemansBlade.SWORD_BEAM_BEHAVIOR); BEHAVIORS.put(THE_HORSEMANS_BLADE, TheHorsemansBlade.SWORD_BEAM_BEHAVIOR);
BEHAVIORS.put(TERRA_BLADE, TerraBlade.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) { public static ISwordBeamBehavior getBehavior(String id) {
@@ -1,6 +1,7 @@
package com.lzxnone.terraria.entity.summon; package com.lzxnone.terraria.entity.summon;
import com.lzxnone.terraria.Config; import com.lzxnone.terraria.Config;
import com.lzxnone.terraria.utils.DamageUtil;
import com.lzxnone.terraria.utils.MathUtil; import com.lzxnone.terraria.utils.MathUtil;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
@@ -121,8 +122,13 @@ public class BeeSummon extends Bee {
@Override @Override
public boolean doHurtTarget(Entity target) { public boolean doHurtTarget(Entity target) {
if(owner == null) return false; if(owner == null) return false;
boolean isHurt;
if(owner instanceof Player player) {
isHurt = DamageUtil.attack(player, target, (float) Config.beeKeeperBeeDamage);
}else {
DamageSource damageSource = this.damageSources().mobAttack(owner); DamageSource damageSource = this.damageSources().mobAttack(owner);
boolean isHurt = target.hurt(damageSource, (float) Config.beeKeeperBeeDamage); isHurt = target.hurt(damageSource, (float) Config.beeKeeperBeeDamage);
}
if(isHurt) { if(isHurt) {
this.customAttackCount++; this.customAttackCount++;
@@ -14,6 +14,9 @@ public class StaticSummonBehaviors {
public static final String INFLUX_WAVER_BEAM = "influx_waver_beam"; public static final String INFLUX_WAVER_BEAM = "influx_waver_beam";
public static final String MEOWMERE_PROJECTILE = "meowmere_projectile"; public static final String MEOWMERE_PROJECTILE = "meowmere_projectile";
public static final String TERRA_BLADE_BEAM = "terra_blade_beam"; 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 { static {
BEHAVIORS.put(DEFAULT, new IStaticSummonBehavior() {}); BEHAVIORS.put(DEFAULT, new IStaticSummonBehavior() {});
@@ -22,6 +25,9 @@ public class StaticSummonBehaviors {
BEHAVIORS.put(INFLUX_WAVER_BEAM, InfluxWaver.SUMMON_BEHAVIOR); BEHAVIORS.put(INFLUX_WAVER_BEAM, InfluxWaver.SUMMON_BEHAVIOR);
BEHAVIORS.put(MEOWMERE_PROJECTILE, Meowmere.SUMMON_BEHAVIOR); BEHAVIORS.put(MEOWMERE_PROJECTILE, Meowmere.SUMMON_BEHAVIOR);
BEHAVIORS.put(TERRA_BLADE_BEAM, TerraBlade.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) { public static IStaticSummonBehavior getBehavior(String id) {
@@ -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));
}
}
}
}
@@ -1,8 +1,6 @@
package com.lzxnone.terraria.item; package com.lzxnone.terraria.item;
import com.lzxnone.terraria.item.weapon.melee.BeeKeeper; import com.lzxnone.terraria.item.weapon.melee.*;
import com.lzxnone.terraria.item.weapon.melee.TerraBlade;
import com.lzxnone.terraria.item.weapon.melee.TheHorsemansBlade;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@@ -14,12 +12,24 @@ public class ItemWaveBehaviors {
public static final String BEE_KEEPER = "bee_keeper"; public static final String BEE_KEEPER = "bee_keeper";
public static final String THE_HORSEMANS_BLADE = "the_horsemans_blade"; public static final String THE_HORSEMANS_BLADE = "the_horsemans_blade";
public static final String TERRA_BLADE = "terra_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 { static {
BEHAVIORS.put(DEFAULT, new IItemWaveBehavior() {}); BEHAVIORS.put(DEFAULT, new IItemWaveBehavior() {});
BEHAVIORS.put(BEE_KEEPER, BeeKeeper.ITEM_WAVE_BEHAVIOR); BEHAVIORS.put(BEE_KEEPER, BeeKeeper.ITEM_WAVE_BEHAVIOR);
BEHAVIORS.put(THE_HORSEMANS_BLADE, TheHorsemansBlade.ITEM_WAVE_BEHAVIOR); BEHAVIORS.put(THE_HORSEMANS_BLADE, TheHorsemansBlade.ITEM_WAVE_BEHAVIOR);
BEHAVIORS.put(TERRA_BLADE, TerraBlade.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) { public static IItemWaveBehavior getBehavior(String id) {
@@ -1,25 +1,115 @@
package com.lzxnone.terraria.item.weapon.melee; package com.lzxnone.terraria.item.weapon.melee;
import com.lzxnone.terraria.Config;
import com.lzxnone.terraria.LzxnoneTerraria; 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.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.EquipmentSlotGroup;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.ai.attributes.AttributeModifier; import net.minecraft.world.entity.ai.attributes.AttributeModifier;
import net.minecraft.world.entity.ai.attributes.Attributes; 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.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.SwordItem; import net.minecraft.world.item.SwordItem;
import net.minecraft.world.item.Tiers; import net.minecraft.world.item.Tiers;
import net.minecraft.world.item.component.ItemAttributeModifiers; 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 class BloodButcherer extends SwordItem {
public BloodButcherer() { public BloodButcherer() {
super(Tiers.IRON, new Item.Properties().attributes(ItemAttributeModifiers.builder() super(Tiers.IRON, new Item.Properties().attributes(ItemAttributeModifiers.builder()
.add(Attributes.ATTACK_DAMAGE, .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) EquipmentSlotGroup.MAINHAND)
.add(Attributes.ATTACK_SPEED, .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) EquipmentSlotGroup.MAINHAND)
.build() .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
);
}
}
}
};
} }
@@ -9,10 +9,7 @@ import com.lzxnone.terraria.entity.projectile.StaticProjectileBehaviors;
import com.lzxnone.terraria.entity.projectile.StaticProjectile; import com.lzxnone.terraria.entity.projectile.StaticProjectile;
import com.lzxnone.terraria.item.ModItems; import com.lzxnone.terraria.item.ModItems;
import com.lzxnone.terraria.particle.ModParticles; import com.lzxnone.terraria.particle.ModParticles;
import com.lzxnone.terraria.utils.FilterUtil; import com.lzxnone.terraria.utils.*;
import com.lzxnone.terraria.utils.MathUtil;
import com.lzxnone.terraria.utils.ParticleUtil;
import com.lzxnone.terraria.utils.SoundUtil;
import net.minecraft.core.component.DataComponents; import net.minecraft.core.component.DataComponents;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
@@ -66,11 +63,11 @@ public class EnchantedSword extends SwordItem {
@Override @Override
public void onHitEntity(StaticProjectile projectile, EntityHitResult result) { public void onHitEntity(StaticProjectile projectile, EntityHitResult result) {
if(!projectile.level().isClientSide()) { if(!projectile.level().isClientSide()) {
if(result.getEntity() instanceof LivingEntity target) { Entity target = result.getEntity();
Entity owner = projectile.getOwner(); Entity owner = projectile.getOwner();
if(owner == null) return; if(owner == null) return;
if(!FilterUtil.createLivingTargetFilter(owner).test(target) || !(owner instanceof Player player)) return; if(!FilterUtil.createTargetFilter(owner).test(target) || !(owner instanceof Player player)) return;
if(target.hurt(projectile.damageSources().playerAttack(player), (float) Config.enchantedSwordDamage)) { if(DamageUtil.attack(player, target, (float) Config.enchantedSwordDamage)) {
target.invulnerableTime = 5; target.invulnerableTime = 5;
ParticleUtil.addParticles( ParticleUtil.addParticles(
(ServerLevel) projectile.level(), ModParticles.COLORFUL_PARTICLE, (ServerLevel) projectile.level(), ModParticles.COLORFUL_PARTICLE,
@@ -81,7 +78,6 @@ public class EnchantedSword extends SwordItem {
} }
} }
} }
}
@Override @Override
public void onHitBlock(StaticProjectile projectile, BlockHitResult result) { public void onHitBlock(StaticProjectile projectile, BlockHitResult result) {
if(projectile.level().isClientSide()) return; if(projectile.level().isClientSide()) return;
@@ -1,25 +1,161 @@
package com.lzxnone.terraria.item.weapon.melee; package com.lzxnone.terraria.item.weapon.melee;
import com.lzxnone.terraria.Config;
import com.lzxnone.terraria.LzxnoneTerraria; 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.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.EquipmentSlotGroup;
import net.minecraft.world.entity.ai.attributes.AttributeModifier; import net.minecraft.world.entity.ai.attributes.AttributeModifier;
import net.minecraft.world.entity.ai.attributes.Attributes; 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.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.SwordItem; import net.minecraft.world.item.SwordItem;
import net.minecraft.world.item.Tiers; import net.minecraft.world.item.Tiers;
import net.minecraft.world.item.component.ItemAttributeModifiers; 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 class Excalibur extends SwordItem {
public Excalibur() { public Excalibur() {
super(Tiers.DIAMOND, new Item.Properties().attributes(ItemAttributeModifiers.builder() super(Tiers.DIAMOND, new Item.Properties().attributes(ItemAttributeModifiers.builder()
.add(Attributes.ATTACK_DAMAGE, .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) EquipmentSlotGroup.MAINHAND)
.add(Attributes.ATTACK_SPEED, .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) EquipmentSlotGroup.MAINHAND)
.build() .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<ItemStack> 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());
}
} }
@@ -12,10 +12,7 @@ import com.lzxnone.terraria.entity.summon.StaticSummon;
import com.lzxnone.terraria.entity.summon.StaticSummonBehaviors; import com.lzxnone.terraria.entity.summon.StaticSummonBehaviors;
import com.lzxnone.terraria.item.ModItems; import com.lzxnone.terraria.item.ModItems;
import com.lzxnone.terraria.particle.ModParticles; import com.lzxnone.terraria.particle.ModParticles;
import com.lzxnone.terraria.utils.CollisionUtil; import com.lzxnone.terraria.utils.*;
import com.lzxnone.terraria.utils.FilterUtil;
import com.lzxnone.terraria.utils.MathUtil;
import com.lzxnone.terraria.utils.ParticleUtil;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
@@ -151,9 +148,9 @@ public class InfluxWaver extends SwordItem {
Entity hitTarget = entityHitResult.getEntity(); Entity hitTarget = entityHitResult.getEntity();
Entity target = customData.contains("target") ? summon.level().getEntity(customData.getInt("target")) : null; Entity target = customData.contains("target") ? summon.level().getEntity(customData.getInt("target")) : null;
if(target != null && !hitTarget.getUUID().equals(target.getUUID())) return; 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(summon.getOwner() instanceof Player player && FilterUtil.createTargetFilter(player).test(hitTarget)) {
if(livingEntity.hurt(summon.damageSources().playerAttack(player), (float) Config.influxWaverDamage)) { if(DamageUtil.attack(player, hitTarget, (float) Config.influxWaverDamage)) {
livingEntity.invulnerableTime = 2; hitTarget.invulnerableTime = 2;
} }
customData.putBoolean("dead", false); customData.putBoolean("dead", false);
summon.getEntityData().set(StaticSummon.CUSTOM_DATA, customData); summon.getEntityData().set(StaticSummon.CUSTOM_DATA, customData);
@@ -1,25 +1,213 @@
package com.lzxnone.terraria.item.weapon.melee; package com.lzxnone.terraria.item.weapon.melee;
import com.lzxnone.terraria.Config;
import com.lzxnone.terraria.LzxnoneTerraria; 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.resources.ResourceLocation;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EquipmentSlotGroup; 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.AttributeModifier;
import net.minecraft.world.entity.ai.attributes.Attributes; 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.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.SwordItem; import net.minecraft.world.item.SwordItem;
import net.minecraft.world.item.Tiers; import net.minecraft.world.item.Tiers;
import net.minecraft.world.item.component.ItemAttributeModifiers; 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 class LightsBane extends SwordItem {
public LightsBane() { public LightsBane() {
super(Tiers.IRON, new Item.Properties().attributes(ItemAttributeModifiers.builder() super(Tiers.IRON, new Item.Properties().attributes(ItemAttributeModifiers.builder()
.add(Attributes.ATTACK_DAMAGE, .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) EquipmentSlotGroup.MAINHAND)
.add(Attributes.ATTACK_SPEED, .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) EquipmentSlotGroup.MAINHAND)
.build() .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<LivingEntity> 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<Monster> 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
);
}
}
}
};
} }
@@ -146,8 +146,8 @@ public class Meowmere extends SwordItem {
EntityHitResult entityHitResult = CollisionUtil.checkEntityHit(summon, summon.position().add(motion)); EntityHitResult entityHitResult = CollisionUtil.checkEntityHit(summon, summon.position().add(motion));
if(entityHitResult != null) { if(entityHitResult != null) {
Entity target = entityHitResult.getEntity(); Entity target = entityHitResult.getEntity();
if(summon.getOwner() instanceof Player player && target instanceof LivingEntity livingEntity) { if(summon.getOwner() instanceof Player player) {
if(livingEntity.hurt(summon.damageSources().playerAttack(player), (float) Config.meowmereDamage)) { if(DamageUtil.attack(player, target, (float) Config.meowmereDamage)) {
if(customData.contains("hitEntity") && customData.getInt("hitEntity") < 4) { if(customData.contains("hitEntity") && customData.getInt("hitEntity") < 4) {
customData.putInt("hitEntity", customData.getInt("hitEntity") + 1); customData.putInt("hitEntity", customData.getInt("hitEntity") + 1);
summon.getEntityData().set(StaticSummon.CUSTOM_DATA, customData); summon.getEntityData().set(StaticSummon.CUSTOM_DATA, customData);
@@ -155,7 +155,7 @@ public class Meowmere extends SwordItem {
onDied(summon); onDied(summon);
return; return;
} }
livingEntity.invulnerableTime = 2; target.invulnerableTime = 2;
} }
} }
return; return;
@@ -1,25 +1,477 @@
package com.lzxnone.terraria.item.weapon.melee; package com.lzxnone.terraria.item.weapon.melee;
import com.lzxnone.terraria.Config;
import com.lzxnone.terraria.LzxnoneTerraria; 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.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.EquipmentSlotGroup;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.ai.attributes.AttributeModifier; import net.minecraft.world.entity.ai.attributes.AttributeModifier;
import net.minecraft.world.entity.ai.attributes.Attributes; 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.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.SwordItem; import net.minecraft.world.item.SwordItem;
import net.minecraft.world.item.Tiers; import net.minecraft.world.item.Tiers;
import net.minecraft.world.item.component.ItemAttributeModifiers; 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 class NightsEdge extends SwordItem {
public NightsEdge() { public NightsEdge() {
super(Tiers.DIAMOND, new Item.Properties().attributes(ItemAttributeModifiers.builder() super(Tiers.DIAMOND, new Item.Properties().attributes(ItemAttributeModifiers.builder()
.add(Attributes.ATTACK_DAMAGE, .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) EquipmentSlotGroup.MAINHAND)
.add(Attributes.ATTACK_SPEED, .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) EquipmentSlotGroup.MAINHAND)
.build() .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<LivingEntity> 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<ItemStack> 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());
}
} }
@@ -60,9 +60,9 @@ public class Seedler extends SwordItem {
EntityHitResult entityHitResult = CollisionUtil.checkEntityHit(summon, summon.position().add(motion)); EntityHitResult entityHitResult = CollisionUtil.checkEntityHit(summon, summon.position().add(motion));
if(entityHitResult != null) { if(entityHitResult != null) {
Entity target = entityHitResult.getEntity(); Entity target = entityHitResult.getEntity();
if(summon.getOwner() instanceof Player player && target instanceof LivingEntity livingEntity) { if(summon.getOwner() instanceof Player player) {
if(livingEntity.hurt(summon.damageSources().playerAttack(player), (float) Config.seedlerThornDamage)) { if(DamageUtil.attack(player, target, (float) Config.seedlerThornDamage)) {
livingEntity.invulnerableTime = 2; target.invulnerableTime = 2;
} }
} }
onDied(summon); onDied(summon);
@@ -173,17 +173,16 @@ public class Seedler extends SwordItem {
@Override @Override
public void onHitEntity(StaticProjectile projectile, EntityHitResult result) { public void onHitEntity(StaticProjectile projectile, EntityHitResult result) {
if(!projectile.level().isClientSide()) { if(!projectile.level().isClientSide()) {
if(result.getEntity() instanceof LivingEntity target) { Entity target = result.getEntity();
Entity owner = projectile.getOwner(); Entity owner = projectile.getOwner();
if(owner == null) return; if(owner == null) return;
if(!FilterUtil.createLivingTargetFilter(owner).test(target) || !(owner instanceof Player player)) return; if(!FilterUtil.createTargetFilter(owner).test(target) || !(owner instanceof Player player)) return;
if(target.hurt(projectile.damageSources().playerAttack(player), (float) Config.seedlerThornDamage)) { if(DamageUtil.attack(player, target, (float) Config.seedlerThornDamage)) {
target.invulnerableTime = 2; target.invulnerableTime = 2;
onDied(projectile); onDied(projectile);
} }
} }
} }
}
@Override @Override
public void onHitBlock(StaticProjectile projectile, BlockHitResult result) { public void onHitBlock(StaticProjectile projectile, BlockHitResult result) {
if(projectile.level().isClientSide()) return; if(projectile.level().isClientSide()) return;
@@ -82,15 +82,14 @@ public class StarWrath extends SwordItem {
@Override @Override
public void onHitEntity(StaticProjectile projectile, EntityHitResult result) { public void onHitEntity(StaticProjectile projectile, EntityHitResult result) {
if(!projectile.level().isClientSide()) { if(!projectile.level().isClientSide()) {
if(result.getEntity() instanceof LivingEntity target) { Entity target = result.getEntity();
Entity owner = projectile.getOwner(); Entity owner = projectile.getOwner();
if(!FilterUtil.createLivingTargetFilter(owner).test(target) || !(owner instanceof Player player)) return; if(!FilterUtil.createTargetFilter(owner).test(target) || !(owner instanceof Player player)) return;
if(target.hurt(projectile.damageSources().playerAttack(player), (float) Config.starWrathDamage)) { if(DamageUtil.attack(player, target, (float) Config.starWrathDamage)) {
target.invulnerableTime = 2; target.invulnerableTime = 2;
} }
} }
} }
}
@Override @Override
public void onHitBlock(StaticProjectile projectile, BlockHitResult result) { public void onHitBlock(StaticProjectile projectile, BlockHitResult result) {
CompoundTag customData = projectile.getEntityData().get(StaticProjectile.CUSTOM_DATA); CompoundTag customData = projectile.getEntityData().get(StaticProjectile.CUSTOM_DATA);
@@ -61,16 +61,15 @@ public class Starfury extends SwordItem {
@Override @Override
public void onHitEntity(StaticProjectile projectile, EntityHitResult result) { public void onHitEntity(StaticProjectile projectile, EntityHitResult result) {
if(!projectile.level().isClientSide()) { if(!projectile.level().isClientSide()) {
if(result.getEntity() instanceof LivingEntity target) { Entity target = result.getEntity();
Entity owner = projectile.getOwner(); Entity owner = projectile.getOwner();
if(owner == null) return; if(owner == null) return;
if(!FilterUtil.createLivingTargetFilter(owner).test(target) || !(owner instanceof Player player)) return; if(!FilterUtil.createTargetFilter(owner).test(target) || !(owner instanceof Player player)) return;
if(target.hurt(projectile.damageSources().playerAttack(player), (float) Config.starfuryDamage)) { if(DamageUtil.attack(player, target, (float) Config.starfuryDamage)) {
target.invulnerableTime = 5; target.invulnerableTime = 5;
} }
} }
} }
}
@Override @Override
public void onHitBlock(StaticProjectile projectile, BlockHitResult result) { public void onHitBlock(StaticProjectile projectile, BlockHitResult result) {
CompoundTag customData = projectile.getEntityData().get(StaticProjectile.CUSTOM_DATA); CompoundTag customData = projectile.getEntityData().get(StaticProjectile.CUSTOM_DATA);
@@ -106,12 +106,13 @@ public class TerraBlade extends SwordItem {
@Override @Override
public void onHitEntity(SwordBeam beam, EntityHitResult result) { public void onHitEntity(SwordBeam beam, EntityHitResult result) {
if(!beam.level().isClientSide()) { 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); CompoundTag custom_data = beam.getEntityData().get(SwordBeam.CUSTOM_DATA);
if(custom_data.contains("hitEntityCount")) { if(custom_data.contains("hitEntityCount")) {
int count = custom_data.getInt("hitEntityCount"); int count = custom_data.getInt("hitEntityCount");
if(count < Config.terraBladeMaxHitCount) { 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; target.invulnerableTime = 20;
count++; count++;
custom_data.putInt("hitEntityCount", count); custom_data.putInt("hitEntityCount", count);
@@ -125,7 +126,6 @@ public class TerraBlade extends SwordItem {
@Override @Override
public void generate(Entity entity, CompoundTag beamData) { public void generate(Entity entity, CompoundTag beamData) {
//beamData.putBoolean("right", entity.getRandom().nextInt(2) == 0);
int randomAngle = (int) (Config.terraBladeRotateRange * (Math.random() * 2 - 1)); int randomAngle = (int) (Config.terraBladeRotateRange * (Math.random() * 2 - 1));
beamData.putInt("rotate", randomAngle); beamData.putInt("rotate", randomAngle);
ISwordBeamBehavior.super.generate(entity, beamData); ISwordBeamBehavior.super.generate(entity, beamData);
@@ -194,26 +194,26 @@ public class TerraBlade extends SwordItem {
//左边 //左边
poseStack.pushPose(); poseStack.pushPose();
this.applyTranslate(poseStack, dirs[0], dirs[2], 90 - 18 * (1.0f - progress), SwordBeam.DIST); RenderUtil.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); RenderUtil.applyRotate(poseStack, dirs[0], dirs[1], 18 * (1.0f - progress), rotate);
renderQuad(poseStack.last().pose(), vertexConsumer0, RenderUtil.renderQuad(poseStack.last().pose(), vertexConsumer0,
COLOR0.x(), COLOR0.y(), COLOR0.z(), alpha, halfWidth, halfHeight, 0f, 0, -0.01f); COLOR0.x(), COLOR0.y(), COLOR0.z(), alpha, halfWidth, halfHeight, 0f, 0, -0.01f);
poseStack.popPose(); poseStack.popPose();
//中间 //中间
poseStack.pushPose(); poseStack.pushPose();
this.applyTranslate(poseStack, dirs[0], dirs[2], 90, SwordBeam.DIST); RenderUtil.applyTranslate(poseStack, dirs[0], dirs[2], 90, SwordBeam.DIST);
this.applyRotate(poseStack, dirs[0], dirs[1], 0, rotate); RenderUtil.applyRotate(poseStack, dirs[0], dirs[1], 0, rotate);
renderQuad(poseStack.last().pose(), vertexConsumer0, RenderUtil.renderQuad(poseStack.last().pose(), vertexConsumer0,
COLOR1.x(), COLOR1.y(), COLOR1.z(), alpha, halfWidth, halfHeight, 0f, 0f, 0f); COLOR1.x(), COLOR1.y(), COLOR1.z(), alpha, halfWidth, halfHeight, 0f, 0f, 0f);
poseStack.popPose(); poseStack.popPose();
//右边 //右边
poseStack.pushPose(); poseStack.pushPose();
this.applyTranslate(poseStack, dirs[0], dirs[2], 108, SwordBeam.DIST); RenderUtil.applyTranslate(poseStack, dirs[0], dirs[2], 108, SwordBeam.DIST);
this.applyRotate(poseStack, dirs[0], dirs[1], -9 * (1.0f - progress), rotate); RenderUtil.applyRotate(poseStack, dirs[0], dirs[1], -9 * (1.0f - progress), rotate);
renderQuad(poseStack.last().pose(), vertexConsumer0, RenderUtil.renderQuad(poseStack.last().pose(), vertexConsumer0,
COLOR2.x(), COLOR2.y(), COLOR2.z(), alpha, halfWidth, halfHeight, 0f, 0, 0.01f); COLOR2.x(), COLOR2.y(), COLOR2.z(), alpha, halfWidth, halfHeight, 0f, 0, 0.01f);
poseStack.popPose(); poseStack.popPose();
@@ -221,26 +221,26 @@ public class TerraBlade extends SwordItem {
//三线 //三线
poseStack.pushPose(); poseStack.pushPose();
this.applyTranslate(poseStack, dirs[0], dirs[2], 90, SwordBeam.DIST / 1.5f); RenderUtil.applyTranslate(poseStack, dirs[0], dirs[2], 90, SwordBeam.DIST / 1.5f);
this.applyRotate(poseStack, dirs[0], dirs[1], 0, rotate); RenderUtil.applyRotate(poseStack, dirs[0], dirs[1], 0, rotate);
poseStack.scale(0.5f, 0.5f, 0.5f); 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); 1.0f, 1.0f, 1.0f, alpha, halfWidth, halfHeight, 0f, 0f, 0.02f);
poseStack.popPose(); poseStack.popPose();
poseStack.pushPose(); poseStack.pushPose();
this.applyTranslate(poseStack, dirs[0], dirs[2], 90, SwordBeam.DIST / 1.25f); RenderUtil.applyTranslate(poseStack, dirs[0], dirs[2], 90, SwordBeam.DIST / 1.25f);
this.applyRotate(poseStack, dirs[0], dirs[1], 0, rotate); RenderUtil.applyRotate(poseStack, dirs[0], dirs[1], 0, rotate);
poseStack.scale(0.75f, 0.75f, 0.75f); 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); 1.0f, 1.0f, 1.0f, alpha, halfWidth, halfHeight, 0f, 0f, 0.02f);
poseStack.popPose(); poseStack.popPose();
poseStack.pushPose(); poseStack.pushPose();
this.applyTranslate(poseStack, dirs[0], dirs[2], 90, SwordBeam.DIST * 1.15f); RenderUtil.applyTranslate(poseStack, dirs[0], dirs[2], 90, SwordBeam.DIST * 1.15f);
this.applyRotate(poseStack, dirs[0], dirs[1], 0, rotate); RenderUtil.applyRotate(poseStack, dirs[0], dirs[1], 0, rotate);
poseStack.scale(0.95f, 0.95f, 0.95f); 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); 1.0f, 1.0f, 1.0f, alpha, halfWidth, halfHeight, 0f, 0f, 0.02f);
poseStack.popPose(); poseStack.popPose();
@@ -248,11 +248,11 @@ public class TerraBlade extends SwordItem {
//边缘高光 //边缘高光
poseStack.pushPose(); poseStack.pushPose();
this.applyTranslate(poseStack, dirs[0], dirs[2], 100, SwordBeam.DIST * 1.15f); RenderUtil.applyTranslate(poseStack, dirs[0], dirs[2], 100, SwordBeam.DIST * 1.15f);
this.applyRotate(poseStack, dirs[0], dirs[1], 0, rotate); RenderUtil.applyRotate(poseStack, dirs[0], dirs[1], 0, rotate);
poseStack.scale(1.0f, 1.0f, 1.0f); poseStack.scale(1.0f, 1.0f, 1.0f);
for(int i = 0;i < 5;i++) { 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); COLOR2.x(), COLOR2.y(), COLOR2.z(), alpha, halfWidth, halfHeight, 0f, 0f, 0.03f);
} }
poseStack.popPose(); poseStack.popPose();
@@ -274,11 +274,11 @@ public class TerraBlade extends SwordItem {
for(int k = 0;k < 2;k++) { for(int k = 0;k < 2;k++) {
poseStack.pushPose(); poseStack.pushPose();
if(k == 0) { if(k == 0) {
this.applyTranslate(poseStack, dirs[0], dirs[2], 90 - 60.0 * progress, SwordBeam.DIST * 2f); RenderUtil.applyTranslate(poseStack, dirs[0], dirs[2], 90 - 60.0 * progress, SwordBeam.DIST * 2f);
this.applyRotate(poseStack, dirs[0], dirs[1], 60 * progress, rotate); RenderUtil.applyRotate(poseStack, dirs[0], dirs[1], 60 * progress, rotate);
}else { }else {
this.applyTranslate(poseStack, dirs[0], dirs[2], 90 + 60.0 * progress, SwordBeam.DIST * 2f + 0.5f * progress); RenderUtil.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.applyRotate(poseStack, dirs[0], dirs[1], -60 * progress, rotate);
} }
for(int j = 0; j < 2; j++) { for(int j = 0; j < 2; j++) {
poseStack.pushPose(); poseStack.pushPose();
@@ -286,7 +286,7 @@ public class TerraBlade extends SwordItem {
else poseStack.mulPose(Axis.ZP.rotationDegrees(45.0F)); else poseStack.mulPose(Axis.ZP.rotationDegrees(45.0F));
poseStack.scale(0.5f, 0.5f, 0.5f); poseStack.scale(0.5f, 0.5f, 0.5f);
for(int i = 0; i < 5; i++) { 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); COLOR2.x(), COLOR2.y(), COLOR2.z(), sparkleAlpha, 32 * SwordBeam.SCALE, 32 * SwordBeam.SCALE, 0f, 0f, 0.03f);
} }
poseStack.popPose(); poseStack.popPose();
@@ -300,11 +300,11 @@ public class TerraBlade extends SwordItem {
for(int k = 0;k < 2;k++) { for(int k = 0;k < 2;k++) {
poseStack.pushPose(); poseStack.pushPose();
if(k == 0) { if(k == 0) {
this.applyTranslate(poseStack, dirs[0], dirs[2], 90 - 30.0 * progress, SwordBeam.DIST * 2f); RenderUtil.applyTranslate(poseStack, dirs[0], dirs[2], 90 - 30.0 * progress, SwordBeam.DIST * 2f);
this.applyRotate(poseStack, dirs[0], dirs[1], 30 * progress, rotate); RenderUtil.applyRotate(poseStack, dirs[0], dirs[1], 30 * progress, rotate);
}else { }else {
this.applyTranslate(poseStack, dirs[0], dirs[2], 90 + 30.0 * progress, SwordBeam.DIST * 2.1f); RenderUtil.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.applyRotate(poseStack, dirs[0], dirs[1], -30 * progress, rotate);
} }
for(int j = 0; j < 2; j++) { for(int j = 0; j < 2; j++) {
poseStack.pushPose(); poseStack.pushPose();
@@ -312,7 +312,7 @@ public class TerraBlade extends SwordItem {
else poseStack.mulPose(Axis.ZP.rotationDegrees(45.0F)); else poseStack.mulPose(Axis.ZP.rotationDegrees(45.0F));
poseStack.scale(0.75f, 0.75f, 0.75f); poseStack.scale(0.75f, 0.75f, 0.75f);
for(int i = 0; i < 5; i++) { 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); COLOR2.x(), COLOR2.y(), COLOR2.z(), sparkleAlpha, 32 * SwordBeam.SCALE, 32 * SwordBeam.SCALE, 0f, 0f, 0.03f);
} }
poseStack.popPose(); poseStack.popPose();
@@ -323,15 +323,15 @@ public class TerraBlade extends SwordItem {
//闪烁(内层) //闪烁(内层)
poseStack.pushPose(); poseStack.pushPose();
this.applyTranslate(poseStack, dirs[0], dirs[2], 90, SwordBeam.DIST * 2f); RenderUtil.applyTranslate(poseStack, dirs[0], dirs[2], 90, SwordBeam.DIST * 2f);
this.applyRotate(poseStack, dirs[0], dirs[1], 0, rotate); RenderUtil.applyRotate(poseStack, dirs[0], dirs[1], 0, rotate);
for(int j = 0; j < 2; j++) { for(int j = 0; j < 2; j++) {
poseStack.pushPose(); poseStack.pushPose();
if(j == 0) poseStack.mulPose(Axis.ZP.rotationDegrees(0.0F)); if(j == 0) poseStack.mulPose(Axis.ZP.rotationDegrees(0.0F));
else poseStack.mulPose(Axis.ZP.rotationDegrees(45.0F)); else poseStack.mulPose(Axis.ZP.rotationDegrees(45.0F));
poseStack.scale(1.0f, 1.0f, 1.0f); poseStack.scale(1.0f, 1.0f, 1.0f);
for(int i = 0; i < 5; i++) { 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); COLOR2.x(), COLOR2.y(), COLOR2.z(), sparkleAlpha, 32 * SwordBeam.SCALE, 32 * SwordBeam.SCALE, 0f, 0f, 0.03f);
} }
poseStack.popPose(); poseStack.popPose();
@@ -341,54 +341,6 @@ public class TerraBlade extends SwordItem {
poseStack.popPose(); 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 @Override
public void tick(StaticSummon summon) { public void tick(StaticSummon summon) {
this.checkBeforeTick(summon); this.checkBeforeTick(summon);
@@ -411,8 +363,8 @@ public class TerraBlade extends SwordItem {
Vec3 center = summon.position().add(summon.getLookAngle().normalize().scale(SwordBeam.DIST)); Vec3 center = summon.position().add(summon.getLookAngle().normalize().scale(SwordBeam.DIST));
if(customData.contains("extX") && customData.contains("extY") && customData.contains("extZ")) { if(customData.contains("extX") && customData.contains("extY") && customData.contains("extZ")) {
summon.setBoundingBox(new AABB( summon.setBoundingBox(new AABB(
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.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")
)); ));
} }
@@ -421,7 +373,7 @@ public class TerraBlade extends SwordItem {
int count = customData.getInt("hitCount"); int count = customData.getInt("hitCount");
List<LivingEntity> targets = summon.level().getEntitiesOfClass(LivingEntity.class, summon.getBoundingBox(), FilterUtil.createTargetFilter(summon, summon.getOwner())); List<LivingEntity> targets = summon.level().getEntitiesOfClass(LivingEntity.class, summon.getBoundingBox(), FilterUtil.createTargetFilter(summon, summon.getOwner()));
for(LivingEntity target : targets) { 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++; count++;
ParticleUtil.addParticles( ParticleUtil.addParticles(
(ServerLevel) summon.level(), ModParticles.TERRA_BEAM_HIT_PARTICLE.get(), (ServerLevel) summon.level(), ModParticles.TERRA_BEAM_HIT_PARTICLE.get(),
@@ -14,10 +14,7 @@ import com.lzxnone.terraria.item.IItemWaveBehavior;
import com.lzxnone.terraria.network.payload.SwordBeamPayload; import com.lzxnone.terraria.network.payload.SwordBeamPayload;
import com.lzxnone.terraria.particle.DustParticleOptions; import com.lzxnone.terraria.particle.DustParticleOptions;
import com.lzxnone.terraria.particle.ModParticles; import com.lzxnone.terraria.particle.ModParticles;
import com.lzxnone.terraria.utils.FilterUtil; import com.lzxnone.terraria.utils.*;
import com.lzxnone.terraria.utils.MathUtil;
import com.lzxnone.terraria.utils.ParticleUtil;
import com.lzxnone.terraria.utils.SoundUtil;
import net.minecraft.Util; import net.minecraft.Util;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
@@ -105,12 +102,13 @@ public class TheHorsemansBlade extends SwordItem {
@Override @Override
public void onHitEntity(SwordBeam beam, EntityHitResult result) { public void onHitEntity(SwordBeam beam, EntityHitResult result) {
if(!beam.level().isClientSide()) { 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); CompoundTag custom_data = beam.getEntityData().get(SwordBeam.CUSTOM_DATA);
if(custom_data.contains("hitEntityCount")) { if(custom_data.contains("hitEntityCount")) {
int count = custom_data.getInt("hitEntityCount"); int count = custom_data.getInt("hitEntityCount");
if(count < Config.horsemansBladeMaxHitCount) { 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; target.invulnerableTime = 20;
count++; count++;
custom_data.putInt("hitEntityCount", count); custom_data.putInt("hitEntityCount", count);
@@ -242,7 +240,7 @@ public class TheHorsemansBlade extends SwordItem {
summon.setYRot(xyRot[1]); summon.setYRot(xyRot[1]);
if(selfPos.distanceToSqr(targetPos) < 2.0D) { 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 { }else {
Vec3 dir = summon.getLookAngle().normalize(); Vec3 dir = summon.getLookAngle().normalize();
@@ -267,7 +265,7 @@ public class TheHorsemansBlade extends SwordItem {
for(Entity hitEntity : hitEntities) { for(Entity hitEntity : hitEntities) {
if(target != null && hitEntity.getUUID() == target.getUUID()) continue; if(target != null && hitEntity.getUUID() == target.getUUID()) continue;
if(summon.getOwner() instanceof Player player) { 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; hitEntity.invulnerableTime = 2;
} }
} }
@@ -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); Vector3f[] dirs = MathUtil.computeCoordinateSystem(player);
int randomAngle = (int) ((Math.random() * 2 - 1) * Config.zenithTrailOffset); int randomAngle = (int) ((Math.random() * 2 - 1) * Config.zenithTrailOffset);
dirs = MathUtil.rotateCoordinateSystem(dirs[0], dirs[2], randomAngle); dirs = MathUtil.rotateCoordinateSystem(dirs[0], dirs[2], randomAngle);
Vec3 pos = (player.getBoundingBox().getCenter()).add(MathUtil.toVec3(dirs[0]).scale(-2)); Vec3 pos = (player.getBoundingBox().getCenter()).add(MathUtil.toVec3(dirs[0]).scale(-2));
double dist;
if(Config.zenithDistanceMode) {
Vec3 targetPos = MathUtil.getCrosshairPos(player, player.level(), Config.zenithMaxRange); Vec3 targetPos = MathUtil.getCrosshairPos(player, player.level(), Config.zenithMaxRange);
double dist = targetPos.subtract(pos).length(); 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); int cycle = (int) Math.max(10, dist / Config.zenithMaxRange * Config.zenithCycle);
double a = Math.max(dist / 2, 2); double a = Math.max(dist / 2, 2);
double b = Math.min(Math.random() * Config.zenithTrailB + Config.zenithTrailB, a / 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(entity instanceof Player player) {
if(isSelected) { if(isSelected) {
if(player.tickCount % 3 == 0) { 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) int count = stack.getOrDefault(DataComponents.CUSTOM_DATA, CustomData.EMPTY)
.copyTag().getInt("attackCount"); .copyTag().getInt("attackCount");
if(count > 0) { if(count > 0) {
summon(player); summon(player, deltaDist);
CustomData.update(DataComponents.CUSTOM_DATA, stack, CustomData.update(DataComponents.CUSTOM_DATA, stack,
tag -> tag.putInt("attackCount", count - 1)); tag -> tag.putInt("attackCount", count - 1));
} }
@@ -1,25 +1,291 @@
package com.lzxnone.terraria.item.weapon.melee; package com.lzxnone.terraria.item.weapon.melee;
import com.lzxnone.terraria.Config;
import com.lzxnone.terraria.LzxnoneTerraria; 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.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.EquipmentSlotGroup;
import net.minecraft.world.entity.ai.attributes.AttributeModifier; import net.minecraft.world.entity.ai.attributes.AttributeModifier;
import net.minecraft.world.entity.ai.attributes.Attributes; 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.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.SwordItem; import net.minecraft.world.item.SwordItem;
import net.minecraft.world.item.Tiers; import net.minecraft.world.item.Tiers;
import net.minecraft.world.item.component.ItemAttributeModifiers; 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 class TrueExcalibur extends SwordItem {
public TrueExcalibur() { public TrueExcalibur() {
super(Tiers.NETHERITE, new Item.Properties().attributes(ItemAttributeModifiers.builder() super(Tiers.NETHERITE, new Item.Properties().attributes(ItemAttributeModifiers.builder()
.add(Attributes.ATTACK_DAMAGE, .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) EquipmentSlotGroup.MAINHAND)
.add(Attributes.ATTACK_SPEED, .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) EquipmentSlotGroup.MAINHAND)
.build() .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<ItemStack> 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());
}
} }
@@ -1,20 +1,58 @@
package com.lzxnone.terraria.item.weapon.melee; package com.lzxnone.terraria.item.weapon.melee;
import com.lzxnone.terraria.Config;
import com.lzxnone.terraria.LzxnoneTerraria; 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.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.EquipmentSlotGroup;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.ai.attributes.AttributeModifier; import net.minecraft.world.entity.ai.attributes.AttributeModifier;
import net.minecraft.world.entity.ai.attributes.Attributes; 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.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.SwordItem; import net.minecraft.world.item.SwordItem;
import net.minecraft.world.item.Tiers; import net.minecraft.world.item.Tiers;
import net.minecraft.world.item.component.ItemAttributeModifiers; 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 class TrueNightsEdge extends SwordItem {
public TrueNightsEdge() { public TrueNightsEdge() {
super(Tiers.NETHERITE, new Item.Properties().attributes(ItemAttributeModifiers.builder() super(Tiers.NETHERITE, new Item.Properties().attributes(ItemAttributeModifiers.builder()
.add(Attributes.ATTACK_DAMAGE, .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) EquipmentSlotGroup.MAINHAND)
.add(Attributes.ATTACK_SPEED, .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"), -2.4, AttributeModifier.Operation.ADD_VALUE),
@@ -22,4 +60,508 @@ public class TrueNightsEdge extends SwordItem {
.build() .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<LivingEntity> 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<ItemStack> 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());
}
} }
@@ -359,8 +359,8 @@ public class Zenith extends SwordItem {
public void onHitEntity(StaticProjectile projectile, EntityHitResult result) { public void onHitEntity(StaticProjectile projectile, EntityHitResult result) {
if(!projectile.level().isClientSide()) { if(!projectile.level().isClientSide()) {
Entity target = result.getEntity(); Entity target = result.getEntity();
if(projectile.getOwner() instanceof Player player && target instanceof LivingEntity livingEntity && FilterUtil.createLivingTargetFilter(projectile, projectile.getOwner()).test(livingEntity)) { if(projectile.getOwner() instanceof Player player && FilterUtil.createTargetFilter(projectile, projectile.getOwner()).test(target)) {
if(target.hurt(projectile.damageSources().playerAttack(player), (float) (Config.zenithDamage + Math.random() * Config.zenithDamage))) { if(DamageUtil.attack(player, target, (float) (Config.zenithDamage + Math.random() * Config.zenithDamage))) {
target.invulnerableTime = 2; 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); Vector3f[] dirs = MathUtil.computeCoordinateSystem(player);
int randomAngle = (int) ((Math.random() * 2 - 1) * Config.zenithTrailOffset); int randomAngle = (int) ((Math.random() * 2 - 1) * Config.zenithTrailOffset);
dirs = MathUtil.rotateCoordinateSystem(dirs[0], dirs[2], randomAngle); dirs = MathUtil.rotateCoordinateSystem(dirs[0], dirs[2], randomAngle);
Vec3 pos = (player.getBoundingBox().getCenter()).add(MathUtil.toVec3(dirs[0]).scale(-2)); Vec3 pos = (player.getBoundingBox().getCenter()).add(MathUtil.toVec3(dirs[0]).scale(-2));
double dist;
if(Config.zenithDistanceMode) {
Vec3 targetPos = MathUtil.getCrosshairPos(player, player.level(), Config.zenithMaxRange); Vec3 targetPos = MathUtil.getCrosshairPos(player, player.level(), Config.zenithMaxRange);
double dist = targetPos.subtract(pos).length(); 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); int cycle = (int) Math.max(10, dist / Config.zenithMaxRange * Config.zenithCycle);
double a = Math.max(dist / 2, 2); double a = Math.max(dist / 2, 2);
double b = Math.min(Math.random() * Config.zenithTrailB + Config.zenithTrailB, a / 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(entity instanceof Player player) {
if(isSelected) { if(isSelected) {
if(player.tickCount % 3 == 0) { 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) boolean isFirst = stack.getOrDefault(DataComponents.CUSTOM_DATA, CustomData.EMPTY)
.copyTag().getBoolean("isFirst"); .copyTag().getBoolean("isFirst");
int count = stack.getOrDefault(DataComponents.CUSTOM_DATA, CustomData.EMPTY) int count = stack.getOrDefault(DataComponents.CUSTOM_DATA, CustomData.EMPTY)
.copyTag().getInt("attackCount"); .copyTag().getInt("attackCount");
if(count > 0) { if(count > 0) {
summon(player, isFirst); summon(player, deltaDist, isFirst);
CustomData.update(DataComponents.CUSTOM_DATA, stack, CustomData.update(DataComponents.CUSTOM_DATA, stack,
tag -> tag.putInt("attackCount", count - 1)); tag -> tag.putInt("attackCount", count - 1));
CustomData.update(DataComponents.CUSTOM_DATA, stack, CustomData.update(DataComponents.CUSTOM_DATA, stack,
@@ -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();
}
}
}
}
@@ -2,7 +2,9 @@ package com.lzxnone.terraria.network;
import com.lzxnone.terraria.LzxnoneTerraria; import com.lzxnone.terraria.LzxnoneTerraria;
import com.lzxnone.terraria.network.handler.SwordBeamHandler; 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.SwordBeamPayload;
import com.lzxnone.terraria.network.payload.ZenithScrollPayload;
import net.neoforged.bus.api.SubscribeEvent; import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.fml.common.EventBusSubscriber; import net.neoforged.fml.common.EventBusSubscriber;
import net.neoforged.neoforge.network.event.RegisterPayloadHandlersEvent; import net.neoforged.neoforge.network.event.RegisterPayloadHandlersEvent;
@@ -18,5 +20,10 @@ public class ModNetwork {
SwordBeamPayload.CODEC, SwordBeamPayload.CODEC,
SwordBeamHandler::handle SwordBeamHandler::handle
); );
registrar.playToServer(
ZenithScrollPayload.TYPE,
ZenithScrollPayload.CODEC,
ZenithScrollHandler::handle
);
} }
} }
@@ -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));
}
});
}
}
@@ -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<ZenithScrollPayload> TYPE = new Type<>(
ResourceLocation.fromNamespaceAndPath("lzxnoneterraria", "zenith_scroll_payload")
);
public static final StreamCodec<FriendlyByteBuf, ZenithScrollPayload> CODEC = StreamCodec.composite(
ByteBufCodecs.DOUBLE, ZenithScrollPayload::scrollDelta,
ZenithScrollPayload::new
);
@Override
public Type<? extends CustomPacketPayload> type() {
return TYPE;
}
}
@@ -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<SimpleParticleType> {
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);
}
}
}
@@ -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<SimpleParticleType> {
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);
}
}
}
@@ -84,4 +84,14 @@ public class ModParticles {
PARTICLE_TYPES.register("influx_waver_drop_particle", () -> new SimpleParticleType(true)); PARTICLE_TYPES.register("influx_waver_drop_particle", () -> new SimpleParticleType(true));
public static final Supplier<SimpleParticleType> TERRA_BEAM_HIT_PARTICLE = public static final Supplier<SimpleParticleType> TERRA_BEAM_HIT_PARTICLE =
PARTICLE_TYPES.register("terra_beam_hit_particle", () -> new SimpleParticleType(true)); PARTICLE_TYPES.register("terra_beam_hit_particle", () -> new SimpleParticleType(true));
public static final Supplier<SimpleParticleType> EXCALIBUR_HIT_PARTICLE =
PARTICLE_TYPES.register("excalibur_hit_particle", () -> new SimpleParticleType(true));
public static final Supplier<SimpleParticleType> TRUE_EXCALIBUR_HIT_PARTICLE =
PARTICLE_TYPES.register("true_excalibur_hit_particle", () -> new SimpleParticleType(true));
public static final Supplier<SimpleParticleType> NIGHTS_EDGE_HIT_PARTICLE =
PARTICLE_TYPES.register("nights_edge_hit_particle", () -> new SimpleParticleType(true));
public static final Supplier<SimpleParticleType> TRUE_NIGHTS_EDGE_HIT_PARTICLE =
PARTICLE_TYPES.register("true_nights_edge_hit_particle", () -> new SimpleParticleType(true));
public static final Supplier<SimpleParticleType> BLOOD_BUTCHERED_PARTICLE =
PARTICLE_TYPES.register("blood_butchered_particle", () -> new SimpleParticleType(true));
} }
@@ -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<SimpleParticleType> {
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);
}
}
}
@@ -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<SimpleParticleType> {
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);
}
}
}
@@ -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<SimpleParticleType> {
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);
}
}
}
@@ -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;
}
}
@@ -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);
}
}
@@ -30,6 +30,7 @@
"entity.lzxnoneterraria.bee_summon": "Bee", "entity.lzxnoneterraria.bee_summon": "Bee",
"effect.lzxnoneterraria.confused": "Confused", "effect.lzxnoneterraria.confused": "Confused",
"effect.lzxnoneterraria.blood_butchered": "Blood Butchered",
"lzxnoneterraria.configuration.enchanted_sword_settings": "Enchanted Sword Settings", "lzxnoneterraria.configuration.enchanted_sword_settings": "Enchanted Sword Settings",
"lzxnoneterraria.configuration.enchanted_sword_damage": "Projectile Damage", "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": "Bee Damage",
"lzxnoneterraria.configuration.bee_keeper_bee_damage.tooltip": "Damage dealt by each bee", "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_settings": "Starfury Settings",
"lzxnoneterraria.configuration.starfury_damage": "Projectile Damage", "lzxnoneterraria.configuration.starfury_damage": "Projectile Damage",
"lzxnoneterraria.configuration.starfury_damage.tooltip": "Damage per hit", "lzxnoneterraria.configuration.starfury_damage.tooltip": "Damage per hit",
@@ -113,6 +122,44 @@
"lzxnoneterraria.configuration.meowmere_initial_speed": "Initial Speed", "lzxnoneterraria.configuration.meowmere_initial_speed": "Initial Speed",
"lzxnoneterraria.configuration.meowmere_initial_speed.tooltip": "Projectile 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_blade_settings": "Terra Blade Settings",
"lzxnoneterraria.configuration.terra_projectile_align_to_blade": "Projectile Align To Blade", "lzxnoneterraria.configuration.terra_projectile_align_to_blade": "Projectile Align To Blade",
"lzxnoneterraria.configuration.terra_projectile_align_to_blade.tooltip": "Whether projectile direction follows blade direction", "lzxnoneterraria.configuration.terra_projectile_align_to_blade.tooltip": "Whether projectile direction follows blade direction",
@@ -136,6 +183,10 @@
"lzxnoneterraria.configuration.zenith_settings": "Zenith Settings", "lzxnoneterraria.configuration.zenith_settings": "Zenith Settings",
"lzxnoneterraria.configuration.zenith_damage": "Projectile Damage", "lzxnoneterraria.configuration.zenith_damage": "Projectile Damage",
"lzxnoneterraria.configuration.zenith_damage.tooltip": "Damage per hit (applied as x~2x this value)", "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": "Max Range",
"lzxnoneterraria.configuration.zenith_max_range.tooltip": "Maximum projectile travel range", "lzxnoneterraria.configuration.zenith_max_range.tooltip": "Maximum projectile travel range",
"lzxnoneterraria.configuration.zenith_trail_b": "Orbit Semi-Axis (b)", "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": "Trail Opacity",
"lzxnoneterraria.configuration.zenith_trail_alpha.tooltip": "Trail rendering opacity", "lzxnoneterraria.configuration.zenith_trail_alpha.tooltip": "Trail rendering opacity",
"lzxnoneterraria.configuration.zenith_trail_max_length": "Trail Length", "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"
} }
@@ -30,6 +30,7 @@
"entity.lzxnoneterraria.bee_summon": "蜜蜂", "entity.lzxnoneterraria.bee_summon": "蜜蜂",
"effect.lzxnoneterraria.confused": "困惑", "effect.lzxnoneterraria.confused": "困惑",
"effect.lzxnoneterraria.blood_butchered": "血腥屠宰",
"lzxnoneterraria.configuration.enchanted_sword_settings": "附魔剑 设置", "lzxnoneterraria.configuration.enchanted_sword_settings": "附魔剑 设置",
"lzxnoneterraria.configuration.enchanted_sword_damage": "弹射伤害", "lzxnoneterraria.configuration.enchanted_sword_damage": "弹射伤害",
@@ -47,6 +48,14 @@
"lzxnoneterraria.configuration.bee_keeper_bee_damage": "蜜蜂伤害", "lzxnoneterraria.configuration.bee_keeper_bee_damage": "蜜蜂伤害",
"lzxnoneterraria.configuration.bee_keeper_bee_damage.tooltip": "每只蜜蜂的攻击伤害", "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_settings": "星怒 设置",
"lzxnoneterraria.configuration.starfury_damage": "弹射伤害", "lzxnoneterraria.configuration.starfury_damage": "弹射伤害",
"lzxnoneterraria.configuration.starfury_damage.tooltip": "每次命中伤害", "lzxnoneterraria.configuration.starfury_damage.tooltip": "每次命中伤害",
@@ -113,6 +122,44 @@
"lzxnoneterraria.configuration.meowmere_initial_speed": "弹射初速度", "lzxnoneterraria.configuration.meowmere_initial_speed": "弹射初速度",
"lzxnoneterraria.configuration.meowmere_initial_speed.tooltip": "弹射物初始速度", "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_blade_settings": "泰拉刃 设置",
"lzxnoneterraria.configuration.terra_projectile_align_to_blade": "弹射匹配刀光方向", "lzxnoneterraria.configuration.terra_projectile_align_to_blade": "弹射匹配刀光方向",
"lzxnoneterraria.configuration.terra_projectile_align_to_blade.tooltip": "弹射方向是否跟随刀光方向", "lzxnoneterraria.configuration.terra_projectile_align_to_blade.tooltip": "弹射方向是否跟随刀光方向",
@@ -136,6 +183,10 @@
"lzxnoneterraria.configuration.zenith_settings": "天顶剑 设置", "lzxnoneterraria.configuration.zenith_settings": "天顶剑 设置",
"lzxnoneterraria.configuration.zenith_damage": "弹射伤害", "lzxnoneterraria.configuration.zenith_damage": "弹射伤害",
"lzxnoneterraria.configuration.zenith_damage.tooltip": "每次命中伤害(实际为 x~2x 此值)", "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": "最大范围",
"lzxnoneterraria.configuration.zenith_max_range.tooltip": "弹射物最大飞行距离", "lzxnoneterraria.configuration.zenith_max_range.tooltip": "弹射物最大飞行距离",
"lzxnoneterraria.configuration.zenith_trail_b": "轨道半短轴 (b)", "lzxnoneterraria.configuration.zenith_trail_b": "轨道半短轴 (b)",
@@ -153,5 +204,35 @@
"lzxnoneterraria.configuration.zenith_trail_alpha": "尾迹透明度", "lzxnoneterraria.configuration.zenith_trail_alpha": "尾迹透明度",
"lzxnoneterraria.configuration.zenith_trail_alpha.tooltip": "尾迹渲染透明度", "lzxnoneterraria.configuration.zenith_trail_alpha.tooltip": "尾迹渲染透明度",
"lzxnoneterraria.configuration.zenith_trail_max_length": "尾迹长度", "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": "弹射物旋转速度"
} }
@@ -1,5 +1,5 @@
{ {
"parent": "minecraft:item/generated", "parent": "lzxnoneterraria:item/weapon3",
"textures": { "textures": {
"layer0": "lzxnoneterraria:item/blood_butcherer" "layer0": "lzxnoneterraria:item/blood_butcherer"
} }
@@ -1,5 +1,5 @@
{ {
"parent": "minecraft:item/generated", "parent": "lzxnoneterraria:item/weapon3",
"textures": { "textures": {
"layer0": "lzxnoneterraria:item/excalibur" "layer0": "lzxnoneterraria:item/excalibur"
} }
@@ -1,5 +1,5 @@
{ {
"parent": "minecraft:item/generated", "parent": "lzxnoneterraria:item/weapon2",
"textures": { "textures": {
"layer0": "lzxnoneterraria:item/lights_bane" "layer0": "lzxnoneterraria:item/lights_bane"
} }
@@ -1,5 +1,5 @@
{ {
"parent": "minecraft:item/generated", "parent": "lzxnoneterraria:item/weapon3",
"textures": { "textures": {
"layer0": "lzxnoneterraria:item/nights_edge" "layer0": "lzxnoneterraria:item/nights_edge"
} }
@@ -1,5 +1,5 @@
{ {
"parent": "minecraft:item/generated", "parent": "lzxnoneterraria:item/weapon3",
"textures": { "textures": {
"layer0": "lzxnoneterraria:item/true_excalibur" "layer0": "lzxnoneterraria:item/true_excalibur"
} }
@@ -1,5 +1,5 @@
{ {
"parent": "minecraft:item/generated", "parent": "lzxnoneterraria:item/weapon3",
"textures": { "textures": {
"layer0": "lzxnoneterraria:item/true_nights_edge" "layer0": "lzxnoneterraria:item/true_nights_edge"
} }
@@ -0,0 +1,5 @@
{
"textures": [
"lzxnoneterraria:blood_butchered_particle"
]
}
@@ -0,0 +1,5 @@
{
"textures": [
"lzxnoneterraria:excalibur_hit_particle"
]
}
@@ -0,0 +1,7 @@
{
"textures": [
"lzxnoneterraria:nights_edge_hit_particle0",
"lzxnoneterraria:nights_edge_hit_particle1",
"lzxnoneterraria:nights_edge_hit_particle2"
]
}
@@ -0,0 +1,5 @@
{
"textures": [
"lzxnoneterraria:true_excalibur_hit_particle"
]
}
@@ -0,0 +1,7 @@
{
"textures": [
"lzxnoneterraria:true_nights_edge_hit_particle0",
"lzxnoneterraria:true_nights_edge_hit_particle1",
"lzxnoneterraria:true_nights_edge_hit_particle2"
]
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 249 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 236 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 264 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 331 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 266 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 249 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 257 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 311 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 250 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 305 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 186 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 165 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 143 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 236 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 251 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 217 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 187 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 226 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 221 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 213 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 199 B

@@ -0,0 +1,3 @@
{
"parent": "bettercombat:claymore"
}
@@ -0,0 +1,3 @@
{
"parent": "bettercombat:claymore"
}
@@ -0,0 +1,3 @@
{
"parent": "bettercombat:sword"
}
@@ -0,0 +1,3 @@
{
"parent": "bettercombat:claymore"
}
@@ -0,0 +1,3 @@
{
"parent": "bettercombat:claymore"
}
@@ -0,0 +1,3 @@
{
"parent": "bettercombat:claymore"
}
@@ -0,0 +1,13 @@
{
"required": true,
"minVersion": "0.8",
"package": "com.lzxnone.terraria.mixin",
"compatibilityLevel": "JAVA_21",
"mixins": [
"ZenithRenderMixin"
],
"client": [],
"injectors": {
"defaultRequire": 1
}
}
@@ -98,6 +98,9 @@ Example mod description.
[modproperties."${mod_id}"."yumi:entrypoints"] [modproperties."${mod_id}"."yumi:entrypoints"]
"lambdynlights:initializer" = "com.lzxnone.terraria.dynamic_lights.MDynamicLightsInitializer" "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 # 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 # 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. # stop your mod loading on the server for example.