blob: 8f7ef286d3049da84c8879fcbcb013c11e77501b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
package de.hysky.skyblocker.skyblock.end;
import de.hysky.skyblocker.config.SkyblockerConfigManager;
import de.hysky.skyblocker.utils.Utils;
import de.hysky.skyblocker.utils.render.RenderHelper;
import net.fabricmc.fabric.api.client.message.v1.ClientReceiveMessageEvents;
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayConnectionEvents;
import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderContext;
import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderEvents;
import net.minecraft.text.Text;
import net.minecraft.util.math.BlockPos;
import java.util.ArrayList;
import java.util.List;
public class BeaconHighlighter {
public static final List<BlockPos> beaconPositions = new ArrayList<>();
private static final float[] RED_COLOR_COMPONENTS = { 1.0f, 0.0f, 0.0f };
/**
* Initializes the beacon highlighting system.
* {@link BeaconHighlighter#render(WorldRenderContext)} is called after translucent rendering.
*/
public static void init() {
WorldRenderEvents.AFTER_TRANSLUCENT.register(BeaconHighlighter::render);
ClientPlayConnectionEvents.JOIN.register((_handler, _sender, _client) -> reset());
ClientReceiveMessageEvents.GAME.register(BeaconHighlighter::onMessage);
}
private static void reset() {
beaconPositions.clear();
}
private static void onMessage(Text text, boolean overlay) {
if (Utils.isInTheEnd() && !overlay) {
String message = text.getString();
if (message.contains("SLAYER QUEST COMPLETE!") || message.contains("NICE! SLAYER BOSS SLAIN!")) reset();
}
}
/**
* Renders the beacon glow around it. It is rendered in a red color with 50% opacity, and
* is visible through walls.
*
* @param context An instance of WorldRenderContext for the RenderHelper to use
*/
private static void render(WorldRenderContext context) {
if (Utils.isInTheEnd() && SkyblockerConfigManager.get().slayers.endermanSlayer.highlightBeacons) {
for (BlockPos pos : beaconPositions) {
RenderHelper.renderFilled(context, pos, RED_COLOR_COMPONENTS, 0.5f, true);
}
}
}
}
|