Refactor vector system to be cleaner

- Move Vector, etc. into `.math` package
- Drop many methods that will be auto-promoted anyways, eg. with
`divide(int)` and `divide(double)` the first is now gone.
- Take Block vectors into their own class hierarchy
- Make it clear throughout the API what takes blockvectors
- many more improvements
This commit is contained in:
Kenzie Togami
2018-10-14 03:40:53 -07:00
parent d7c528247b
commit 399e0ad5fa
230 changed files with 4216 additions and 3913 deletions

View File

@ -26,8 +26,7 @@ import com.sk89q.jnbt.ListTag;
import com.sk89q.jnbt.LongArrayTag;
import com.sk89q.jnbt.NBTUtils;
import com.sk89q.jnbt.Tag;
import com.sk89q.worldedit.BlockVector;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.registry.state.Property;
import com.sk89q.worldedit.world.DataException;
import com.sk89q.worldedit.world.block.BlockState;
@ -52,7 +51,7 @@ public class AnvilChunk13 implements Chunk {
private int rootX;
private int rootZ;
private Map<BlockVector, Map<String,Tag>> tileEntities;
private Map<BlockVector3, Map<String,Tag>> tileEntities;
/**
* Construct the chunk with a compound tag.
@ -201,7 +200,7 @@ public class AnvilChunk13 implements Chunk {
values.put(entry.getKey(), entry.getValue());
}
BlockVector vec = new BlockVector(x, y, z);
BlockVector3 vec = new BlockVector3(x, y, z);
tileEntities.put(vec, values);
}
}
@ -216,12 +215,12 @@ public class AnvilChunk13 implements Chunk {
* @throws DataException thrown if there is a data error
*/
@Nullable
private CompoundTag getBlockTileEntity(Vector position) throws DataException {
private CompoundTag getBlockTileEntity(BlockVector3 position) throws DataException {
if (tileEntities == null) {
populateTileEntities();
}
Map<String, Tag> values = tileEntities.get(new BlockVector(position));
Map<String, Tag> values = tileEntities.get(position);
if (values == null) {
return null;
}
@ -230,10 +229,10 @@ public class AnvilChunk13 implements Chunk {
}
@Override
public BlockStateHolder getBlock(Vector position) throws DataException {
int x = position.getBlockX() - rootX * 16;
int y = position.getBlockY();
int z = position.getBlockZ() - rootZ * 16;
public BlockStateHolder getBlock(BlockVector3 position) throws DataException {
int x = position.getX() - rootX * 16;
int y = position.getY();
int z = position.getZ() - rootZ * 16;
int section = y >> 4;
int yIndex = y & 0x0F;