Skip to content

Commit 68f788a

Browse files
committed
In holograms no more need server ip
1 parent 8c90735 commit 68f788a

3 files changed

Lines changed: 26 additions & 21 deletions

File tree

src/main/java/nekiplay/meteorplus/features/modules/render/holograms/HologramData.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public class HologramData {
1818
public HologramData() {
1919

2020
}
21-
public HologramData(double x, double y, double z, String text, String world, String dimension, Color color, double max_render_distance) {
21+
public HologramData(double x, double y, double z, String text, String dimension, Color color, double max_render_distance) {
2222
this.x = x;
2323
this.y = y;
2424
this.z = z;
@@ -27,7 +27,7 @@ public HologramData(double x, double y, double z, String text, String world, Str
2727
this.text = text;
2828
}
2929

30-
public HologramData(BlockPos pos, String text, String world, Dimension dimension, Color color, double max_render_distance) {
30+
public HologramData(BlockPos pos, String text, Dimension dimension, Color color, double max_render_distance) {
3131
this.x = pos.getX();
3232
this.y = pos.getY();
3333
this.z = pos.getZ();

src/main/java/nekiplay/meteorplus/features/modules/render/holograms/HologramDataListed.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ public class HologramDataListed {
1313
public double y;
1414
public double z;
1515
public String text;
16-
public String world;
1716
public String dimension;
1817
public Color color;
1918
public double max_render_distance = 16;
@@ -27,26 +26,24 @@ public class HologramDataListed {
2726
public HologramDataListed() {
2827

2928
}
30-
public HologramDataListed(double x, double y, double z, String text, String world, String dimension, Color color, double max_render_distance) {
29+
public HologramDataListed(double x, double y, double z, String text, String dimension, Color color, double max_render_distance) {
3130
this.x = x;
3231
this.y = y;
3332
this.z = z;
3433
this.color = color;
3534

3635
this.text = text;
37-
this.world = world;
3836
this.dimension = dimension;
3937
this.max_render_distance = max_render_distance;
4038
}
4139

42-
public HologramDataListed(BlockPos pos, String text, String world, Dimension dimension, Color color, double max_render_distance) {
40+
public HologramDataListed(BlockPos pos, String text, Dimension dimension, Color color, double max_render_distance) {
4341
this.x = pos.getX();
4442
this.y = pos.getY();
4543
this.z = pos.getZ();
4644
this.color = color;
4745

4846
this.text = text;
49-
this.world = world;
5047
this.dimension = dimension.name();
5148
this.max_render_distance = max_render_distance;
5249
}

src/main/java/nekiplay/meteorplus/features/modules/render/holograms/HologramModule.java

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import com.google.gson.Gson;
55
import com.google.gson.JsonSyntaxException;
66
import meteordevelopment.meteorclient.MeteorClient;
7+
import meteordevelopment.meteorclient.events.game.GameJoinedEvent;
78
import meteordevelopment.meteorclient.events.render.Render2DEvent;
89
import meteordevelopment.meteorclient.events.world.TickEvent;
910
import meteordevelopment.meteorclient.renderer.text.TextRenderer;
@@ -57,7 +58,7 @@ private void onTick(TickEvent.Post event) {
5758
inWorldHolograms.clear();
5859
Dimension dim = PlayerUtils.getDimension();
5960
for (HologramDataListed hologramData : allHolograms) {
60-
if (hologramData.world.equals(Utils.getWorldName()) && hologramData.dimension.equals(dim.name())) {
61+
if (hologramData.dimension.equals(dim.name())) {
6162
inWorldHolograms.add(hologramData);
6263
}
6364
}
@@ -84,20 +85,23 @@ private void on2DRender(Render2DEvent event) {
8485
double hX = -widthHalf;
8586
double hY = -heightDown;
8687

87-
text.render(MeteorStarscript.run(scripts.get(hologram_text)), hX, hY, hologramData.color, true);
88-
for (HologramData hologramData1 : hologramData.other_holograms) {
89-
text.render(MeteorStarscript.run(scripts.get(hologramData1.text)), hX - hologramData1.x, hY - hologramData1.y, hologramData1.color, true);
90-
if (hologramData1.item_id != 0) {
91-
Item item = Item.byRawId(hologramData1.item_id);
92-
RenderUtils.drawItem(event.drawContext, item.getDefaultStack(), (int) ((int) hX - hologramData1.x), (int) ((int) 0 - hologramData1.y), hologramData1.item_scale, true);
88+
var script = scripts.get(hologram_text);
89+
if (script != null) {
90+
text.render(MeteorStarscript.run(script), hX, hY, hologramData.color, true);
91+
for (HologramData hologramData1 : hologramData.other_holograms) {
92+
text.render(MeteorStarscript.run(scripts.get(hologramData1.text)), hX - hologramData1.x, hY - hologramData1.y, hologramData1.color, true);
93+
if (hologramData1.item_id != 0) {
94+
Item item = Item.byRawId(hologramData1.item_id);
95+
RenderUtils.drawItem(event.drawContext, item.getDefaultStack(), (int) ((int) hX - hologramData1.x), (int) ((int) 0 - hologramData1.y), hologramData1.item_scale, true);
96+
}
9397
}
94-
}
9598

96-
text.end();
97-
if (hologramData.item_id != 0) {
98-
Item item = Item.byRawId(hologramData.item_id);
99-
RenderUtils.drawItem(event.drawContext, item.getDefaultStack(), (int) hX, (int) 0, hologramData.item_scale, true);
99+
if (hologramData.item_id != 0) {
100+
Item item = Item.byRawId(hologramData.item_id);
101+
RenderUtils.drawItem(event.drawContext, item.getDefaultStack(), (int) hX, (int) 0, hologramData.item_scale, true);
102+
}
100103
}
104+
text.end();
101105
NametagUtils.end(event.drawContext);
102106
}
103107
}
@@ -162,8 +166,8 @@ private void createDefault() {
162166
if (!dir2.exists()) {
163167
dir2.mkdir();
164168

165-
HologramDataListed hologramData = new HologramDataListed(new BlockPos(0, 64, 0), "Spawn", world_name, PlayerUtils.getDimension(), Color.RED, 16);
166-
HologramData hologramData2 = new HologramData(new BlockPos(0, 15, 0), PlayerUtils.getDimension().name(), world_name, PlayerUtils.getDimension(), Color.RED, 16);
169+
HologramDataListed hologramData = new HologramDataListed(new BlockPos(0, 64, 0), "Spawn", PlayerUtils.getDimension(), Color.RED, 16);
170+
HologramData hologramData2 = new HologramData(new BlockPos(0, 15, 0), PlayerUtils.getDimension().name(), PlayerUtils.getDimension(), Color.RED, 16);
167171
hologramData.other_holograms.add(hologramData2);
168172
String json = gson.toJson(hologramData);
169173

@@ -185,4 +189,8 @@ private void createDefault() {
185189
}
186190
}
187191
}
192+
@EventHandler
193+
public void onJoinGame(GameJoinedEvent event) {
194+
load();
195+
}
188196
}

0 commit comments

Comments
 (0)