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();
}
}
}
}
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;
}
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;
}
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;
}
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;
}
};
}
Aggregations