예제 #1
0
 /**
  * Finds the center of the end portal object
  *
  * @param frameBlock to start looking from
  * @return Center origin block
  */
 private Block getOrigin(Block frameBlock) {
   if (!frameBlock.isMaterial(VanillaMaterials.END_PORTAL_FRAME)) {
     return null;
   }
   BlockFace facing = VanillaMaterials.END_PORTAL_FRAME.getFacing(frameBlock);
   // Rotates the facing 90 degrees to the left
   BlockFace lookDirection = BlockFaces.NESW.previous(facing);
   // Get the corner piece
   Block corner = frameBlock;
   for (int i = 0; i < 4 && isEndFrame(corner, facing, false); i++) {
     corner = corner.translate(lookDirection);
   }
   // Now go two steps back and two steps towards the middle (facing)
   return corner.translate(lookDirection, -2).translate(facing, 2);
 }
예제 #2
0
 private boolean findFrame(Block origin, boolean withEnderEye) {
   for (BlockFace face : BlockFaces.NESW) {
     Block frame = origin.translate(face, 2);
     BlockFace facing = face.getOpposite();
     if (!isEndFrame(frame, facing, withEnderEye)) {
       return false;
     }
     if (!isEndFrame(frame.translate(BlockFaces.NESW.previous(face)), facing, withEnderEye)) {
       return false;
     }
     if (!isEndFrame(frame.translate(BlockFaces.NESW.next(face)), facing, withEnderEye)) {
       return false;
     }
   }
   return true;
 }
예제 #3
0
  @Override
  public void placeObject(World w, int x, int y, int z) {
    Block origin = w.getBlock(x, y, z);

    // Generate the frames
    for (BlockFace face : BlockFaces.NESW) {
      Block frame = origin.translate(face, 2);
      BlockFace facing = face.getOpposite();
      // Place the three pieces
      placeFrame(frame, facing);
      placeFrame(frame.translate(BlockFaces.NESW.previous(face)), facing);
      placeFrame(frame.translate(BlockFaces.NESW.next(face)), facing);
    }

    // Set to a random state
    setRandomActive(origin, 0.1f);
  }