コード例 #1
0
 @Override
 public boolean addCollisionBoxesToList(
     Block ignore, AxisAlignedBB aabb, List<AxisAlignedBB> list, Entity entity) {
   Block block = new Block(Material.rock);
   ClayState state = getState();
   if (state == ClayState.WET) {
     block.setBlockBounds(0, 0, 0, 1, 1F / 8F, 1);
     AxisAlignedBB a = block.getCollisionBoundingBox(worldObj, pos, null);
     if (aabb.intersectsWith(a)) {
       list.add(a);
     }
   }
   for (ClayLump lump : parts) {
     lump.toRotatedBlockBounds(this, block);
     AxisAlignedBB a = block.getCollisionBoundingBox(worldObj, pos, null);
     if (aabb.intersectsWith(a)) {
       list.add(a);
     }
   }
   return true;
 }
コード例 #2
0
  public boolean isValidLump(ClayLump lump) {
    // check volume
    if (!(Core.cheat)) {
      int wX = lump.maxX - lump.minX;
      int wY = lump.maxY - lump.minY;
      int wZ = lump.maxZ - lump.minZ;
      int area = wX * wY * wZ;
      int max_area = 16 * 16 * 16 /* / 4 */;
      if (!FzConfig.stretchy_clay) {
        max_area /= 4;
      }
      if (area <= 0 || area > max_area) {
        return false;
      }
    }

    // check bounds
    final int B = 16 * 3;
    if (lump.minX < 0) return false;
    if (lump.minY < 0) return false;
    if (lump.minZ < 0) return false;
    if (lump.maxX > B) return false;
    if (lump.maxY > B) return false;
    if (lump.maxZ > B) return false;

    // check for free space (needs to be last, as it can mutate the world)
    Block block = FzUtil.getTraceHelper();
    for (int dx = -1; dx <= 1; dx++) {
      for (int dy = -1; dy <= 1; dy++) {
        for (int dz = -1; dz <= 1; dz++) {
          AxisAlignedBB ab =
              new AxisAlignedBB(
                  pos.getX() + dx,
                  pos.getY() + dy,
                  pos.getZ() + dz,
                  pos.getX() + dx + 1,
                  pos.getY() + dy + 1,
                  pos.getZ() + dz + 1);
          Coord c = getCoord();
          c.x += dx;
          c.y += dy;
          c.z += dz;
          lump.toRotatedBlockBounds(this, block);
          AxisAlignedBB in = block.getCollisionBoundingBox(worldObj, pos, c.getState());
          if (in != null && ab.intersectsWith(in)) {
            // This block needs to be an Extension, or this
            if (c.isAir() || c.isReplacable()) {
              c.setId(Core.registry.legacy_factory_block);
              TileEntityExtension tex = new TileEntityExtension(this);
              c.setTE(tex);
              tex.getBlockClass().enforce(c);
              continue;
            }
            TileEntity te = c.getTE();
            if (te == this) {
              continue;
            }
            if (te instanceof TileEntityExtension) {
              TileEntityExtension tex = (TileEntityExtension) te;
              if (tex.getParent() == this) {
                continue;
              }
            }
            // We used to not allow this. We just make a bit of noise instead.
            // A notification will indicate that things will be a bit messed up here.
            // FIXME: Let block collision boxes go outside the block (Notch hard-coded for fences)
            new Notice(c, "!").sendToAll();
          }
        }
      }
    }
    return true;
  }