@Override public Chunk getChunk() { return base.getChunk(); }
@Override public org.bukkit.Chunk convertSpecial(Object value, Class<?> valueType, org.bukkit.Chunk def) { if (value instanceof Chunk) { return ((Chunk) value).bukkitChunk; } else if (value instanceof org.bukkit.block.Block) { return ((org.bukkit.block.Block) value).getChunk(); } else if (value instanceof BlockState) { return ((BlockState) value).getChunk(); } else if (value instanceof Location) { return ((Location) value).getChunk(); } else { return def; } } };
@Override public boolean isReady() { if ((mode == BrushMode.CLONE || mode == BrushMode.REPLICATE) && materialTarget != null) { Block block = materialTarget.getBlock(); return (block.getChunk().isLoaded()); } else if (mode == BrushMode.SCHEMATIC) { return checkSchematic(); } return true; }
public static boolean setBlockFast(Block block, Material material, int data) { return setBlockFast(block.getChunk(), block.getX(), block.getY(), block.getZ(), material, data); }
@Override public boolean onRightClick(ItemUseEvent e, Player p, ItemStack stack) { if (e.getClickedBlock() == null) return false; SlimefunItem item = BlockStorage.check(e.getClickedBlock()); if (item == null || !item.getName().equals("GPS_GEO_SCANNER")) return false; e.setCancelled(true); try { Slimefun.getGPSNetwork().scanChunk(p, e.getClickedBlock().getChunk()); } catch (Exception e1) { e1.printStackTrace(); } return true; } });
public Block getHeadTarget() { if (this.targetHeadBlock == null) { return null; } this.getTargetHeadBlock().getBlock().getChunk().load(true); return this.getTargetHeadBlock().getBlock(); }
public Block getHeadTarget() { if (this.targetHeadBlock == null) { return null; } this.getTargetHeadBlock().getBlock().getChunk().load(true); return this.getTargetHeadBlock().getBlock(); }
public Block getFeetTarget() { if (this.getTargetFeetBlock() == null) { return null; } this.getTargetFeetBlock().getBlock().getChunk().load(true); return this.getTargetFeetBlock().getBlock(); }
public Block getFeetTarget() { if (this.getTargetFeetBlock() == null) { return null; } this.getTargetFeetBlock().getBlock().getChunk().load(true); return this.getTargetFeetBlock().getBlock(); }
public static Item findItem(Block b) { for (Entity n: b.getChunk().getEntities()) { if (n instanceof Item) { if (b.getLocation().add(0.5, 1.2, 0.5).distanceSquared(n.getLocation()) < 0.5D && n.getCustomName() != null) return (Item) n; } } return null; }
public void closeDoors() { // get door locations ResultSetDoorBlocks rs = new ResultSetDoorBlocks(plugin, id); if (rs.resultSet()) { close(rs.getOuterBlock(), rs.getInnerBlock().getLocation()); // inner if (!rs.getInnerBlock().getChunk().isLoaded()) { rs.getInnerBlock().getChunk().load(); } plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> close(rs.getInnerBlock(), null), 5L); } }
public void openDoors() { // get door locations // inner ResultSetDoorBlocks rs = new ResultSetDoorBlocks(plugin, id); if (rs.resultSet()) { open(rs.getInnerBlock(), rs.getOuterBlock(), true); // outer if (!rs.getOuterBlock().getChunk().isLoaded()) { rs.getOuterBlock().getChunk().load(); } plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> open(rs.getOuterBlock(), rs.getInnerBlock(), false), 5L); } }
@Override public boolean canOpen(Block b, Player p) { if (!(p.hasPermission("slimefun.inventory.bypass") || CSCoreLib.getLib().getProtectionManager().canAccessChest(p.getUniqueId(), b, true))) { return false; } if (!OreGenSystem.wasResourceGenerated(OreGenSystem.getResource("Oil"), b.getChunk())) { Messages.local.sendTranslation(p, "gps.geo.scan-required", true); return false; } return true; }
@Override public boolean canOpen(Block b, Player p) { if (!(p.hasPermission("slimefun.inventory.bypass") || CSCoreLib.getLib().getProtectionManager().canAccessChest(p.getUniqueId(), b, true))) { return false; } if (!OreGenSystem.wasResourceGenerated(getOreGenResource(), b.getChunk())) { Messages.local.sendTranslation(p, "gps.geo.scan-required", true); return false; } return true; }
public boolean isDead(Game game) { Material targetMaterial = game.getTargetMaterial(); this.getTargetHeadBlock().getBlock().getChunk().load(true); if (this.getTargetFeetBlock() == null) { return this.getTargetHeadBlock().getBlock().getType() != targetMaterial; } this.getTargetFeetBlock().getBlock().getChunk().load(true); return (this.getTargetHeadBlock().getBlock().getType() != targetMaterial && this.getTargetFeetBlock().getBlock().getType() != targetMaterial); }
public boolean isDead(Game game) { Material targetMaterial = game.getTargetMaterial(); this.getTargetHeadBlock().getBlock().getChunk().load(true); if (this.getTargetFeetBlock() == null) { return this.getTargetHeadBlock().getBlock().getType() != targetMaterial; } this.getTargetFeetBlock().getBlock().getChunk().load(true); return (this.getTargetHeadBlock().getBlock().getType() != targetMaterial && this.getTargetFeetBlock().getBlock().getType() != targetMaterial); }
public RegenerateBatch(UndoableSpell spell, Location p1, Location p2) { super(spell); this.restoredBlocks = new com.elmakers.mine.bukkit.block.UndoList(mage, spell.getName()); this.restoredBlocks.setSpell(spell); this.restoredBlocks.setBatch(this); this.world = this.mage.getLocation().getWorld(); this.state = RegenerateState.SAVING; int deltax = p2.getBlock().getChunk().getX() - p1.getChunk().getX(); int deltaz = p2.getChunk().getZ() - p1.getChunk().getZ(); absx = Math.abs(deltax) + 1; absz = Math.abs(deltaz) + 1; dx = (int)Math.signum(deltax); dz = (int)Math.signum(deltaz); x = p1.getChunk().getX(); z = p1.getChunk().getZ(); bounds = new BoundingBox(p1.toVector(), p2.toVector()); }
@Override public void teleport(Location location, TeleportCause cause) { if (!isSpawned()) return; NPCTeleportEvent event = new NPCTeleportEvent(this, location); Bukkit.getPluginManager().callEvent(event); if (event.isCancelled()) return; Entity entity = getEntity(); while (entity.getVehicle() != null) { entity = entity.getVehicle(); } location.getBlock().getChunk(); teleport(entity, location, 5); }