mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-15 19:34:49 +00:00
IPos:
-Added crossProduct(IPos), divide(scalar), and to/FromLong functions. NpcAPI: -Added getAllInBox(from,to) IBlock: -Added setPosition functions IBlock, IPos, IEntity, IWorld: -Added a readable toString() function
This commit is contained in:
1 parent
084e6e4149
commit
c8a8e866cb
10 files changed
+191
-25
No files matched your search
@@ -54,10 +54,7 @@ import noppes.npcs.util.LRUHashMap;
|
||||
import noppes.npcs.util.NBTJsonUtil;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
|
||||
public class NpcAPI extends AbstractNpcAPI {
|
||||
private static final Map<Integer, ScriptWorld> worldCache = new LRUHashMap<>(10);
|
||||
@@ -238,6 +235,20 @@ public class NpcAPI extends AbstractNpcAPI {
|
||||
return this.getIPos((int)x,(int)y,(int)z);
|
||||
}
|
||||
|
||||
public IPos[] getAllInBox(IPos from, IPos to, boolean sortByDistance) {
|
||||
Iterator<BlockPos> posIterable = BlockPos.getAllInBox(from.getMCPos(),to.getMCPos()).iterator();
|
||||
ArrayList<IPos> list = new ArrayList<>();
|
||||
posIterable.forEachRemaining(BlockPos -> list.add(this.getIPos(BlockPos)));
|
||||
if (sortByDistance) {
|
||||
list.sort(Comparator.comparingDouble(pos -> pos.distanceTo(from)));
|
||||
}
|
||||
return list.toArray(new IPos[0]);
|
||||
}
|
||||
|
||||
public IPos[] getAllInBox(IPos from, IPos to) {
|
||||
return this.getAllInBox(from,to,true);
|
||||
}
|
||||
|
||||
public INbt getINbt(NBTTagCompound nbtTagCompound) {
|
||||
return nbtTagCompound == null?new ScriptNbt(new NBTTagCompound()):new ScriptNbt(nbtTagCompound);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user