Search in sources :

Example 36 with MovecraftLocation

use of net.countercraft.movecraft.MovecraftLocation in project Movecraft by APDevTeam.

the class SpeedSign method onCraftDetect.

@EventHandler
public void onCraftDetect(CraftDetectEvent event) {
    World world = event.getCraft().getWorld();
    for (MovecraftLocation location : event.getCraft().getHitBox()) {
        var block = location.toBukkit(world).getBlock();
        if (!Tag.SIGNS.isTagged(block.getType())) {
            continue;
        }
        BlockState state = block.getState();
        if (state instanceof Sign) {
            Sign sign = (Sign) state;
            if (ChatColor.stripColor(sign.getLine(0)).equalsIgnoreCase("Speed:")) {
                sign.setLine(1, "0 m/s");
                sign.setLine(2, "0ms");
                sign.setLine(3, "0T");
                sign.update();
            }
        }
    }
}
Also used : BlockState(org.bukkit.block.BlockState) Sign(org.bukkit.block.Sign) World(org.bukkit.World) MovecraftLocation(net.countercraft.movecraft.MovecraftLocation) EventHandler(org.bukkit.event.EventHandler)

Example 37 with MovecraftLocation

use of net.countercraft.movecraft.MovecraftLocation in project Movecraft by APDevTeam.

the class BitmapLocationSet method addAll.

@Override
public boolean addAll(@NotNull Collection<? extends MovecraftLocation> locations) {
    boolean out = false;
    for (MovecraftLocation location : locations) {
        var packed = location.pack();
        if (!out && !backing.contains(packed)) {
            out = true;
        }
        backing.addLong(packed);
    }
    return out;
}
Also used : MovecraftLocation(net.countercraft.movecraft.MovecraftLocation)

Example 38 with MovecraftLocation

use of net.countercraft.movecraft.MovecraftLocation in project Movecraft by APDevTeam.

the class BitmapLocationSet method remove.

@Override
public boolean remove(Object o) {
    if (o instanceof MovecraftLocation) {
        MovecraftLocation location = (MovecraftLocation) o;
        var packed = location.pack();
        if (!backing.contains(packed)) {
            return false;
        }
        backing.removeLong(location.pack());
        return true;
    }
    return false;
}
Also used : MovecraftLocation(net.countercraft.movecraft.MovecraftLocation)

Example 39 with MovecraftLocation

use of net.countercraft.movecraft.MovecraftLocation in project Movecraft by APDevTeam.

the class LocationSet method contains.

@Override
public boolean contains(Object o) {
    if (o instanceof MovecraftLocation) {
        MovecraftLocation location = (MovecraftLocation) o;
        long packed = location.pack();
        var suffix = this.getPrefixLeafIfPresent(packed);
        if (suffix == null) {
            return false;
        }
        return suffix.get((int) location.pack() & LOW_MASK);
    }
    return false;
}
Also used : MovecraftLocation(net.countercraft.movecraft.MovecraftLocation)

Example 40 with MovecraftLocation

use of net.countercraft.movecraft.MovecraftLocation in project Movecraft by APDevTeam.

the class SolidHitBox method iterator.

@NotNull
@Override
public Iterator<MovecraftLocation> iterator() {
    return new Iterator<MovecraftLocation>() {

        private int lastX = minX;

        private int lastY = minY;

        private int lastZ = minZ;

        @Override
        public boolean hasNext() {
            return lastZ <= maxZ;
        }

        @Override
        public MovecraftLocation next() {
            MovecraftLocation output = new MovecraftLocation(lastX, lastY, lastZ);
            lastX++;
            if (lastX > maxX) {
                lastX = minX;
                lastY++;
            }
            if (lastY > maxY) {
                lastY = minY;
                lastZ++;
            }
            return output;
        }
    };
}
Also used : Iterator(java.util.Iterator) MovecraftLocation(net.countercraft.movecraft.MovecraftLocation) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

MovecraftLocation (net.countercraft.movecraft.MovecraftLocation)60 Craft (net.countercraft.movecraft.craft.Craft)18 EventHandler (org.bukkit.event.EventHandler)18 Material (org.bukkit.Material)17 World (org.bukkit.World)15 Sign (org.bukkit.block.Sign)14 BlockState (org.bukkit.block.BlockState)13 Block (org.bukkit.block.Block)12 ArrayList (java.util.ArrayList)11 Location (org.bukkit.Location)11 Map (java.util.Map)10 HashMap (java.util.HashMap)9 SetHitBox (net.countercraft.movecraft.util.hitboxes.SetHitBox)9 HashSet (java.util.HashSet)8 SinkingCraft (net.countercraft.movecraft.craft.SinkingCraft)8 NotNull (org.jetbrains.annotations.NotNull)8 MovecraftRotation (net.countercraft.movecraft.MovecraftRotation)6 HitBox (net.countercraft.movecraft.util.hitboxes.HitBox)6 SolidHitBox (net.countercraft.movecraft.util.hitboxes.SolidHitBox)6 LinkedList (java.util.LinkedList)5