Skip to content
This repository has been archived by the owner on Sep 24, 2024. It is now read-only.

Commit

Permalink
Big recursive fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Nekiplay committed Feb 26, 2024
1 parent b3f4903 commit 839f450
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ public class HologramData {
public int item_scale = 2;
public boolean distanceScaling = false;

public ArrayList<HologramData> other_holograms = new ArrayList<HologramData>();

public HologramData() {

}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package nekiplay.meteorplus.features.modules.render.holograms;

import meteordevelopment.meteorclient.utils.render.color.Color;
import meteordevelopment.meteorclient.utils.world.Dimension;
import net.minecraft.util.math.BlockPos;

import java.util.ArrayList;

public class HologramDataListed {
public double x;
public double y;
public double z;
public String text;
public String world;
public String dimension;
public Color color;
public double max_render_distance = 16;
public int item_id = 0;
public double scale = 1;
public int item_scale = 2;
public boolean distanceScaling = false;

public ArrayList<HologramData> other_holograms = new ArrayList<HologramData>();

public HologramDataListed() {

}
public HologramDataListed(double x, double y, double z, String text, String world, String dimension, Color color, double max_render_distance) {
this.x = x;
this.y = y;
this.z = z;
this.color = color;

this.text = text;
this.world = world;
this.dimension = dimension;
this.max_render_distance = max_render_distance;
}

public HologramDataListed(BlockPos pos, String text, String world, Dimension dimension, Color color, double max_render_distance) {
this.x = pos.getX();
this.y = pos.getY();
this.z = pos.getZ();
this.color = color;

this.text = text;
this.world = world;
this.dimension = dimension.name();
this.max_render_distance = max_render_distance;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ public HologramModule() {
}
public Gson gson = new Gson();

public List<HologramData> allHolograms = new ArrayList<HologramData>();
public List<HologramData> inWorldHolograms = new ArrayList<HologramData>();
public List<HologramDataListed> allHolograms = new ArrayList<HologramData>();
public List<HologramDataListed> inWorldHolograms = new ArrayList<HologramData>();

@Override
public void onActivate() {
Expand All @@ -48,7 +48,7 @@ public void onActivate() {
private void onTick(TickEvent.Post event) {
inWorldHolograms.clear();
Dimension dim = PlayerUtils.getDimension();
for (HologramData hologramData : allHolograms) {
for (HologramDataListed hologramData : allHolograms) {
if (hologramData.world.equals(Utils.getWorldName()) && hologramData.dimension.equals(dim.name())) {
inWorldHolograms.add(hologramData);
}
Expand All @@ -58,7 +58,7 @@ private void onTick(TickEvent.Post event) {
@EventHandler
private void on2DRender(Render2DEvent event) {
Vec3d camera_pos = mc.gameRenderer.getCamera().getPos();
for (HologramData hologramData : inWorldHolograms) {
for (HologramDataListed hologramData : inWorldHolograms) {
Vector3d pos = new Vector3d(hologramData.x, hologramData.y, hologramData.z);
if (pos.distance(camera_pos.x, camera_pos.y, camera_pos.z) <= hologramData.max_render_distance) {
if (NametagUtils.to2D(pos, hologramData.scale, hologramData.distanceScaling)) {
Expand Down Expand Up @@ -113,7 +113,7 @@ private void load() {
BufferedReader reader = new BufferedReader(fr);
try {
String json = reader.readLine();
HologramData hologramData = gson.fromJson(json, HologramData.class);
HologramDataListed hologramData = gson.fromJson(json, HologramDataListed.class);
if (hologramData != null) {
allHolograms.add(hologramData);
MeteorPlusAddon.LOG.info(MeteorPlusAddon.LOGPREFIX + " Success loaded hologram: " + file.getName());
Expand Down Expand Up @@ -144,7 +144,7 @@ private void createDefault() {
if (!dir2.exists()) {
dir2.mkdir();

HologramData hologramData = new HologramData(new BlockPos(0, 64, 0), "Spawn", world_name, PlayerUtils.getDimension(), Color.RED, 16);
HologramDataListed hologramData = new HologramDataListed(new BlockPos(0, 64, 0), "Spawn", world_name, PlayerUtils.getDimension(), Color.RED, 16);
HologramData hologramData2 = new HologramData(new BlockPos(0, 15, 0), PlayerUtils.getDimension().name(), world_name, PlayerUtils.getDimension(), Color.RED, 16);
hologramData.other_holograms.add(hologramData2);
String json = gson.toJson(hologramData);
Expand Down

0 comments on commit 839f450

Please sign in to comment.