Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions ALGORITHM.MD
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
- 渲染:按运算结果渲染

## 算法概述
### 中心环绕型
### 中心环绕型
#### 固有转换:经度锁定
- 计算玩家视坐标到目标坐标的位向量(概念上是三维射线的意思)
- 三维变换归一化获得在“单位球壳”上的坐标点
Expand All @@ -17,7 +17,7 @@
- 对球壳上两点(玩家视觉点与目标位置点)进行选择的投影,获得平面点
- 求得视坐标投影点->位坐标投影点的弧度、距离

投影类型
投影类型
: 墨卡托投影
: 艾托夫投影
: 温克尔三重投影(线性混合)
Expand All @@ -40,16 +40,18 @@

该投影逻辑为
: 获取游戏的V(经过视坐标转换)、P矩阵,合为一个转换矩阵
: 将目标坐标包装成带有距离缩放信息的向量(即四维向量,w基础值为1.0f)
: 将目标坐标包装成带有距离缩放信息的向量(即三维上使用的齐次坐标,w基础值为1.0f)
: 使目标四维向量与转换矩阵相乘,得到实际V模式对应信息
: 计算并转换成屏幕坐标(包括边界框限制性取值)

由此,我彻底理解了投影转换的方法,也算是对之前思考的一个进步性回馈——我现在明白为什么会出现坐标转换问题了

将会在第三种投影完成后对第一种投影进行完全重构

> 26.01.26注: 或许我可以先留着中心的投影, 它可能更加符合人的转动倾向

> 一路走来,了解的知识越多,对未知的恐惧就越大——知识是无穷无尽的
>
>
> 我们站在诸位巨人的肩膀上,并渴望着成为巨人

### 经度轴提示型
Expand Down
29 changes: 22 additions & 7 deletions README.MD
Original file line number Diff line number Diff line change
@@ -1,19 +1,34 @@
# Entity Tracker (简体中文|[English](README_EN.MD))
这是一个用于在MC中跟踪实体的HUD模组。
# The Trackers (简体中文|[English](README_EN.MD))
这是一个用于在MC中跟踪实体的纯客户端HUD工具模组。

同时也是一个使用HUD icon标记三维坐标的实用功能库。

作为玩家使用本模组,可以通过模组配置设置需要追踪的实体。

作为开发者使用本模组,可以便捷地声明指针模板,并快速使用模板注册指针并应用。

### 工作原理
使用投影计算在2D屏幕上显示标志以表示实体位置。

详见[算法](ALGORITHM.MD)
在代码层面,额外支持渲染物品。

投影内容详见详见[算法-中文](ALGORITHM.MD)

### 特性
- 直接通过指示显示实体的位置
- 可自定义某实体类型的实体定位
- 可自定义HUD指针
- 直接通过指示图标表示世界上的位置
- 自动扫描附近的实体
- 可自定义指示某种实体
- 可自定义HUD指针样式
- 在代码层面简化屏上HUD图标的创建
- 自动的、可控的指针回收机制
### 作者
[@MakerTechno](https://github.com/MakerTechno)

### 协议
[LGPLv3](https://www.gnu.org/licenses/lgpl-3.0.html)

### 依赖

### 联动
[汇流来世 Confluence Of The Afterlife](https://github.com/MagicHarp/confluence)

28 changes: 21 additions & 7 deletions README_EN.MD
Original file line number Diff line number Diff line change
@@ -1,13 +1,27 @@
# Entity Tracker (English|[简体中文](README.MD))
This is a simple HUD for tracking entities in Minecraft.
# The Trackers (English|[简体中文](README.MD))
This is a client-side HUD mod for tracking entities in Minecraft.

It also serves as a utility library for marking 3D coordinates with HUD icons.

As a player, you can configure the mod to track specific entities.

As a developer, you can conveniently define pointer templates and quickly register and apply them.

### How it works
Using a set of projection, it displays entities' positions in 2D with customized icon.
It uses projection calculations to display icons on the 2D screen representing entity positions.

At the code level, it additionally supports rendering items.

For details on the projection algorithm, see [ALGORITHM (Chinese only)](ALGORITHM.MD) for details.

See [ALGORITHM (Chinese only)](ALGORITHM.MD) for details.
### Features
- Display entities' positions in 2D
- Specific entities tracking
- Customizable HUD pointers
- Display world positions directly with HUD icons
- Automatically scan for nearby entities
- Customizable tracking targets for specific entities
- Customizable HUD pointer styles
- Simplified creation of HUD icons at the code level
- Automatic and controllable pointer recycling mechanism

### Author
[@MakerTechno](https://github.com/MakerTechno)
### License
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ parchment_mappings_version=2024.11.13

minecraft_version=1.21.1
minecraft_version_range=[1.21.1, 1.22)
neo_version=21.1.209
neo_version=21.1.218
neo_version_range=[21.1.0,)
loader_version_range=[4,)

mod_id=the_trackers
mod_name=The Trackers
mod_license=LGPLv3
mod_version=1.21.1-0.2.3
mod_version=1.21.1-0.2.5
mod_group_id=nowebsite.makertechno.the_trackers
mod_authors=MakerTechno
mod_description=To follow the light to where all shadows begin.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
package nowebsite.makertechno.the_trackers.api.component;

import net.minecraft.data.models.model.TextureMapping;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.Item;
import nowebsite.makertechno.the_trackers.client.gui.icons.IconComponentFactory;
import nowebsite.makertechno.the_trackers.client.gui.icons.Icon;
import net.minecraft.world.item.ItemStack;
import nowebsite.makertechno.the_trackers.client.gui.components.BasicComponentFactory;
import nowebsite.makertechno.the_trackers.client.gui.components.IRenderElement;
import nowebsite.makertechno.the_trackers.client.gui.components.Icon;
import nowebsite.makertechno.the_trackers.client.gui.components.ItemComponent;
import nowebsite.makertechno.the_trackers.client.gui.provider.TextureCache;
import nowebsite.makertechno.the_trackers.core.tool.TextureBuildTool;

import javax.annotation.Nullable;
import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.function.Supplier;

Expand All @@ -19,16 +21,17 @@
public class ComponentBuilder {
private ComponentType type = ComponentType.DIRECT;
private String cursorPattern = null;
private Supplier<Icon> icon1 = () -> Icon.NONE;
private Supplier<IRenderElement> icon1 = () -> Icon.NONE;
private String component1Pattern = null;
private Supplier<Icon> icon2 = () -> Icon.NONE;
private Supplier<IRenderElement> icon2 = () -> Icon.NONE;
private String component2Pattern = null;
private Supplier<Icon> icon3 = () -> Icon.NONE;
private Supplier<IRenderElement> icon3 = () -> Icon.NONE;
private String component3Pattern = null;
private boolean isSmoothMove = false;
private boolean affectedByPlayerSettingsScale = false;
private boolean autoLifecycle = false;
private Function<Float, Float> definedScaleMultiple = scale -> scale;
private Function<Float, Float> rescaleFunc = scale -> scale;
private BiFunction<Float, Float, Float> alphaTransformer = (distance, alpha) -> alpha;


public ComponentBuilder() {}
Expand Down Expand Up @@ -60,10 +63,9 @@ public ComponentBuilder setIcon1(ResourceLocation location) {

/**
* <p>对于一般情况,该方法设置其中心图标。具有多个图标位的指针需要填充其它icon。</p>
* <p>将传入的物品的贴图作为图标。图标默认为空。</p>
*/
public ComponentBuilder setIcon1(Item item) {
icon1 = () -> getIcon(TextureMapping.getItemTexture(item).withPrefix("textures/"));
public ComponentBuilder setIcon1(ItemStack itemStack) {
icon1 = () -> getItemComponent(itemStack);
return this;
}

Expand All @@ -77,7 +79,7 @@ public ComponentBuilder setIcon1(String key) {
}

/**
* 设置图标1的容器。默认为null(获取时使用default),设置请参见{@link IconComponentFactory}
* 设置图标1的容器。默认为null(获取时使用default),设置请参见{@link BasicComponentFactory}
*/
public ComponentBuilder setIcon1Pattern(String pattern) {
this.component1Pattern = pattern;
Expand All @@ -89,8 +91,8 @@ public ComponentBuilder setIcon1Pattern(String pattern) {
* <p>对于一般情况,该方法设置其中心图标。具有多个图标位的指针需要填充其它icon。</p>
* <p>将传入的物品的贴图作为图标。图标默认为空。</p>
*/
public ComponentBuilder setIcon2(Item item) {
icon2 = () -> getIcon(TextureMapping.getItemTexture(item).withPrefix("textures/"));
public ComponentBuilder setIcon2(ItemStack itemStack) {
icon2 = () -> getItemComponent(itemStack);
return this;
}

Expand All @@ -104,7 +106,7 @@ public ComponentBuilder setIcon2(String key) {
}

/**
* 设置图标1的容器。默认为null(获取时使用default),设置请参见{@link IconComponentFactory}
* 设置图标1的容器。默认为null(获取时使用default),设置请参见{@link BasicComponentFactory}
*/
public ComponentBuilder setIcon2Pattern(String pattern) {
this.component2Pattern = pattern;
Expand All @@ -116,8 +118,8 @@ public ComponentBuilder setIcon2Pattern(String pattern) {
* <p>对于一般情况,该方法设置其中心图标。具有多个图标位的指针需要填充其它icon。</p>
* <p>将传入的物品的贴图作为图标。图标默认为空。</p>
*/
public ComponentBuilder setIcon3(Item item) {
icon3 = () -> getIcon(TextureMapping.getItemTexture(item).withPrefix("textures/"));
public ComponentBuilder setIcon3(ItemStack itemStack) {
icon3 = () -> getItemComponent(itemStack);
return this;
}

Expand All @@ -131,7 +133,7 @@ public ComponentBuilder setIcon3(String key) {
}

/**
* 设置图标1的容器。默认为null(获取时使用default),设置请参见{@link IconComponentFactory}
* 设置图标1的容器。默认为null(获取时使用default),设置请参见{@link BasicComponentFactory}
*/
public ComponentBuilder setIcon3Pattern(String pattern) {
this.component3Pattern = pattern;
Expand Down Expand Up @@ -165,8 +167,16 @@ public ComponentBuilder setAutoLifecycle(boolean autoLifecycle) {
/**
* 设置乘数再运算器,一般建议在这里对最终大小进行区间移动和缩放。
* */
public ComponentBuilder defineScaleMultiple(Function<Float, Float> definedScaleMultipleApplier) {
this.definedScaleMultiple = definedScaleMultipleApplier;
public ComponentBuilder defineRescale(Function<Float, Float> rescale) {
this.rescaleFunc = rescale;
return this;
}

/**
* 设置透明度再运算器。
* */
public ComponentBuilder defineAlphaTransformer(BiFunction<Float, Float, Float> alphaTransformer) {
this.alphaTransformer = alphaTransformer;
return this;
}

Expand All @@ -183,46 +193,54 @@ public BuilderResult build() {
isSmoothMove,
autoLifecycle,
affectedByPlayerSettingsScale,
definedScaleMultiple
rescaleFunc,
alphaTransformer
);
}

private static Icon getIcon(ResourceLocation location) {
return TextureBuildTool.initIcon("dynamic", location.withSuffix(".png"), Icon::new).orElse(Icon.NONE);
}

private static ItemComponent getItemComponent(ItemStack stack) {
return new ItemComponent(stack);
}

public static final class BuilderResult {
public final @Nullable String component1Pattern, component2Pattern, component3Pattern, cursorPattern;
public final ComponentType type;
public final Supplier<Icon> icon1, icon2, icon3;
public final Supplier<IRenderElement> element1, element2, element3;
public final boolean isSmoothMove, autoLifecycle, affectedBySettings;
public final Function<Float, Float> multiple;
public final Function<Float, Float> rescale;
public final BiFunction<Float, Float, Float> transformAlpha;
private BuilderResult(
ComponentType type,
Supplier<Icon> icon1,
Supplier<IRenderElement> element1,
@Nullable String component1Pattern,
Supplier<Icon> icon2,
Supplier<IRenderElement> element2,
@Nullable String component2Pattern,
Supplier<Icon> icon3,
Supplier<IRenderElement> element3,
@Nullable String component3Pattern,
@Nullable String cursorPattern,
boolean isSmoothMove,
boolean autoLifecycle,
boolean affectedBySettings,
Function<Float, Float> multiple
Function<Float, Float> rescale,
BiFunction<Float, Float, Float> transformAlpha
) {
this.type = type;
this.icon1 = icon1;
this.element1 = element1;
this.component1Pattern = component1Pattern;
this.icon2 = icon2;
this.element2 = element2;
this.component2Pattern = component2Pattern;
this.icon3 = icon3;
this.element3 = element3;
this.component3Pattern = component3Pattern;
this.cursorPattern = cursorPattern;
this.isSmoothMove = isSmoothMove;
this.autoLifecycle = autoLifecycle;
this.affectedBySettings = affectedBySettings;
this.multiple = multiple;
this.rescale = rescale;
this.transformAlpha = transformAlpha;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
public class TestAdd1 {
private static final ComponentBuilder.BuilderResult posTo0 = new ComponentBuilder()
.setComponentType(ComponentBuilder.ComponentType.DIRECT)
.setIcon1(Items.DIAMOND)
.setIcon1(Items.DIAMOND.getDefaultInstance())
.setIcon1Pattern("rainbow:2")
.defineScaleMultiple(scale -> (float) (1F + Math.min(scale / 2.2, 1f) * Math.min(scale / 2.2, 1f)))
.defineRescale(scale -> (float) (1F + Math.min(scale / 2.2, 1f) * Math.min(scale / 2.2, 1f)))
.setSmoothMove(true)
.build();

Expand Down
Loading
Loading