public static void unpath(World world, int i, int j, int k) {
   List<ChunkCoordinates> blocks = Lists.newLinkedList();
   List<ChunkCoordinates> notify = Lists.newLinkedList();
   blocks.add(new ChunkCoordinates(i, j, k));
   while (blocks.size() > 0) {
     ChunkCoordinates coords = blocks.remove(0);
     depolarize(world, coords.posX + 1, coords.posY, coords.posZ, blocks);
     depolarize(world, coords.posX, coords.posY + 1, coords.posZ, blocks);
     depolarize(world, coords.posX, coords.posY, coords.posZ + 1, blocks);
     depolarize(world, coords.posX - 1, coords.posY, coords.posZ, blocks);
     depolarize(world, coords.posX, coords.posY - 1, coords.posZ, blocks);
     depolarize(world, coords.posX, coords.posY, coords.posZ - 1, blocks);
     notify.add(coords);
   }
   for (ChunkCoordinates coords : notify) {
     if (world.blockExists(coords.posX, coords.posY, coords.posZ)) {
       world.markBlockForUpdate(coords.posX, coords.posY, coords.posZ);
       world.notifyBlocksOfNeighborChange(
           coords.posX,
           coords.posY,
           coords.posZ,
           world.getBlock(coords.posX, coords.posY, coords.posZ));
     }
   }
 }
  @Override
  public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, Block block) {
    ChunkCoordinates coord =
        getBase(par2, par3, par4, par1World.getBlockMetadata(par2, par3, par4));
    if (par1World.getBlock(coord.posX, coord.posY, coord.posZ) != NailedBlocks.portalCrystal) {
      this.dropBlockAsItem(par1World, par2, par3, par4, 0, 0);
      par1World.setBlockToAir(par2, par3, par4);
    }

    super.onNeighborBlockChange(par1World, par2, par3, par4, block);
  }
 private static void depolarize(World world, int i, int j, int k, List<ChunkCoordinates> blocks) {
   Block block = world.getBlock(i, j, k);
   if (isValidLinkPortalBlock(block) == 0) {
     return;
   }
   if (world.getBlockMetadata(i, j, k) == 0) {
     return;
   }
   world.setBlockMetadataWithNotify(i, j, k, 0, 0);
   if ((block == NailedBlocks.portal) && (!BlockPortal.isValidPortal(world, i, j, k))) {
     world.setBlock(i, j, k, Blocks.air, 0, 2);
   }
   blocks.add(new ChunkCoordinates(i, j, k));
 }
 private static void directPortal(
     World world,
     int i,
     int j,
     int k,
     int meta,
     List<ChunkCoordinates> blocks,
     List<ChunkCoordinates> portals) {
   if (isValidLinkPortalBlock(world.getBlock(i, j, k)) == 0) {
     return;
   }
   if (world.getBlockMetadata(i, j, k) != 0) {
     return;
   }
   world.setBlockMetadataWithNotify(i, j, k, meta, 0);
   if (world.getBlock(i, j, k) == NailedBlocks.portal) {
     portals.add(new ChunkCoordinates(i, j, k));
   } else {
     blocks.add(new ChunkCoordinates(i, j, k));
   }
 }
 private static void pathto(World world, int i, int j, int k) {
   List<ChunkCoordinates> blocks = Lists.newLinkedList();
   List<ChunkCoordinates> portals = Lists.newLinkedList();
   List<ChunkCoordinates> repath = Lists.newLinkedList();
   List<ChunkCoordinates> redraw = Lists.newLinkedList();
   blocks.add(new ChunkCoordinates(i, j, k));
   while ((portals.size() > 0) || (blocks.size() > 0)) {
     while (blocks.size() > 0) {
       ChunkCoordinates coords = blocks.remove(0);
       directPortal(world, coords.posX + 1, coords.posY, coords.posZ, 5, blocks, portals);
       directPortal(world, coords.posX, coords.posY + 1, coords.posZ, 1, blocks, portals);
       directPortal(world, coords.posX, coords.posY, coords.posZ + 1, 3, blocks, portals);
       directPortal(world, coords.posX - 1, coords.posY, coords.posZ, 6, blocks, portals);
       directPortal(world, coords.posX, coords.posY - 1, coords.posZ, 2, blocks, portals);
       directPortal(world, coords.posX, coords.posY, coords.posZ - 1, 4, blocks, portals);
       redraw.add(coords);
     }
     if (portals.size() > 0) {
       ChunkCoordinates coords = portals.remove(0);
       directPortal(world, coords.posX + 1, coords.posY, coords.posZ, 5, blocks, portals);
       directPortal(world, coords.posX, coords.posY + 1, coords.posZ, 1, blocks, portals);
       directPortal(world, coords.posX, coords.posY, coords.posZ + 1, 3, blocks, portals);
       directPortal(world, coords.posX - 1, coords.posY, coords.posZ, 6, blocks, portals);
       directPortal(world, coords.posX, coords.posY - 1, coords.posZ, 2, blocks, portals);
       directPortal(world, coords.posX, coords.posY, coords.posZ - 1, 4, blocks, portals);
       if (world.getBlock(coords.posX, coords.posY, coords.posZ) == NailedBlocks.portal) {
         repath.add(coords);
       }
     }
   }
   while (repath.size() > 0) {
     ChunkCoordinates coords = repath.remove(0);
     if (world.getBlock(coords.posX, coords.posY, coords.posZ) == NailedBlocks.portal) {
       if (!BlockPortal.isValidPortal(world, coords.posX, coords.posY, coords.posZ)) {
         repathNeighbors(world, coords.posX, coords.posY, coords.posZ);
         world.setBlock(coords.posX, coords.posY, coords.posZ, Blocks.air, 0, 0);
         addSurrounding(repath, coords.posX, coords.posY, coords.posZ);
       } else {
         redraw.add(coords);
       }
     }
   }
   for (ChunkCoordinates coords : redraw) {
     if (world.blockExists(coords.posX, coords.posY, coords.posZ)) {
       world.markBlockForUpdate(coords.posX, coords.posY, coords.posZ);
       world.notifyBlocksOfNeighborChange(
           coords.posX,
           coords.posY,
           coords.posZ,
           world.getBlock(coords.posX, coords.posY, coords.posZ));
     }
   }
 }
  private void updateTileEntityOrientation(World world, int i, int j, int k) {
    TileEntityPortalController controller =
        (TileEntityPortalController) world.getTileEntity(i, j, k);
    int metadata = world.getBlockMetadata(i, j, k);

    if (metadata == 1) {
      controller.pitch = -90;
      controller.yaw = -90;
      /*}else if(metadata == 1){
      controller.pitch = 90;
      controller.yaw = -90;*/
    } else if (metadata == 2) {
      controller.yaw = 270;
    } else if (metadata == 3) {
      controller.yaw = 90;
    } else if (metadata == 4) {
      controller.yaw = 0;
    } else if (metadata == 5) {
      controller.yaw = 180;
    }

    controller.markDirty();
  }
 private static void redirectPortal(
     World world,
     TileEntity tileentity,
     int i,
     int j,
     int k,
     int meta,
     List<ChunkCoordinates> blocks) {
   if (isValidLinkPortalBlock(world.getBlock(i, j, k)) == 0) {
     return;
   }
   if (world.getBlockMetadata(i, j, k) == meta) {
     for (int m = 1; m < 7; m++) {
       if (m != meta) {
         world.setBlockMetadataWithNotify(i, j, k, m, 2);
         TileEntity local = getTileEntity(world, i, j, k);
         if ((local == tileentity) || ((local != null) && (tileentity == null))) {
           return;
         }
       }
     }
     world.setBlockMetadataWithNotify(i, j, k, 0, 2);
   }
 }
 private static void repathNeighbors(World world, int i, int j, int k) {
   TileEntity tileentity = getTileEntity(world, i, j, k);
   List<ChunkCoordinates> blocks = Lists.newLinkedList();
   blocks.add(new ChunkCoordinates(i, j, k));
   world.setBlockMetadataWithNotify(i, j, k, 8, 2);
   while (blocks.size() > 0) {
     ChunkCoordinates coords = blocks.remove(0);
     redirectPortal(world, tileentity, coords.posX + 1, coords.posY, coords.posZ, 5, blocks);
     redirectPortal(world, tileentity, coords.posX, coords.posY + 1, coords.posZ, 1, blocks);
     redirectPortal(world, tileentity, coords.posX, coords.posY, coords.posZ + 1, 3, blocks);
     redirectPortal(world, tileentity, coords.posX - 1, coords.posY, coords.posZ, 6, blocks);
     redirectPortal(world, tileentity, coords.posX, coords.posY - 1, coords.posZ, 2, blocks);
     redirectPortal(world, tileentity, coords.posX, coords.posY, coords.posZ - 1, 4, blocks);
   }
 }
 private static void onpulse(World world, int i, int j, int k) {
   List<ChunkCoordinates> set = Lists.newLinkedList();
   Stack<ChunkCoordinates> validate = new Stack<ChunkCoordinates>();
   addSurrounding(set, i, j, k);
   while (set.size() > 0) {
     ChunkCoordinates coords = set.remove(0);
     expandPortal(world, coords.posX, coords.posY, coords.posZ, set, validate);
   }
   while (validate.size() > 0) {
     ChunkCoordinates coords = validate.pop();
     i = coords.posX;
     j = coords.posY;
     k = coords.posZ;
     if (!BlockPortal.checkPortalTension(world, i, j, k)) {
       world.setBlock(i, j, k, Blocks.air, 0, 0);
     }
   }
 }
예제 #10
0
  @Override
  public AxisAlignedBB getSelectedBoundingBoxFromPool(
      World par1World, int par2, int par3, int par4) {
    int i = par1World.getBlockMetadata(par2, par3, par4);
    float f = 0.375F;

    setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, f, 1.0F);
    if (i == 0) {
      setBlockBounds(0.0F, 1.0F - f, 0.0F, 1.0F, 1.0F, 1.0F);
    }

    if (i == 1) {
      setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, f, 1.0F);
    }

    if (i == 2) {
      setBlockBounds(0.0F, 0.0F, 1.0F - f, 1.0F, 1.0F, 1.0F);
    }

    if (i == 3) {
      setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, f);
    }

    if (i == 4) {
      setBlockBounds(1.0F - f, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
    }

    if (i == 5) {
      setBlockBounds(0.0F, 0.0F, 0.0F, f, 1.0F, 1.0F);
    }
    AxisAlignedBB box =
        AxisAlignedBB.getAABBPool()
            .getAABB(
                par2 + this.minX,
                par3 + this.minY,
                par4 + this.minZ,
                par2 + this.maxX,
                par3 + this.maxY,
                par4 + this.maxZ);
    setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 0.375F);
    return box;
  }
예제 #11
0
 @Override
 public boolean canPlaceBlockOnSide(World world, int x, int y, int z, int side) {
   if ((side == 0) && (world.getBlock(x, y + 1, z) != NailedBlocks.portalCrystal)) {
     return false;
   } else if ((side == 1) && (world.getBlock(x, y - 1, z) != NailedBlocks.portalCrystal)) {
     return false;
   } else if ((side == 2) && (world.getBlock(x, y, z + 1) != NailedBlocks.portalCrystal)) {
     return false;
   } else if ((side == 3) && (world.getBlock(x, y, z - 1) != NailedBlocks.portalCrystal)) {
     return false;
   } else if ((side == 4) && (world.getBlock(x + 1, y, z) != NailedBlocks.portalCrystal)) {
     return false;
   } else if ((side == 5) && (world.getBlock(x - 1, y, z) != NailedBlocks.portalCrystal)) {
     return false;
   } else {
     return this.canPlaceBlockAt(world, x, y, z);
   }
 }
예제 #12
0
  private static void expandPortal(
      World world,
      int i,
      int j,
      int k,
      Collection<ChunkCoordinates> set,
      Stack<ChunkCoordinates> created) {
    if (!world.isAirBlock(i, j, k)) {
      return;
    }

    int score =
        isValidLinkPortalBlock(world.getBlock(i + 1, j, k))
            + isValidLinkPortalBlock(world.getBlock(i - 1, j, k))
            + isValidLinkPortalBlock(world.getBlock(i, j + 1, k))
            + isValidLinkPortalBlock(world.getBlock(i, j - 1, k))
            + isValidLinkPortalBlock(world.getBlock(i, j, k + 1))
            + isValidLinkPortalBlock(world.getBlock(i, j, k - 1));
    if (score > 1) {
      world.setBlock(i, j, k, NailedBlocks.portal, 0, 0);
      created.push(new ChunkCoordinates(i, j, k));
      addSurrounding(set, i, j, k);
    }
  }
예제 #13
0
 public static void fire(World world, int i, int j, int k) {
   ChunkCoordinates coord = getBase(i, j, k, world.getBlockMetadata(i, j, k));
   onpulse(world, coord.posX, coord.posY, coord.posZ);
   pathto(world, i, j, k);
 }