nageyqma·git
HTTPS https://git.nageyqma.icu/nageyqma/blade-addons-next.git SSH git@git.nageyqma.icu:nageyqma/blade-addons-next.git

HTTPS 链接可直接 git clone;推送代码请使用 SSH。

2.0 KB · 79 行raw
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
package blade.addon.features.dungeon.f7.location;

import blade.addon.utils.Misc;
import blade.addon.utils.config.values.Floor7;
import blade.addon.utils.dungeon.Section;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.Vec3;

public class PositionMessage {

    private final String message;
    private final String[] checks;
    private final AABB box;
    private boolean sent;
    private boolean personallySent;
    private final int[] sections;

    public PositionMessage(String message, String[] checks, AABB box, int[] sections) {
        this.message = message;
        this.checks = checks;
        this.box = box;
        this.sent = true;
        this.personallySent = true;
        this.sections = sections;
        PositionMessages.positionMessages.add(this);
    }

    private boolean inRange(Vec3 pos) {
        return box.contains(pos);
    }

    private boolean inAValidSection() {
        for (int section : sections) {
            if (Section.inSection(section)) return true;
        }
        return false;
    }

    public void tick(LocalPlayer player) {
        if (sent || personallySent || !inAValidSection() || !inRange(player.position())) return;
        if (Floor7.enablePositionalMessages) {
            Misc.executeCommand("pc " + message);
            personallySent = true;
        }
    }

    private boolean matchesACheck(String string) {
        for (String check : checks) {
            if (string.contains(check)) return true;
        }
        return false;
    }

    public boolean hasBeenSent(String string) {
        if (!matchesACheck(string.toLowerCase())) return false;

        if (sent) {
            return true;
        } else {
            sent = true;
            return false;
        }
    }

    public void setSent(boolean sent) {
        this.sent = sent;
        this.personallySent = sent;
    }

    public boolean sent() {
        return sent;
    }

    public AABB getBox() {
        return box;
    }
}