diff --git a/build.gradle b/build.gradle index 8df4661..4e201d5 100644 --- a/build.gradle +++ b/build.gradle @@ -27,7 +27,10 @@ sourceSets.main.resources { } repositories { - // Add here additional repositories if required by some of the dependencies below. + maven { + name = "Gegy" + url = "https://maven.gegy.dev" + } } base { @@ -117,10 +120,25 @@ configurations { runtimeClasspath.extendsFrom localRuntime } +def mappingsAttribute = Attribute.of("net.minecraft.mappings", String.class) + dependencies { implementation 'net.objecthunter:exp4j:0.4.8' jarJar('net.objecthunter:exp4j:0.4.8') additionalRuntimeClasspath 'net.objecthunter:exp4j:0.4.8' + attributesSchema { + attribute(mappingsAttribute) + } + compileOnly("dev.lambdaurora.lambdynamiclights:lambdynamiclights-api:4.8.10+1.21.1") { + attributes { + attribute(mappingsAttribute, "mojmap") + } + } + localRuntime("dev.lambdaurora.lambdynamiclights:lambdynamiclights-runtime:4.8.10+1.21.1") { + attributes { + attribute(mappingsAttribute, "mojmap") + } + } // Example optional mod dependency with JEI // The JEI API is declared for compile time use, while the full JEI artifact is used at runtime // compileOnly "mezz.jei:jei-${mc_version}-common-api:${jei_version}" diff --git a/gradle.properties b/gradle.properties index f1e4b38..e60018a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -32,7 +32,7 @@ mod_name=Lzxnone Terraria # The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default. mod_license=All Rights Reserved # The mod version. See https://semver.org/ -mod_version=1.1.0 +mod_version=1.2.0 # The group ID for the mod. It is only important when publishing as an artifact to a Maven repository. # This should match the base package used for the mod sources. # See https://maven.apache.org/guides/mini/guide-naming-conventions.html diff --git a/src/main/java/com/lzxnone/terraria/Config.java b/src/main/java/com/lzxnone/terraria/Config.java index 099d36c..2aac968 100644 --- a/src/main/java/com/lzxnone/terraria/Config.java +++ b/src/main/java/com/lzxnone/terraria/Config.java @@ -1,10 +1,86 @@ package com.lzxnone.terraria; - +import net.neoforged.api.distmarker.Dist; +import net.neoforged.bus.api.SubscribeEvent; +import net.neoforged.fml.common.EventBusSubscriber; +import net.neoforged.fml.event.config.ModConfigEvent; import net.neoforged.neoforge.common.ModConfigSpec; +@EventBusSubscriber(modid = LzxnoneTerraria.MODID, value = Dist.CLIENT) public class Config { - private static final ModConfigSpec.Builder BUILDER = new ModConfigSpec.Builder(); + public static final ModConfigSpec SPEC; - static final ModConfigSpec SPEC = BUILDER.build(); + public static final ModConfigSpec.DoubleValue ZENITH_DAMAGE; + public static final ModConfigSpec.DoubleValue ZENITH_MAX_RANGE; + public static final ModConfigSpec.DoubleValue ZENITH_TRAIL_B; + public static final ModConfigSpec.DoubleValue ZENITH_BOUNDING_BOX_SIZE; + public static final ModConfigSpec.IntValue ZENITH_CYCLE; + public static final ModConfigSpec.DoubleValue ZENITH_SCALE; + public static final ModConfigSpec.DoubleValue ZENITH_TRAIL_ALPHA; + public static final ModConfigSpec.IntValue ZENITH_TRAIL_MAX_LENGTH; + + public static double zenithDamage; + public static double zenithMaxRange; + public static double zenithTrailB; + public static double zenithBoundingBoxSize; + public static int zenithCycle; + public static double zenithScale; + public static double zenithTrailAlpha; + public static int zenithTrailMaxLength; + + static { + ModConfigSpec.Builder builder = new ModConfigSpec.Builder(); + + builder.push("zenith_settings"); + + ZENITH_DAMAGE = builder + .comment("弹射单次伤害x-2x") + .defineInRange("zenith_damage", 4.0, 1.0, 114514.0); + + ZENITH_MAX_RANGE = builder + .comment("最大范围(2a)") + .defineInRange("zenith_max_range", 64.0, 1.0, 1024.0); + + ZENITH_TRAIL_B = builder + .comment("椭圆轨道半短轴(b)") + .defineInRange("zenith_trail_b", 4.0, 0.1, 512.0); + + ZENITH_BOUNDING_BOX_SIZE = builder + .comment("弹射碰撞箱大小") + .defineInRange("zenith_bounding_box_size", 1.5, 0.1, 4.0); + + ZENITH_CYCLE = builder + .comment("弹射运动周期") + .defineInRange("zenith_cycle", 20, 10, 100); + + ZENITH_SCALE = builder + .comment("弹射大小倍数") + .defineInRange("zenith_scale", 2.0, 0.1, 10.0); + + ZENITH_TRAIL_ALPHA = builder + .comment("尾迹透明度") + .defineInRange("zenith_trail_alpha", 0.15, 0.0, 1.0); + + ZENITH_TRAIL_MAX_LENGTH = builder + .comment("尾迹长度") + .defineInRange("zenith_trail_max_length", 10, 0, 100); + + builder.pop(); + + SPEC = builder.build(); + } + + @SubscribeEvent + static void onLoad(final ModConfigEvent event) { + if(event.getConfig().getSpec() == SPEC) { + zenithDamage = ZENITH_DAMAGE.get(); + zenithMaxRange = ZENITH_MAX_RANGE.get(); + zenithTrailB = ZENITH_TRAIL_B.get(); + zenithBoundingBoxSize = ZENITH_BOUNDING_BOX_SIZE.get(); + zenithCycle = ZENITH_CYCLE.get(); + zenithScale = ZENITH_SCALE.get(); + zenithTrailAlpha = ZENITH_TRAIL_ALPHA.get(); + zenithTrailMaxLength = ZENITH_TRAIL_MAX_LENGTH.get(); + } + } } diff --git a/src/main/java/com/lzxnone/terraria/LzxnoneTerraria.java b/src/main/java/com/lzxnone/terraria/LzxnoneTerraria.java index 77bd358..20dba7a 100644 --- a/src/main/java/com/lzxnone/terraria/LzxnoneTerraria.java +++ b/src/main/java/com/lzxnone/terraria/LzxnoneTerraria.java @@ -8,7 +8,9 @@ import com.lzxnone.terraria.entity.summon.BeeSummon; import com.lzxnone.terraria.entity.summon.StaticSummon; import com.lzxnone.terraria.item.ModItems; import com.lzxnone.terraria.particle.ModParticles; +import net.minecraft.core.registries.Registries; import net.neoforged.neoforge.event.entity.EntityAttributeCreationEvent; +import net.neoforged.neoforge.registries.RegisterEvent; import org.slf4j.Logger; import com.mojang.logging.LogUtils; diff --git a/src/main/java/com/lzxnone/terraria/LzxnoneTerrariaClient.java b/src/main/java/com/lzxnone/terraria/LzxnoneTerrariaClient.java index 4d7f885..9e51cde 100644 --- a/src/main/java/com/lzxnone/terraria/LzxnoneTerrariaClient.java +++ b/src/main/java/com/lzxnone/terraria/LzxnoneTerrariaClient.java @@ -1,8 +1,11 @@ package com.lzxnone.terraria; import com.lzxnone.terraria.entity.ModEntities; +import com.lzxnone.terraria.entity.beam.SwordBeam; import com.lzxnone.terraria.entity.beam.SwordBeamRenderer; +import com.lzxnone.terraria.entity.projectile.StaticProjectile; import com.lzxnone.terraria.entity.projectile.StaticProjectileRenderer; +import com.lzxnone.terraria.entity.summon.StaticSummon; import com.lzxnone.terraria.entity.summon.StaticSummonRenderer; import com.lzxnone.terraria.particle.*; import net.minecraft.client.renderer.entity.BeeRenderer; @@ -56,5 +59,6 @@ public class LzxnoneTerrariaClient { modEventBus.addListener(RegisterParticleProvidersEvent.class, event -> { event.registerSpriteSet(ModParticles.TERRA_BEAM_HIT_PARTICLE.get(), TerraBeamHitParticle.Provider::new); }); + } } diff --git a/src/main/java/com/lzxnone/terraria/creative_mode_tab/ModCreativeModeTabs.java b/src/main/java/com/lzxnone/terraria/creative_mode_tab/ModCreativeModeTabs.java index 86c8af5..bc605cb 100644 --- a/src/main/java/com/lzxnone/terraria/creative_mode_tab/ModCreativeModeTabs.java +++ b/src/main/java/com/lzxnone/terraria/creative_mode_tab/ModCreativeModeTabs.java @@ -28,5 +28,6 @@ public class ModCreativeModeTabs { output.accept(ModItems.MEOWMERE.get()); output.accept(ModItems.TERRA_BLADE.get()); output.accept(ModItems.ZENITH.get()); + output.accept(ModItems.TRUE_COPPER_SHORTSWORD.get()); }).build()); } diff --git a/src/main/java/com/lzxnone/terraria/dynamic_lights/MDynamicLightsInitializer.java b/src/main/java/com/lzxnone/terraria/dynamic_lights/MDynamicLightsInitializer.java new file mode 100644 index 0000000..abeee8c --- /dev/null +++ b/src/main/java/com/lzxnone/terraria/dynamic_lights/MDynamicLightsInitializer.java @@ -0,0 +1,36 @@ +package com.lzxnone.terraria.dynamic_lights; + +import com.lzxnone.terraria.LzxnoneTerraria; +import com.lzxnone.terraria.entity.ModEntities; +import dev.lambdaurora.lambdynlights.api.DynamicLightsContext; +import dev.lambdaurora.lambdynlights.api.DynamicLightsInitializer; +import dev.lambdaurora.lambdynlights.api.entity.luminance.EntityLuminance; +import dev.lambdaurora.lambdynlights.api.entity.luminance.ItemDerivedEntityLuminance; +import dev.lambdaurora.lambdynlights.api.item.ItemLightSourceManager; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import org.jspecify.annotations.NonNull; + +import java.util.Optional; + +public class MDynamicLightsInitializer implements DynamicLightsInitializer { + public static final EntityLuminance.Type CONSTANT = EntityLuminance.Type.registerSimple( + ResourceLocation.fromNamespaceAndPath("lzxnoneterraria", "custom"), + MEntityLuminance.INSTANCE + ); + + @Override + public void onInitializeDynamicLights(@NonNull DynamicLightsContext context) { + context.entityLightSourceManager().onRegisterEvent().register(reg -> { + reg.register(ModEntities.STATIC_PROJECTILE.get(), MEntityLuminance.INSTANCE); + reg.register(ModEntities.STATIC_SUMMON.get(), MEntityLuminance.INSTANCE); + reg.register(ModEntities.SWORD_BEAM.get(), MEntityLuminance.INSTANCE); + }); + } + + @Override + @Deprecated + public void onInitializeDynamicLights(@NonNull ItemLightSourceManager itemLightSourceManager) {} +} diff --git a/src/main/java/com/lzxnone/terraria/dynamic_lights/MEntityLuminance.java b/src/main/java/com/lzxnone/terraria/dynamic_lights/MEntityLuminance.java new file mode 100644 index 0000000..7e8a9e8 --- /dev/null +++ b/src/main/java/com/lzxnone/terraria/dynamic_lights/MEntityLuminance.java @@ -0,0 +1,58 @@ +package com.lzxnone.terraria.dynamic_lights; + +import com.lzxnone.terraria.LzxnoneTerraria; +import com.lzxnone.terraria.entity.beam.SwordBeam; +import com.lzxnone.terraria.entity.beam.SwordBeamBehaviors; +import com.lzxnone.terraria.entity.projectile.StaticProjectile; +import com.lzxnone.terraria.entity.projectile.StaticProjectileBehaviors; +import com.lzxnone.terraria.entity.summon.StaticSummon; +import com.lzxnone.terraria.entity.summon.StaticSummonBehaviors; +import dev.lambdaurora.lambdynlights.api.entity.luminance.EntityLuminance; +import dev.lambdaurora.lambdynlights.api.item.ItemLightSourceManager; +import net.minecraft.world.entity.Entity; +import org.jetbrains.annotations.Range; +import org.jspecify.annotations.NonNull; + +public class MEntityLuminance implements EntityLuminance { + public static final MEntityLuminance INSTANCE = new MEntityLuminance(); + + private MEntityLuminance() {} + + @Override + public @NonNull Type type() { + return MDynamicLightsInitializer.CONSTANT; + } + + @Override + public @Range(from = 0, to = 15) int getLuminance(@NonNull ItemLightSourceManager itemLightSourceManager, @NonNull Entity entity) { + if(entity instanceof StaticProjectile projectile) { + switch(projectile.getEntityData().get(StaticProjectile.BEHAVIOR)) { + case StaticProjectileBehaviors.ENCHANTED_SWORD_BEAM, StaticProjectileBehaviors.STARFURY_STAR, StaticProjectileBehaviors.STAR_WRATH_STAR, StaticProjectileBehaviors.ZENITH_PROJECTILE -> { + return 15; + } + default -> { + return 0; + } + } + }else if(entity instanceof StaticSummon summon) { + switch(summon.getEntityData().get(StaticProjectile.BEHAVIOR)) { + case StaticSummonBehaviors.THE_HORSEMANS_BLADE_JACK, StaticSummonBehaviors.INFLUX_WAVER_BEAM, StaticSummonBehaviors.MEOWMERE_PROJECTILE, StaticSummonBehaviors.TERRA_BLADE_BEAM -> { + return 15; + } + default -> { + return 0; + } + } + }else if(entity instanceof SwordBeam beam) { + switch(beam.getEntityData().get(SwordBeam.BEHAVIOR)) { + case SwordBeamBehaviors.THE_HORSEMANS_BLADE, SwordBeamBehaviors.TERRA_BLADE -> { + return 15; + } + default -> { + return 0; + } + } + } + return 0; + } +} diff --git a/src/main/java/com/lzxnone/terraria/entity/EntityEmissiveRenderer.java b/src/main/java/com/lzxnone/terraria/entity/EntityEmissiveRenderer.java index a87616c..7fa6992 100644 --- a/src/main/java/com/lzxnone/terraria/entity/EntityEmissiveRenderer.java +++ b/src/main/java/com/lzxnone/terraria/entity/EntityEmissiveRenderer.java @@ -7,7 +7,9 @@ import com.lzxnone.terraria.entity.projectile.StaticProjectile; import com.lzxnone.terraria.entity.projectile.StaticProjectileBehaviors; import com.lzxnone.terraria.entity.summon.StaticSummon; import com.lzxnone.terraria.entity.summon.StaticSummonBehaviors; +import com.mojang.blaze3d.vertex.ByteBufferBuilder; import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.vertex.Tesselator; import net.minecraft.client.Camera; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.MultiBufferSource; @@ -28,42 +30,44 @@ public class EntityEmissiveRenderer { if(mc.level == null || mc.player == null) return; PoseStack poseStack = event.getPoseStack(); - Camera camera = event.getCamera(); - float partialTick = event.getPartialTick().getGameTimeDeltaPartialTick(true); - MultiBufferSource.BufferSource bufferSource = mc.renderBuffers().bufferSource(); - for(Entity entity : mc.level.entitiesForRendering()) { - double x = Mth.lerp(partialTick, entity.xo, entity.getX()); - double y = Mth.lerp(partialTick, entity.yo, entity.getY()); - double z = Mth.lerp(partialTick, entity.zo, entity.getZ()); - float entityYaw = Mth.lerp(partialTick, entity.yRotO, entity.getYRot()); + try(ByteBufferBuilder byteBuf = new ByteBufferBuilder(65536)) { + MultiBufferSource.BufferSource bufferSource = MultiBufferSource.immediate(byteBuf); + Camera camera = event.getCamera(); + float partialTick = event.getPartialTick().getGameTimeDeltaPartialTick(true); + for(Entity entity : mc.level.entitiesForRendering()) { + double x = Mth.lerp(partialTick, entity.xo, entity.getX()); + double y = Mth.lerp(partialTick, entity.yo, entity.getY()); + double z = Mth.lerp(partialTick, entity.zo, entity.getZ()); + float entityYaw = Mth.lerp(partialTick, entity.yRotO, entity.getYRot()); - double camX = x - camera.getPosition().x(); - double camY = y - camera.getPosition().y(); - double camZ = z - camera.getPosition().z(); + double camX = x - camera.getPosition().x(); + double camY = y - camera.getPosition().y(); + double camZ = z - camera.getPosition().z(); - if(entity instanceof StaticProjectile projectile && projectile.getEntityData().get(StaticProjectile.RENDER_MODE).equals("custom") && projectile.getEntityData().get(StaticProjectile.GLOW)) { - poseStack.pushPose(); - poseStack.translate(camX, camY, camZ); - StaticProjectileBehaviors.getBehavior(projectile.getEntityData().get(StaticProjectile.BEHAVIOR)) - .render(projectile, entityYaw, partialTick, poseStack, bufferSource, 15728880); + if(entity instanceof StaticProjectile projectile && projectile.getEntityData().get(StaticProjectile.RENDER_MODE).equals("custom") && projectile.getEntityData().get(StaticProjectile.GLOW)) { + poseStack.pushPose(); + poseStack.translate(camX, camY, camZ); + StaticProjectileBehaviors.getBehavior(projectile.getEntityData().get(StaticProjectile.BEHAVIOR)) + .render(projectile, entityYaw, partialTick, poseStack, bufferSource, 15728880); - poseStack.popPose(); - }else if(entity instanceof StaticSummon summon && summon.getEntityData().get(StaticSummon.RENDER_MODE).equals("custom") && summon.getEntityData().get(StaticSummon.GLOW)) { - poseStack.pushPose(); - poseStack.translate(camX, camY, camZ); - StaticSummonBehaviors.getBehavior(summon.getEntityData().get(StaticSummon.BEHAVIOR)) - .render(summon, entityYaw, partialTick, poseStack, bufferSource, 15728880); + poseStack.popPose(); + }else if(entity instanceof StaticSummon summon && summon.getEntityData().get(StaticSummon.RENDER_MODE).equals("custom") && summon.getEntityData().get(StaticSummon.GLOW)) { + poseStack.pushPose(); + poseStack.translate(camX, camY, camZ); + StaticSummonBehaviors.getBehavior(summon.getEntityData().get(StaticSummon.BEHAVIOR)) + .render(summon, entityYaw, partialTick, poseStack, bufferSource, 15728880); - poseStack.popPose(); - }else if(entity instanceof SwordBeam beam) { - poseStack.pushPose(); - poseStack.translate(camX, camY, camZ); - SwordBeamBehaviors.getBehavior(beam.getEntityData().get(SwordBeam.BEHAVIOR)) - .render(beam, entityYaw, partialTick, poseStack, bufferSource, 15728880); + poseStack.popPose(); + }else if(entity instanceof SwordBeam beam) { + poseStack.pushPose(); + poseStack.translate(camX, camY, camZ); + SwordBeamBehaviors.getBehavior(beam.getEntityData().get(SwordBeam.BEHAVIOR)) + .render(beam, entityYaw, partialTick, poseStack, bufferSource, 15728880); - poseStack.popPose(); + poseStack.popPose(); + } } + bufferSource.endBatch(); } - bufferSource.endBatch(); } } diff --git a/src/main/java/com/lzxnone/terraria/entity/beam/ISwordBeamBehavior.java b/src/main/java/com/lzxnone/terraria/entity/beam/ISwordBeamBehavior.java index 7431093..c0984dd 100644 --- a/src/main/java/com/lzxnone/terraria/entity/beam/ISwordBeamBehavior.java +++ b/src/main/java/com/lzxnone/terraria/entity/beam/ISwordBeamBehavior.java @@ -2,6 +2,7 @@ package com.lzxnone.terraria.entity.beam; import com.lzxnone.terraria.LzxnoneTerraria; import com.lzxnone.terraria.entity.ModEntities; +import com.lzxnone.terraria.entity.summon.StaticSummon; import com.lzxnone.terraria.utils.MathUtil; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; @@ -46,16 +47,11 @@ public interface ISwordBeamBehavior { int lifetime = Math.max(1, beam.getEntityData().get(SwordBeam.LIFETIME)); float progress = (age + partialTick) / (float) lifetime; - if(progress > 1.0f) progress = 1.0f; + if(progress > 1.0f) return; Vector3f[] dirs = MathUtil.computeCoordinateSystem(beam.getOwner()); - - VertexConsumer vertexConsumer0 = bufferSource.getBuffer(RenderType.entityTranslucentEmissive(RES0)); - VertexConsumer vertexConsumer1 = bufferSource.getBuffer(RenderType.entityTranslucentEmissive(RES0)); - VertexConsumer vertexConsumer2 = bufferSource.getBuffer(RenderType.entityTranslucentEmissive(RES0)); - VertexConsumer vertexConsumer3 = bufferSource.getBuffer(RenderType.entityTranslucentEmissive(RES3)); - VertexConsumer vertexConsumer4 = bufferSource.getBuffer(RenderType.entityTranslucentEmissive(RES4)); - VertexConsumer vertexConsumer5 = bufferSource.getBuffer(RenderType.entityTranslucentEmissive(RES5)); + 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); @@ -70,90 +66,100 @@ public interface ISwordBeamBehavior { }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(); - this.applyTranslate(poseStack, dirs, progress - 0.1f * (1.0f - progress), SwordBeam.DIST); - this.applyRotate(poseStack, dirs, progress - 0.1f * (1.0f - progress)); + this.applyTranslate(poseStack, dirs[0], dirs[2], progress - 0.1f * (1.0f - progress), SwordBeam.DIST); + this.applyRotate(poseStack, dirs[0], dirs[1], progress - 0.1f * (1.0f - progress), rotate); renderQuad(poseStack.last().pose(), vertexConsumer0, color0.x(), color0.y(), color0.z(), alpha, halfWidth, halfHeight, 0f, 0, -0.01f); poseStack.popPose(); //右边 poseStack.pushPose(); - this.applyTranslate(poseStack, dirs, progress + 0.1f, SwordBeam.DIST); - this.applyRotate(poseStack, dirs, progress + 0.05f); - renderQuad(poseStack.last().pose(), vertexConsumer2, + this.applyTranslate(poseStack, dirs[0], dirs[2], progress + 0.1f, SwordBeam.DIST); + this.applyRotate(poseStack, dirs[0], dirs[1], progress + 0.05f, rotate); + renderQuad(poseStack.last().pose(), vertexConsumer0, color2.x(), color2.y(), color2.z(), alpha, halfWidth, halfHeight, 0f, 0, -0.02f); poseStack.popPose(); //中间 poseStack.pushPose(); - this.applyTranslate(poseStack, dirs, progress, SwordBeam.DIST); - this.applyRotate(poseStack, dirs, progress); - renderQuad(poseStack.last().pose(), vertexConsumer1, + this.applyTranslate(poseStack, dirs[0], dirs[2], progress, SwordBeam.DIST); + this.applyRotate(poseStack, dirs[0], dirs[1], progress, 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(); - this.applyTranslate(poseStack, dirs, progress, SwordBeam.DIST / 1.5f); - this.applyRotate(poseStack, dirs, progress); + this.applyTranslate(poseStack, dirs[0], dirs[2], progress + 0.05f, SwordBeam.DIST / 1.5f); + this.applyRotate(poseStack, dirs[0], dirs[1], progress, rotate); poseStack.scale(0.5f, 0.5f, 0.5f); - renderQuad(poseStack.last().pose(), vertexConsumer3, + renderQuad(poseStack.last().pose(), vertexConsumer1, color3.x(), color3.y(), color3.z(), alpha, halfWidth, halfHeight, 0f, 0f, 0.02f); poseStack.popPose(); poseStack.pushPose(); - this.applyTranslate(poseStack, dirs, progress, SwordBeam.DIST / 1.25f); - this.applyRotate(poseStack, dirs, progress); + this.applyTranslate(poseStack, dirs[0], dirs[2], progress + 0.05f, SwordBeam.DIST / 1.25f); + this.applyRotate(poseStack, dirs[0], dirs[1], progress, rotate); poseStack.scale(0.75f, 0.75f, 0.75f); - renderQuad(poseStack.last().pose(), vertexConsumer3, + renderQuad(poseStack.last().pose(), vertexConsumer1, color3.x(), color3.y(), color3.z(), alpha, halfWidth, halfHeight, 0f, 0f, 0.02f); poseStack.popPose(); poseStack.pushPose(); - this.applyTranslate(poseStack, dirs, progress, SwordBeam.DIST * 1.15f); - this.applyRotate(poseStack, dirs, progress); + this.applyTranslate(poseStack, dirs[0], dirs[2], progress, SwordBeam.DIST * 1.15f); + this.applyRotate(poseStack, dirs[0], dirs[1], progress, rotate); poseStack.scale(0.95f, 0.95f, 0.95f); - renderQuad(poseStack.last().pose(), vertexConsumer3, + 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(RES4)); + //边缘高光 poseStack.pushPose(); - this.applyTranslate(poseStack, dirs, progress + 0.05f, SwordBeam.DIST * 1.15f); - this.applyRotate(poseStack, dirs, progress + 0.05f); + this.applyTranslate(poseStack, dirs[0], dirs[2], progress + 0.05f, SwordBeam.DIST * 1.15f); + this.applyRotate(poseStack, dirs[0], dirs[1], progress + 0.05f, rotate); poseStack.scale(1.0f, 1.0f, 1.0f); for(int i = 0;i < 20;i++) { - renderQuad(poseStack.last().pose(), vertexConsumer4, + 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(); - this.applyTranslate(poseStack, dirs, progress + 0.25f, SwordBeam.DIST * 2.25f); - this.applyRotate(poseStack, dirs, progress + 0.25f); + this.applyTranslate(poseStack, dirs[0], dirs[2], progress + 0.25f, SwordBeam.DIST * 2.25f); + this.applyRotate(poseStack, dirs[0], dirs[1], progress + 0.25f, rotate); 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(), vertexConsumer5, + renderQuad(poseStack.last().pose(), vertexConsumer3, color1.x(), color1.y(), color1.z(), alpha, 32 * SwordBeam.SCALE, 32 * SwordBeam.SCALE, 0f, 0f, 0.03f); } poseStack.popPose(); } - default void applyRotate(PoseStack poseStack, Vector3f[] dirs, float progress) { - Vector3f dir = dirs[0]; - Vector3f up = dirs[1]; - + 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 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])); @@ -163,10 +169,7 @@ public interface ISwordBeamBehavior { poseStack.mulPose(Axis.ZP.rotationDegrees(-90.0F)); } - default void applyTranslate(PoseStack poseStack, Vector3f[] dirs, float progress, float dist) { - Vector3f dir = dirs[0]; - Vector3f right = dirs[2]; - + 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( @@ -204,7 +207,8 @@ public interface ISwordBeamBehavior { Vec3 pos = new Vec3(entity.getX(), entity.getY() + entity.getBbHeight() / 2, entity.getZ()); beam.setPos(pos); if(beamData.contains("behavior")) beam.getEntityData().set(SwordBeam.BEHAVIOR, beamData.getString("behavior")); - + if(beamData.contains("rotate")) beam.getEntityData().set(SwordBeam.ROTATE, beamData.getInt("rotate")); + if(beamData.contains("right")) beam.getEntityData().set(SwordBeam.RIGHT, beamData.getBoolean("right")); if(beamData.contains("color0R") && beamData.contains("color0G") && beamData.contains("color0B")) { beam.getEntityData().set(SwordBeam.COLOR0, new Vector3f(beamData.getFloat("color0R"), beamData.getFloat("color0G"), beamData.getFloat("color0B"))); } diff --git a/src/main/java/com/lzxnone/terraria/entity/beam/SwordBeam.java b/src/main/java/com/lzxnone/terraria/entity/beam/SwordBeam.java index 2340efe..d32f570 100644 --- a/src/main/java/com/lzxnone/terraria/entity/beam/SwordBeam.java +++ b/src/main/java/com/lzxnone/terraria/entity/beam/SwordBeam.java @@ -1,7 +1,5 @@ package com.lzxnone.terraria.entity.beam; -import com.lzxnone.terraria.LzxnoneTerraria; -import com.lzxnone.terraria.entity.projectile.StaticProjectile; import com.lzxnone.terraria.utils.FilterUtil; import com.lzxnone.terraria.utils.MathUtil; import net.minecraft.nbt.CompoundTag; @@ -11,7 +9,6 @@ import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityType; -import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.level.ClipContext; import net.minecraft.world.level.Level; import net.minecraft.world.phys.*; @@ -31,6 +28,8 @@ public class SwordBeam extends Entity { public static final EntityDataAccessor BEHAVIOR = SynchedEntityData.defineId(SwordBeam.class, EntityDataSerializers.STRING); + public static final EntityDataAccessor ROTATE = + SynchedEntityData.defineId(SwordBeam.class, EntityDataSerializers.INT); public static final EntityDataAccessor COLOR0 = SynchedEntityData.defineId(SwordBeam.class, EntityDataSerializers.VECTOR3); public static final EntityDataAccessor COLOR1 = @@ -39,6 +38,8 @@ public class SwordBeam extends Entity { SynchedEntityData.defineId(SwordBeam.class, EntityDataSerializers.VECTOR3); public static final EntityDataAccessor COLOR3 = SynchedEntityData.defineId(SwordBeam.class, EntityDataSerializers.VECTOR3); + public static final EntityDataAccessor RIGHT = + SynchedEntityData.defineId(SwordBeam.class, EntityDataSerializers.BOOLEAN); public static final EntityDataAccessor AGE = SynchedEntityData.defineId(SwordBeam.class, EntityDataSerializers.INT); public static final EntityDataAccessor LIFETIME = @@ -111,9 +112,11 @@ public class SwordBeam extends Entity { public void checkCollision() { Entity owner = getOwner(); float progress = (float) this.entityData.get(AGE) / (float) this.entityData.get(LIFETIME); - if(progress > 1.0f) progress = 1.0f; + if(progress > 1.0f) return; + if(this.entityData.get(RIGHT)) progress = 1.0f - progress; this.dirs = MathUtil.computeCoordinateSystem(owner); + this.dirs = MathUtil.rotateCoordinateSystem(dirs[0], dirs[2], this.entityData.get(ROTATE)); Vector3f dir = dirs[0]; Vector3f up = dirs[1]; Vector3f right = dirs[2]; @@ -132,8 +135,20 @@ public class SwordBeam extends Entity { this.currentPosition = new Vec3(centerX, centerY, centerZ); + float[] xyRot = MathUtil.computeXYRot(dirs[0], dirs[1]); + float angle = (float) ((0.5 - progress) * Math.PI); - float xzLen = (float) Math.sqrt(current.x() * current.x() + current.z() * current.z()); + Quaternionf rotation = new Quaternionf() + .fromAxisAngleRad(dir, (float) Math.toRadians(Math.abs(dirs[0].y) > 0.999 ? 0 : this.entityData.get(ROTATE))) + .rotateY((float) Math.toRadians(-xyRot[1])) + .rotateX((float) Math.toRadians(xyRot[0])) + .rotateX((float) Math.toRadians(-90.0)) + .rotateZ((float) Math.toRadians(-90.0)); + Quaternionf rotation2 = new Quaternionf() + .fromAxisAngleRad(up, angle); + + + /*float xzLen = (float) Math.sqrt(current.x() * current.x() + current.z() * current.z()); float pitch = (float) (Math.atan2(-current.y(), xzLen) * (180.0 / Math.PI)); float yaw = (float) (Math.atan2(-current.x(), current.z()) * (180.0 / Math.PI)); @@ -142,11 +157,11 @@ public class SwordBeam extends Entity { .rotateY((float) Math.toRadians(-yaw)) .rotateX((float) Math.toRadians(pitch)) .rotateX((float) Math.toRadians(-90.0)) - .rotateZ((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); + Vector3f axisX = new Vector3f(1, 0, 0).rotate(rotation).rotate(rotation2); + Vector3f axisY = new Vector3f(0, 1, 0).rotate(rotation).rotate(rotation2); + Vector3f axisZ = new Vector3f(0, 0, 1).rotate(rotation).rotate(rotation2); float extX = HALF_WIDTH * SCALE * Math.abs(axisX.x()) + HALF_HEIGHT * SCALE * Math.abs(axisY.x()) + HALF_THICKNESS * SCALE * Math.abs(axisZ.x()); float extY = HALF_WIDTH * SCALE * Math.abs(axisX.y()) + HALF_HEIGHT * SCALE * Math.abs(axisY.y()) + HALF_THICKNESS * SCALE * Math.abs(axisZ.y()); @@ -184,6 +199,8 @@ public class SwordBeam extends Entity { @Override protected void defineSynchedData(SynchedEntityData.Builder builder) { builder.define(BEHAVIOR, "default"); + builder.define(ROTATE, 0); + builder.define(RIGHT, false); builder.define(COLOR0, new Vector3f(1.0f, 1.0f, 1.0f)); builder.define(COLOR1, new Vector3f(1.0f, 1.0f, 1.0f)); builder.define(COLOR2, new Vector3f(1.0f, 1.0f, 1.0f)); @@ -197,6 +214,8 @@ public class SwordBeam extends Entity { @Override protected void addAdditionalSaveData(CompoundTag tag) { tag.putString("behavior", this.entityData.get(BEHAVIOR)); + tag.putInt("rotate", this.entityData.get(ROTATE)); + tag.putBoolean("right", this.entityData.get(RIGHT)); Vector3f c0 = this.entityData.get(COLOR0); tag.putFloat("color0R", c0.x); tag.putFloat("color0G", c0.y); @@ -222,6 +241,8 @@ public class SwordBeam extends Entity { @Override protected void readAdditionalSaveData(CompoundTag tag) { if(tag.contains("behavior")) this.entityData.set(BEHAVIOR, tag.getString("behavior")); + if(tag.contains("rotate")) this.entityData.set(ROTATE, tag.getInt("rotate")); + if(tag.contains("right")) this.entityData.set(RIGHT, tag.getBoolean("right")); if(tag.contains("color0R")) { this.entityData.set(COLOR0, new Vector3f( tag.getFloat("color0R"), tag.getFloat("color0G"), tag.getFloat("color0B") diff --git a/src/main/java/com/lzxnone/terraria/entity/beam/SwordBeamRenderer.java b/src/main/java/com/lzxnone/terraria/entity/beam/SwordBeamRenderer.java index 545f68c..511881d 100644 --- a/src/main/java/com/lzxnone/terraria/entity/beam/SwordBeamRenderer.java +++ b/src/main/java/com/lzxnone/terraria/entity/beam/SwordBeamRenderer.java @@ -15,11 +15,12 @@ public class SwordBeamRenderer extends EntityRenderer { @Override public void render(Entity entity, float entityYaw, float partialTick, PoseStack poseStack, MultiBufferSource bufferSource, int packedLight) { + if(!(entity instanceof SwordBeam)) return; super.render(entity, entityYaw, partialTick, poseStack, bufferSource, packedLight); } @Override public ResourceLocation getTextureLocation(Entity entity) { - return ResourceLocation.parse("lzxnoneterraria:textures/item/terra_beam.png"); + return ResourceLocation.parse("lzxnoneterraria:textures/vfx/terra_beam0.png"); } } diff --git a/src/main/java/com/lzxnone/terraria/entity/projectile/StaticProjectileRenderer.java b/src/main/java/com/lzxnone/terraria/entity/projectile/StaticProjectileRenderer.java index 1988536..7d5d692 100644 --- a/src/main/java/com/lzxnone/terraria/entity/projectile/StaticProjectileRenderer.java +++ b/src/main/java/com/lzxnone/terraria/entity/projectile/StaticProjectileRenderer.java @@ -4,6 +4,7 @@ import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.entity.EntityRenderer; import net.minecraft.client.renderer.entity.EntityRendererProvider; +import net.minecraft.core.BlockPos; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.Entity; import net.minecraft.world.inventory.InventoryMenu; diff --git a/src/main/java/com/lzxnone/terraria/item/ModItems.java b/src/main/java/com/lzxnone/terraria/item/ModItems.java index e7c44de..8dc2d7c 100644 --- a/src/main/java/com/lzxnone/terraria/item/ModItems.java +++ b/src/main/java/com/lzxnone/terraria/item/ModItems.java @@ -31,6 +31,7 @@ public class ModItems { public static final DeferredItem TRUE_NIGHTS_EDGE = ITEMS.register("true_nights_edge", TrueNightsEdge::new); public static final DeferredItem EXCALIBUR = ITEMS.register("excalibur", Excalibur::new); public static final DeferredItem TRUE_EXCALIBUR = ITEMS.register("true_excalibur", TrueExcalibur::new); + public static final DeferredItem TRUE_COPPER_SHORTSWORD = ITEMS.register("true_copper_shortsword", TrueCopperShortsword::new); //弹射物 public static final DeferredItem ENCHANTED_SWORD_BEAM = ITEMS.register("enchanted_sword_beam", EnchantedSwordBeam::new); diff --git a/src/main/java/com/lzxnone/terraria/item/weapon/melee/TerraBlade.java b/src/main/java/com/lzxnone/terraria/item/weapon/melee/TerraBlade.java index e3de417..596562f 100644 --- a/src/main/java/com/lzxnone/terraria/item/weapon/melee/TerraBlade.java +++ b/src/main/java/com/lzxnone/terraria/item/weapon/melee/TerraBlade.java @@ -25,6 +25,8 @@ import net.minecraft.client.renderer.texture.OverlayTexture; import net.minecraft.nbt.CompoundTag; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResultHolder; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EquipmentSlotGroup; import net.minecraft.world.entity.LivingEntity; @@ -37,6 +39,7 @@ import net.minecraft.world.item.SwordItem; import net.minecraft.world.item.Tiers; import net.minecraft.world.item.component.ItemAttributeModifiers; import net.minecraft.world.level.ClipContext; +import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.phys.*; import net.neoforged.neoforge.event.entity.player.AttackEntityEvent; @@ -55,7 +58,7 @@ public class TerraBlade extends SwordItem { new AttributeModifier(ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "base_attack_damage"), 10, AttributeModifier.Operation.ADD_VALUE), EquipmentSlotGroup.MAINHAND) .add(Attributes.ATTACK_SPEED, - new AttributeModifier(ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "base_attack_speed"), -2.4, AttributeModifier.Operation.ADD_VALUE), + new AttributeModifier(ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "base_attack_speed"), -1.0, AttributeModifier.Operation.ADD_VALUE), EquipmentSlotGroup.MAINHAND) .build() )); @@ -123,6 +126,7 @@ public class TerraBlade extends SwordItem { @Override public void generate(Entity entity, CompoundTag beamData) { + //beamData.putBoolean("right", entity.getRandom().nextInt(2) == 0); ISwordBeamBehavior.super.generate(entity, beamData); if(entity instanceof Player player) summon(player); } @@ -151,11 +155,6 @@ public class TerraBlade extends SwordItem { PoseStack poseStack, MultiBufferSource bufferSource, int packedLight) { if(!(entity instanceof StaticSummon summon)) return; - VertexConsumer vertexConsumer0 = bufferSource.getBuffer(RenderType.entityTranslucentEmissive(RES0)); - VertexConsumer vertexConsumer1 = bufferSource.getBuffer(RenderType.entityTranslucentEmissive(RES1)); - VertexConsumer vertexConsumer2 = bufferSource.getBuffer(RenderType.entityTranslucentEmissive(RES2)); - VertexConsumer vertexConsumer3 = bufferSource.getBuffer(RenderType.entityTranslucentEmissive(RES3)); - float halfWidth = SwordBeam.HALF_WIDTH * SwordBeam.SCALE; float halfHeight = SwordBeam.HALF_HEIGHT * SwordBeam.SCALE; @@ -188,16 +187,19 @@ public class TerraBlade extends SwordItem { if(customData.contains("rightZ")) right.z = customData.getFloat("rightZ"); Vector3f[] dirs = new Vector3f[]{dir, up, right}; + double rotate = summon.getEntityData().get(StaticSummon.RZP); poseStack.pushPose(); float size = 1.0f - 0.25f * progress; poseStack.scale(size, size, size); + VertexConsumer vertexConsumer0 = bufferSource.getBuffer(RenderType.entityTranslucentEmissive(RES0)); + //左边 poseStack.pushPose(); this.applyTranslate(poseStack, dirs[0], dirs[2], 90 - 18 * (1.0f - progress), SwordBeam.DIST); - this.applyRotate(summon, poseStack, dirs[0], dirs[1], 18 * (1.0f - progress)); + this.applyRotate(poseStack, dirs[0], dirs[1], 18 * (1.0f - progress), rotate); renderQuad(poseStack.last().pose(), vertexConsumer0, COLOR0.x(), COLOR0.y(), COLOR0.z(), alpha, halfWidth, halfHeight, 0f, 0, -0.01f); poseStack.popPose(); @@ -206,24 +208,25 @@ public class TerraBlade extends SwordItem { //中间 poseStack.pushPose(); this.applyTranslate(poseStack, dirs[0], dirs[2], 90, SwordBeam.DIST); - this.applyRotate(summon, poseStack, dirs[0], dirs[1], 0); + this.applyRotate(poseStack, dirs[0], dirs[1], 0, rotate); renderQuad(poseStack.last().pose(), vertexConsumer0, COLOR1.x(), COLOR1.y(), COLOR1.z(), alpha, halfWidth, halfHeight, 0f, 0f, 0f); poseStack.popPose(); //右边 - poseStack.pushPose(); this.applyTranslate(poseStack, dirs[0], dirs[2], 108, SwordBeam.DIST); - this.applyRotate(summon, poseStack, dirs[0], dirs[1], -9 * (1.0f - progress)); + this.applyRotate(poseStack, dirs[0], dirs[1], -9 * (1.0f - progress), rotate); renderQuad(poseStack.last().pose(), vertexConsumer0, COLOR2.x(), COLOR2.y(), COLOR2.z(), alpha, halfWidth, halfHeight, 0f, 0, 0.01f); poseStack.popPose(); + VertexConsumer vertexConsumer1 = bufferSource.getBuffer(RenderType.entityTranslucentEmissive(RES1)); + //三线 poseStack.pushPose(); this.applyTranslate(poseStack, dirs[0], dirs[2], 90, SwordBeam.DIST / 1.5f); - this.applyRotate(summon, poseStack, dirs[0], dirs[1], 0); + this.applyRotate(poseStack, dirs[0], dirs[1], 0, rotate); poseStack.scale(0.5f, 0.5f, 0.5f); renderQuad(poseStack.last().pose(), vertexConsumer1, 1.0f, 1.0f, 1.0f, alpha, halfWidth, halfHeight, 0f, 0f, 0.02f); @@ -231,7 +234,7 @@ public class TerraBlade extends SwordItem { poseStack.pushPose(); this.applyTranslate(poseStack, dirs[0], dirs[2], 90, SwordBeam.DIST / 1.25f); - this.applyRotate(summon, poseStack, dirs[0], dirs[1], 0); + this.applyRotate(poseStack, dirs[0], dirs[1], 0, rotate); poseStack.scale(0.75f, 0.75f, 0.75f); renderQuad(poseStack.last().pose(), vertexConsumer1, 1.0f, 1.0f, 1.0f, alpha, halfWidth, halfHeight, 0f, 0f, 0.02f); @@ -239,16 +242,18 @@ public class TerraBlade extends SwordItem { poseStack.pushPose(); this.applyTranslate(poseStack, dirs[0], dirs[2], 90, SwordBeam.DIST * 1.15f); - this.applyRotate(summon, poseStack, dirs[0], dirs[1], 0); + this.applyRotate(poseStack, dirs[0], dirs[1], 0, rotate); poseStack.scale(0.95f, 0.95f, 0.95f); 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(); this.applyTranslate(poseStack, dirs[0], dirs[2], 100, SwordBeam.DIST * 1.15f); - this.applyRotate(summon, poseStack, dirs[0], dirs[1], 0); + this.applyRotate(poseStack, dirs[0], dirs[1], 0, rotate); poseStack.scale(1.0f, 1.0f, 1.0f); for(int i = 0;i < 5;i++) { renderQuad(poseStack.last().pose(), vertexConsumer2, @@ -266,16 +271,18 @@ public class TerraBlade extends SwordItem { sparkleAlpha = (progress - FADE_IN) / (FADE_OUT - FADE_IN); } + VertexConsumer vertexConsumer3 = bufferSource.getBuffer(RenderType.entityTranslucentEmissive(RES3)); + //闪烁(外层) poseStack.pushPose(); for(int k = 0;k < 2;k++) { poseStack.pushPose(); if(k == 0) { this.applyTranslate(poseStack, dirs[0], dirs[2], 90 - 60.0 * progress, SwordBeam.DIST * 2f); - this.applyRotate(summon, poseStack, dirs[0], dirs[1], 60 * progress); + this.applyRotate(poseStack, dirs[0], dirs[1], 60 * progress, rotate); }else { this.applyTranslate(poseStack, dirs[0], dirs[2], 90 + 60.0 * progress, SwordBeam.DIST * 2f + 0.5f * progress); - this.applyRotate(summon, poseStack, dirs[0], dirs[1], -60 * progress); + this.applyRotate(poseStack, dirs[0], dirs[1], -60 * progress, rotate); } for(int j = 0; j < 2; j++) { poseStack.pushPose(); @@ -298,10 +305,10 @@ public class TerraBlade extends SwordItem { poseStack.pushPose(); if(k == 0) { this.applyTranslate(poseStack, dirs[0], dirs[2], 90 - 30.0 * progress, SwordBeam.DIST * 2f); - this.applyRotate(summon, poseStack, dirs[0], dirs[1], 30 * progress); + this.applyRotate(poseStack, dirs[0], dirs[1], 30 * progress, rotate); }else { this.applyTranslate(poseStack, dirs[0], dirs[2], 90 + 30.0 * progress, SwordBeam.DIST * 2.1f); - this.applyRotate(summon, poseStack, dirs[0], dirs[1], -30 * progress); + this.applyRotate(poseStack, dirs[0], dirs[1], -30 * progress, rotate); } for(int j = 0; j < 2; j++) { poseStack.pushPose(); @@ -321,7 +328,7 @@ public class TerraBlade extends SwordItem { //闪烁(内层) poseStack.pushPose(); this.applyTranslate(poseStack, dirs[0], dirs[2], 90, SwordBeam.DIST * 2f); - this.applyRotate(summon, poseStack, dirs[0], dirs[1], 0); + this.applyRotate(poseStack, dirs[0], dirs[1], 0, rotate); for(int j = 0; j < 2; j++) { poseStack.pushPose(); if(j == 0) poseStack.mulPose(Axis.ZP.rotationDegrees(0.0F)); @@ -335,15 +342,16 @@ public class TerraBlade extends SwordItem { } poseStack.popPose(); - poseStack.popPose(); } - public void applyRotate(StaticSummon summon, PoseStack poseStack, Vector3f dir, Vector3f up, double angle) { + public void applyRotate(PoseStack poseStack, Vector3f dir, Vector3f up, double angle, double rotate) { Quaternionf rotation = new Quaternionf() - .fromAxisAngleRad(up, (float) Math.toRadians(angle)) - .fromAxisAngleRad(dir, (float) Math.toRadians(Math.abs(dir.y) > 0.999 ? 0 : summon.getEntityData().get(StaticSummon.RZP))); + .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])); @@ -558,4 +566,16 @@ public class TerraBlade extends SwordItem { event.setCanceled(true); } }; + + @Override + public InteractionResultHolder use(Level level, Player player, InteractionHand hand) { + ItemStack stack = player.getItemInHand(hand); + if(!level.isClientSide()) { + SwordBeamBehaviors.getBehavior("terra_blade").generate(player, BEAM_DATA); + }else { + SoundUtil.playClientSound(player, ModSounds.WAVE.get()); + SoundUtil.playClientSound(player, ModSounds.WAVE3.get()); + } + return InteractionResultHolder.sidedSuccess(stack, level.isClientSide()); + } } diff --git a/src/main/java/com/lzxnone/terraria/item/weapon/melee/TheHorsemansBlade.java b/src/main/java/com/lzxnone/terraria/item/weapon/melee/TheHorsemansBlade.java index a7ef93a..6344ea5 100644 --- a/src/main/java/com/lzxnone/terraria/item/weapon/melee/TheHorsemansBlade.java +++ b/src/main/java/com/lzxnone/terraria/item/weapon/melee/TheHorsemansBlade.java @@ -22,6 +22,8 @@ import net.minecraft.nbt.CompoundTag; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResultHolder; import net.minecraft.world.damagesource.DamageTypes; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EquipmentSlotGroup; @@ -36,6 +38,7 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.SwordItem; import net.minecraft.world.item.Tiers; import net.minecraft.world.item.component.ItemAttributeModifiers; +import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.EntityHitResult; @@ -151,6 +154,13 @@ public class TheHorsemansBlade extends SwordItem { } } } + + @Override + public void generate(Entity entity, CompoundTag beamData) { + beamData.putInt("rotate", (int) (45 * (Math.random() * 2 - 1))); + //beamData.putBoolean("right", entity.getRandom().nextInt(2) == 0); + ISwordBeamBehavior.super.generate(entity, beamData); + } }; public static final IItemWaveBehavior ITEM_WAVE_BEHAVIOR = new IItemWaveBehavior() { @@ -180,6 +190,17 @@ public class TheHorsemansBlade extends SwordItem { } }; + @Override + public InteractionResultHolder use(Level level, Player player, InteractionHand hand) { + ItemStack stack = player.getItemInHand(hand); + if(!level.isClientSide()) { + SwordBeamBehaviors.getBehavior("the_horsemans_blade").generate(player, BEAM_DATA); + }else { + SoundUtil.playClientSound(player, ModSounds.WAVE.get()); + } + return InteractionResultHolder.sidedSuccess(stack, level.isClientSide()); + } + public static final IStaticSummonBehavior SUMMON_BEHAVIOR = new IStaticSummonBehavior() { public static final double SPEED = 0.5; public static final float DAMAGE = 15.0f; diff --git a/src/main/java/com/lzxnone/terraria/item/weapon/melee/TrueCopperShortsword.java b/src/main/java/com/lzxnone/terraria/item/weapon/melee/TrueCopperShortsword.java new file mode 100644 index 0000000..361a439 --- /dev/null +++ b/src/main/java/com/lzxnone/terraria/item/weapon/melee/TrueCopperShortsword.java @@ -0,0 +1,165 @@ +package com.lzxnone.terraria.item.weapon.melee; + +import com.lzxnone.terraria.Config; +import com.lzxnone.terraria.LzxnoneTerraria; +import com.lzxnone.terraria.ModSounds; +import com.lzxnone.terraria.entity.ModEntities; +import com.lzxnone.terraria.entity.projectile.StaticProjectile; +import com.lzxnone.terraria.entity.projectile.StaticProjectileBehaviors; +import com.lzxnone.terraria.item.ModItems; +import com.lzxnone.terraria.utils.MathUtil; +import com.lzxnone.terraria.utils.SoundUtil; +import net.minecraft.core.component.DataComponents; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResultHolder; +import net.minecraft.world.entity.EquipmentSlotGroup; +import net.minecraft.world.entity.ai.attributes.AttributeModifier; +import net.minecraft.world.entity.ai.attributes.Attributes; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.*; +import net.minecraft.world.item.component.CustomData; +import net.minecraft.world.item.component.ItemAttributeModifiers; +import net.minecraft.world.level.Level; +import net.minecraft.world.phys.Vec3; +import org.joml.Vector3f; + +public class TrueCopperShortsword extends SwordItem { + public TrueCopperShortsword() { + super(Tiers.NETHERITE, new Item.Properties().attributes(ItemAttributeModifiers.builder() + .add(Attributes.ATTACK_DAMAGE, + new AttributeModifier(ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "base_attack_damage"), 20, AttributeModifier.Operation.ADD_VALUE), + EquipmentSlotGroup.MAINHAND) + .add(Attributes.ATTACK_SPEED, + new AttributeModifier(ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "base_attack_speed"), -2.4, AttributeModifier.Operation.ADD_VALUE), + EquipmentSlotGroup.MAINHAND) + .build() + )); + } + + public static void summon(Player player) { + Vector3f[] dirs = MathUtil.computeCoordinateSystem(player); + int randomAngle = (int) ((Math.random() * 2 - 1) * 30); + dirs = MathUtil.rotateCoordinateSystem(dirs[0], dirs[2], randomAngle); + + Vec3 pos = (player.getBoundingBox().getCenter()).add(MathUtil.toVec3(dirs[0]).scale(-2)); + Vec3 targetPos = MathUtil.getCrosshairPos(player, player.level(), Config.zenithMaxRange); + double dist = targetPos.subtract(pos).length(); + int cycle = (int) Math.max(10, dist / Config.zenithMaxRange * Config.zenithCycle); + double a = Math.max(dist / 2, 2); + double b = Math.min(Math.random() * Config.zenithTrailB + Config.zenithTrailB, a / 2); + double w = Math.PI * 2 / (double) cycle; + if(player.getRandom().nextInt(2) == 0) w = -w; + + for(int i = 0;i < 3;i++) { + StaticProjectile projectile = new StaticProjectile(ModEntities.STATIC_PROJECTILE.get(), player.level()); + projectile.setOwner(player); + + projectile.setPos(pos); + projectile.getEntityData().set(StaticProjectile.BEHAVIOR, StaticProjectileBehaviors.ZENITH_PROJECTILE); + projectile.getEntityData().set(StaticProjectile.RENDER_MODE, "custom"); + projectile.getEntityData().set(StaticProjectile.ITEM, new ItemStack(ModItems.COPPER_SHORTSWORD.get())); + projectile.getEntityData().set(StaticProjectile.ORIGIN, pos.toVector3f()); + projectile.getEntityData().set(StaticProjectile.DIRECTION, dirs[0]); + projectile.getEntityData().set(StaticProjectile.UP, dirs[1]); + projectile.getEntityData().set(StaticProjectile.RIGHT, dirs[2]); + projectile.getEntityData().set(StaticProjectile.COLOR_R, 0.922f); + projectile.getEntityData().set(StaticProjectile.COLOR_G, 0.651f); + projectile.getEntityData().set(StaticProjectile.COLOR_B, 0.529f); + projectile.getEntityData().set(StaticProjectile.RXP, -90); + projectile.getEntityData().set(StaticProjectile.RZP, -135); + projectile.getEntityData().set(StaticProjectile.GLOW, true); + + CompoundTag customData = new CompoundTag(); + customData.putDouble("a", a); + customData.putDouble("b", b); + customData.putDouble("w", w); + customData.putInt("angle", randomAngle); + if(i == 0) { + projectile.getEntityData().set(StaticProjectile.COLOR_A, 1.0f); + projectile.getEntityData().set(StaticProjectile.SCALE_X, (float) Config.zenithScale); + projectile.getEntityData().set(StaticProjectile.SCALE_Y, (float) Config.zenithScale); + projectile.getEntityData().set(StaticProjectile.LIFETIME, cycle); + projectile.getEntityData().set(StaticProjectile.EXPRESSION_X, String.format("%.3f*cos(%.3ft-1.571)", b, w)); + projectile.getEntityData().set(StaticProjectile.EXPRESSION_Z, String.format("%.3f*sin(%.3ft-1.571)+%.3f", a, w, a)); + customData.putInt("start", 0); + }else if(i == 1) { + projectile.getEntityData().set(StaticProjectile.COLOR_A, 0.75f); + projectile.getEntityData().set(StaticProjectile.SCALE_X, (float) Config.zenithScale * 0.75f); + projectile.getEntityData().set(StaticProjectile.SCALE_Y, (float) Config.zenithScale * 0.75f); + projectile.getEntityData().set(StaticProjectile.LIFETIME, (int) (cycle * 1.25)); + if(w > 0) { + projectile.getEntityData().set(StaticProjectile.EXPRESSION_X, String.format("%.3f*cos(%.3ft-3.142)", b, w)); + projectile.getEntityData().set(StaticProjectile.EXPRESSION_Z, String.format("%.3f*sin(%.3ft-3.142)+%.3f", a, w, a)); + }else { + projectile.getEntityData().set(StaticProjectile.EXPRESSION_X, String.format("%.3f*cos(%.3ft)", b, w)); + projectile.getEntityData().set(StaticProjectile.EXPRESSION_Z, String.format("%.3f*sin(%.3ft)+%.3f", a, w, a)); + } + customData.putInt("start", (int) (cycle * 0.25)); + }else if(i == 2) { + projectile.getEntityData().set(StaticProjectile.COLOR_A, 0.5f); + projectile.getEntityData().set(StaticProjectile.SCALE_X, (float) Config.zenithScale * 0.5f); + projectile.getEntityData().set(StaticProjectile.SCALE_Y, (float) Config.zenithScale * 0.5f); + projectile.getEntityData().set(StaticProjectile.LIFETIME, (int) (cycle * 1.5)); + if(w > 0) { + projectile.getEntityData().set(StaticProjectile.EXPRESSION_X, String.format("%.3f*cos(%.3ft-4.713)", b, w)); + projectile.getEntityData().set(StaticProjectile.EXPRESSION_Z, String.format("%.3f*sin(%.3ft-4.713)+%.3f", a, w, a)); + }else { + projectile.getEntityData().set(StaticProjectile.EXPRESSION_X, String.format("%.3f*cos(%.3ft+1.571)", b, w)); + projectile.getEntityData().set(StaticProjectile.EXPRESSION_Z, String.format("%.3f*sin(%.3ft+1.571)+%.3f", a, w, a)); + } + customData.putInt("start", (int) (cycle * 0.5)); + } + customData.putInt("idx", i); + projectile.getEntityData().set(StaticProjectile.CUSTOM_DATA, customData); + + float[] xyRot = MathUtil.computeXYRot(dirs[0], dirs[1]); + projectile.setXRot(xyRot[0]); + projectile.setYRot(xyRot[1]); + player.level().addFreshEntity(projectile); + } + } + + @Override + public InteractionResultHolder use(Level level, Player player, InteractionHand hand) { + ItemStack stack = player.getItemInHand(hand); + + if(!level.isClientSide()) { + CustomData.update(DataComponents.CUSTOM_DATA, stack, + tag -> tag.putInt("attackCount", 3)); + }else { + SoundUtil.playClientSound(player, ModSounds.WAVE.get()); + } + + player.getCooldowns().addCooldown(stack.getItem(), 3); + return InteractionResultHolder.sidedSuccess(stack, level.isClientSide()); + } + + @Override + public void inventoryTick(ItemStack stack, Level level, net.minecraft.world.entity.Entity entity, int slotId, boolean isSelected) { + super.inventoryTick(stack, level, entity, slotId, isSelected); + if(entity instanceof Player player) { + if(isSelected) { + if(player.tickCount % 3 == 0) { + int count = stack.getOrDefault(DataComponents.CUSTOM_DATA, CustomData.EMPTY) + .copyTag().getInt("attackCount"); + if(count > 0) { + summon(player); + CustomData.update(DataComponents.CUSTOM_DATA, stack, + tag -> tag.putInt("attackCount", count - 1)); + } + } + }else { + int count = stack.getOrDefault(DataComponents.CUSTOM_DATA, CustomData.EMPTY) + .copyTag().getInt("attackCount"); + if(count > 0) { + CustomData.update(DataComponents.CUSTOM_DATA, stack, + tag -> tag.putInt("attackCount", 0)); + } + } + } + } +} + + diff --git a/src/main/java/com/lzxnone/terraria/item/weapon/melee/Zenith.java b/src/main/java/com/lzxnone/terraria/item/weapon/melee/Zenith.java index 9276990..4500202 100644 --- a/src/main/java/com/lzxnone/terraria/item/weapon/melee/Zenith.java +++ b/src/main/java/com/lzxnone/terraria/item/weapon/melee/Zenith.java @@ -1,5 +1,6 @@ package com.lzxnone.terraria.item.weapon.melee; +import com.lzxnone.terraria.Config; import com.lzxnone.terraria.LzxnoneTerraria; import com.lzxnone.terraria.ModSounds; import com.lzxnone.terraria.entity.ModEntities; @@ -112,10 +113,6 @@ public class Zenith extends SwordItem { public static final ResourceLocation RES0 = ResourceLocation.parse("lzxnoneterraria:textures/vfx/sword_trail.png"); public static final ResourceLocation RES1 = ResourceLocation.parse("lzxnoneterraria:textures/vfx/beam_sparkle.png"); - public static final double RANGE = 64; - public static final int CYCLE = 30; - public static final double BOUNDING_BOX = 1.5; - public static final int MAX_LENGTH = 10; public static final IStaticProjectileBehavior PROJECTILE_BEHAVIOR = new IStaticProjectileBehavior() { @Override @@ -125,7 +122,10 @@ public class Zenith extends SwordItem { if(stack.isEmpty()) return; CompoundTag customData = proj.getEntityData().get(StaticProjectile.CUSTOM_DATA); - if(!customData.contains("a") || !customData.contains("w") || !customData.contains("angle")) return; + if(!customData.contains("a") || !customData.contains("w") || !customData.contains("angle") || !customData.contains("start") || !customData.contains("idx")) return; + int start = customData.getInt("start"); + if(proj.getEntityData().get(StaticProjectile.AGE) <= start) return; + int idx = customData.getInt("idx"); Vec3 dir = MathUtil.toVec3(proj.getEntityData().get(StaticProjectile.DIRECTION)).normalize(); Vec3 up = MathUtil.toVec3(proj.getEntityData().get(StaticProjectile.UP)).normalize(); @@ -134,7 +134,7 @@ public class Zenith extends SwordItem { Quaternionf rotationDir = new Quaternionf() .fromAxisAngleRad(dir.toVector3f(), (float) Math.toRadians(customData.getInt("angle"))); Quaternionf rotationUp1 = new Quaternionf() - .fromAxisAngleRad(up.toVector3f(), (float) -(customData.getDouble("w") * (proj.getEntityData().get(StaticProjectile.AGE) + partialTick))); + .fromAxisAngleRad(up.toVector3f(), (float) -(customData.getDouble("w") * (proj.getEntityData().get(StaticProjectile.AGE) - start + partialTick))); Quaternionf rotationUp2 = new Quaternionf() .fromAxisAngleRad(up.toVector3f(), (float) Math.PI); @@ -148,9 +148,9 @@ public class Zenith extends SwordItem { poseStack.mulPose(rotationDir); poseStack.mulPose(Axis.YP.rotationDegrees(-xyRot[1])); poseStack.mulPose(Axis.XP.rotationDegrees(xyRot[0])); - poseStack.mulPose(Axis.XP.rotationDegrees(proj.getEntityData().get(StaticProjectile.RXP) + proj.getEntityData().get(StaticProjectile.RXPS) * (proj.getEntityData().get(StaticProjectile.AGE) + partialTick))); - poseStack.mulPose(Axis.YP.rotationDegrees(proj.getEntityData().get(StaticProjectile.RYP) + proj.getEntityData().get(StaticProjectile.RYPS) * (proj.getEntityData().get(StaticProjectile.AGE) + partialTick))); - poseStack.mulPose(Axis.ZP.rotationDegrees(proj.getEntityData().get(StaticProjectile.RZP) + proj.getEntityData().get(StaticProjectile.RZPS) * (proj.getEntityData().get(StaticProjectile.AGE) + partialTick))); + poseStack.mulPose(Axis.XP.rotationDegrees(proj.getEntityData().get(StaticProjectile.RXP))); + poseStack.mulPose(Axis.YP.rotationDegrees(proj.getEntityData().get(StaticProjectile.RYP))); + poseStack.mulPose(Axis.ZP.rotationDegrees(proj.getEntityData().get(StaticProjectile.RZP))); //缩放 poseStack.scale( @@ -168,9 +168,9 @@ public class Zenith extends SwordItem { renderType -> { VertexConsumer vertexConsumer = bufferSource.getBuffer(renderType); return new TintedVertexConsumer(vertexConsumer, - proj.getEntityData().get(StaticProjectile.COLOR_R), - proj.getEntityData().get(StaticProjectile.COLOR_G), - proj.getEntityData().get(StaticProjectile.COLOR_B), + 1.0f, + 1.0f, + 1.0f, proj.getEntityData().get(StaticProjectile.COLOR_A)); }, entity.level(), @@ -189,6 +189,9 @@ public class Zenith extends SwordItem { proj.getEntityData().get(StaticProjectile.COLOR_G), proj.getEntityData().get(StaticProjectile.COLOR_B) ); + float mainAlpha = (float) Config.zenithTrailAlpha; + if(idx == 1) mainAlpha = mainAlpha * 0.5f; + if(idx == 2) mainAlpha = mainAlpha * 0.25f; //尾迹 int quadCount = proj.trailPositions.size() / 2 - 1; @@ -219,7 +222,7 @@ public class Zenith extends SwordItem { float radio2 = (float) (i + 1) / quadCount; vertexConsumer0.addVertex(matrix, (float) x1, (float) y1, (float) z1) - .setColor(color.x, color.y, color.z, 1).setUv(radio1, 0.0f) + .setColor(color.x, color.y, color.z, mainAlpha).setUv(radio1, 0.0f) .setOverlay(OverlayTexture.NO_OVERLAY).setLight(LightTexture.FULL_BRIGHT).setNormal(0, 1, 0); vertexConsumer0.addVertex(matrix, (float) x2, (float) y2, (float) z2) .setColor(color.x, color.y, color.z, 0).setUv(radio1, 1.0f) @@ -228,22 +231,23 @@ public class Zenith extends SwordItem { .setColor(color.x, color.y, color.z, 0).setUv(radio2, 1.0f) .setOverlay(OverlayTexture.NO_OVERLAY).setLight(LightTexture.FULL_BRIGHT).setNormal(0, 1, 0); vertexConsumer0.addVertex(matrix, (float) x4, (float) y4, (float) z4) - .setColor(color.x, color.y, color.z, 1).setUv(radio2, 0.0f) + .setColor(color.x, color.y, color.z, mainAlpha).setUv(radio2, 0.0f) .setOverlay(OverlayTexture.NO_OVERLAY).setLight(LightTexture.FULL_BRIGHT).setNormal(0, 1, 0); } } //闪烁 + if(idx != 0) return; float halfWidth = 32 * 0.05f; float halfHeight = 32 * 0.05f; - float radio = (float) proj.getEntityData().get(StaticProjectile.AGE) / (float) proj.getEntityData().get(StaticProjectile.LIFETIME); + float radio = (float) (proj.getEntityData().get(StaticProjectile.AGE) - start) / (float) proj.getEntityData().get(StaticProjectile.LIFETIME); float alpha; if(radio > 0.25f && radio < 0.4f) { alpha = (radio - 0.25f) / 0.15f; - }else if(radio > 0.4f && radio < 0.6f) { + }else if(radio >= 0.4f && radio < 0.6f) { alpha = 1.0f; - }else if(radio > 0.6f && radio < 0.75f) { + }else if(radio >= 0.6f && radio < 0.75f) { alpha = 1.0f - (radio - 0.6f) / 0.15f; }else { alpha = 0; @@ -254,7 +258,7 @@ public class Zenith extends SwordItem { poseStack.pushPose(); Vector3f tempRight = right.toVector3f(); - double rad = customData.getDouble("w") * (proj.getEntityData().get(StaticProjectile.AGE) + partialTick); + double rad = customData.getDouble("w") * (proj.getEntityData().get(StaticProjectile.AGE) - start + partialTick); Vector3f swordTipDir = tempRight.rotate(new Quaternionf().fromAxisAngleRad(up.toVector3f(), (float) (Math.PI / 2 - rad))).normalize(); Vec3 trans = MathUtil.toVec3(swordTipDir).scale(1.25); @@ -289,16 +293,23 @@ public class Zenith extends SwordItem { if(projectile.getOwner() == null) return; CompoundTag customData = projectile.getEntityData().get(StaticProjectile.CUSTOM_DATA); - if(!customData.contains("w") || !customData.contains("angle")) return; + if(!customData.contains("w") || !customData.contains("angle") || !customData.contains("start")) return; - float lifeRadio = (float) projectile.getEntityData().get(StaticProjectile.AGE) / (float) projectile.getEntityData().get(StaticProjectile.LIFETIME); + int start = customData.getInt("start"); + if(projectile.getEntityData().get(StaticProjectile.AGE) < start) { + Vec3 currentPos = (projectile.getOwner().getBoundingBox().getCenter()).add(MathUtil.toVec3(projectile.getEntityData().get(StaticProjectile.DIRECTION).normalize()).scale(-2)); + projectile.getEntityData().set(StaticProjectile.ORIGIN, currentPos.toVector3f()); + return; + } + + float lifeRadio = (float) (projectile.getEntityData().get(StaticProjectile.AGE) - start) / (float) projectile.getEntityData().get(StaticProjectile.LIFETIME); Vector3f originalRight = projectile.getEntityData().get(StaticProjectile.RIGHT).normalize(); Vector3f tempRight = new Vector3f(originalRight); Vector3f originalDir = projectile.getEntityData().get(StaticProjectile.DIRECTION).normalize(); Vector3f tempDir = new Vector3f(originalDir); Vector3f up = projectile.getEntityData().get(StaticProjectile.UP).normalize(); - double rad = customData.getDouble("w") * projectile.getEntityData().get(StaticProjectile.AGE); + double rad = customData.getDouble("w") * (projectile.getEntityData().get(StaticProjectile.AGE) - start); Quaternionf rotation = new Quaternionf() .fromAxisAngleRad(up, (float) (Math.PI / 2 - rad)); @@ -308,11 +319,11 @@ public class Zenith extends SwordItem { projectile.trailPositions.addFirst(projectile.position().add(right.scale(-1.2))); projectile.trailPositions.addFirst(projectile.position().add(right.scale(1.5))); - while(projectile.trailPositions.size() > MAX_LENGTH) projectile.trailPositions.removeLast(); + while(projectile.trailPositions.size() > Config.zenithTrailMaxLength) projectile.trailPositions.removeLast(); projectile.setBoundingBox(new AABB( - projectile.getX() - BOUNDING_BOX, projectile.getY() - BOUNDING_BOX, projectile.getZ() - BOUNDING_BOX, - projectile.getX() + BOUNDING_BOX, projectile.getY() + BOUNDING_BOX, projectile.getZ() + BOUNDING_BOX + projectile.getX() - Config.zenithBoundingBoxSize, projectile.getY() - Config.zenithBoundingBoxSize, projectile.getZ() - Config.zenithBoundingBoxSize, + projectile.getX() + Config.zenithBoundingBoxSize, projectile.getY() + Config.zenithBoundingBoxSize, projectile.getZ() + Config.zenithBoundingBoxSize )); if(!projectile.level().isClientSide()) { @@ -323,7 +334,7 @@ public class Zenith extends SwordItem { ); for(LivingEntity target : targets) this.onHitEntity(projectile, new EntityHitResult(target, target.position())); }else { - if(lifeRadio > 0.1f && lifeRadio < 0.9f && projectile.getRandom().nextInt(2) == 0) { + if(lifeRadio > 0.1f && lifeRadio < 0.9f && projectile.getRandom().nextInt(5) == 0) { Vector3f color = new Vector3f( projectile.getEntityData().get(StaticProjectile.COLOR_R), projectile.getEntityData().get(StaticProjectile.COLOR_G), @@ -349,7 +360,7 @@ public class Zenith extends SwordItem { if(!projectile.level().isClientSide()) { Entity target = result.getEntity(); if(projectile.getOwner() instanceof Player player && target instanceof LivingEntity livingEntity && FilterUtil.createLivingTargetFilter(projectile, projectile.getOwner()).test(livingEntity)) { - if(target.hurt(projectile.damageSources().playerAttack(player), 20.f)) { + if(target.hurt(projectile.damageSources().playerAttack(player), (float) (Config.zenithDamage + Math.random() * Config.zenithDamage))) { target.invulnerableTime = 2; } } @@ -359,54 +370,87 @@ public class Zenith extends SwordItem { public static void summon(Player player, boolean isFirst) { Vector3f[] dirs = MathUtil.computeCoordinateSystem(player); - int randomAngle = (int) ((Math.random() * 2 - 1) * 80); + int randomAngle = (int) ((Math.random() * 2 - 1) * 30); dirs = MathUtil.rotateCoordinateSystem(dirs[0], dirs[2], randomAngle); Vec3 pos = (player.getBoundingBox().getCenter()).add(MathUtil.toVec3(dirs[0]).scale(-2)); - Vec3 targetPos = MathUtil.getCrosshairPos(player, player.level(), RANGE); + Vec3 targetPos = MathUtil.getCrosshairPos(player, player.level(), Config.zenithMaxRange); double dist = targetPos.subtract(pos).length(); - int cycle = (int) Math.max(10, dist / RANGE * CYCLE); - double a = Math.max(dist / 2 + 1, 2); - double b = Math.min(Math.random() * 2 + 2, a / 2); + int cycle = (int) Math.max(10, dist / Config.zenithMaxRange * Config.zenithCycle); + double a = Math.max(dist / 2, 2); + double b = Math.min(Math.random() * Config.zenithTrailB + Config.zenithTrailB, a / 2); double w = Math.PI * 2 / (double) cycle; if(player.getRandom().nextInt(2) == 0) w = -w; int randomIndex = isFirst ? getWeapons().length - 1 : player.getRandom().nextInt(getWeapons().length); - StaticProjectile projectile = new StaticProjectile(ModEntities.STATIC_PROJECTILE.get(), player.level()); - projectile.setOwner(player); + for(int i = 0;i < 3;i++) { + StaticProjectile projectile = new StaticProjectile(ModEntities.STATIC_PROJECTILE.get(), player.level()); + projectile.setOwner(player); - projectile.setPos(pos); - projectile.getEntityData().set(StaticProjectile.BEHAVIOR, StaticProjectileBehaviors.ZENITH_PROJECTILE); - projectile.getEntityData().set(StaticProjectile.RENDER_MODE, "custom"); - projectile.getEntityData().set(StaticProjectile.ITEM, getWeapons()[randomIndex]); - projectile.getEntityData().set(StaticProjectile.ORIGIN, pos.toVector3f()); - projectile.getEntityData().set(StaticProjectile.DIRECTION, dirs[0]); - projectile.getEntityData().set(StaticProjectile.UP, dirs[1]); - projectile.getEntityData().set(StaticProjectile.RIGHT, dirs[2]); - projectile.getEntityData().set(StaticProjectile.COLOR_R, COLORS[randomIndex].x); - projectile.getEntityData().set(StaticProjectile.COLOR_G, COLORS[randomIndex].y); - projectile.getEntityData().set(StaticProjectile.COLOR_B, COLORS[randomIndex].z); - projectile.getEntityData().set(StaticProjectile.SCALE_X, 2.0f); - projectile.getEntityData().set(StaticProjectile.SCALE_Y, 2.0f); - projectile.getEntityData().set(StaticProjectile.RXP, -90); - projectile.getEntityData().set(StaticProjectile.RZP, -135); - projectile.getEntityData().set(StaticProjectile.EXPRESSION_X, String.format("%.3f*cos(%.3ft-1.571)", b, w)); - projectile.getEntityData().set(StaticProjectile.EXPRESSION_Z, String.format("%.3f*sin(%.3ft-1.571)+%.3f", a, w, a)); - projectile.getEntityData().set(StaticProjectile.LIFETIME, cycle); - projectile.getEntityData().set(StaticProjectile.GLOW, true); + projectile.setPos(pos); + projectile.getEntityData().set(StaticProjectile.BEHAVIOR, StaticProjectileBehaviors.ZENITH_PROJECTILE); + projectile.getEntityData().set(StaticProjectile.RENDER_MODE, "custom"); + projectile.getEntityData().set(StaticProjectile.ITEM, getWeapons()[randomIndex]); + projectile.getEntityData().set(StaticProjectile.ORIGIN, pos.toVector3f()); + projectile.getEntityData().set(StaticProjectile.DIRECTION, dirs[0]); + projectile.getEntityData().set(StaticProjectile.UP, dirs[1]); + projectile.getEntityData().set(StaticProjectile.RIGHT, dirs[2]); + projectile.getEntityData().set(StaticProjectile.COLOR_R, COLORS[randomIndex].x); + projectile.getEntityData().set(StaticProjectile.COLOR_G, COLORS[randomIndex].y); + projectile.getEntityData().set(StaticProjectile.COLOR_B, COLORS[randomIndex].z); + projectile.getEntityData().set(StaticProjectile.RXP, -90); + projectile.getEntityData().set(StaticProjectile.RZP, -135); + projectile.getEntityData().set(StaticProjectile.GLOW, true); - CompoundTag customData = new CompoundTag(); - customData.putDouble("a", a); - customData.putDouble("b", b); - customData.putDouble("w", w); - customData.putInt("angle", randomAngle); - projectile.getEntityData().set(StaticProjectile.CUSTOM_DATA, customData); + CompoundTag customData = new CompoundTag(); + customData.putDouble("a", a); + customData.putDouble("b", b); + customData.putDouble("w", w); + customData.putInt("angle", randomAngle); + if(i == 0) { + projectile.getEntityData().set(StaticProjectile.COLOR_A, 1.0f); + projectile.getEntityData().set(StaticProjectile.SCALE_X, (float) Config.zenithScale); + projectile.getEntityData().set(StaticProjectile.SCALE_Y, (float) Config.zenithScale); + projectile.getEntityData().set(StaticProjectile.LIFETIME, cycle); + projectile.getEntityData().set(StaticProjectile.EXPRESSION_X, String.format("%.3f*cos(%.3ft-1.571)", b, w)); + projectile.getEntityData().set(StaticProjectile.EXPRESSION_Z, String.format("%.3f*sin(%.3ft-1.571)+%.3f", a, w, a)); + customData.putInt("start", 0); + }else if(i == 1) { + projectile.getEntityData().set(StaticProjectile.COLOR_A, 0.75f); + projectile.getEntityData().set(StaticProjectile.SCALE_X, (float) Config.zenithScale * 0.75f); + projectile.getEntityData().set(StaticProjectile.SCALE_Y, (float) Config.zenithScale * 0.75f); + projectile.getEntityData().set(StaticProjectile.LIFETIME, (int) (cycle * 1.25)); + if(w > 0) { + projectile.getEntityData().set(StaticProjectile.EXPRESSION_X, String.format("%.3f*cos(%.3ft-3.142)", b, w)); + projectile.getEntityData().set(StaticProjectile.EXPRESSION_Z, String.format("%.3f*sin(%.3ft-3.142)+%.3f", a, w, a)); + }else { + projectile.getEntityData().set(StaticProjectile.EXPRESSION_X, String.format("%.3f*cos(%.3ft)", b, w)); + projectile.getEntityData().set(StaticProjectile.EXPRESSION_Z, String.format("%.3f*sin(%.3ft)+%.3f", a, w, a)); + } + customData.putInt("start", (int) (cycle * 0.25)); + }else if(i == 2) { + projectile.getEntityData().set(StaticProjectile.COLOR_A, 0.5f); + projectile.getEntityData().set(StaticProjectile.SCALE_X, (float) Config.zenithScale * 0.5f); + projectile.getEntityData().set(StaticProjectile.SCALE_Y, (float) Config.zenithScale * 0.5f); + projectile.getEntityData().set(StaticProjectile.LIFETIME, (int) (cycle * 1.5)); + if(w > 0) { + projectile.getEntityData().set(StaticProjectile.EXPRESSION_X, String.format("%.3f*cos(%.3ft-4.713)", b, w)); + projectile.getEntityData().set(StaticProjectile.EXPRESSION_Z, String.format("%.3f*sin(%.3ft-4.713)+%.3f", a, w, a)); + }else { + projectile.getEntityData().set(StaticProjectile.EXPRESSION_X, String.format("%.3f*cos(%.3ft+1.571)", b, w)); + projectile.getEntityData().set(StaticProjectile.EXPRESSION_Z, String.format("%.3f*sin(%.3ft+1.571)+%.3f", a, w, a)); + } + customData.putInt("start", (int) (cycle * 0.5)); + } + customData.putInt("idx", i); + projectile.getEntityData().set(StaticProjectile.CUSTOM_DATA, customData); - float[] xyRot = MathUtil.computeXYRot(dirs[0], dirs[1]); - projectile.setXRot(xyRot[0]); - projectile.setYRot(xyRot[1]); - player.level().addFreshEntity(projectile); + float[] xyRot = MathUtil.computeXYRot(dirs[0], dirs[1]); + projectile.setXRot(xyRot[0]); + projectile.setYRot(xyRot[1]); + player.level().addFreshEntity(projectile); + } } @Override diff --git a/src/main/java/com/lzxnone/terraria/particle/ZenithTrailParticle.java b/src/main/java/com/lzxnone/terraria/particle/ZenithTrailParticle.java index a58545c..19b5776 100644 --- a/src/main/java/com/lzxnone/terraria/particle/ZenithTrailParticle.java +++ b/src/main/java/com/lzxnone/terraria/particle/ZenithTrailParticle.java @@ -70,7 +70,7 @@ public class ZenithTrailParticle extends TextureSheetParticle { float lifeRatio = (float) this.age / (float) this.lifetime; this.quadSize = this.baseSize * (1.0F - lifeRatio); - this.alpha = 1.0F - lifeRatio; + this.alpha = (1.0F - lifeRatio) * 0.5f; } @Override diff --git a/src/main/resources/assets/lzxnoneterraria/lang/en_us.json b/src/main/resources/assets/lzxnoneterraria/lang/en_us.json index 5a9961f..11aaaee 100644 --- a/src/main/resources/assets/lzxnoneterraria/lang/en_us.json +++ b/src/main/resources/assets/lzxnoneterraria/lang/en_us.json @@ -23,10 +23,29 @@ "item.lzxnoneterraria.true_nights_edge": "True Night's Edge", "item.lzxnoneterraria.excalibur": "Excalibur", "item.lzxnoneterraria.true_excalibur": "True Excalibur", + "item.lzxnoneterraria.true_copper_shortsword": "True Copper Shortsword", "entity.lzxnoneterraria.static_projectile": "Projectile", "entity.lzxnoneterraria.static_summon": "Summon", "entity.lzxnoneterraria.bee_summon": "Bee", - "effect.lzxnoneterraria.confused": "Confused" + "effect.lzxnoneterraria.confused": "Confused", + + "lzxnoneterraria.configuration.zenith_settings": "Zenith Settings", + "lzxnoneterraria.configuration.zenith_damage": "Projectile Damage", + "lzxnoneterraria.configuration.zenith_damage.tooltip": "Damage per hit (applied as x~2x this value)", + "lzxnoneterraria.configuration.zenith_max_range": "Max 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.tooltip": "Elliptical orbit semi-minor axis (b)", + "lzxnoneterraria.configuration.zenith_bounding_box_size": "Hitbox Size", + "lzxnoneterraria.configuration.zenith_bounding_box_size.tooltip": "Projectile collision hitbox size", + "lzxnoneterraria.configuration.zenith_cycle": "Cycle Duration", + "lzxnoneterraria.configuration.zenith_cycle.tooltip": "Projectile movement cycle duration", + "lzxnoneterraria.configuration.zenith_scale": "Projectile Scale", + "lzxnoneterraria.configuration.zenith_scale.tooltip": "Projectile size multiplier", + "lzxnoneterraria.configuration.zenith_trail_alpha": "Trail Opacity", + "lzxnoneterraria.configuration.zenith_trail_alpha.tooltip": "Trail rendering opacity", + "lzxnoneterraria.configuration.zenith_trail_max_length": "Trail Length", + "lzxnoneterraria.configuration.zenith_trail_max_length.tooltip": "Maximum number of trail segments" } diff --git a/src/main/resources/assets/lzxnoneterraria/lang/zh_cn.json b/src/main/resources/assets/lzxnoneterraria/lang/zh_cn.json index f4e2942..46abc56 100644 --- a/src/main/resources/assets/lzxnoneterraria/lang/zh_cn.json +++ b/src/main/resources/assets/lzxnoneterraria/lang/zh_cn.json @@ -23,10 +23,29 @@ "item.lzxnoneterraria.true_nights_edge": "真永夜刃", "item.lzxnoneterraria.excalibur": "断钢剑", "item.lzxnoneterraria.true_excalibur": "真断钢剑", + "item.lzxnoneterraria.true_copper_shortsword": "真铜短剑", "entity.lzxnoneterraria.static_projectile": "弹射物", "entity.lzxnoneterraria.static_summon": "召唤物", "entity.lzxnoneterraria.bee_summon": "蜜蜂", - "effect.lzxnoneterraria.confused": "困惑" + "effect.lzxnoneterraria.confused": "困惑", + + "lzxnoneterraria.configuration.zenith_settings": "天顶剑 设置", + "lzxnoneterraria.configuration.zenith_damage": "弹射伤害", + "lzxnoneterraria.configuration.zenith_damage.tooltip": "每次命中伤害(实际为 x~2x 此值)", + "lzxnoneterraria.configuration.zenith_max_range": "最大范围", + "lzxnoneterraria.configuration.zenith_max_range.tooltip": "弹射物最大飞行距离", + "lzxnoneterraria.configuration.zenith_trail_b": "轨道半短轴 (b)", + "lzxnoneterraria.configuration.zenith_trail_b.tooltip": "椭圆轨道半短轴", + "lzxnoneterraria.configuration.zenith_bounding_box_size": "碰撞箱大小", + "lzxnoneterraria.configuration.zenith_bounding_box_size.tooltip": "弹射物的碰撞检测体积", + "lzxnoneterraria.configuration.zenith_cycle": "运动周期", + "lzxnoneterraria.configuration.zenith_cycle.tooltip": "弹射物运动周期", + "lzxnoneterraria.configuration.zenith_scale": "弹射大小倍数", + "lzxnoneterraria.configuration.zenith_scale.tooltip": "弹射物尺寸缩放倍数", + "lzxnoneterraria.configuration.zenith_trail_alpha": "尾迹透明度", + "lzxnoneterraria.configuration.zenith_trail_alpha.tooltip": "尾迹渲染透明度", + "lzxnoneterraria.configuration.zenith_trail_max_length": "尾迹长度", + "lzxnoneterraria.configuration.zenith_trail_max_length.tooltip": "尾迹最大段数" } diff --git a/src/main/resources/assets/lzxnoneterraria/models/item/bee_keeper.json b/src/main/resources/assets/lzxnoneterraria/models/item/bee_keeper.json index b05c93b..4d01763 100644 --- a/src/main/resources/assets/lzxnoneterraria/models/item/bee_keeper.json +++ b/src/main/resources/assets/lzxnoneterraria/models/item/bee_keeper.json @@ -1,5 +1,5 @@ { - "parent": "lzxnoneterraria:item/weapon", + "parent": "lzxnoneterraria:item/weapon3", "textures": { "layer0": "lzxnoneterraria:item/bee_keeper" } diff --git a/src/main/resources/assets/lzxnoneterraria/models/item/enchanted_sword.json b/src/main/resources/assets/lzxnoneterraria/models/item/enchanted_sword.json index 9d3d8d6..71a275c 100644 --- a/src/main/resources/assets/lzxnoneterraria/models/item/enchanted_sword.json +++ b/src/main/resources/assets/lzxnoneterraria/models/item/enchanted_sword.json @@ -1,5 +1,5 @@ { - "parent": "lzxnoneterraria:item/weapon", + "parent": "lzxnoneterraria:item/weapon2", "textures": { "layer0": "lzxnoneterraria:item/enchanted_sword" } diff --git a/src/main/resources/assets/lzxnoneterraria/models/item/influx_waver.json b/src/main/resources/assets/lzxnoneterraria/models/item/influx_waver.json index e54e7a1..476f40a 100644 --- a/src/main/resources/assets/lzxnoneterraria/models/item/influx_waver.json +++ b/src/main/resources/assets/lzxnoneterraria/models/item/influx_waver.json @@ -1,5 +1,5 @@ { - "parent": "lzxnoneterraria:item/weapon", + "parent": "lzxnoneterraria:item/weapon3", "textures": { "layer0": "lzxnoneterraria:item/influx_waver" } diff --git a/src/main/resources/assets/lzxnoneterraria/models/item/meowmere.json b/src/main/resources/assets/lzxnoneterraria/models/item/meowmere.json index 588c98e..c9c44b1 100644 --- a/src/main/resources/assets/lzxnoneterraria/models/item/meowmere.json +++ b/src/main/resources/assets/lzxnoneterraria/models/item/meowmere.json @@ -1,5 +1,5 @@ { - "parent": "lzxnoneterraria:item/weapon", + "parent": "lzxnoneterraria:item/weapon3", "textures": { "layer0": "lzxnoneterraria:item/meowmere" } diff --git a/src/main/resources/assets/lzxnoneterraria/models/item/seedler.json b/src/main/resources/assets/lzxnoneterraria/models/item/seedler.json index c0b2ebe..2ed988e 100644 --- a/src/main/resources/assets/lzxnoneterraria/models/item/seedler.json +++ b/src/main/resources/assets/lzxnoneterraria/models/item/seedler.json @@ -1,5 +1,5 @@ { - "parent": "lzxnoneterraria:item/weapon", + "parent": "lzxnoneterraria:item/weapon3", "textures": { "layer0": "lzxnoneterraria:item/seedler" } diff --git a/src/main/resources/assets/lzxnoneterraria/models/item/star_wrath.json b/src/main/resources/assets/lzxnoneterraria/models/item/star_wrath.json index 62f33a3..ee19c90 100644 --- a/src/main/resources/assets/lzxnoneterraria/models/item/star_wrath.json +++ b/src/main/resources/assets/lzxnoneterraria/models/item/star_wrath.json @@ -1,5 +1,5 @@ { - "parent": "lzxnoneterraria:item/weapon", + "parent": "lzxnoneterraria:item/weapon3", "textures": { "layer0": "lzxnoneterraria:item/star_wrath" } diff --git a/src/main/resources/assets/lzxnoneterraria/models/item/starfury.json b/src/main/resources/assets/lzxnoneterraria/models/item/starfury.json index ba5afd0..ae7a395 100644 --- a/src/main/resources/assets/lzxnoneterraria/models/item/starfury.json +++ b/src/main/resources/assets/lzxnoneterraria/models/item/starfury.json @@ -1,5 +1,5 @@ { - "parent": "lzxnoneterraria:item/weapon", + "parent": "lzxnoneterraria:item/weapon2", "textures": { "layer0": "lzxnoneterraria:item/starfury" } diff --git a/src/main/resources/assets/lzxnoneterraria/models/item/terra_blade.json b/src/main/resources/assets/lzxnoneterraria/models/item/terra_blade.json index d3cd754..b058082 100644 --- a/src/main/resources/assets/lzxnoneterraria/models/item/terra_blade.json +++ b/src/main/resources/assets/lzxnoneterraria/models/item/terra_blade.json @@ -1,5 +1,5 @@ { - "parent": "lzxnoneterraria:item/weapon", + "parent": "lzxnoneterraria:item/weapon3", "textures": { "layer0": "lzxnoneterraria:item/terra_blade" } diff --git a/src/main/resources/assets/lzxnoneterraria/models/item/the_horsemans_blade.json b/src/main/resources/assets/lzxnoneterraria/models/item/the_horsemans_blade.json index a9a48da..e0f43b0 100644 --- a/src/main/resources/assets/lzxnoneterraria/models/item/the_horsemans_blade.json +++ b/src/main/resources/assets/lzxnoneterraria/models/item/the_horsemans_blade.json @@ -1,5 +1,5 @@ { - "parent": "lzxnoneterraria:item/weapon", + "parent": "lzxnoneterraria:item/weapon3", "textures": { "layer0": "lzxnoneterraria:item/the_horsemans_blade" } diff --git a/src/main/resources/assets/lzxnoneterraria/models/item/true_copper_shortsword.json b/src/main/resources/assets/lzxnoneterraria/models/item/true_copper_shortsword.json new file mode 100644 index 0000000..be0dfbd --- /dev/null +++ b/src/main/resources/assets/lzxnoneterraria/models/item/true_copper_shortsword.json @@ -0,0 +1,6 @@ +{ + "parent": "lzxnoneterraria:item/weapon", + "textures": { + "layer0": "lzxnoneterraria:item/true_copper_shortsword" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/lzxnoneterraria/models/item/weapon2.json b/src/main/resources/assets/lzxnoneterraria/models/item/weapon2.json new file mode 100644 index 0000000..40ac073 --- /dev/null +++ b/src/main/resources/assets/lzxnoneterraria/models/item/weapon2.json @@ -0,0 +1,25 @@ +{ + "parent": "item/handheld", + "display": { + "thirdperson_righthand": { + "rotation": [0, 90, 55], + "translation": [0, 7.0, 4.0], + "scale": [1.25, 1.25, 1.25] + }, + "thirdperson_lefthand": { + "rotation": [0, -90, -55], + "translation": [0, 7.0, 4.0], + "scale": [1.25, 1.25, 1.25] + }, + "firstperson_righthand": { + "rotation": [0, 90, 25], + "translation": [1.13, 8.0, 0.0], + "scale": [1.0, 1.0, 1.0] + }, + "firstperson_lefthand": { + "rotation": [0, -90, -25], + "translation": [1.13, 8.0, 0.0], + "scale": [1.0, 1.0, 1.0] + } + } +} diff --git a/src/main/resources/assets/lzxnoneterraria/models/item/weapon3.json b/src/main/resources/assets/lzxnoneterraria/models/item/weapon3.json new file mode 100644 index 0000000..2af4948 --- /dev/null +++ b/src/main/resources/assets/lzxnoneterraria/models/item/weapon3.json @@ -0,0 +1,25 @@ +{ + "parent": "item/handheld", + "display": { + "thirdperson_righthand": { + "rotation": [0, 90, 55], + "translation": [0, 13.0, 5.0], + "scale": [1.8, 1.8, 1.8] + }, + "thirdperson_lefthand": { + "rotation": [0, -90, -55], + "translation": [0, 13.0, 5.0], + "scale": [1.8, 1.8, 1.8] + }, + "firstperson_righthand": { + "rotation": [0, 90, 25], + "translation": [1.13, 10.0, 0.0], + "scale": [1.25, 1.25, 1.25] + }, + "firstperson_lefthand": { + "rotation": [0, -90, -25], + "translation": [1.13, 10.0, 0.0], + "scale": [1.25, 1.25, 1.25] + } + } +} diff --git a/src/main/resources/assets/lzxnoneterraria/models/item/zenith.json b/src/main/resources/assets/lzxnoneterraria/models/item/zenith.json index 57e1dd0..ba64689 100644 --- a/src/main/resources/assets/lzxnoneterraria/models/item/zenith.json +++ b/src/main/resources/assets/lzxnoneterraria/models/item/zenith.json @@ -1,5 +1,5 @@ { - "parent": "lzxnoneterraria:item/weapon", + "parent": "lzxnoneterraria:item/weapon3", "textures": { "layer0": "lzxnoneterraria:item/zenith" } diff --git a/src/main/resources/assets/lzxnoneterraria/textures/item/true_copper_shortsword.png b/src/main/resources/assets/lzxnoneterraria/textures/item/true_copper_shortsword.png new file mode 100644 index 0000000..b3fc7a2 Binary files /dev/null and b/src/main/resources/assets/lzxnoneterraria/textures/item/true_copper_shortsword.png differ diff --git a/src/main/resources/data/lzxnoneterraria/bettercombat/weapon_attributes/bee_keeper.json b/src/main/resources/data/lzxnoneterraria/bettercombat/weapon_attributes/bee_keeper.json new file mode 100644 index 0000000..30d5174 --- /dev/null +++ b/src/main/resources/data/lzxnoneterraria/bettercombat/weapon_attributes/bee_keeper.json @@ -0,0 +1,3 @@ +{ + "parent": "bettercombat:sword" +} diff --git a/src/main/resources/data/lzxnoneterraria/bettercombat/weapon_attributes/copper_shortsword.json b/src/main/resources/data/lzxnoneterraria/bettercombat/weapon_attributes/copper_shortsword.json new file mode 100644 index 0000000..30d5174 --- /dev/null +++ b/src/main/resources/data/lzxnoneterraria/bettercombat/weapon_attributes/copper_shortsword.json @@ -0,0 +1,3 @@ +{ + "parent": "bettercombat:sword" +} diff --git a/src/main/resources/data/lzxnoneterraria/bettercombat/weapon_attributes/enchanted_sword.json b/src/main/resources/data/lzxnoneterraria/bettercombat/weapon_attributes/enchanted_sword.json new file mode 100644 index 0000000..30d5174 --- /dev/null +++ b/src/main/resources/data/lzxnoneterraria/bettercombat/weapon_attributes/enchanted_sword.json @@ -0,0 +1,3 @@ +{ + "parent": "bettercombat:sword" +} diff --git a/src/main/resources/data/lzxnoneterraria/bettercombat/weapon_attributes/influx_waver.json b/src/main/resources/data/lzxnoneterraria/bettercombat/weapon_attributes/influx_waver.json new file mode 100644 index 0000000..30d5174 --- /dev/null +++ b/src/main/resources/data/lzxnoneterraria/bettercombat/weapon_attributes/influx_waver.json @@ -0,0 +1,3 @@ +{ + "parent": "bettercombat:sword" +} diff --git a/src/main/resources/data/lzxnoneterraria/bettercombat/weapon_attributes/meowmere.json b/src/main/resources/data/lzxnoneterraria/bettercombat/weapon_attributes/meowmere.json new file mode 100644 index 0000000..30d5174 --- /dev/null +++ b/src/main/resources/data/lzxnoneterraria/bettercombat/weapon_attributes/meowmere.json @@ -0,0 +1,3 @@ +{ + "parent": "bettercombat:sword" +} diff --git a/src/main/resources/data/lzxnoneterraria/bettercombat/weapon_attributes/seedler.json b/src/main/resources/data/lzxnoneterraria/bettercombat/weapon_attributes/seedler.json new file mode 100644 index 0000000..30d5174 --- /dev/null +++ b/src/main/resources/data/lzxnoneterraria/bettercombat/weapon_attributes/seedler.json @@ -0,0 +1,3 @@ +{ + "parent": "bettercombat:sword" +} diff --git a/src/main/resources/data/lzxnoneterraria/bettercombat/weapon_attributes/star_wrath.json b/src/main/resources/data/lzxnoneterraria/bettercombat/weapon_attributes/star_wrath.json new file mode 100644 index 0000000..30d5174 --- /dev/null +++ b/src/main/resources/data/lzxnoneterraria/bettercombat/weapon_attributes/star_wrath.json @@ -0,0 +1,3 @@ +{ + "parent": "bettercombat:sword" +} diff --git a/src/main/resources/data/lzxnoneterraria/bettercombat/weapon_attributes/starfury.json b/src/main/resources/data/lzxnoneterraria/bettercombat/weapon_attributes/starfury.json new file mode 100644 index 0000000..30d5174 --- /dev/null +++ b/src/main/resources/data/lzxnoneterraria/bettercombat/weapon_attributes/starfury.json @@ -0,0 +1,3 @@ +{ + "parent": "bettercombat:sword" +} diff --git a/src/main/resources/data/lzxnoneterraria/bettercombat/weapon_attributes/terra_blade.json b/src/main/resources/data/lzxnoneterraria/bettercombat/weapon_attributes/terra_blade.json new file mode 100644 index 0000000..f5917e2 --- /dev/null +++ b/src/main/resources/data/lzxnoneterraria/bettercombat/weapon_attributes/terra_blade.json @@ -0,0 +1,3 @@ +{ + "parent": "bettercombat:claymore" +} diff --git a/src/main/resources/data/lzxnoneterraria/bettercombat/weapon_attributes/the_horsemans_blade.json b/src/main/resources/data/lzxnoneterraria/bettercombat/weapon_attributes/the_horsemans_blade.json new file mode 100644 index 0000000..f5917e2 --- /dev/null +++ b/src/main/resources/data/lzxnoneterraria/bettercombat/weapon_attributes/the_horsemans_blade.json @@ -0,0 +1,3 @@ +{ + "parent": "bettercombat:claymore" +} diff --git a/src/main/resources/data/lzxnoneterraria/bettercombat/weapon_attributes/zenith.json b/src/main/resources/data/lzxnoneterraria/bettercombat/weapon_attributes/zenith.json new file mode 100644 index 0000000..30d5174 --- /dev/null +++ b/src/main/resources/data/lzxnoneterraria/bettercombat/weapon_attributes/zenith.json @@ -0,0 +1,3 @@ +{ + "parent": "bettercombat:sword" +} diff --git a/src/main/templates/META-INF/neoforge.mods.toml b/src/main/templates/META-INF/neoforge.mods.toml index cc5e2d2..cd6519a 100644 --- a/src/main/templates/META-INF/neoforge.mods.toml +++ b/src/main/templates/META-INF/neoforge.mods.toml @@ -88,6 +88,16 @@ Example mod description. ordering="NONE" side="BOTH" +#Optional dependency for dynamic lighting +[[dependencies.${mod_id}]] + modId="lambdynlights" + type="optional" + ordering="NONE" + side="CLIENT" + +[modproperties."${mod_id}"."yumi:entrypoints"] + "lambdynlights:initializer" = "com.lzxnone.terraria.dynamic_lights.MDynamicLightsInitializer" + # Features are specific properties of the game environment, that you may want to declare you require. This example declares # that your mod requires GL version 3.2 or higher. Other features will be added. They are side aware so declaring this won't # stop your mod loading on the server for example.