- NodeManipulator: Multiblock fixxes

- NodeManipulationResults: init
- moved node-related stuff to node package
This commit is contained in:
HellFirePvP committed 2015-10-28 17:05:48 +01:00
1 parent 0d59f9b90a
commit 3241ac6b5c
17 files changed
+213 -36

No files matched your search

@@ -17,16 +17,16 @@ import java.util.LinkedHashMap;
public class MultiblockHelper {
public static boolean isMultiblockPresent(World world, int x, int y, int z, MultiblockPattern pattern) {
for(Vec3 vec : pattern.keySet()) {
for(IntVec3 vec : pattern.keySet()) {
BlockInfo expected = pattern.get(vec);
Block realBlock = world.getBlock(x + (int) vec.xCoord, y + (int) vec.yCoord, z + (int) vec.zCoord);
int realMeta = world.getBlockMetadata(x + (int) vec.xCoord, y + (int) vec.yCoord, z + (int) vec.zCoord);
Block realBlock = world.getBlock(x + vec.x, y + vec.y, z + vec.z);
int realMeta = world.getBlockMetadata(x + vec.x, y + vec.y, z + vec.z);
if(expected.block != realBlock || expected.meta != realMeta) return false;
}
return true;
}
public static class MultiblockPattern extends LinkedHashMap<Vec3, BlockInfo> {
public static class MultiblockPattern extends LinkedHashMap<IntVec3, BlockInfo> {
public MultiblockPattern(Block originBlock, int originMeta) {
put(createIntVec3(0, 0, 0), new BlockInfo(originBlock, originMeta));
@@ -37,12 +37,39 @@ public class MultiblockHelper {
return this;
}
private Vec3 createIntVec3(int x, int y, int z) {
return Vec3.createVectorHelper(x, y, z);
private IntVec3 createIntVec3(int x, int y, int z) {
return new IntVec3(x, y, z);
}
}
public static class IntVec3 {
public int x, y, z;
public IntVec3(int x, int y, int z) {
this.x = x;
this.y = y;
this.z = z;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
IntVec3 intVec3 = (IntVec3) o;
return x == intVec3.x && y == intVec3.y && z == intVec3.z;
}
@Override
public int hashCode() {
int result = x;
result = 31 * result + y;
result = 31 * result + z;
return result;
}
}
public static class BlockInfo {
public Block block;
public int meta;