Ejemplo n.º 1
0
    protected void checkForGround() {
      checkCounter = 0;

      Location playerLocation = player.getLocation();
      World world = playerLocation.getWorld();
      Block targetBlock = world.getBlockAt(playerLocation);
      targetBlock = targetBlock.getFace(BlockFace.DOWN);

      int newGroundHeight = targetBlock.getY();

      while (targetBlock.getType() == Material.AIR && newGroundHeight > 1) {
        newGroundHeight--;
        targetBlock = targetBlock.getFace(BlockFace.DOWN);
      }

      // if the terrain has changed more than the auto-hover tolerance, re-adjust hover height and
      // keep level.
      if (groundHeight == 0 || targetHeight == 0) {
        hoverHeight = player.getLocation().getBlockY() - newGroundHeight;
        if (hoverHeight < defaultHoverHeight) {
          hoverHeight = defaultHoverHeight;
        }
      } else if (Math.abs(newGroundHeight - groundHeight) > maxTerrainChangeHeight) {
        hoverHeight = targetHeight - newGroundHeight;
      }

      groundHeight = newGroundHeight;

      updateTargetHeight();
    }
Ejemplo n.º 2
0
 public static int[] getSums(
     Location firstPoint, Location secndPoint, List<List<CountBlock>> ArrayPaints) {
   World world = firstPoint.getWorld();
   if (world.equals(secndPoint.getWorld())) {
     int[] sum_paint = new int[ArrayPaints.size()];
     int[] cords = area(firstPoint, secndPoint);
     for (int x = cords[0]; x <= cords[1]; x++) {
       for (int y = cords[2]; y <= cords[3]; y++) {
         for (int z = cords[4]; z <= cords[5]; z++) {
           Block block = new Location(world, x, y, z).getBlock();
           for (int i = 0; i < ArrayPaints.size(); i++) {
             for (CountBlock paint : ArrayPaints.get(i)) {
               if (paint.equals(block)) {
                 sum_paint[i]++;
                 break;
               }
             }
           }
         }
       }
     }
     return sum_paint;
   }
   return new int[] {-1};
 }
Ejemplo n.º 3
0
  private boolean moveEarth() {
    progress++;
    Block affectedblock = location.clone().add(direction).getBlock();
    location = location.add(direction);
    if (GeneralMethods.isRegionProtectedFromBuild(player, "IceSpike", location)) return false;
    for (Entity en : GeneralMethods.getEntitiesAroundPoint(location, 1.4)) {
      if (en instanceof LivingEntity && en != player && !damaged.contains(((LivingEntity) en))) {
        LivingEntity le = (LivingEntity) en;
        affect(le);
        // le.setVelocity(thrown);
        // le.damage(damage);
        // damaged.add(le);
        // Methods.verbose(damage + " Hp:" + le.getHealth());
      }
    }
    affectedblock.setType(Material.ICE);
    WaterMethods.playIcebendingSound(block.getLocation());
    loadAffectedBlocks();

    if (location.distance(origin) >= height) {
      return false;
    }

    return true;
  }
Ejemplo n.º 4
0
 public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
   Gamer gamer = pm.getGamer(sender.getName());
   if (!gamer.isAlive()) {
     if (args.length > 0) {
       if (Bukkit.getPlayer(args[0]) != null) {
         gamer.getPlayer().eject();
         gamer
             .getPlayer()
             .teleport(sender.getServer().getPlayer(args[0]).getLocation().add(0, 0.1, 0));
         return true;
       } else if (args[0].equalsIgnoreCase(cm.getCommandGotoNameOfFeast())) {
         Location feastLoc = LibsFeastManager.getFeastManager().getFeastLocation();
         if (feastLoc.getBlockY() > 0) {
           gamer.getPlayer().eject();
           gamer
               .getPlayer()
               .teleport(
                   feastLoc
                       .getWorld()
                       .getHighestBlockAt(feastLoc)
                       .getLocation()
                       .clone()
                       .add(0.5, 1, 0.5));
         } else sender.sendMessage(cm.getCommandGotoFeastFailed());
         return true;
       } else sender.sendMessage(cm.getCommandGotoPlayerDoesntExist());
     } else sender.sendMessage(cm.getCommandGotoNotEnoughArgs());
   } else sender.sendMessage(cm.getCommandGotoNotSpectator());
   return true;
 }
Ejemplo n.º 5
0
  /**
   * Set the values, all constructors uses this function
   *
   * @param loc location of the view
   * @param maxDistance how far it checks for blocks
   * @param viewHeight where the view is positioned in y-axis
   * @param checkDistance how often to check for blocks, the smaller the more precise
   */
  private void setValues(
      Location loc,
      int maxDistance,
      double viewHeight,
      double checkDistance,
      TIntHashSet transparent) {
    this.maxDistance = maxDistance;
    this.checkDistance = checkDistance;
    curDistance = 0;
    int xRotation = (int) (loc.getYaw() + 90) % 360;
    int yRotation = (int) loc.getPitch() * -1;

    double h = checkDistance * Math.cos(Math.toRadians(yRotation));

    offset =
        new Vector(
            (h * Math.cos(Math.toRadians(xRotation))),
            (checkDistance * Math.sin(Math.toRadians(yRotation))),
            (h * Math.sin(Math.toRadians(xRotation))));

    targetPosDouble = loc.add(0, viewHeight, 0).toVector();
    targetPos = targetPosDouble.toBlockVector();
    prevPos = targetPos;
    transparentBlocks = transparent;
    if (transparentBlocks == null) {
      transparentBlocks = new TIntHashSet(new int[] {0});
    }
  }
Ejemplo n.º 6
0
  private boolean isCloseDoor(Location actual) {
    BlockFace[] blockFaces = {BlockFace.EAST, BlockFace.NORTH, BlockFace.WEST, BlockFace.SOUTH};
    actual.setY(actual.getY());
    Block base = actual.getBlock();
    for (BlockFace bf : blockFaces) {
      Block bu = base.getRelative(bf);
      if ((bu.getType() == Material.WOODEN_DOOR)) {
        byte openData = 0x4;
        byte doorData = (byte) (bu.getData());
        if ((doorData & 0x4) == 0x4) {
          doorData = (byte) (doorData & 0x3);
        } else {
          doorData = (byte) (doorData | 0x7);
        }
        bu.setData(doorData);

        if ((bu.getRelative(BlockFace.UP).getType() == Material.WOODEN_DOOR)) {
          doorData = (byte) (bu.getRelative(BlockFace.UP).getData());
          if ((doorData & 0x1) == 1) {
            doorData = 0x9;
          } else {
            doorData = 0x8;
          }
          bu.getRelative(BlockFace.UP).setData(doorData);
        }
        return true;
      }
    }
    return false;
  }
Ejemplo n.º 7
0
  @EventHandler
  public void onMove(PlayerMoveEvent e) {
    Player p = e.getPlayer();
    double x = p.getLocation().getX();
    double y = p.getLocation().getY() - 1;
    double z = p.getLocation().getZ();
    Location loc = new Location(p.getWorld(), x, y, z);
    Block b1 = loc.getBlock();
    Block b2 = p.getLocation().getBlock();

    if (b1.getType().equals(Material.REDSTONE_BLOCK) && b2.getType().equals(Material.WOOD_PLATE)) {
      // p.sendMessage("ON " + b1.getType().toString() + " + " + b2.getType().toString());
      p.setVelocity(p.getLocation().getDirection().multiply(2).setY(p.getVelocity().getY() + 1));
      p.setFallDistance(0f);
      for (Player all : Bukkit.getOnlinePlayers()) {
        all.playSound(p.getLocation(), Sound.WITHER_SHOOT, 0.1f, 0.1f);
      }
    }

    p.setSaturation(100f);
    p.setFoodLevel(20);
    p.setHealth(20f);

    if (p.getLocation().getY() <= 80) {
      p.teleport(p.getWorld().getSpawnLocation());
      p.setGameMode(GameMode.ADVENTURE);
      p.setAllowFlight(true);
      p.setFlying(false);
    }
  }
Ejemplo n.º 8
0
  public static void perform(Fx fx, String dataString, Collection<Location> locations) {
    if (fx == TNT) {
      for (Location location : locations) {
        if (location == null) continue;
        SmokeUtil.fakeExplosion(location);
      }
      return;
    } else if (fx == STRIKE) {
      for (Location location : locations) {
        if (location == null) continue;
        location.getWorld().strikeLightningEffect(location);
      }
      return;
    } else if (fx == SMOKE) {
      SmokeUtil.spawnCloudSimple(locations);
      return;
    }

    // Decide the data
    Integer data = 0;
    try {
      data = Integer.parseInt(dataString);
    } catch (Exception e) {
    }

    for (Location location : locations) {
      if (location == null) continue;
      location.getWorld().playEffect(location, fx.bukkitEffect, data.intValue());
    }
  }
Ejemplo n.º 9
0
 public void save() {
   if (hasUpdated) {
     hasUpdated = false;
     String sql =
         "UPDATE "
             + DeityNPCMain.getNPCTableName()
             + " SET name = ?, name_color = ?, x_coord = ?, y_coord = ?, z_coord = ?, yaw = ?, pitch = ?, held_item_row_id = ?, armor_helm_row_id = ?, armor_chest_row_id = ?, armor_legging_row_id = ?, armor_boot_row_id = ? WHERE id = ?;";
     DeityAPI.getAPI()
         .getDataAPI()
         .getMySQL()
         .write(
             sql,
             name,
             (nameColor.getChar() + "").toUpperCase(),
             location.getBlockX(),
             location.getBlockY(),
             location.getBlockZ(),
             location.getYaw(),
             location.getPitch(),
             heldItem.getId(),
             armorHelm.getId(),
             armorChest.getId(),
             armorLegging.getId(),
             armorBoot.getId(),
             databaseId);
   }
 }
    public ItemProjectile(Player caster, float power) {
      this.caster = caster;
      this.power = power;
      Location location = caster.getEyeLocation().add(0, yOffset, 0);
      location.setPitch(0f);
      if (vertSpeedUsed) {
        vel = caster.getLocation().getDirection().setY(0).multiply(speed).setY(vertSpeed);
      } else {
        vel = caster.getLocation().getDirection().multiply(speed);
      }
      entity = caster.getWorld().dropItem(location, item.clone());
      MagicSpells.getVolatileCodeHandler().setGravity(entity, projectileHasGravity);
      playSpellEffects(EffectPosition.PROJECTILE, entity);
      playTrackingLinePatterns(
          EffectPosition.DYNAMIC_CASTER_PROJECTILE_LINE,
          caster.getLocation(),
          entity.getLocation(),
          caster,
          entity);
      entity.teleport(location);
      entity.setPickupDelay(1000000);
      entity.setVelocity(vel);

      taskId = MagicSpells.scheduleRepeatingTask(this, 3, 3);
    }
Ejemplo n.º 11
0
 public void negativeeffecttype(
     Player name, Location loc, int dist, int level, PotionEffectType type) {
   if (name.getLocation().getWorld() != loc.getWorld()) return;
   if (loc.distance(name.getLocation()) <= dist) {
     name.addPotionEffect(new PotionEffect(type, config_.getInt("apply_effects"), level), true);
   }
 }
 @Override
 public void undo(Undo undo) {
   World w = Bukkit.getWorld(worldName);
   Location loc = new Location(Bukkit.getWorld(worldName), blockX, blockY, blockZ);
   w.getBlockAt(loc).setType(Material.AIR);
   undo.chunks.add(loc.getChunk());
 }
 @Override
 public void rollback(Rollback rollback) {
   Location loc = new Location(Bukkit.getWorld(worldName), blockX, blockY, blockZ);
   setBlockFast(loc, Material.WOOD_DOOR.getId(), blockData);
   setBlockFast(getOtherDoorBlock(loc), Material.WOOD_DOOR.getId(), blockData);
   rollback.chunks.add(loc.getChunk());
 }
Ejemplo n.º 14
0
    @Override
    public void run() {
      if (!MyWarp.inst().getTimerFactory().hasRunningTimer(type, WarpWarmup.class)) {
        cancel();
        return;
      }

      Player player = MyWarp.server().getPlayerExact(type);
      if (player == null) {
        cancel();
        return;
      }

      Location loc = player.getLocation();
      if (loc.distanceSquared(originalLoc) >= 2 * 2) {
        if (!MyWarp.inst()
            .getPermissionsManager()
            .hasPermission(player, "mywarp.warmup.disobey.moveabort")) {
          WarpWarmup.this.cancel();
          player.sendMessage(
              MyWarp.inst()
                  .getLocalizationManager()
                  .getString("commands.warp-to.warmup.cancelled-move", player));
          cancel();
        }
      }
    }
Ejemplo n.º 15
0
  @Override
  public boolean effect(Event event, Player player) {
    int slot = player.getInventory().getHeldItemSlot();

    ItemStack potion = player.getInventory().getItem(slot + 1);
    Location loc = player.getLocation();
    if (potion != null && potion.getType().toString().contains("POTION")) {
      ThrownPotion tp = player.launchProjectile(ThrownPotion.class);
      EffectManager.playSound(loc, "ENTITY_GENERIC_EXPLODE", 0.5f, 2f);

      try {
        tp.setItem(potion);
      } catch (IllegalArgumentException ex) {
        ItemStack pt = potion.clone();
        if (potion.getType().equals(Material.POTION)
            || potion.getType().equals(Material.LINGERING_POTION))
          pt.setType(Material.SPLASH_POTION);
        tp.setItem(pt);
      }

      tp.setBounce(false);
      tp.setVelocity(loc.getDirection().multiply(ProjectileSpeedMultiplier));
      if (!player.getGameMode().equals(GameMode.CREATIVE)) {
        potion.setAmount(potion.getAmount() - 1);
        player.getInventory().setItem(slot + 1, potion);
        player.updateInventory();
      }
      return true;
    } else {
      player.sendMessage(
          ChatColor.RED + "You need a Potion in the slot to the right of the Potion Launcher!");
      player.getWorld().playEffect(loc, Effect.CLICK1, 5);
    }
    return false;
  }
Ejemplo n.º 16
0
  public void save(File file) throws IOException {
    if (isMysql) {
      saveMysql();
      return;
    }

    FileOutputStream fos = new FileOutputStream(file);
    BufferedWriter br = new BufferedWriter(new OutputStreamWriter(fos));

    for (PrisonPearl pp : pearls_byimprisoned.values()) {
      if (pp.getHolderBlockState() == null) continue;

      Location loc = pp.getLocation();
      br.append(pp.getImprisonedId().toString());
      br.append(" ");
      br.append(loc.getWorld().getName());
      br.append(" ");
      br.append(String.valueOf(loc.getBlockX()));
      br.append(" ");
      br.append(String.valueOf(loc.getBlockY()));
      br.append(" ");
      br.append(String.valueOf(loc.getBlockZ()));
      br.append(" ");
      br.append(String.valueOf(pp.getUniqueIdentifier()));
      br.append(" ");
      br.append(pp.getMotd());
      br.append("\n");
    }

    br.write("lastFeed:" + lastFeed);
    br.flush();
    fos.close();

    dirty = false;
  }
Ejemplo n.º 17
0
  /**
   * @param location the {@link Location} around which players must be to see the effect
   * @param effectName list of effects: https://gist.github.com/riking/5759002
   * @param offsetX the amount to be randomly offset by in the X axis
   * @param offsetY the amount to be randomly offset by in the Y axis
   * @param offsetZ the amount to be randomly offset by in the Z axis
   * @param speed the speed of the particles
   * @param count the number of particles
   * @param radius the radius around the location
   */
  public static void playParticleEffect(
      Location location,
      String effectName,
      float offsetX,
      float offsetY,
      float offsetZ,
      float speed,
      int count,
      int radius) {
    Validate.notNull(location, "Location cannot be null");
    Validate.notNull(effectName, "Effect cannot be null");
    Validate.notNull(location.getWorld(), "World cannot be null");

    PacketPlayOutWorldParticles packet =
        new PacketPlayOutWorldParticles(
            effectName,
            (float) location.getX(),
            (float) location.getY(),
            (float) location.getZ(),
            offsetX,
            offsetY,
            offsetZ,
            speed,
            count);

    for (Player player : location.getWorld().getPlayers()) {
      if ((int) player.getLocation().distance(location) <= radius) {
        ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
      }
    }
  }
Ejemplo n.º 18
0
  @Override
  public void progress() {
    if ((System.currentTimeMillis() - time) >= interval) {
      time = System.currentTimeMillis();

      // Compute effect
      for (LivingEntity entity : EntityTools.getLivingEntitiesAroundPoint(origin, RADIUS)) {
        affect(entity);
      }

      if (noDisplayTick <= 0) {
        // Compute particles
        for (double theta = 0; theta < 360; theta += 36) {
          for (double phi = 0; phi < 360; phi += 36) {
            double x =
                particleDistance * Math.cos(Math.toRadians(theta)) * Math.sin(Math.toRadians(phi));
            double y =
                particleDistance * Math.sin(Math.toRadians(theta)) * Math.sin(Math.toRadians(phi));
            double z = particleDistance * Math.cos(Math.toRadians(phi));
            origin.getWorld().playEffect(origin.clone().add(x, y, z), Effect.SMOKE, 4, (int) RANGE);
          }
        }
        particleDistance -= 1;
        if (particleDistance < 0) {
          particleDistance = RADIUS;
        }
        noDisplayTick = 4;
      }
      noDisplayTick--;
    }
  }
Ejemplo n.º 19
0
 @EventHandler(priority = EventPriority.LOW)
 public void onPlayerMove(PlayerMoveEvent event) {
   // No Entity move :/
   final Player player = event.getPlayer();
   final Location location = player.getLocation().subtract(0, 1, 0);
   final Sprout sprout =
       plugin
           .getWorldRegistry()
           .get(
               player.getWorld().getName(),
               location.getBlockX(),
               location.getBlockY(),
               location.getBlockZ());
   if (sprout == null) {
     return;
   }
   if (sprout.getVariables().damagePlayer()) {
     int damage;
     if (sprout.getCurrentStage() == null) {
       damage = sprout.getDamage();
     } else {
       damage = sprout.getCurrentStage().getDamage();
     }
     player.damage(damage);
   }
 }
 private void getDestination(int id, Player p) {
   // get the destination sign
   Sign s = getDestinationSign(id);
   if (s != null) {
     String line1 = s.getLine(1);
     String line2 = s.getLine(2);
     String line3 = s.getLine(3);
     if (line1.isEmpty() || line2.isEmpty() || line3.isEmpty()) {
       TARDISMessage.send(p, "JUNK_LINES");
       return;
     }
     World w = plugin.getServer().getWorld(line1);
     int x = TARDISNumberParsers.parseInt(line2);
     int z = TARDISNumberParsers.parseInt(line3);
     // load the chunk
     Chunk chunk = w.getChunkAt(x, z);
     while (!chunk.isLoaded()) {
       w.loadChunk(chunk);
     }
     int y = w.getHighestBlockYAt(x, z);
     Location d = new Location(w, x, y, z);
     // TODO check destination
     if (plugin.getPluginRespect().getRespect(d, new Parameters(p, FLAG.getNoMessageFlags()))) {
       while (!chunk.isLoaded()) {
         chunk.load();
       }
       d.setY(getActualHighestY(d));
       plugin.getGeneralKeeper().setJunkDestination(d);
     }
   }
 }
Ejemplo n.º 21
0
 @Override
 public void setBedSpawnLocation(Location location, boolean force) {
   getHandle()
       .setSpawnChunk(
           new ChunkCoordinates(location.getBlockX(), location.getBlockY(), location.getBlockZ()),
           force);
 }
 private int getActualHighestY(Location l) {
   int startx = l.getBlockX() - 3,
       resetx = startx,
       starty = l.getBlockY(),
       startz = l.getBlockZ() - 2,
       resetz = startz,
       level,
       row,
       col;
   for (level = 0; level < 5; level++) {
     boolean found = false;
     for (row = 0; row < 6; row++) {
       for (col = 0; col < 6; col++) {
         Material mat = l.getWorld().getBlockAt(startx, starty, startz).getType();
         if (!TARDISConstants.GOOD_MATERIALS.contains(mat)) {
           found = true;
         }
         startx += 1;
       }
       startx = resetx;
       startz += 1;
     }
     if (!found) {
       return starty;
     }
     startz = resetz;
     starty += 1;
   }
   return starty;
 }
Ejemplo n.º 23
0
 /**
  * @param l
  * @return
  */
 private Location getRandomLocation(Location l) {
   return new Location(
       l.getWorld(),
       l.getBlockX() + plugin.getRNG().nextInt(17) - 8,
       l.getBlockY() + plugin.getRNG().nextInt(6),
       l.getBlockZ() + plugin.getRNG().nextInt(17) - 8);
 }
Ejemplo n.º 24
0
  public boolean readBlocks(Location l1, World w) {
    try {
      FileInputStream fstream = new FileInputStream("plugins/NerdLocker/blocks.lock");
      DataInputStream in = new DataInputStream(fstream);
      BufferedReader br = new BufferedReader(new InputStreamReader(in));
      String strLine;
      while ((strLine = br.readLine()) != null) {
        String delims = ",";
        String[] cords = strLine.split(delims);

        int x = Integer.parseInt(cords[0]);
        int y = Integer.parseInt(cords[1]);
        int z = Integer.parseInt(cords[2]);

        Location l = w.getBlockAt(x, y, z).getLocation();

        if (l1.getBlock().getX() == l.getBlock().getX()
            && l1.getBlock().getY() == l.getBlock().getY()
            && l1.getBlock().getZ() == l.getBlock().getZ()) {
          return false;
        }
      }
      in.close();
      br.close();
      fstream.close();
      return true;
    } catch (Exception e) {
      System.err.println("Error1: " + e.getMessage());
    }
    return false;
  }
Ejemplo n.º 25
0
  public static void smite(final Player p) {
    TFM_Util.bcastMsg(p.getName() + " has been a naughty, naughty boy.", ChatColor.RED);

    // Deop
    p.setOp(false);

    // Set gamemode to survival:
    p.setGameMode(GameMode.SURVIVAL);

    // Clear inventory:
    p.getInventory().clear();

    // Strike with lightning effect:
    final Location target_pos = p.getLocation();
    final World world = p.getWorld();
    for (int x = -1; x <= 1; x++) {
      for (int z = -1; z <= 1; z++) {
        final Location strike_pos =
            new Location(
                world,
                target_pos.getBlockX() + x,
                target_pos.getBlockY(),
                target_pos.getBlockZ() + z);
        world.strikeLightning(strike_pos);
      }
    }

    // Kill:
    p.setHealth(0.0);
  }
Ejemplo n.º 26
0
 public OtherLocation(Location loc, String name) {
   this.world = loc.getWorld().getName();
   this.X = loc.getBlockX();
   this.Y = loc.getBlockY();
   this.Z = loc.getBlockZ();
   this.name = "unknown";
 }
Ejemplo n.º 27
0
 @EventHandler(ignoreCancelled = true)
 public void onEntityExplode(EntityExplodeEvent event) {
   Location loc = event.getEntity().getLocation();
   WorldSettings settings =
       plugin.getConfigManager().getWorldSettings(event.getEntity().getWorld().getName());
   boolean above = loc.getY() >= settings.getWorldSplit();
   switch (event.getEntityType()) {
     case CREEPER:
       switch (settings.getCreeperType()) {
         case DESPAWN:
           event.getEntity().remove();
           break;
         case ABOVE_DESPAWN:
           event.setCancelled(above);
           break;
         default:
           event.setCancelled(true);
           loc.getWorld().createExplosion(loc, settings.getCreeperRadius());
       }
       break;
     case PRIMED_TNT:
       switch (settings.getTntType()) {
         case DESPAWN:
           event.setCancelled(true);
           break;
         case ABOVE_DESPAWN:
           event.setCancelled(above);
           break;
         default:
           event.setCancelled(true);
           loc.getWorld().createExplosion(loc, settings.getTntRadius());
       }
   }
 }
Ejemplo n.º 28
0
  // RŽcupŽration du Relative et ajout du SignManager dans le Set
  public static boolean registerSign(Location locsign) {
    try {
      locsign.getBlock();
    } catch (Exception e) {
      return false;
    } // VŽrifie sur la locsign est un block

    if (!(locsign.getBlock().getState() instanceof org.bukkit.block.Sign)) return false;

    Block bs = locsign.getBlock();
    org.bukkit.material.Sign signmat = (org.bukkit.material.Sign) bs.getState().getData();
    Location relative = null;

    if (!signmat.isWallSign()) relative = bs.getRelative(BlockFace.DOWN).getLocation();
    else if (signmat.getAttachedFace() == BlockFace.EAST)
      relative = bs.getRelative(BlockFace.EAST).getLocation();
    else if (signmat.getAttachedFace() == BlockFace.WEST)
      relative = bs.getRelative(BlockFace.WEST).getLocation();
    else if (signmat.getAttachedFace() == BlockFace.NORTH)
      relative = bs.getRelative(BlockFace.NORTH).getLocation();
    else if (signmat.getAttachedFace() == BlockFace.SOUTH)
      relative = bs.getRelative(BlockFace.SOUTH).getLocation();

    SignManager sm = new SignManager(locsign, relative);
    sm.RefreshSign();
    return true;
  }
Ejemplo n.º 29
0
  private void calculateRay(int ox, int oy, int oz, Collection<BlockVector> result) {
    double x = ox / 7.5 - 1;
    double y = oy / 7.5 - 1;
    double z = oz / 7.5 - 1;
    Vector direction = new Vector(x, y, z);
    direction.normalize();
    direction.multiply(0.3f); // 0.3 blocks away with each step

    Location current = location.clone();

    float currentPower = calculateStartPower();

    while (currentPower > 0) {
      GlowBlock block = world.getBlockAt(current);

      if (block.getType() != Material.AIR) {
        double blastDurability = getBlastDurability(block) / 5d;
        blastDurability += 0.3F;
        blastDurability *= 0.3F;
        currentPower -= blastDurability;

        if (currentPower > 0) {
          result.add(new BlockVector(block.getX(), block.getY(), block.getZ()));
        }
      }

      current.add(direction);
      currentPower -= 0.225f;
    }
  }
Ejemplo n.º 30
0
 // currently unused
 public static boolean getWithinDistanceToForceField(int distance, Location loc) {
   if (Math.abs(loc.getZ() - loc.getZ()) > Config.forcefieldSideLength - distance
       || Math.abs(loc.getX() - loc.getX()) > Config.forcefieldSideLength - distance) {
     return true;
   }
   return false;
 }