HTTPS
https://git.nageyqma.icu/nageyqma/blade-addons-next.git
SSH
git@git.nageyqma.icu:nageyqma/blade-addons-next.git
HTTPS 链接可直接 git clone;推送代码请使用 SSH。
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
package blade.addon.features.dungeon.f7.terms;
import blade.addon.utils.Location;
import blade.addon.utils.config.components.Categories;
import blade.addon.utils.config.values.Floor7;
import blade.addon.utils.data.EntityUtil;
import blade.addon.utils.dungeon.Phase;
import blade.addon.utils.rendering.RenderUtils;
import config.practical.hud.HUDCategory;
import config.practical.hud.HUDComponent;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.minecraft.client.gui.GuiGraphicsExtractor;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.network.chat.Component;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.Vec3;
import org.jspecify.annotations.NonNull;
import java.util.List;
/**
* Ported from valley with minimal changes
*/
public class LeapDisplay extends HUDComponent {
private static final AABB[] REGIONS = {
new AABB(91, 105, 46, 111, 127, 123),
new AABB(17, 106, 121, 108, 145, 143),
new AABB(-2, 106, 51, 20, 145, 128),
new AABB(20, 26, 29, 191, 145, 58),
new AABB(3, 5, 0, 128, 48, 140)
};
private static final AABB RED_PILLAR_BOX = AABB.ofSize(new Vec3(100, 116, 46), 2, 2, 2);
private static final AABB SS_BOX = new AABB(107, 119, 92, 108, 121, 95);
private static final AABB EE2_BOX = new AABB(57, 108, 130, 59, 110, 132);
private static final AABB HEE2_BOX = new AABB(59, 132, 138, 62, 133, 140);
private static final AABB EE3_BOX = new AABB(1, 108, 103, 3, 110, 105);
private static final AABB CORE_BOX = new AABB(53.5, 114, 49.5, 55.5, 116, 51.5);
private static final AABB RELIC_BOX = new AABB(51.5, 3, 73.5, 57.5, 8, 79.5);
private int count = 0;
private int currentSpot = -1;
private boolean inBounds = false;
public LeapDisplay() {
super("Leap display");
}
public void init() {
ClientTickEvents.END_CLIENT_TICK.register(client -> {
if (!Floor7.leapNotifications || !Phase.isInFloor7() || !Location.inDungeon() || !Phase.inBoss()) {
inBounds = false;
return;
}
LocalPlayer player = client.player;
ClientLevel world = client.level;
if (player == null || world == null) return;
currentSpot = getSpot(player);
if (currentSpot < 1) {
count = 0;
inBounds = false;
return;
} else {
inBounds = true;
}
AABB box = REGIONS[currentSpot - 1];
count = getCount(world, player, box);
});
}
@Override
public int getWidth() {
return 110;
}
@Override
public int getHeight() {
return 10;
}
@Override
public boolean editable() {
return Floor7.leapNotifications;
}
@Override
public boolean shouldRender() {
return Floor7.leapNotifications && inBounds && Phase.inBoss() && Location.inDungeon();
}
@Override
public List<HUDCategory> categories() {
return List.of(Categories.P3);
}
@Override
public void render(@NonNull GuiGraphicsExtractor guiGraphicsExtractor) {
int maxCount = getMaxCount();
String startFormat;
startFormat = (maxCount - count <= 1 ? "§9" : "§4");
RenderUtils.drawCenteredText(guiGraphicsExtractor, this, Component.literal(startFormat + count + "§9/" + maxCount + " Players Leaped"));
}
private int getCount(ClientLevel world, LocalPlayer player, AABB box) {
List<Entity> entities = world.getEntities(player, box);
int currentCount = 0;
for (Entity entity : entities) {
if (EntityUtil.isARealPlayer(entity)) {
currentCount++;
}
}
return currentCount;
}
private int getSpot(LocalPlayer player) {
Vec3 pos = player.position();
if (HEE2_BOX.contains(pos)) return 2;
if (EE2_BOX.contains(pos)) return 2;
else if (EE3_BOX.contains(pos)) return 3;
else if (CORE_BOX.contains(pos)) return 4;
else if (RELIC_BOX.contains(pos) && !Phase.inP5()) return 5;
else return -1;
}
private int getMaxCount() {
if (currentSpot == 2 && Floor7.assumeSplitEE2) return 3;
if (currentSpot == 3 && Floor7.assumeCore) return 3;
return 4;
}
}