Esempio n. 1
0
 public boolean intersectsLiquids() {
   final int startX = min.getX();
   final int startY = min.getY();
   final int startZ = min.getZ();
   final int endX = max.getX();
   final int endY = max.getY();
   final int endZ = max.getZ();
   for (int yy = startY; yy <= endY; yy++) {
     if (yy == startY || yy == endY) {
       for (int xx = startX; xx <= endX; xx++) {
         for (int zz = startZ; zz <= endZ; zz++) {
           if (parent.getBlockMaterial(xx, yy, zz) instanceof Liquid) {
             return true;
           }
         }
       }
     } else {
       for (int xx = startX; xx <= endX; xx++) {
         if (parent.getBlockMaterial(xx, yy, startZ) instanceof Liquid
             || parent.getBlockMaterial(xx, yy, endZ) instanceof Liquid) {
           return true;
         }
       }
       for (int zz = startZ + 1; zz < endZ; zz++) {
         if (parent.getBlockMaterial(startX, yy, zz) instanceof Liquid
             || parent.getBlockMaterial(endX, yy, zz) instanceof Liquid) {
           return true;
         }
       }
     }
   }
   return false;
 }
Esempio n. 2
0
 @Override
 public void sphericalFill(boolean ignoreAir) {
   final float xScale = max.getX() - min.getX() + 1;
   final float yScale = max.getY() - min.getY() + 1;
   final float zScale = max.getZ() - min.getZ() + 1;
   final float xOffset = min.getX() + xScale / 2;
   final float zOffset = min.getZ() + zScale / 2;
   final int endX = max.getX();
   final int endY = max.getY();
   final int endZ = max.getZ();
   for (int xx = min.getX(); xx <= endX; xx++) {
     final float dx = (xx - xOffset) / (xScale * 0.5f);
     for (int yy = min.getY(); yy <= endY; yy++) {
       final float dy = (yy - min.getY()) / yScale;
       for (int zz = min.getZ(); zz <= endZ; zz++) {
         final float dz = (zz - zOffset) / (zScale * 0.5f);
         if (dx * dx + dy * dy + dz * dz <= 1.05) {
           if (ignoreAir
               && !parent.getBlockMaterial(xx, yy, zz).isMaterial(VanillaMaterials.AIR)) {
             continue;
           }
           parent.setBlockMaterial(xx, yy, zz, picker.get(false));
         }
       }
     }
   }
 }
Esempio n. 3
0
 protected boolean isOuter(int xx, int yy, int zz) {
   return xx == min.getX()
       || yy == min.getY()
       || zz == min.getZ()
       || xx == max.getX()
       || yy == max.getY()
       || zz == max.getZ();
 }
Esempio n. 4
0
 @Override
 public void fill(boolean ignoreAir) {
   final int endX = max.getX();
   final int endY = max.getY();
   final int endZ = max.getZ();
   for (int xx = min.getX(); xx <= endX; xx++) {
     for (int yy = min.getY(); yy <= endY; yy++) {
       for (int zz = min.getZ(); zz <= endZ; zz++) {
         if (!ignoreAir || !parent.getBlockMaterial(xx, yy, zz).isMaterial(VanillaMaterials.AIR)) {
           parent.setBlockMaterial(xx, yy, zz, picker.get(isOuter(xx, yy, zz)));
         }
       }
     }
   }
 }
Esempio n. 5
0
 @Override
 public void randomFill(float odd, boolean ignoreAir) {
   final int endX = max.getX();
   final int endY = max.getY();
   final int endZ = max.getZ();
   for (int xx = min.getX(); xx <= endX; xx++) {
     for (int yy = min.getY(); yy <= endY; yy++) {
       for (int zz = min.getZ(); zz <= endZ; zz++) {
         if (parent.getRandom().nextFloat() > odd) {
           continue;
         }
         if (!ignoreAir || !parent.getBlockMaterial(xx, yy, zz).isMaterial(VanillaMaterials.AIR)) {
           parent.setBlockMaterial(xx, yy, zz, picker.get(isOuter(xx, yy, zz)));
         }
       }
     }
   }
 }
Esempio n. 6
0
 protected EffectRangeImpl(Iterator<IntVector3> blocks) {
   int mxx = 0;
   int mxy = 0;
   int mxz = 0;
   int mnx = 0;
   int mny = 0;
   int mnz = 0;
   boolean first = true;
   while (blocks.hasNext()) {
     IntVector3 next = blocks.next();
     int x = next.getX();
     int y = next.getY();
     int z = next.getZ();
     if (first) {
       first = false;
       mxx = x;
       mnx = x;
       mxy = y;
       mny = y;
       mxz = z;
       mnz = z;
       continue;
     }
     if (x > mxx) {
       mxx = x;
     } else if (x < mnx) {
       mnx = x;
     }
     if (z > mxz) {
       mxz = z;
     } else if (z < mnz) {
       mnz = z;
     }
     if (y > mxy) {
       mxy = y;
     } else if (y < mny) {
       mny = y;
     }
   }
   this.maxX = mxx;
   this.maxY = mxy;
   this.maxZ = mxz;
   this.minX = mnx;
   this.minY = mny;
   this.minZ = mnz;
   if (maxX < minX || maxY < minY || maxZ < minZ) {
     throw new IllegalArgumentException("MaxX/Y/Z must be greater than MinX/Y/Z");
   }
 }
Esempio n. 7
0
 public boolean commitAsyncQueue() {
   boolean updated = false;
   PhysicsUpdate update;
   EffectIterator ei = new EffectIterator();
   while ((update = asyncQueue.poll()) != null) {
     updated = true;
     update.getRange().initEffectIterator(ei);
     int x = update.getX();
     int y = update.getY();
     int z = update.getZ();
     while (ei.hasNext()) {
       IntVector3 v = ei.next();
       int ox = x + v.getX();
       int oy = y + v.getY();
       int oz = z + v.getZ();
       if ((ox & MASK) == (x & MASK) && (oy & MASK) == (y & MASK) && (oz & MASK) == (z & MASK)) {
         queueForUpdate(ox, oy, oz, update.getOldMaterial());
       } else if (ox >= 0
           && ox < Region.BLOCKS.SIZE
           && oy >= 0
           && oy < Region.BLOCKS.SIZE
           && oz >= 0
           && oz < Region.BLOCKS.SIZE) {
         region.updateBlockPhysics(ox, oy, oz, update.getOldMaterial());
       } else {
         region
             .getWorld()
             .queueBlockPhysics(
                 region.getBlockX() + ox,
                 region.getBlockY() + oy,
                 region.getBlockZ() + oz,
                 EffectRange.THIS,
                 update.getOldMaterial());
       }
     }
   }
   return updated;
 }