Compare commits

...
10 Commits
46 changed files with 1208 additions and 237 deletions

No files matched your search

-30
View File
@@ -1,30 +0,0 @@
name: Build
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- name: Setup JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
# This is needed to be able to run ./gradlew below
# You can run `git update-index --chmod +x gradlew` then remove this step.
- name: Make Gradle wrapper executable
run: chmod +x ./gradlew
- name: Build with Gradle
run: ./gradlew build
+223
View File
@@ -0,0 +1,223 @@
Dual Licensing Notice
=====================
This project is licensed under a dual-licensing scheme separating source code from media assets:
1. SOURCE CODE:
All Java source code, shaders, scripts, and build configuration files in this repository
are licensed under the GNU Lesser General Public License, version 3.0 (LGPL-3.0).
See Section I below for details.
2. ASSETS & MEDIA:
All visual and audio assets (including but not limited to textures, models, sound effects,
particle definitions, and UI layouts located under `src/main/resources/assets`)
are licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0
International Public License (CC BY-NC-SA 4.0).
See Section II below for details.
3. FAN-CONTENT & THIRD-PARTY DISCLAIMER:
This project is an unofficial, non-commercial fan-made mod for Minecraft.
- "Terraria" and related weapon, accessory, mechanic designs, textures, and sounds are
copyright (c) Re-Logic.
- "Calamity Mod" and its respective assets and designs are copyright (c) Calamity Mod Team.
See Section III below for details.
========================================================================
SECTION I: SOURCE CODE LICENSE (GNU LGPL-3.0)
========================================================================
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that, taken
together, effectively do not restrict modification of the portions of
the Library contained in the Combined Work and reverse engineering for
debugging such modifications, if you also do each of the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.
========================================================================
SECTION II: ASSETS & MEDIA LICENSE (CC BY-NC-SA 4.0)
========================================================================
Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International
You are free to:
- Share — copy and redistribute the material in any medium or format
- Adapt — remix, transform, and build upon the material
Under the following terms:
- Attribution — You must give appropriate credit, provide a link to the
license, and indicate if changes were made.
- NonCommercial — You may NOT use the material for commercial purposes
(including commercial Minecraft servers, monetized packs, or selling assets).
- ShareAlike — If you remix, transform, or build upon the material, you
must distribute your contributions under the same license as the original.
Full legal code: https://creativecommons.org/licenses/by-nc-sa/4.0/legalcode
========================================================================
SECTION III: FAN-CONTENT & INTELLECTUAL PROPERTY DISCLAIMER
========================================================================
1. "Terraria" is a registered trademark of Re-Logic. All original Terraria
designs, concepts, weapon lore, sound effects, and sprites are the intellectual
property of Re-Logic.
2. "Calamity Mod" content, concepts, and designs are the intellectual property
of the Calamity Mod Development Team.
3. This mod is a non-commercial, fan-made creation distributed under fair use
and community fan-art principles. No commercial profit is derived from this project.
+54 -19
View File
@@ -1,25 +1,60 @@
# 🌟 Lzxnone Terraria
Installation information
=======
<div align="center">
This template repository can be directly cloned to get you started with a new
mod. Simply create a new repository cloned from this one, by following the
instructions provided by [GitHub](https://docs.github.com/en/repositories/creating-and-managing-repositories/creating-a-repository-from-a-template).
![Platform](https://img.shields.io/badge/Platform-Minecraft%20NeoForge-brightgreen.svg?style=flat-square&logo=minecraft)
![License: Code LGPL-3.0](https://img.shields.io/badge/Code-LGPL--3.0-blue.svg?style=flat-square)
![License: Assets CC BY-NC-SA 4.0](https://img.shields.io/badge/Assets-CC%20BY--NC--SA%204.0-orange.svg?style=flat-square)
Once you have your clone, simply open the repository in the IDE of your choice. The usual recommendation for an IDE is either IntelliJ IDEA or Eclipse.
**将《泰拉瑞亚》(Terraria)的职业体系、经典武器、饰品与战斗机制引入 Minecraft。**
If at any point you are missing libraries in your IDE, or you've run into problems you can
run `gradlew --refresh-dependencies` to refresh the local cache. `gradlew clean` to reset everything
{this does not affect your code} and then start the process again.
**简体中文** | [English](README_EN.md)
Mapping Names:
============
By default, the MDK is configured to use the official mapping names from Mojang for methods and fields
in the Minecraft codebase. These names are covered by a specific license. All modders should be aware of this
license. For the latest license text, refer to the mapping file itself, or the reference copy here:
https://github.com/NeoForged/NeoForm/blob/main/Mojang.md
</div>
Additional Resources:
==========
Community Documentation: https://docs.neoforged.net/
NeoForged Discord: https://discord.neoforged.net/
---
## 模组概述
**Lzxnone Terraria** 是一款面向 Minecraft NeoForge 的冒险战斗模组。模组忠实再现了《泰拉瑞亚》的经典战斗体系,并融入了《灾厄》(Calamity)模组的特色内容。
### 核心内容总览
- **职业与武器库**
- **近战**:收录泰拉系列经典剑刃(如永夜刃、泰拉刃、天顶剑等)与特异武器,支持弹道剑气与挥砍特效;包含灾厄特色近战武器(如破灭魔王剑)及专属杀戮模式。
- **魔法**:引入独立魔力值(Mana)系统、魔力水晶上限提升、魔力药水及耐魔性机制;包含终极棱镜、月耀等标志性法术武器与法师长袍。
- **远程**:涵盖各阶段枪械、重火器与神弓,配备专属弹药库(叶绿弹追踪、灵液弹等)与狙击镜战术瞄准变焦系统。
- **召唤**:支持仆从槽位上限管理,提供多节星尘巨龙、自律环绕飞剑(泰拉棱镜)及长鞭等召唤物与控制指令。
- **饰品体系 (Curios)**
- 深度兼容 **Curios API**,还原十字章护盾合成树、各职业战斗徽章、天界贝壳、强化手套等丰富饰品与属性增益。
- **专属机制与增强**
- 包含多项围绕魔力、远程弹药与召唤物的专属附魔词条。
- 采用原生着色器与粒子效果,并支持动态光源(如 LambDynamicLights)联动。
---
## 前置依赖
运行本模组需要安装以下前置组件(请选择与您游戏版本对应的构件):
- **Minecraft** 与对应版本的 **NeoForge**
- [Curios API (NeoForge)](https://www.curseforge.com/minecraft/mc-mods/curios-continuation)
- [LDLib2 (LowDragLib2)](https://github.com/Low-Drag-MC/LDLib2)
*可选兼容:推荐安装 [LambDynamicLights](https://github.com/LambdAurora/LambDynamicLights) 以获得武器光束与弹幕的动态发光效果。*
---
## 开源协议与致谢
- 本模组采用**代码与资产分离的双重开源协议**:
- **源代码(Java / 着色器 / 逻辑)**:遵循 [GNU LGPL-3.0](LICENSE) 协议开源。
- **美术与音频资产(贴图 / 音效 / 模型 / 粒子)**:遵循 [CC BY-NC-SA 4.0](LICENSE)(知识共享 署名-非商业性使用-相同方式共享 4.0 国际许可协议)。**严禁将资产用于任何商业用途或商业服务器**。
- **免责与致谢声明**:
- 本项目为非官方、非盈利性质的 Minecraft 同人模组。
- 《Terraria》及其相关的武器、饰品设计、贴图与音效版权均归 **Re-Logic** 所有。
- 《Calamity Mod》(灾厄)相关特色元素与内容版权均归 **Calamity Mod 开发团队** 所有。
---
+60
View File
@@ -0,0 +1,60 @@
# 🌟 Lzxnone Terraria
<div align="center">
![Platform](https://img.shields.io/badge/Platform-Minecraft%20NeoForge-brightgreen.svg?style=flat-square&logo=minecraft)
![License: Code LGPL-3.0](https://img.shields.io/badge/Code-LGPL--3.0-blue.svg?style=flat-square)
![License: Assets CC BY-NC-SA 4.0](https://img.shields.io/badge/Assets-CC%20BY--NC--SA%204.0-orange.svg?style=flat-square)
**Bringing the class system, iconic weapons, accessories, and combat mechanics of *Terraria* into Minecraft.**
[简体中文](README.md) | **English**
</div>
---
## Mod Overview
**Lzxnone Terraria** is an adventure and combat mod for Minecraft NeoForge. It faithfully recreates the classic combat progression of *Terraria* while incorporating signature elements inspired by *Calamity Mod*.
### Key Features
- **Classes & Arsenal**
- **Melee**: Includes classic Terraria blades (such as Night's Edge, Terra Blade, Zenith, etc.) and unique weapons with projectile beams and swing effects, alongside Calamity-inspired melee weapons (such as Murasama) and dedicated slash/slaughter modes.
- **Magic**: Introduces a dedicated Mana system, Mana Crystal capacity upgrades, Mana Potions, and Mana Sickness mechanics, featuring iconic magic weapons like the Last Prism and Lunar Flare as well as mage robes.
- **Ranged**: Covers guns, heavy launchers, and bows across progression tiers, complete with specialized ammunition (homing Chlorophyte Bullets, Ichor Bullets, etc.) and Sniper Scope tactical zoom aiming.
- **Summoner**: Supports minion slot management, featuring multi-segment Stardust Dragon summons, autonomous orbiting swords (Terraprisma), whips, and command controls.
- **Accessories System (Curios)**
- Deep integration with **Curios API**, recreating the Ankh Shield crafting tree, class emblems, Celestial Shell, upgraded gloves, and rich stat-boosting accessories.
- **Custom Mechanics & Visuals**
- Adds custom enchantments tailored around mana, ranged ammunition, and summons.
- Uses native shaders and particle effects, with dynamic lighting support (such as LambDynamicLights).
---
## Dependencies
Running this mod requires the following dependencies (choose builds matching your Minecraft / NeoForge version):
- **Minecraft** with matching **NeoForge**
- [Curios API (NeoForge)](https://www.curseforge.com/minecraft/mc-mods/curios-continuation)
- [LDLib2 (LowDragLib2)](https://github.com/Low-Drag-MC/LDLib2)
*Optional compatibility: [LambDynamicLights](https://github.com/LambdAurora/LambDynamicLights) is recommended for dynamic glow effects on weapon beams and projectiles.*
---
## License & Acknowledgments
- This mod adopts a **dual-licensing model separating code and assets**:
- **Source Code (Java / Shaders / Logic)**: Open-sourced under [GNU LGPL-3.0](LICENSE).
- **Art & Audio Assets (Textures / Sounds / Models / Particles)**: Licensed under [CC BY-NC-SA 4.0](LICENSE) (Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International). **Commercial use of assets or deployment on commercial servers is strictly prohibited.**
- **Disclaimer & Credits**:
- This is an unofficial, non-profit Minecraft fan mod.
- All *Terraria* weapon/accessory designs, sprites, and sound copyrights belong to **Re-Logic**.
- *Calamity Mod*-inspired elements and content copyrights belong to the **Calamity Mod Development Team**.
---
+2 -2
View File
@@ -32,9 +32,9 @@ mod_id=lzxnoneterraria
# The human-readable display name for the mod.
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
mod_license=LGPL-3.0-only AND CC-BY-NC-SA-4.0
# The mod version. See https://semver.org/
mod_version=1.9.1
mod_version=1.9.2
## 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
@@ -9,12 +9,17 @@ import net.minecraft.nbt.NbtOps;
import net.minecraft.nbt.Tag;
import net.minecraft.world.item.ItemStack;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
public class TargetMarks {
public static final String PROPHETIC = "prophetic";
public static final String POSSESSION = "possession";
public static final String KALEIDOSCOPE = "kaleidoscope";
private static final Codec<UUID> UUID_CODEC = Codec.STRING.xmap(UUID::fromString, UUID::toString);
private static final UUID EMPTY_OWNER = new UUID(0L, 0L);
private static final Codec<CompoundTag> COMPOUND_TAG_CODEC = Codec.PASSTHROUGH.xmap(
@@ -73,6 +78,47 @@ public class TargetMarks {
return new TargetMarks(marks, customData);
}
public void addMark(String id, Mark mark, int maxSlots, long gameTime) {
if(id == null || mark == null) return;
// 1. 同一标记直接刷新
if(marks.containsKey(id)) {
marks.put(id, mark);
return;
}
// 2. 清理已过期的标记
if(gameTime > 0) {
marks.entrySet().removeIf(entry -> {
Mark m = entry.getValue();
return m != null && m.getDuration() > 0 && gameTime - m.getStartTime() >= m.getDuration();
});
}
// 3. 统计该施加者的有效标记
UUID owner = mark.getOwner();
List<Map.Entry<String, Mark>> ownerMarks = new ArrayList<>();
for(Map.Entry<String, Mark> entry : marks.entrySet()) {
Mark m = entry.getValue();
if(m != null && (owner == null || owner.equals(m.getOwner()))) {
ownerMarks.add(entry);
}
}
// 4. 若超出最大槽位上限,按 startTime 剔除最老的标记(FIFO)
while(ownerMarks.size() >= maxSlots && !ownerMarks.isEmpty()) {
Map.Entry<String, Mark> oldest = Collections.min(
ownerMarks,
Comparator.comparingLong(e -> e.getValue().getStartTime())
);
marks.remove(oldest.getKey());
ownerMarks.remove(oldest);
}
// 5. 存入新标记
marks.put(id, mark);
}
public static class Mark {
public static final Codec<Mark> CODEC = RecordCodecBuilder.create(instance -> instance.group(
Codec.LONG.optionalFieldOf("start_time", 0L).forGetter(Mark::getStartTime),
@@ -21,6 +21,7 @@ import com.lzxnone.terraria.client.item.ranged.ClientSuperStarShooter;
import com.lzxnone.terraria.client.item.summon.ClientStardustDragonStaff;
import com.lzxnone.terraria.client.item.summon.ClientStardustCellStaff;
import com.lzxnone.terraria.client.item.summon.ClientTerraprisma;
import com.lzxnone.terraria.client.item.summon.ClientKaleidoscope;
import com.lzxnone.terraria.client.item.summon.ClientWhip;
import com.lzxnone.terraria.entity.summon.StaticSummonBehaviors;
@@ -61,7 +62,8 @@ public class ClientStaticSummonRenderBehaviors {
BEHAVIORS.put(StaticSummonBehaviors.NEBULA_ARCANUM_PROJECTILE, ClientNebulaArcanum.SUMMON_BEHAVIOR);
BEHAVIORS.put(StaticSummonBehaviors.NEBULA_ARCANUM_SMALL_PROJECTILE, ClientNebulaArcanum.SUMMON_BEHAVIOR2);
BEHAVIORS.put(StaticSummonBehaviors.TERRAPRISMA, ClientTerraprisma.SUMMON_BEHAVIOR);
BEHAVIORS.put(StaticSummonBehaviors.POSSESSION, ClientWhip.SUMMON_BEHAVIOR);
BEHAVIORS.put(StaticSummonBehaviors.WHIP, ClientWhip.SUMMON_BEHAVIOR);
BEHAVIORS.put(StaticSummonBehaviors.KALEIDOSCOPE, ClientKaleidoscope.SUMMON_BEHAVIOR);
BEHAVIORS.put(StaticSummonBehaviors.POSSESSION_VISION, DEFAULT_BEHAVIOR);
BEHAVIORS.put(StaticSummonBehaviors.STARDUST_DRAGON_STAFF, ClientStardustDragonStaff.SUMMON_BEHAVIOR);
BEHAVIORS.put(StaticSummonBehaviors.STARDUST_CELL_STAFF, ClientStardustCellStaff.SUMMON_BEHAVIOR);
@@ -6,6 +6,7 @@ import com.lzxnone.terraria.item.weapon.MeleeWeapon;
import com.lzxnone.terraria.item.weapon.RangedWeapon;
import com.lzxnone.terraria.item.weapon.SummonWeapon;
import com.lzxnone.terraria.item.weapon.summon.minion.MinionWeapon;
import com.lzxnone.terraria.item.weapon.summon.whip.Whip;
import net.minecraft.ChatFormatting;
import net.minecraft.core.Holder;
import net.minecraft.core.component.DataComponents;
@@ -33,6 +34,7 @@ public class ItemTooltipHandler {
addMeleeWeaponTooltip(event);
addRangedWeaponTooltip(event);
addSummonWeaponTooltip(event);
addWhipTooltip(event);
addMagicWeaponTooltip(event);
}
@@ -116,10 +118,18 @@ public class ItemTooltipHandler {
Component.translatable(
"tooltip.lzxnoneterraria.melee_weapon_damage",
damage == Math.rint(damage) ? String.valueOf((int) damage) : String.format("%.2f", damage)
).withStyle(ChatFormatting.RED)
).withStyle(ChatFormatting.RED)
);
}
}
if(stack.getItem() instanceof com.lzxnone.terraria.item.weapon.melee.DevilsDevastation) {
Component keyMsg = com.lzxnone.terraria.ModKeyBindings.KILL_MODE.getTranslatedKeyMessage();
event.getToolTip().add(
Component.translatable("tooltip.lzxnoneterraria.devils_devastation.kill_mode_key", keyMsg)
.withStyle(style -> style.withColor(0xFF5555))
);
}
}
}
@@ -158,4 +168,29 @@ public class ItemTooltipHandler {
}
}
}
private static void addWhipTooltip(ItemTooltipEvent event) {
ItemStack stack = event.getItemStack();
if(stack.getItem() instanceof Whip whip) {
float tagDamage = whip.getTagDamage();
if(tagDamage > 0.0F) {
event.getToolTip().add(
Component.translatable(
"tooltip.lzxnoneterraria.whip_tag_damage",
tagDamage == Math.rint(tagDamage) ? String.valueOf((int) tagDamage) : String.format("%.2f", tagDamage)
).withStyle(ChatFormatting.RED)
);
}
int tagCrit = whip.getTagCrit();
if(tagCrit > 0) {
event.getToolTip().add(
Component.translatable(
"tooltip.lzxnoneterraria.whip_tag_crit",
tagCrit
).withStyle(ChatFormatting.RED)
);
}
}
}
}
@@ -24,12 +24,18 @@ import net.minecraft.client.renderer.texture.OverlayTexture;
import net.minecraft.util.Mth;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.player.Player;
import com.lzxnone.terraria.effect.ModEffects;
import com.lzxnone.terraria.item.ModItems;
import com.lzxnone.terraria.particle.IronSparkParticleOptions;
import org.joml.Vector4f;
import net.minecraft.world.item.*;
import net.minecraft.world.phys.Vec3;
import org.joml.Matrix4f;
import org.joml.Quaternionf;
import org.joml.Vector3f;
import net.minecraft.client.Camera;
import net.minecraft.network.chat.Component;
import net.neoforged.neoforge.client.GlStateBackup;
import java.util.*;
@@ -605,6 +611,118 @@ public class ClientDevilsDevastation {
}
}
public static void renderEnergyParticles(PoseStack poseStack, ItemDisplayContext displayContext, Player player) {
if (player.getEffect(ModEffects.KILL_MODE) == null || player.getCooldowns().isOnCooldown(ModItems.DEVILS_DEVASTATION.get())) {
return;
}
Minecraft mc = Minecraft.getInstance();
if (mc.level == null) return;
poseStack.pushPose();
poseStack.translate(0.0, 1.4, 0.2);
Matrix4f energyMatrix = poseStack.last().pose();
Camera camera = mc.gameRenderer.getMainCamera();
Vec3 cameraWorldPos = camera.getPosition();
Quaternionf cameraRotation = camera.rotation();
boolean isFirstPerson = displayContext.firstPerson();
net.minecraft.util.RandomSource random = player.getRandom();
int sampleCount = 2;
for (int i = 0; i < sampleCount; i++) {
// 1. 采样能量体剑身内的位置点
float localY = 0.5f + random.nextFloat() * 23.5f;
float halfWidth = (1.0f - localY / 32.0f) * 0.8f;
float localZ = (random.nextFloat() * 2.0f - 1.0f) * halfWidth;
float localX = (random.nextFloat() * 2.0f - 1.0f) * 0.04f;
// 局部坐标转为渲染空间坐标
Vector4f localPos = new Vector4f(localX, localY, localZ, 1.0f);
localPos.mul(energyMatrix);
// 2. 解算粒子的绝对世界发射位置
Vec3 actualWorldPos;
if (isFirstPerson) {
Vector3f viewOffset = new Vector3f(localPos.x(), localPos.y(), localPos.z());
cameraRotation.transform(viewOffset);
actualWorldPos = new Vec3(
cameraWorldPos.x + viewOffset.x(),
cameraWorldPos.y + viewOffset.y(),
cameraWorldPos.z + viewOffset.z()
);
} else {
actualWorldPos = new Vec3(
cameraWorldPos.x + localPos.x(),
cameraWorldPos.y + localPos.y(),
cameraWorldPos.z + localPos.z()
);
}
// 3. 计算粒子朝向:
// 剑身中轴为局部 +Y 轴 (0, 1, 0)
// 沿剑身延申为主方向 (Y=1.0),在 X/Z 方向施加偏移倾角,使朝向与中轴呈约 12° ~ 24° 夹角
float tilt = 0.22f + random.nextFloat() * 0.20f;
float phi = random.nextFloat() * (float) (2 * Math.PI);
float localDirX = (float) Math.cos(phi) * tilt * 0.35f;
float localDirY = 1.0f;
float localDirZ = (float) Math.sin(phi) * tilt;
Vector3f localDir = new Vector3f(localDirX, localDirY, localDirZ).normalize();
// 计算局部的侧向正交基向量 (right),用于铁火花平面的广告牌计算
Vector3f localRight = new Vector3f(-localDirZ, 0.0f, localDirX);
if (localRight.lengthSquared() < 0.001f) localRight.set(1.0f, 0.0f, 0.0f);
localRight.normalize();
// 4. 将方向向量和基向量变换到视角空间
Vector3f viewDir = energyMatrix.transformDirection(localDir, new Vector3f()).normalize();
Vector3f viewRight = energyMatrix.transformDirection(localRight, new Vector3f()).normalize();
// 5. 视角空间向量转换为世界空间向量
Vector3f worldDir;
Vector3f worldRight;
if (isFirstPerson) {
worldDir = cameraRotation.transform(viewDir, new Vector3f());
worldRight = cameraRotation.transform(viewRight, new Vector3f());
} else {
worldDir = new Vector3f(viewDir);
worldRight = new Vector3f(viewRight);
}
// 速度大小控制火花的移动速度与拉伸方向
float speed = 0.18f + random.nextFloat() * 0.12f;
worldDir.mul(speed);
Vector3f[] energyColors = new Vector3f[]{
new Vector3f(0.725f, 0.345f, 1.0f),
new Vector3f(0.847f, 0.247f, 0.745f),
new Vector3f(0.882f, 0.345f, 0.247f)
};
// 6. 生成铁火花粒子
Vector3f color = energyColors[random.nextInt(energyColors.length)];
IronSparkParticleOptions sparkOptions = new IronSparkParticleOptions(
0.2f, // initSize (火花粗细)
16 + random.nextInt(8), // initLifetime (生命周期)
3.5f, // sparkLength (拉伸长度倍率)
color, // 颜色
worldDir, // 飞行初速度及延伸朝向
worldRight // 侧向基向量
);
mc.level.addParticle(
sparkOptions,
actualWorldPos.x, actualWorldPos.y, actualWorldPos.z,
0.0, 0.0, 0.0
);
}
poseStack.popPose();
}
private static void addEnergyVertex(
BufferBuilder bb,
float x, float y, float z
@@ -0,0 +1,23 @@
package com.lzxnone.terraria.client.item.summon;
import com.lzxnone.terraria.client.entity.summon.IStaticSummonRenderBehavior;
import com.lzxnone.terraria.entity.summon.StaticSummon;
import net.minecraft.util.Mth;
import org.joml.Vector4f;
public class ClientKaleidoscope extends ClientWhip {
public static final IStaticSummonRenderBehavior SUMMON_BEHAVIOR = new ClientKaleidoscope();
@Override
protected Vector4f getVertexColor(StaticSummon summon, float progressAlongWhip, float partialTick) {
float time = summon.tickCount + partialTick;
// 沿鞭身呈现完整彩虹色谱,并随时间平滑流动
float hue = (progressAlongWhip + time * 0.04F) % 1.0F;
int rgb = Mth.hsvToRgb(hue, 0.85F, 1.0F);
float r = ((rgb >> 16) & 255) / 255.0F;
float g = ((rgb >> 8) & 255) / 255.0F;
float b = (rgb & 255) / 255.0F;
float a = summon.getEntityData().get(StaticSummon.COLOR_A);
return new Vector4f(r, g, b, a);
}
}
@@ -13,101 +13,112 @@ import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.phys.Vec3;
import org.joml.Vector4f;
import java.util.ArrayList;
import java.util.List;
public class ClientWhip {
public class ClientWhip implements IStaticSummonRenderBehavior {
private static final int SEGMENTS = 24;
private static final float WIDTH = 1.0F;
public static final IStaticSummonRenderBehavior SUMMON_BEHAVIOR = new IStaticSummonRenderBehavior() {
@Override
public void render(Entity entity, float entityYaw, float partialTick, PoseStack poseStack, MultiBufferSource bufferSource, int packedLight) {
if(!(entity instanceof StaticSummon summon) || summon.getOwner() == null) return;
CompoundTag customData = summon.getEntityData().get(StaticSummon.CUSTOM_DATA);
int lifetime = Math.max(1, summon.getEntityData().get(StaticSummon.LIFETIME));
float progress = Mth.clamp((summon.getEntityData().get(StaticSummon.AGE) + partialTick) / lifetime, 0.0F, 1.0F);
public static final IStaticSummonRenderBehavior SUMMON_BEHAVIOR = new ClientWhip();
Vec3 origin = entity.getPosition(partialTick);
Vec3 hand = origin;
Vec3 dir = readVec3(customData, "dir", new Vec3(0.0D, 0.0D, 1.0D)).normalize();
Vec3 up = readVec3(customData, "up", new Vec3(0.0D, 1.0D, 0.0D)).normalize();
Vec3 right = readVec3(customData, "right", new Vec3(1.0D, 0.0D, 0.0D)).normalize();
if(dir.lengthSqr() < 1.0E-6D) dir = new Vec3(0.0D, 0.0D, 1.0D);
if(up.lengthSqr() < 1.0E-6D) up = new Vec3(0.0D, 1.0D, 0.0D);
if(right.lengthSqr() < 1.0E-6D) right = new Vec3(1.0D, 0.0D, 0.0D);
protected Vector4f getVertexColor(StaticSummon summon, float progressAlongWhip, float partialTick) {
return new Vector4f(
summon.getEntityData().get(StaticSummon.COLOR_R),
summon.getEntityData().get(StaticSummon.COLOR_G),
summon.getEntityData().get(StaticSummon.COLOR_B),
summon.getEntityData().get(StaticSummon.COLOR_A)
);
}
double range = customData.contains("range") ? customData.getDouble("range") : 8.0D;
double height = customData.contains("height") ? customData.getDouble("height") : range * 0.25D;
double bend = customData.contains("bend") ? customData.getDouble("bend") : range * 0.25D;
boolean reverse = customData.contains("reverse") && customData.getBoolean("reverse");
@Override
public void render(Entity entity, float entityYaw, float partialTick, PoseStack poseStack, MultiBufferSource bufferSource, int packedLight) {
if(!(entity instanceof StaticSummon summon) || summon.getOwner() == null) return;
CompoundTag customData = summon.getEntityData().get(StaticSummon.CUSTOM_DATA);
int lifetime = Math.max(1, summon.getEntityData().get(StaticSummon.LIFETIME));
float progress = Mth.clamp((summon.getEntityData().get(StaticSummon.AGE) + partialTick) / lifetime, 0.0F, 1.0F);
List<Vec3> points = computePoints(hand, dir, up, progress, range, height, bend, reverse, SEGMENTS);
if(points.size() < 2) return;
Vec3 origin = entity.getPosition(partialTick);
Vec3 hand = origin;
Vec3 dir = readVec3(customData, "dir", new Vec3(0.0D, 0.0D, 1.0D)).normalize();
Vec3 up = readVec3(customData, "up", new Vec3(0.0D, 1.0D, 0.0D)).normalize();
Vec3 right = readVec3(customData, "right", new Vec3(1.0D, 0.0D, 0.0D)).normalize();
if(dir.lengthSqr() < 1.0E-6D) dir = new Vec3(0.0D, 0.0D, 1.0D);
if(up.lengthSqr() < 1.0E-6D) up = new Vec3(0.0D, 1.0D, 0.0D);
if(right.lengthSqr() < 1.0E-6D) right = new Vec3(1.0D, 0.0D, 0.0D);
// 计算归一化累积弧长序列
int n = points.size();
double[] cumulativeDist = new double[n];
double totalLength = 0.0D;
for(int i = 1; i < n; i++) {
totalLength += points.get(i).distanceTo(points.get(i - 1));
cumulativeDist[i] = totalLength;
}
if(totalLength < 1.0E-5D) return;
double range = customData.contains("range") ? customData.getDouble("range") : 8.0D;
double height = customData.contains("height") ? customData.getDouble("height") : range * 0.25D;
double bend = customData.contains("bend") ? customData.getDouble("bend") : range * 0.25D;
boolean reverse = customData.contains("reverse") && customData.getBoolean("reverse");
double[] normalizedDist = new double[n];
for(int i = 0; i < n; i++) {
normalizedDist[i] = cumulativeDist[i] / totalLength;
}
List<Vec3> points = computePoints(hand, dir, up, progress, range, height, bend, reverse, SEGMENTS);
if(points.size() < 2) return;
if(!customData.contains("tailRes") || !customData.contains("bodyRes") || !customData.contains("headRes")) return;
// 计算归一化累积弧长序列
int n = points.size();
double[] cumulativeDist = new double[n];
double totalLength = 0.0D;
for(int i = 1; i < n; i++) {
totalLength += points.get(i).distanceTo(points.get(i - 1));
cumulativeDist[i] = totalLength;
}
if(totalLength < 1.0E-5D) return;
String tailResStr = customData.getString("tailRes");
String bodyResStr = customData.getString("bodyRes");
String headResStr = customData.getString("headRes");
if(tailResStr.isEmpty() || bodyResStr.isEmpty() || headResStr.isEmpty()) return;
double[] normalizedDist = new double[n];
for(int i = 0; i < n; i++) {
normalizedDist[i] = cumulativeDist[i] / totalLength;
}
float tailRatio = customData.getFloat("tailRatio");
float headRatio = customData.getFloat("headRatio");
float bodyUnitRatio = customData.getFloat("bodyUnitRatio");
if(!customData.contains("tailRes") || !customData.contains("bodyRes") || !customData.contains("headRes")) return;
tailRatio = Mth.clamp(tailRatio, 0.0F, 0.9F);
headRatio = Mth.clamp(headRatio, 0.0F, 0.9F - tailRatio);
bodyUnitRatio = Math.max(0.001F, bodyUnitRatio);
String tailResStr = customData.getString("tailRes");
String bodyResStr = customData.getString("bodyRes");
String headResStr = customData.getString("headRes");
if(tailResStr.isEmpty() || bodyResStr.isEmpty() || headResStr.isEmpty()) return;
float bodyStart = tailRatio;
float bodyEnd = 1.0F - headRatio;
float tailRatio = customData.getFloat("tailRatio");
float headRatio = customData.getFloat("headRatio");
float bodyUnitRatio = customData.getFloat("bodyUnitRatio");
ResourceLocation tailRes = ResourceLocation.parse(tailResStr);
ResourceLocation bodyRes = ResourceLocation.parse(bodyResStr);
ResourceLocation headRes = ResourceLocation.parse(headResStr);
tailRatio = Mth.clamp(tailRatio, 0.0F, 0.9F);
headRatio = Mth.clamp(headRatio, 0.0F, 0.9F - tailRatio);
bodyUnitRatio = Math.max(0.001F, bodyUnitRatio);
// 1. 渲染尾部 (Tail - 不拉伸,单张贴图完整映射)
if(tailRatio > 1.0E-4F) {
List<Vec3> tailPoints = extractSubPath(points, normalizedDist, 0.0F, tailRatio);
renderRibbonCross(tailPoints, origin, right, up, tailRes, 0.0F, 1.0F, poseStack, bufferSource);
}
float bodyStart = tailRatio;
float bodyEnd = 1.0F - headRatio;
// 2. 渲染身体 (Body - Tiling 平铺渲染,按 bodyUnitRatio 单元循环平铺)
if(bodyEnd > bodyStart + 1.0E-4F) {
float cur = bodyStart;
while(cur < bodyEnd - 1.0E-5F) {
float next = Math.min(bodyEnd, cur + bodyUnitRatio);
float uMax = (next - cur) / bodyUnitRatio;
List<Vec3> bodyTilePoints = extractSubPath(points, normalizedDist, cur, next);
renderRibbonCross(bodyTilePoints, origin, right, up, bodyRes, 0.0F, uMax, poseStack, bufferSource);
cur = next;
}
}
ResourceLocation tailRes = ResourceLocation.parse(tailResStr);
ResourceLocation bodyRes = ResourceLocation.parse(bodyResStr);
ResourceLocation headRes = ResourceLocation.parse(headResStr);
// 3. 渲染头部 (Head - 不拉伸,单张贴图完整映射)
if(headRatio > 1.0E-4F) {
List<Vec3> headPoints = extractSubPath(points, normalizedDist, bodyEnd, 1.0F);
renderRibbonCross(headPoints, origin, right, up, headRes, 0.0F, 1.0F, poseStack, bufferSource);
// 1. 渲染尾部 (Tail - 不拉伸,单张贴图完整映射)
if(tailRatio > 1.0E-4F) {
List<Vec3> tailPoints = extractSubPath(points, normalizedDist, 0.0F, tailRatio);
renderRibbonCross(summon, tailPoints, 0.0F, tailRatio, origin, right, up, tailRes, 0.0F, 1.0F, poseStack, bufferSource, partialTick);
}
// 2. 渲染身体 (Body - Tiling 平铺渲染,按 bodyUnitRatio 单元循环平铺)
if(bodyEnd > bodyStart + 1.0E-4F) {
float cur = bodyStart;
while(cur < bodyEnd - 1.0E-5F) {
float next = Math.min(bodyEnd, cur + bodyUnitRatio);
float uMax = (next - cur) / bodyUnitRatio;
List<Vec3> bodyTilePoints = extractSubPath(points, normalizedDist, cur, next);
renderRibbonCross(summon, bodyTilePoints, cur, next, origin, right, up, bodyRes, 0.0F, uMax, poseStack, bufferSource, partialTick);
cur = next;
}
}
// 3. 渲染头部 (Head - 不拉伸,单张贴图完整映射)
if(headRatio > 1.0E-4F) {
List<Vec3> headPoints = extractSubPath(points, normalizedDist, bodyEnd, 1.0F);
renderRibbonCross(summon, headPoints, bodyEnd, 1.0F, origin, right, up, headRes, 0.0F, 1.0F, poseStack, bufferSource, partialTick);
}
}
private static List<Vec3> computePoints(Vec3 hand, Vec3 dir, Vec3 up, float progress, double range, double height, double bend, boolean reverse, int segments) {
float phase = 1.0F - Math.abs(progress * 2.0F - 1.0F);
float s = easeInOut(phase);
@@ -176,63 +187,70 @@ public class ClientWhip {
return result;
}
private static void renderRibbonCross(List<Vec3> points, Vec3 origin, Vec3 right, Vec3 up, ResourceLocation res, float uMin, float uMax, PoseStack poseStack, MultiBufferSource bufferSource) {
renderRibbon(points, origin, right, res, uMin, uMax, poseStack, bufferSource);
renderRibbon(points, origin, up, res, uMin, uMax, poseStack, bufferSource);
private void renderRibbonCross(StaticSummon summon, List<Vec3> points, float segStartProgress, float segEndProgress, Vec3 origin, Vec3 right, Vec3 up, ResourceLocation res, float uMin, float uMax, PoseStack poseStack, MultiBufferSource bufferSource, float partialTick) {
renderRibbon(summon, points, segStartProgress, segEndProgress, origin, right, res, uMin, uMax, poseStack, bufferSource, partialTick);
renderRibbon(summon, points, segStartProgress, segEndProgress, origin, up, res, uMin, uMax, poseStack, bufferSource, partialTick);
}
private void renderRibbon(StaticSummon summon, List<Vec3> points, float segStartProgress, float segEndProgress, Vec3 origin, Vec3 widthDir, ResourceLocation res, float uMin, float uMax, PoseStack poseStack, MultiBufferSource bufferSource, float partialTick) {
if(points.size() < 2) return;
VertexConsumer consumer = bufferSource.getBuffer(ModRenderTypes.entityTranslucentEmissive(res));
Vec3 halfWidth = widthDir.normalize().scale(WIDTH * 0.5F);
double subLength = 0.0D;
double[] distances = new double[points.size()];
for(int i = 1; i < points.size(); i++) {
subLength += points.get(i).distanceTo(points.get(i - 1));
distances[i] = subLength;
}
if(subLength < 1.0E-5D) return;
private static void renderRibbon(List<Vec3> points, Vec3 origin, Vec3 widthDir, ResourceLocation res, float uMin, float uMax, PoseStack poseStack, MultiBufferSource bufferSource) {
if(points.size() < 2) return;
VertexConsumer consumer = bufferSource.getBuffer(ModRenderTypes.entityTranslucentEmissive(res));
Vec3 halfWidth = widthDir.normalize().scale(WIDTH * 0.5F);
double subLength = 0.0D;
double[] distances = new double[points.size()];
for(int i = 0; i < points.size() - 1; i++) {
Vec3 p0 = points.get(i);
Vec3 p1 = points.get(i + 1);
Vec3 tangent = p1.subtract(p0);
if(tangent.lengthSqr() < 1.0E-6D) continue;
for(int i = 1; i < points.size(); i++) {
subLength += points.get(i).distanceTo(points.get(i - 1));
distances[i] = subLength;
}
if(subLength < 1.0E-5D) return;
Vec3 a = p0.add(halfWidth).subtract(origin);
Vec3 b = p0.subtract(halfWidth).subtract(origin);
Vec3 c = p1.subtract(halfWidth).subtract(origin);
Vec3 d = p1.add(halfWidth).subtract(origin);
float u0 = uMin + (float)(distances[i] / subLength) * (uMax - uMin);
float u1 = uMin + (float)(distances[i + 1] / subLength) * (uMax - uMin);
for(int i = 0; i < points.size() - 1; i++) {
Vec3 p0 = points.get(i);
Vec3 p1 = points.get(i + 1);
Vec3 tangent = p1.subtract(p0);
if(tangent.lengthSqr() < 1.0E-6D) continue;
float localProgress0 = (float)(distances[i] / subLength);
float localProgress1 = (float)(distances[i + 1] / subLength);
float globalProgress0 = Mth.lerp(localProgress0, segStartProgress, segEndProgress);
float globalProgress1 = Mth.lerp(localProgress1, segStartProgress, segEndProgress);
Vec3 a = p0.add(halfWidth).subtract(origin);
Vec3 b = p0.subtract(halfWidth).subtract(origin);
Vec3 c = p1.subtract(halfWidth).subtract(origin);
Vec3 d = p1.add(halfWidth).subtract(origin);
float u0 = uMin + (float)(distances[i] / subLength) * (uMax - uMin);
float u1 = uMin + (float)(distances[i + 1] / subLength) * (uMax - uMin);
Vector4f color0 = getVertexColor(summon, globalProgress0, partialTick);
Vector4f color1 = getVertexColor(summon, globalProgress1, partialTick);
addVertex(consumer, poseStack, a, u0, 0.0F);
addVertex(consumer, poseStack, b, u0, 1.0F);
addVertex(consumer, poseStack, c, u1, 1.0F);
addVertex(consumer, poseStack, d, u1, 0.0F);
}
addVertex(consumer, poseStack, a, u0, 0.0F, color0);
addVertex(consumer, poseStack, b, u0, 1.0F, color0);
addVertex(consumer, poseStack, c, u1, 1.0F, color1);
addVertex(consumer, poseStack, d, u1, 0.0F, color1);
}
}
private static void addVertex(VertexConsumer consumer, PoseStack poseStack, Vec3 pos, float u, float v) {
consumer.addVertex(poseStack.last().pose(), (float)pos.x, (float)pos.y, (float)pos.z)
.setColor(1.0F, 1.0F, 1.0F, 1.0F)
.setUv(u, v)
.setOverlay(OverlayTexture.NO_OVERLAY)
.setLight(LightTexture.FULL_BRIGHT)
.setNormal(0.0F, 1.0F, 0.0F);
}
private static void addVertex(VertexConsumer consumer, PoseStack poseStack, Vec3 pos, float u, float v, Vector4f color) {
consumer.addVertex(poseStack.last().pose(), (float)pos.x, (float)pos.y, (float)pos.z)
.setColor(color.x(), color.y(), color.z(), color.w())
.setUv(u, v)
.setOverlay(OverlayTexture.NO_OVERLAY)
.setLight(LightTexture.FULL_BRIGHT)
.setNormal(0.0F, 1.0F, 0.0F);
}
private static Vec3 readVec3(CompoundTag tag, String prefix, Vec3 fallback) {
String x = prefix + "X";
String y = prefix + "Y";
String z = prefix + "Z";
if(!tag.contains(x) || !tag.contains(y) || !tag.contains(z)) return fallback;
return new Vec3(tag.getDouble(x), tag.getDouble(y), tag.getDouble(z));
}
private static Vec3 readVec3(CompoundTag tag, String prefix, Vec3 fallback) {
String x = prefix + "X";
String y = prefix + "Y";
String z = prefix + "Z";
if(!tag.contains(x) || !tag.contains(y) || !tag.contains(z)) return fallback;
return new Vec3(tag.getDouble(x), tag.getDouble(y), tag.getDouble(z));
}
private static float easeInOut(float value) {
return value < 0.5F ? 2.0F * value * value : 1.0F - (float)Math.pow(-2.0F * value + 2.0F, 2.0D) / 2.0F;
}
};
private static float easeInOut(float value) {
return value < 0.5F ? 2.0F * value * value : 1.0F - (float)Math.pow(-2.0F * value + 2.0F, 2.0D) / 2.0F;
}
}
@@ -36,7 +36,7 @@ public class RobeModel extends HumanoidArmorModel<LivingEntity> {
.texOffs(46, 0).addBox(-2.5F, 0.0F, -2.5F, 5.0F, 5.0F, 1.0F, new CubeDeformation(0.0F))
.texOffs(76, 0).addBox(-3.8F, 0.5F, -2.8F, 2.0F, 6.0F, 1.0F, new CubeDeformation(0.0F))
.texOffs(76, 0).mirror().addBox(1.8F, 0.5F, -2.8F, 2.0F, 6.0F, 1.0F, new CubeDeformation(0.0F)).mirror(false)
.texOffs(60, 0).addBox(-1.0F, 4.0F, -3.2F, 2.0F, 2.0F, 1.0F, new CubeDeformation(0.0F))
.texOffs(60, 0).addBox(-1.0F, 2.0F, -3.2F, 2.0F, 2.0F, 1.0F, new CubeDeformation(0.0F))
.texOffs(68, 0).addBox(-1.0F, 6.0F, -2.5F, 2.0F, 6.0F, 1.0F, new CubeDeformation(0.0F)),
PartPose.ZERO
);
@@ -69,7 +69,7 @@ public class RobeModel extends HumanoidArmorModel<LivingEntity> {
.texOffs(64, 36).addBox(-3.0F, 6.0F, -3.0F, 5.0F, 6.0F, 6.0F, new CubeDeformation(0.0F))
.texOffs(10, 52).addBox(-2.4F, 0.0F, -2.9F, 2.0F, 6.0F, 1.0F, new CubeDeformation(0.0F))
.texOffs(30, 52).addBox(-3.3F, 6.0F, -1.5F, 1.0F, 6.0F, 3.0F, new CubeDeformation(0.0F)),
PartPose.offset(-1.9F, 12.0F, 0.0F)
PartPose.offset(-2.0F, 12.0F, 0.0F)
);
// 左腿 (长袍内衬 + 左半侧裙摆,随左腿前后摆动)
@@ -79,7 +79,7 @@ public class RobeModel extends HumanoidArmorModel<LivingEntity> {
.texOffs(64, 36).mirror().addBox(-2.0F, 6.0F, -3.0F, 5.0F, 6.0F, 6.0F, new CubeDeformation(0.0F)).mirror(false)
.texOffs(10, 52).mirror().addBox(0.4F, 0.0F, -2.9F, 2.0F, 6.0F, 1.0F, new CubeDeformation(0.0F)).mirror(false)
.texOffs(30, 52).mirror().addBox(2.3F, 6.0F, -1.5F, 1.0F, 6.0F, 3.0F, new CubeDeformation(0.0F)).mirror(false),
PartPose.offset(1.9F, 12.0F, 0.0F)
PartPose.offset(2.0F, 12.0F, 0.0F)
);
return LayerDefinition.create(meshdefinition, 128, 128);
@@ -246,6 +246,7 @@ public class ModCreativeModeTabs {
output.accept(ModItems.STARDUST_DRAGON_STAFF.get());
output.accept(ModItems.STARDUST_CELL_STAFF.get());
output.accept(ModItems.POSSESSION.get());
output.accept(ModItems.KALEIDOSCOPE.get());
output.accept(ModItems.SUMMONING_POTION.get());
}).build());
}
@@ -47,7 +47,7 @@ public class BetsysCurseEffect extends MobEffect {
AttributeInstance armor = entity.getAttribute(Attributes.ARMOR);
if(armor != null) {
armor.addTransientModifier(new AttributeModifier(
armor.addOrUpdateTransientModifier(new AttributeModifier(
ARMOR_REDUCTION_ID,
-reduction,
AttributeModifier.Operation.ADD_VALUE
@@ -42,7 +42,7 @@ public class IchorEffect extends MobEffect {
AttributeInstance armor = entity.getAttribute(Attributes.ARMOR);
if(armor != null) {
armor.addTransientModifier(new AttributeModifier(
armor.addOrUpdateTransientModifier(new AttributeModifier(
ARMOR_REDUCTION_ID,
-reduction,
AttributeModifier.Operation.ADD_VALUE
@@ -60,7 +60,8 @@ public class StaticSummonBehaviors {
public static final String STARDUST_DRAGON_STAFF = "stardust_dragon_staff";
public static final String STARDUST_CELL_STAFF = "stardust_cell_staff";
public static final String STARDUST_CELL_STUCK_PROJECTILE = "stardust_cell_stuck_projectile";
public static final String POSSESSION = "possession";
public static final String WHIP = "whip";
public static final String KALEIDOSCOPE = "kaleidoscope";
public static final String POSSESSION_VISION = "possession_vision";
public static final String NIGHTGLOW_PROJECTILE = "nightglow_projectile";
public static final String ARC_SURGE_LIGHTNING = "arc_surge_lightning";
@@ -126,7 +127,8 @@ public class StaticSummonBehaviors {
BEHAVIORS.put(STARDUST_DRAGON_STAFF, StardustDragonStaff.SUMMON_BEHAVIOR);
BEHAVIORS.put(STARDUST_CELL_STAFF, StardustCellStaff.SUMMON_BEHAVIOR);
BEHAVIORS.put(STARDUST_CELL_STUCK_PROJECTILE, StardustCellStaff.SUMMON_BEHAVIOR2);
BEHAVIORS.put(POSSESSION, Whip.SUMMON_BEHAVIOR);
BEHAVIORS.put(WHIP, Whip.SUMMON_BEHAVIOR);
BEHAVIORS.put(KALEIDOSCOPE, Whip.SUMMON_BEHAVIOR);
BEHAVIORS.put(POSSESSION_VISION, Possession.SUMMON_BEHAVIOR);
BEHAVIORS.put(NIGHTGLOW_PROJECTILE, Nightglow.SUMMON_BEHAVIOR);
BEHAVIORS.put(ARC_SURGE_LIGHTNING, ArcSurge.SUMMON_BEHAVIOR);
@@ -21,6 +21,7 @@ import com.lzxnone.terraria.item.weapon.RangedWeapon;
import com.lzxnone.terraria.item.weapon.Weapon;
import com.lzxnone.terraria.item.weapon.melee.DevilsDevastation;
import com.lzxnone.terraria.item.weapon.summon.minion.StardustCellStaff;
import com.lzxnone.terraria.item.weapon.summon.whip.Kaleidoscope;
import com.lzxnone.terraria.item.weapon.summon.whip.Possession;
import com.lzxnone.terraria.utils.ParticleUtil;
import net.minecraft.nbt.CompoundTag;
@@ -215,6 +216,8 @@ public class EntityEventHandler {
public static void onLivingDamagePost(LivingDamageEvent.Post event) {
//支配之鞭 预兆标记
Possession.markEvent(event);
//万花筒 标记攻击粒子
Kaleidoscope.markEvent(event);
if(event.getEntity() instanceof Player player) {
//无敌时间
@@ -60,7 +60,7 @@ public class LzxnoneTerrariaJeiPlugin implements IModPlugin {
);
registration.addItemStackInfo(
new ItemStack(ModItems.ARMOR_POLISH.get()),
Component.translatable("jei.lzxnoneterraria.info.armor_polish")
Component.translatable("jei.lzxnoneterraria.info.armor_polish")
);
registration.addItemStackInfo(
new ItemStack(ModItems.MEGAPHONE.get()),
@@ -20,6 +20,7 @@ import com.lzxnone.terraria.item.weapon.ranged.gun.*;
import com.lzxnone.terraria.item.weapon.summon.minion.StardustDragonStaff;
import com.lzxnone.terraria.item.weapon.summon.minion.StardustCellStaff;
import com.lzxnone.terraria.item.weapon.summon.minion.Terraprisma;
import com.lzxnone.terraria.item.weapon.summon.whip.Kaleidoscope;
import com.lzxnone.terraria.item.weapon.summon.whip.Possession;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.Item;
@@ -107,6 +108,7 @@ public class ModItems {
public static final DeferredItem<Item> STARDUST_DRAGON_STAFF = ITEMS.register("stardust_dragon_staff", StardustDragonStaff::new);
public static final DeferredItem<Item> STARDUST_CELL_STAFF = ITEMS.register("stardust_cell_staff", StardustCellStaff::new);
public static final DeferredItem<Item> POSSESSION = ITEMS.register("possession", Possession::new);
public static final DeferredItem<Item> KALEIDOSCOPE = ITEMS.register("kaleidoscope", Kaleidoscope::new);
//近战武器 灾厄
public static final DeferredItem<Item> DEVILS_DEVASTATION = ITEMS.register("devils_devastation", DevilsDevastation::new);
@@ -59,9 +59,7 @@ public class AccessoryUtil {
if(instance == null) return;
AttributeModifier existing = instance.getModifier(attributeModifier.id());
if(current.containsEntry(attribute, attributeModifier)) {
if(existing == null) {
instance.addTransientModifier(attributeModifier);
}else if(existing.amount() != attributeModifier.amount() || existing.operation() != attributeModifier.operation()) {
if(existing == null || existing.amount() != attributeModifier.amount() || existing.operation() != attributeModifier.operation()) {
instance.addOrUpdateTransientModifier(attributeModifier);
}
}else if(existing != null) {
@@ -371,6 +369,8 @@ public class AccessoryUtil {
//为目标挂载护甲/护甲韧性减小修饰符(返回是否实际挂载了)
public static boolean applyTargetArmorModifiers(LivingEntity attacker, LivingEntity target) {
removeTargetArmorModifiers(target);
double[] armorReduction = {0.0D};
double[] toughnessReduction = {0.0D};
AccessoryUtil.forEachAccessory(attacker, (accessory, stack) -> {
@@ -384,14 +384,14 @@ public class AccessoryUtil {
if(armorReduction[0] > 0.0D) {
AttributeInstance armor = target.getAttribute(Attributes.ARMOR);
if(armor != null) {
armor.addTransientModifier(new AttributeModifier(TARGET_ARMOR_PIERCE_ID, -armorReduction[0], AttributeModifier.Operation.ADD_VALUE));
armor.addOrUpdateTransientModifier(new AttributeModifier(TARGET_ARMOR_PIERCE_ID, -armorReduction[0], AttributeModifier.Operation.ADD_VALUE));
applied = true;
}
}
if(toughnessReduction[0] > 0.0D) {
AttributeInstance toughness = target.getAttribute(Attributes.ARMOR_TOUGHNESS);
if(toughness != null) {
toughness.addTransientModifier(new AttributeModifier(TARGET_ARMOR_TOUGHNESS_PIERCE_ID, -toughnessReduction[0], AttributeModifier.Operation.ADD_VALUE));
toughness.addOrUpdateTransientModifier(new AttributeModifier(TARGET_ARMOR_TOUGHNESS_PIERCE_ID, -toughnessReduction[0], AttributeModifier.Operation.ADD_VALUE));
applied = true;
}
}
@@ -613,4 +613,26 @@ public class AccessoryUtil {
}
}
}
//鞭子标记槽位加成:累加所有饰品的槽位加成
public static int getWhipSlotBonus(LivingEntity entity) {
if(entity == null) return 0;
int[] bonus = {0};
AccessoryUtil.forEachAccessory(entity, (accessory, stack) -> {
if(accessory instanceof WhipSlotModifier modifier) {
bonus[0] += modifier.getWhipSlotBonus(stack, entity);
}
});
return bonus[0];
}
//施加者最大鞭子标记数:基础 1 个槽位 + 饰品槽位加成
public static int getMaxWhipMarks(LivingEntity entity) {
return Math.max(1, 1 + getWhipSlotBonus(entity));
}
//最大鞭子标记槽位(别名)
public static int getMaxWhipSlots(LivingEntity entity) {
return getMaxWhipMarks(entity);
}
}
@@ -0,0 +1,9 @@
package com.lzxnone.terraria.item.effect;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.item.ItemStack;
public interface WhipSlotModifier {
// 鞭子标记槽位加成
int getWhipSlotBonus(ItemStack stack, LivingEntity entity);
}
@@ -81,28 +81,45 @@ public class FallenStar extends Item {
);
if(players.isEmpty()) return false;
ServerPlayer player = players.getFirst();
// 1. 标准包围盒碰撞检测捡起
for (ServerPlayer player : players) {
if (player.getBoundingBox().intersects(summon.getBoundingBox())) {
ItemStack stack = new ItemStack(ModItems.FALLEN_STAR.get());
if (player.getInventory().add(stack)) {
player.take(summon, 1);
player.containerMenu.broadcastChanges();
player.playNotifySound(
SoundEvents.ITEM_PICKUP,
SoundSource.PLAYERS,
0.2F,
((player.getRandom().nextFloat() - player.getRandom().nextFloat()) * 0.7F + 1.0F) * 2.0F
);
onDied(summon);
return true;
}
}
}
double attractRange = Math.max(AccessoryUtil.getStarPickupRange(player), MIN_ATTRACT_RADIUS);
Vec3 dir = player.getBoundingBox().getCenter().subtract(summon.position());
double dist = dir.length();
if(dist <= attractRange) {
summon.setDeltaMovement(dir.scale(ATTRACT_SPEED));
// 2. 吸引逻辑(保持原有吸引范围,寻找最近的可吸引玩家)
ServerPlayer closestPlayer = null;
double closestDistSq = Double.MAX_VALUE;
for (ServerPlayer player : players) {
double distSq = summon.distanceToSqr(player);
if (distSq < closestDistSq) {
closestDistSq = distSq;
closestPlayer = player;
}
}
if(dist <= PICKUP_RADIUS) {
ItemStack stack = new ItemStack(ModItems.FALLEN_STAR.get());
if(!player.getInventory().add(stack)) return false;
player.take(summon, 1);
player.containerMenu.broadcastChanges();
player.playNotifySound(
SoundEvents.ITEM_PICKUP,
SoundSource.PLAYERS,
0.2F,
((player.getRandom().nextFloat() - player.getRandom().nextFloat()) * 0.7F + 1.0F) * 2.0F
);
onDied(summon);
return true;
if (closestPlayer != null) {
double attractRange = Math.max(AccessoryUtil.getStarPickupRange(closestPlayer), MIN_ATTRACT_RADIUS);
Vec3 dir = closestPlayer.getBoundingBox().getCenter().subtract(summon.position());
double dist = dir.length();
if (dist <= attractRange) {
summon.setDeltaMovement(dir.scale(ATTRACT_SPEED));
}
}
return false;
}
};
@@ -54,7 +54,7 @@ public class ManaStar extends Item {
summon.getEntityData().set(StaticSummon.AGE, age + 1);
}
private boolean tryPickup(StaticSummon summon) {
private boolean tryPickup(StaticSummon summon) {
List<ServerPlayer> players = summon.level().getEntitiesOfClass(
ServerPlayer.class,
summon.getBoundingBox().inflate(MAX_PICKUP_RADIUS),
@@ -62,22 +62,39 @@ public class ManaStar extends Item {
);
if(players.isEmpty()) return false;
ServerPlayer player = players.getFirst();
CompoundTag customData = summon.getEntityData().get(StaticSummon.CUSTOM_DATA);
double attractRange = Math.max(AccessoryUtil.getStarPickupRange(player), customData.contains("min_attract_range") ? customData.getDouble("min_attract_range") : 4.0D);
Vec3 dir = player.getBoundingBox().getCenter().subtract(summon.position());
double dist = dir.length();
if(dist <= attractRange) {
summon.setDeltaMovement(dir.scale(ATTRACT_SPEED));
// 1. 标准包围盒碰撞检测捡起
for (ServerPlayer player : players) {
if (player.getBoundingBox().intersects(summon.getBoundingBox())) {
int amount = customData.contains("mana") ? customData.getInt("mana") : 0;
PlayerMana.recoverMana(player, amount);
player.addEffect(new MobEffectInstance(ModEffects.MANA_SURGE, MANA_SURGE_DURATION_TICKS, 0));
onDied(summon);
return true;
}
}
if(dist <= PICKUP_RADIUS) {
int amount = customData.contains("mana") ? customData.getInt("mana") : 0;
PlayerMana.recoverMana(player, amount);
player.addEffect(new MobEffectInstance(ModEffects.MANA_SURGE, MANA_SURGE_DURATION_TICKS, 0));
onDied(summon);
return true;
// 2. 吸引逻辑(保持原有基础吸引范围不变,寻找最近的可吸引玩家)
ServerPlayer closestPlayer = null;
double closestDistSq = Double.MAX_VALUE;
for (ServerPlayer player : players) {
double distSq = summon.distanceToSqr(player);
if (distSq < closestDistSq) {
closestDistSq = distSq;
closestPlayer = player;
}
}
if (closestPlayer != null) {
double attractRange = Math.max(AccessoryUtil.getStarPickupRange(closestPlayer), customData.contains("min_attract_range") ? customData.getDouble("min_attract_range") : 4.0D);
Vec3 dir = closestPlayer.getBoundingBox().getCenter().subtract(summon.position());
double dist = dir.length();
if (dist <= attractRange) {
summon.setDeltaMovement(dir.scale(ATTRACT_SPEED));
}
}
return false;
}
};
@@ -9,6 +9,7 @@ import com.lzxnone.terraria.entity.summon.StaticSummonBehaviors;
import com.lzxnone.terraria.item.IItemWaveBehavior;
import com.lzxnone.terraria.particle.DustParticleOptions;
import com.lzxnone.terraria.particle.ModParticles;
import net.minecraft.core.particles.ParticleTypes;
import com.lzxnone.terraria.ui.config.ConfigListItem;
import com.lzxnone.terraria.ui.config.IConfigData;
import com.lzxnone.terraria.ui.config.struct.ConfigDouble;
@@ -215,7 +216,12 @@ public class Volcano extends MeleeWeapon {
ParticleUtil.addParticles(
(ServerLevel) target.level(), ModParticles.EXPLODE_PARTICLE.get(),
new Vec3(target.getX(), target.getY() + target.getBbHeight() / 2.0, target.getZ()), new Vec3(0, 0, 0),
0.2, (int) (30 + Math.random() * 30)
0.2, (int) (2 + Math.random() * 2)
);
ParticleUtil.addParticles(
(ServerLevel) target.level(), ParticleTypes.LAVA,
new Vec3(target.getX(), target.getY() + target.getBbHeight() / 2.0, target.getZ()), new Vec3(0.4, 0.4, 0.4),
0.2, (int) (12 + Math.random() * 8)
);
ParticleUtil.addParticles(
(ServerLevel) target.level(), PARTICLE,
@@ -0,0 +1,242 @@
package com.lzxnone.terraria.item.weapon.summon.whip;
import com.lzxnone.terraria.LzxnoneTerraria;
import com.lzxnone.terraria.attachment.ModAttachments;
import com.lzxnone.terraria.attachment.TargetMarks;
import com.lzxnone.terraria.entity.summon.StaticSummon;
import com.lzxnone.terraria.entity.summon.StaticSummonBehaviors;
import com.lzxnone.terraria.item.weapon.summon.minion.MinionWeapon;
import com.lzxnone.terraria.item.weapon.summon.sentry.SentryWeapon;
import com.lzxnone.terraria.particle.DustParticleOptions;
import com.lzxnone.terraria.particle.ModParticles;
import com.lzxnone.terraria.particle.StarlightParticleOptions;
import com.lzxnone.terraria.ui.config.ConfigListItem;
import com.lzxnone.terraria.ui.config.IConfigData;
import com.lzxnone.terraria.ui.config.struct.ConfigDouble;
import com.lzxnone.terraria.ui.config.struct.ConfigFloat;
import com.lzxnone.terraria.ui.config.struct.ConfigInt;
import com.lzxnone.terraria.ui.config.struct.ConfigStruct;
import com.lzxnone.terraria.utils.ParticleUtil;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Rarity;
import net.minecraft.world.item.Tiers;
import net.minecraft.world.level.Level;
import net.minecraft.world.phys.Vec3;
import net.neoforged.neoforge.event.entity.living.LivingDamageEvent;
import org.joml.Vector3f;
public class Kaleidoscope extends Whip {
public static final StarlightParticleOptions STARLIGHT_PARTICLE = new StarlightParticleOptions(
0.8f,
0.5f,
25,
ModParticles.COLORFUL_PARTICLE.colors
);
public static final DustParticleOptions TIP_PARTICLE = new DustParticleOptions(
0.5f,
0.5f,
40,
true,
ModParticles.COLORFUL_PARTICLE.colors
);
private static final ConfigDouble RANGE = new ConfigDouble("weapon.kaleidoscope.range", "kaleidoscope_range", 32.0D, 1.0D, 256.0D);
private static final ConfigFloat DAMAGE = new ConfigFloat("weapon.kaleidoscope.damage", "kaleidoscope_damage", 15.0F, 0.0F, 8388600.0F);
private static final ConfigInt ROTATE = new ConfigInt("weapon.kaleidoscope.rotate", "kaleidoscope_rotate", 60, 0, 360);
private static final ConfigInt MARK_DURATION = new ConfigInt("weapon.kaleidoscope.mark_duration", "kaleidoscope_mark_duration", 80, 1, 72000);
private static final ConfigFloat TAG_DAMAGE = new ConfigFloat("weapon.kaleidoscope.tag_damage", "kaleidoscope_tag_damage", 2.0F, 0.0F, 8388600.0F);
private static final ConfigInt TAG_CRIT = new ConfigInt("weapon.kaleidoscope.tag_crit", "kaleidoscope_tag_crit", 10, 0, 100);
private static final ConfigFloat DAMAGE_FALLOFF = new ConfigFloat("weapon.kaleidoscope.damage_falloff", "kaleidoscope_damage_falloff", 0.8F, 0.0F, 1.0F);
public Kaleidoscope() {
super(Tiers.DIAMOND, new Item.Properties().stacksTo(1).rarity(Rarity.RARE));
}
@Override
protected double getRange() {
return RANGE.get();
}
@Override
protected String getTailRes(StaticSummon summon) {
return "lzxnoneterraria:textures/vfx/kaleidoscope_projectile_tail.png";
}
@Override
protected String getBodyRes(StaticSummon summon) {
return "lzxnoneterraria:textures/vfx/kaleidoscope_projectile_body.png";
}
@Override
protected String getHeadRes(StaticSummon summon) {
return "lzxnoneterraria:textures/vfx/kaleidoscope_projectile_head.png";
}
@Override
protected float getTailRatio() {
return 0.06F;
}
@Override
protected float getHeadRatio() {
return 0.06F;
}
@Override
protected float getBodyUnitRatio() {
return 0.18F;
}
@Override
protected float getDamage() {
return DAMAGE.get();
}
@Override
protected float getDamageFalloff() {
return DAMAGE_FALLOFF.get();
}
@Override
public float getTagDamage() {
return TAG_DAMAGE.get();
}
@Override
public int getTagCrit() {
return TAG_CRIT.get();
}
@Override
protected int getLifetime() {
return 12;
}
@Override
protected int getRotateAngle() {
return ROTATE.get();
}
@Override
protected String getBehavior() {
return StaticSummonBehaviors.KALEIDOSCOPE;
}
@Override
protected int getUseTime() {
return 30;
}
@Override
protected int getInvulnerableTime() {
return 10;
}
@Override
protected void onHitTarget(StaticSummon summon, Entity target) {
if(summon.level() instanceof ServerLevel serverLevel) {
LivingEntity owner = summon.getOwner() instanceof LivingEntity living ? living : null;
applyMark(
target,
owner,
TargetMarks.KALEIDOSCOPE,
new TargetMarks.Mark(
serverLevel.getGameTime(),
MARK_DURATION.get(),
0,
owner == null ? null : owner.getUUID(),
summon.getEntityData().get(StaticSummon.STACK_SOURCE),
getTagDamage(),
getTagCrit()
)
);
ParticleUtil.addParticles(
serverLevel, ModParticles.COLORFUL_PARTICLE,
target.getBoundingBox().getCenter(), new Vec3(0, 0, 0),
0.15, 8
);
}
}
@Override
protected void onTick(StaticSummon summon) {
if(summon.level() instanceof ServerLevel serverLevel) {
Vec3 tip = getTipPosition(summon);
ParticleUtil.addParticles(
serverLevel, TIP_PARTICLE,
tip, Vec3.ZERO,
0.02, 1
);
}
}
@Override
protected void shoot(Level level, Player player, InteractionHand hand, ItemStack stack) {
super.shoot(level, player, hand, stack);
if(level instanceof ServerLevel serverLevel) {
ParticleUtil.addParticles(
serverLevel, ModParticles.COLORFUL_PARTICLE,
player.getBoundingBox().getCenter(), Vec3.ZERO,
0.2, 8
);
}
}
public static void markEvent(LivingDamageEvent.Post event) {
LivingEntity target = event.getEntity();
if(!(target.level() instanceof ServerLevel serverLevel)) return;
TargetMarks marks = target.getData(ModAttachments.TARGET_MARKS);
TargetMarks.Mark mark = marks.getMarks().get(TargetMarks.KALEIDOSCOPE);
if(mark == null) return;
if(mark.getDuration() > 0 && serverLevel.getGameTime() - mark.getStartTime() >= mark.getDuration()) {
TargetMarks copiedMarks = marks.copy();
copiedMarks.getMarks().remove(TargetMarks.KALEIDOSCOPE);
target.setData(ModAttachments.TARGET_MARKS, copiedMarks);
return;
}
Entity damageEntity = event.getSource().getDirectEntity();
if(!(damageEntity instanceof StaticSummon summon)) return;
ItemStack sourceStack = summon.getEntityData().get(StaticSummon.STACK_SOURCE);
if(sourceStack.isEmpty() || !(sourceStack.getItem() instanceof MinionWeapon || sourceStack.getItem() instanceof SentryWeapon)) return;
ParticleUtil.addParticles(
serverLevel, STARLIGHT_PARTICLE,
target.getBoundingBox().getCenter(), Vec3.ZERO,
0.2, 6
);
}
public static final IConfigData CONFIG_DATA = new IConfigData() {
@Override
public void onConfigLoad() {
ConfigStruct.loadAll(
RANGE,
DAMAGE,
ROTATE,
MARK_DURATION,
TAG_DAMAGE,
TAG_CRIT,
DAMAGE_FALLOFF
);
}
};
public static final ConfigListItem CONFIG_LIST_ITEM = new ConfigListItem(
"kaleidoscope",
ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "textures/item/kaleidoscope.png"),
Component.translatable("item.lzxnoneterraria.kaleidoscope"),
CONFIG_DATA
);
}
@@ -49,7 +49,7 @@ public class Possession extends Whip {
private static final ConfigFloat BEAM_DAMAGE = new ConfigFloat("weapon.possession.beam_damage", "possession_beam_damage", 10.0F, 0.0F, 8388600.0F);
private static final ConfigInt PROPHETIC_MARK_DURATION = new ConfigInt("weapon.possession.prophetic_mark_duration", "possession_prophetic_mark_duration", 80, 1, 72000);
public static final ConfigInt MAX_PROPHETIC_MARK_STACKS = new ConfigInt("weapon.possession.max_prophetic_mark_stacks", "possession_max_prophetic_mark_stacks", 3, 0, 1024);
private static final ConfigFloat TAG_DAMAGE = new ConfigFloat("weapon.possession.tag_damage", "possession_tag_damage", 25.0F, 0.0F, 8388600.0F);
private static final ConfigFloat TAG_DAMAGE = new ConfigFloat("weapon.possession.tag_damage", "possession_tag_damage", 2.5F, 0.0F, 8388600.0F);
private static final ConfigInt TAG_CRIT = new ConfigInt("weapon.possession.tag_crit", "possession_tag_crit", 10, 0, 100);
private static final ConfigFloat DAMAGE_FALLOFF = new ConfigFloat("weapon.possession.damage_falloff", "possession_damage_falloff", 0.95F, 0.0F, 1.0F);
@@ -103,12 +103,12 @@ public class Possession extends Whip {
}
@Override
protected float getTagDamage() {
public float getTagDamage() {
return TAG_DAMAGE.get();
}
@Override
protected int getTagCrit() {
public int getTagCrit() {
return TAG_CRIT.get();
}
@@ -208,20 +208,21 @@ public class Possession extends Whip {
@Override
protected void onHitTarget(StaticSummon summon, Entity target) {
if(summon.level() instanceof ServerLevel serverLevel) {
TargetMarks marks = target.getData(ModAttachments.TARGET_MARKS).copy();
marks.getMarks().put(
TargetMarks.PROPHETIC,
LivingEntity owner = summon.getOwner() instanceof LivingEntity living ? living : null;
applyMark(
target,
owner,
TargetMarks.POSSESSION,
new TargetMarks.Mark(
serverLevel.getGameTime(),
PROPHETIC_MARK_DURATION.get(),
0,
summon.getOwner() == null ? null : summon.getOwner().getUUID(),
owner == null ? null : owner.getUUID(),
summon.getEntityData().get(StaticSummon.STACK_SOURCE),
getTagDamage(),
getTagCrit()
)
);
target.setData(ModAttachments.TARGET_MARKS, marks);
ParticleUtil.addParticles(
serverLevel, PARTICLE,
@@ -257,12 +258,12 @@ public class Possession extends Whip {
if(!(target.level() instanceof ServerLevel serverLevel)) return;
TargetMarks marks = target.getData(ModAttachments.TARGET_MARKS);
TargetMarks.Mark mark = marks.getMarks().get(TargetMarks.PROPHETIC);
TargetMarks.Mark mark = marks.getMarks().get(TargetMarks.POSSESSION);
if(mark == null) return;
if(serverLevel.getGameTime() - mark.getStartTime() >= mark.getDuration()) {
TargetMarks copiedMarks = marks.copy();
copiedMarks.getMarks().remove(TargetMarks.PROPHETIC);
copiedMarks.getMarks().remove(TargetMarks.POSSESSION);
target.setData(ModAttachments.TARGET_MARKS, copiedMarks);
return;
}
@@ -283,7 +284,7 @@ public class Possession extends Whip {
TargetMarks copiedMarks = marks.copy();
TargetMarks.Mark copiedMark = mark.copy();
copiedMark.setStacks(copiedMark.getStacks() + 1);
copiedMarks.getMarks().put(TargetMarks.PROPHETIC, copiedMark);
copiedMarks.getMarks().put(TargetMarks.POSSESSION, copiedMark);
target.setData(ModAttachments.TARGET_MARKS, copiedMarks);
}
@@ -7,6 +7,7 @@ import com.lzxnone.terraria.entity.ModEntities;
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.accessory.AccessoryUtil;
import com.lzxnone.terraria.item.weapon.SummonWeapon;
import com.lzxnone.terraria.utils.DamageUtil;
import com.lzxnone.terraria.utils.MathUtil;
@@ -60,9 +61,9 @@ public abstract class Whip extends SummonWeapon {
protected abstract float getDamageFalloff();
protected abstract float getTagDamage();
public abstract float getTagDamage();
protected abstract int getTagCrit();
public abstract int getTagCrit();
public static float applyMarkDamageBonus(Entity target, float damage) {
if(target == null) return damage;
@@ -94,6 +95,14 @@ public abstract class Whip extends SummonWeapon {
return baseCrit + bonus;
}
public static void applyMark(Entity target, LivingEntity applier, String markId, TargetMarks.Mark newMark) {
if(target == null || target.level().isClientSide() || newMark == null || markId == null) return;
int maxSlots = AccessoryUtil.getMaxWhipMarks(applier);
TargetMarks marks = target.getData(ModAttachments.TARGET_MARKS).copy();
marks.addMark(markId, newMark, maxSlots, target.level().getGameTime());
target.setData(ModAttachments.TARGET_MARKS, marks);
}
@Override
public float getTooltipDamage(ItemStack weaponStack, LivingEntity entity) {
float damage = entity instanceof Player player ? DamageUtil.applyPlayerDamageEffects(player, getDamage()) : getDamage();
@@ -126,6 +135,10 @@ public abstract class Whip extends SummonWeapon {
return 0;
}
protected String getBehavior() {
return StaticSummonBehaviors.WHIP;
}
protected void onTick(StaticSummon summon) {}
protected void onHitTarget(StaticSummon summon, Entity target) {}
@@ -233,7 +246,7 @@ public abstract class Whip extends SummonWeapon {
player.getY() + dirs[0].y * offset.z + dirs[1].y * offset.y + dirs[2].y * offset.x,
player.getZ() + dirs[0].z * offset.z + dirs[1].z * offset.y + dirs[2].z * offset.x
));
summon.getEntityData().set(StaticSummon.BEHAVIOR, StaticSummonBehaviors.POSSESSION);
summon.getEntityData().set(StaticSummon.BEHAVIOR, getBehavior());
summon.getEntityData().set(StaticSummon.RENDER_MODE, "custom");
summon.getEntityData().set(StaticSummon.LIFETIME, getLifetime());
@@ -323,6 +336,29 @@ public abstract class Whip extends SummonWeapon {
return sourceStack.getItem() instanceof Whip whip ? whip : null;
}
public static Vec3 getTipPosition(StaticSummon summon) {
Whip whip = getWhip(summon);
if(whip == null) return summon.position();
CompoundTag customData = summon.getEntityData().get(StaticSummon.CUSTOM_DATA);
int lifetime = Math.max(1, summon.getEntityData().get(StaticSummon.LIFETIME));
float progress = Mth.clamp(summon.getEntityData().get(StaticSummon.AGE) / (float)lifetime, 0.0F, 1.0F);
Vec3 hand = summon.position();
Vec3 dir = readVec3(customData, "dir", new Vec3(0.0D, 0.0D, 1.0D)).normalize();
Vec3 up = readVec3(customData, "up", new Vec3(0.0D, 1.0D, 0.0D)).normalize();
if(dir.lengthSqr() < 1.0E-6D) dir = new Vec3(0.0D, 0.0D, 1.0D);
if(up.lengthSqr() < 1.0E-6D) up = new Vec3(0.0D, 1.0D, 0.0D);
double range = customData.contains("range") ? customData.getDouble("range") : whip.getRange();
double height = customData.contains("height") ? customData.getDouble("height") : whip.getHeight();
double bend = customData.contains("bend") ? customData.getDouble("bend") : whip.getBend();
boolean reverse = customData.contains("reverse") && customData.getBoolean("reverse");
List<Vec3> points = computePoints(hand, dir, up, progress, range, height, bend, reverse, SEGMENTS);
return points.isEmpty() ? hand : points.get(points.size() - 1);
}
private static boolean intersectsWhip(List<Vec3> points, Entity target) {
AABB targetBox = target.getBoundingBox().inflate(HITBOX_INFLATE);
for(int i = 0; i < points.size() - 1; i++) {
@@ -0,0 +1,38 @@
package com.lzxnone.terraria.mixin;
import com.lzxnone.terraria.client.item.melee.ClientDevilsDevastation;
import com.lzxnone.terraria.item.ModItems;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.entity.ItemRenderer;
import net.minecraft.client.resources.model.BakedModel;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemDisplayContext;
import net.minecraft.world.item.ItemStack;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(ItemRenderer.class)
public class ItemRendererMixin {
@Inject(method = "render", at = @At("HEAD"))
private void onRenderEffect(ItemStack itemStack, ItemDisplayContext displayContext, boolean leftHand,
PoseStack poseStack, MultiBufferSource bufferSource, int combinedLight,
int combinedOverlay, BakedModel model, CallbackInfo ci) {
// 仅在手持视角下处理(第一人称或第三人称手持),忽略 GUI、掉落物、展示框等
boolean isFirstPerson = displayContext.firstPerson();
boolean isThirdPerson = displayContext == ItemDisplayContext.THIRD_PERSON_RIGHT_HAND ||
displayContext == ItemDisplayContext.THIRD_PERSON_LEFT_HAND;
if(!isFirstPerson && !isThirdPerson) return;
Minecraft mc = Minecraft.getInstance();
Player player = mc.player;
if(player == null || mc.level == null) return;
if(itemStack.is(ModItems.DEVILS_DEVASTATION.get())) {
ClientDevilsDevastation.renderEnergyParticles(poseStack, displayContext, player);
}
}
}
@@ -136,6 +136,7 @@ import com.lzxnone.terraria.item.weapon.ranged.gun.*;
import com.lzxnone.terraria.item.weapon.summon.minion.StardustDragonStaff;
import com.lzxnone.terraria.item.weapon.summon.minion.StardustCellStaff;
import com.lzxnone.terraria.item.weapon.summon.minion.Terraprisma;
import com.lzxnone.terraria.item.weapon.summon.whip.Kaleidoscope;
import com.lzxnone.terraria.item.weapon.summon.whip.Possession;
import java.util.HashMap;
@@ -182,6 +183,7 @@ public class ConfigList {
StardustDragonStaff.CONFIG_LIST_ITEM,
StardustCellStaff.CONFIG_LIST_ITEM,
Possession.CONFIG_LIST_ITEM,
Kaleidoscope.CONFIG_LIST_ITEM,
LastPrism.CONFIG_LIST_ITEM,
BetsyWrath.CONFIG_LIST_ITEM,
LunarFlare.CONFIG_LIST_ITEM,
@@ -51,6 +51,7 @@
"item.lzxnoneterraria.stardust_dragon_staff": "Stardust Dragon Staff",
"item.lzxnoneterraria.stardust_cell_staff": "Stardust Cell Staff",
"item.lzxnoneterraria.possession": "Possession",
"item.lzxnoneterraria.kaleidoscope": "Kaleidoscope",
"item.lzxnoneterraria.musket": "Musket",
"item.lzxnoneterraria.minishark": "Minishark",
"item.lzxnoneterraria.flintlock_pistol": "Flintlock Pistol",
@@ -238,6 +239,7 @@
"tooltip.lzxnoneterraria.devils_devastation.0": "The perfect blade of the Underworld, wielding the power of Brimstone directly.",
"tooltip.lzxnoneterraria.devils_devastation.1": "Humans understand this force as Havoc, the inevitable sundering of all order in fire.",
"tooltip.lzxnoneterraria.devils_devastation.2": "Perhaps this is why the Brimstone Elemental had strength unrivaled by her sisters.",
"tooltip.lzxnoneterraria.devils_devastation.kill_mode_key": "Press [%s] to enter Kill Mode",
"tooltip.lzxnoneterraria.mana_crystal": "Permanently increases maximum mana by 20, up to 200",
"tooltip.lzxnoneterraria.summoning_potion": "Increases minion capacity by %s for 8 minutes",
"tooltip.lzxnoneterraria.mana_regeneration_potion": "Greatly increases mana regeneration rate for 8 minutes",
@@ -397,6 +399,8 @@
"tooltip.lzxnoneterraria.summon_damage_increase": "+%s%% summon damage",
"tooltip.lzxnoneterraria.summon_damage_decrease": "-%s%% summon damage",
"tooltip.lzxnoneterraria.summon_weapon_damage": "Summon Damage: %s",
"tooltip.lzxnoneterraria.whip_tag_damage": "Tag Damage: %s",
"tooltip.lzxnoneterraria.whip_tag_crit": "Tag Critical Strike Chance: %s%%",
"tooltip.lzxnoneterraria.minion_knockback_increase": "+%s%% minion knockback",
"tooltip.lzxnoneterraria.minion_knockback_decrease": "-%s%% minion knockback",
"tooltip.lzxnoneterraria.minion_slot_add": "+%s minion capacity",
@@ -849,6 +853,20 @@
"lzxnoneterraria.configuration.possession_tag_crit.tooltip": "Bonus critical strike chance percentage granted to minions and sentries striking marked enemies",
"lzxnoneterraria.configuration.possession_damage_falloff": "Damage Falloff",
"lzxnoneterraria.configuration.possession_damage_falloff.tooltip": "Multiplicative damage reduction factor for each subsequent enemy struck in a single swing (e.g. 0.95)",
"lzxnoneterraria.configuration.kaleidoscope_range": "Range",
"lzxnoneterraria.configuration.kaleidoscope_range.tooltip": "Maximum whip strike distance",
"lzxnoneterraria.configuration.kaleidoscope_damage": "Damage",
"lzxnoneterraria.configuration.kaleidoscope_damage.tooltip": "Damage dealt by the whip hit",
"lzxnoneterraria.configuration.kaleidoscope_rotate": "Rotate Angle",
"lzxnoneterraria.configuration.kaleidoscope_rotate.tooltip": "Random rotation angle range when casting the whip",
"lzxnoneterraria.configuration.kaleidoscope_mark_duration": "Mark Duration",
"lzxnoneterraria.configuration.kaleidoscope_mark_duration.tooltip": "Duration of the mark applied by Kaleidoscope, in ticks",
"lzxnoneterraria.configuration.kaleidoscope_tag_damage": "Tag Damage",
"lzxnoneterraria.configuration.kaleidoscope_tag_damage.tooltip": "Bonus flat damage granted to minions and sentries striking marked enemies",
"lzxnoneterraria.configuration.kaleidoscope_tag_crit": "Tag Critical Strike Chance",
"lzxnoneterraria.configuration.kaleidoscope_tag_crit.tooltip": "Bonus critical strike chance percentage granted to minions and sentries striking marked enemies",
"lzxnoneterraria.configuration.kaleidoscope_damage_falloff": "Damage Falloff",
"lzxnoneterraria.configuration.kaleidoscope_damage_falloff.tooltip": "Multiplicative damage reduction factor for each subsequent enemy struck in a single swing (e.g. 0.9)",
"lzxnoneterraria.configuration.last_prism_damage": "Damage",
"lzxnoneterraria.configuration.last_prism_damage.tooltip": "Damage per hit",
"lzxnoneterraria.configuration.last_prism_charge_time": "Charge Time",
@@ -51,6 +51,7 @@
"item.lzxnoneterraria.stardust_dragon_staff": "星尘之龙法杖",
"item.lzxnoneterraria.stardust_cell_staff": "星尘细胞法杖",
"item.lzxnoneterraria.possession": "支配之鞭",
"item.lzxnoneterraria.kaleidoscope": "万花筒",
"item.lzxnoneterraria.musket": "火枪",
"item.lzxnoneterraria.minishark": "迷你鲨",
"item.lzxnoneterraria.flintlock_pistol": "燧发枪",
@@ -238,6 +239,7 @@
"tooltip.lzxnoneterraria.devils_devastation.0": "完美的地狱之剑,直接掌握着硫磺火之力。",
"tooltip.lzxnoneterraria.devils_devastation.1": "人类将这种力量理解为浩劫,即一切秩序在火焰之中的必然毁灭。",
"tooltip.lzxnoneterraria.devils_devastation.2": "或许这就是硫磺火元素掌握着她的姐妹所不能匹敌之力量的原因。",
"tooltip.lzxnoneterraria.devils_devastation.kill_mode_key": "按 [%s] 键进入杀戮模式",
"tooltip.lzxnoneterraria.mana_crystal": "永久提升 20 点最大魔力,最高提升到 200",
"tooltip.lzxnoneterraria.summoning_potion": "增加 %s 个仆从栏位,持续 8 分钟",
"tooltip.lzxnoneterraria.mana_regeneration_potion": "极大提升魔力再生速度,持续 8 分钟",
@@ -397,6 +399,8 @@
"tooltip.lzxnoneterraria.summon_damage_increase": "召唤伤害 +%s%%",
"tooltip.lzxnoneterraria.summon_damage_decrease": "召唤伤害 -%s%%",
"tooltip.lzxnoneterraria.summon_weapon_damage": "召唤伤害: %s",
"tooltip.lzxnoneterraria.whip_tag_damage": "标记伤害: %s",
"tooltip.lzxnoneterraria.whip_tag_crit": "标记暴击率: %s%%",
"tooltip.lzxnoneterraria.minion_knockback_increase": "仆从击退 +%s%%",
"tooltip.lzxnoneterraria.minion_knockback_decrease": "仆从击退 -%s%%",
"tooltip.lzxnoneterraria.minion_slot_add": "仆从数量上限 +%s",
@@ -849,6 +853,20 @@
"lzxnoneterraria.configuration.possession_tag_crit.tooltip": "支配之鞭标记赋予仆从和哨兵的额外暴击率(百分比)",
"lzxnoneterraria.configuration.possession_damage_falloff": "伤害衰减系数",
"lzxnoneterraria.configuration.possession_damage_falloff.tooltip": "每次命中一个敌人后,后续击中敌人所承受伤害的衰减比例(如 0.95)",
"lzxnoneterraria.configuration.kaleidoscope_range": "射程",
"lzxnoneterraria.configuration.kaleidoscope_range.tooltip": "鞭子最大抽打距离",
"lzxnoneterraria.configuration.kaleidoscope_damage": "伤害",
"lzxnoneterraria.configuration.kaleidoscope_damage.tooltip": "鞭子命中伤害",
"lzxnoneterraria.configuration.kaleidoscope_rotate": "旋转角度",
"lzxnoneterraria.configuration.kaleidoscope_rotate.tooltip": "鞭子甩出时的随机偏转角范围",
"lzxnoneterraria.configuration.kaleidoscope_mark_duration": "标记持续时间",
"lzxnoneterraria.configuration.kaleidoscope_mark_duration.tooltip": "万花筒标记持续时间(刻)",
"lzxnoneterraria.configuration.kaleidoscope_tag_damage": "标记伤害",
"lzxnoneterraria.configuration.kaleidoscope_tag_damage.tooltip": "万花筒标记赋予仆从和哨兵的额外基础点伤",
"lzxnoneterraria.configuration.kaleidoscope_tag_crit": "标记暴击率",
"lzxnoneterraria.configuration.kaleidoscope_tag_crit.tooltip": "万花筒标记赋予仆从和哨兵的额外暴击率(百分比)",
"lzxnoneterraria.configuration.kaleidoscope_damage_falloff": "伤害衰减系数",
"lzxnoneterraria.configuration.kaleidoscope_damage_falloff.tooltip": "每次命中一个敌人后,后续击中敌人所承受伤害的衰减比例(如 0.9)",
"lzxnoneterraria.configuration.last_prism_damage": "伤害",
"lzxnoneterraria.configuration.last_prism_damage.tooltip": "每次命中伤害",
"lzxnoneterraria.configuration.last_prism_charge_time": "蓄力时间",
@@ -0,0 +1,6 @@
{
"parent": "lzxnoneterraria:item/whip",
"textures": {
"layer0": "lzxnoneterraria:item/kaleidoscope"
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 507 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 285 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 217 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 260 B

@@ -12,6 +12,7 @@
"GuiMixin",
"HumanoidModelMixin",
"ItemInHandRenderMixin",
"ItemRendererMixin",
"UseSpeedMixin"
],
"injectors": {
@@ -42,11 +42,11 @@ displayName="${mod_name}" #mandatory
#credits="" #optional
# The authors of the mod, displayed in the mod UI (optional)
#authors=""
authors="lzxnone"
# The description text for the mod (multi line!) (#mandatory)
description='''
Example mod description.
为我的世界增加了一些泰拉瑞亚的武器
'''
# The [[mixins]] block allows you to declare your mixin config to FML so that it gets loaded.