Esempio n. 1
0
  /** Checking right click actions on blocks. */
  public boolean checkBlockInteraction(
      Resident res, BlockPos bp, PlayerInteractEvent.Action action) {
    Block blockType =
        DimensionManager.getWorld(bp.getDim()).getBlock(bp.getX(), bp.getY(), bp.getZ());
    for (SegmentBlock segment : segmentsBlocks) {
      if (segment.getCheckClass().isAssignableFrom(blockType.getClass())
          && (segment.getMeta() == -1
              || segment.getMeta()
                  == DimensionManager.getWorld(bp.getDim())
                      .getBlockMetadata(bp.getX(), bp.getY(), bp.getZ()))
          && (segment.getType() == BlockType.ANY_CLICK
              || segment.getType() == BlockType.RIGHT_CLICK
                  && action == PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK
              || segment.getType() == BlockType.LEFT_CLICK
                  && action == PlayerInteractEvent.Action.LEFT_CLICK_BLOCK)) {
        int dim = bp.getDim();
        int x = bp.getX();
        int y = bp.getY();
        int z = bp.getZ();

        if (!hasPermission(res, segment, dim, x, y, z)) {
          if (segment.hasClientUpdate())
            sendClientUpdate(
                segment.getClientUpdateCoords(), bp, (EntityPlayerMP) res.getPlayer(), null);
          return true;
        }
      }
    }

    return false;
  }
Esempio n. 2
0
  public static boolean checkBlockBreak(Block block) {
    for (SegmentSpecialBlock segment : segmentsSpecialBlock.get(block.getClass())) {
      if (segment.isAlwaysBreakable()) {
        return true;
      }
    }

    return false;
  }
Esempio n. 3
0
  public static void checkBlockInteraction(
      Resident res, BlockPos bp, PlayerInteractEvent.Action action, Event ev) {
    if (!ev.isCancelable()) {
      return;
    }
    World world = MinecraftServer.getServer().worldServerForDimension(bp.getDim());
    Block block = world.getBlock(bp.getX(), bp.getY(), bp.getZ());

    for (SegmentBlock segment : segmentsBlock.get(block.getClass())) {
      if (!segment.shouldInteract(res, bp, action)) {
        ev.setCanceled(true);
      }
    }
  }
Esempio n. 4
0
 public boolean reCheckStructure(World w, int x, int y, int z, Block originalb) {
   int size = mapStructure.size();
   for (Entry<String, Coord4> entry : mapStructure.entrySet()) {
     int xT = entry.getValue().x + x;
     int yT = entry.getValue().y + y;
     int zT = entry.getValue().z + z;
     Block b = w.getBlock(xT, yT, zT);
     TileEntity t = w.getTileEntity(xT, yT, zT);
     if (b == null || b.getClass() != originalb.getClass()) {
       return false;
     }
     if (t != null) {
       /*if( ( t instanceof TileMasterPillar && ((TileMasterPillar)t).hasMaster() ) ){
       	return false;
       }*/
       if (t instanceof TileMasterPillar == false
           && t instanceof TileRenderPillarModel == false
           && t instanceof TileBlockPillar == false) {
         return false;
       }
     }
   }
   return true;
 }
Esempio n. 5
0
  private void SearchNext(World world, Position now) {
    if (SpawnMap.containsKey(now.getVisualityValue())) return;

    Block cb = Block.blocksList[UtilWorld.getBlockID(world, now)];
    String cz = cb == null ? "!@#@!" : cb.getClass().getSimpleName();

    if (UtilBlock.isEqualWoodBlocks(world, now, new Position(X, Y, Z))
        || AnimalCrossing.isLeaf(
            UtilWorld.getBlockID(world, now), UtilWorld.getBlockMetadata(world, now), cz)) {
      SpawnMap.put(now.getVisualityValue(), Boolean.valueOf(true));
      DataMap.put(
          now.getVisualityValue(),
          String.format(
              "%d:%d", UtilWorld.getBlockID(world, now), UtilWorld.getBlockMetadata(world, now)));

      UtilPosition.putAroundNextPositions(now, WideSearchQueue);
    } else {
      SpawnMap.put(now.getVisualityValue(), Boolean.valueOf(false));
    }
  }
Esempio n. 6
0
    private boolean classMatch(Item base, Item matched) {
      if (base.getClass() == Item.class) {
        return base == matched;
      } else if (base.getClass() == matched.getClass()) {
        if (base instanceof ItemBlock) {
          Block baseBlock = ((ItemBlock) base).field_150939_a;
          Block matchedBlock = ((ItemBlock) matched).field_150939_a;

          if (baseBlock.getClass() == Block.class) {
            return baseBlock == matchedBlock;
          } else {
            return baseBlock.equals(matchedBlock);
          }
        } else {
          return true;
        }
      } else {
        return false;
      }
    }
 @Override
 public boolean preventMovement(
     World world, int x, int y, int z, Block block, int meta, TileEntity tile) {
   return !(canMoveClass(block.getClass()) && (tile == null || canMoveClass(tile.getClass())));
 }
Esempio n. 8
0
 /** Checks the block if it can be activated by a right-click */
 public static boolean checkActivatedBlocks(Block block, int meta) {
   for (Protection prot : Protections.instance.getProtectionList()) {
     if (prot.isBlockTracked(block.getClass(), meta)) return true;
   }
   return false;
 }