public GlowDesertTemple(Random random, Location location) { super(random, location.add(0, -18, 0), new Vector(21, 29, 21)); }
/** * Get all LeashHitch Entities in the specified block. * * @param block the Block to search LeashHitch Entities in * @return a Stream of all found LeashHitch Entities */ private static Stream<LeashHitch> getExistingLeashHitches(Block block) { Location location = block.getLocation().add(0.5, 0.5, 0.5); Collection<Entity> nearbyEntities = block.getWorld() .getNearbyEntities(location, 0.49, 0.49, 0.49); return nearbyEntities.stream() .filter(e -> e instanceof LeashHitch) .map(e -> (LeashHitch) e); }
@Override public Location getEyeLocation() { return getLocation().add(0, getEyeHeight(), 0); }
public Location getMountLocation() { return this.location.clone().add(0, this.getHeight(), 0); }
@Override public void rightClickBlock(GlowPlayer player, GlowBlock target, BlockFace face, ItemStack holding, Vector clickedLoc, EquipmentSlot hand) { spawnFirework(player, holding, target.getLocation().add(clickedLoc), player.getUniqueId(), null); }
@Override public void blockDestroy(GlowPlayer player, GlowBlock block, BlockFace face) { //only spawn silverfish if block broke by player in survival if (player.getGameMode() == GameMode.SURVIVAL) { block.getWorld().spawn(block.getLocation().add(0.5, 0, 0.5), GlowSilverfish.class, CreatureSpawnEvent.SpawnReason.SILVERFISH_BLOCK); } }
@Override public void pulse() { super.pulse(); fuseTicks--; if (fuseTicks <= 0) { explode(); } else { world.playEffect(location.clone().add(0, 0.5, 0), Effect.SMOKE, 0); } }
private boolean hasNearVineBlocks(GlowBlock block) { GlowWorld world = block.getWorld(); int vineCount = 0; for (int x = 0; x < 9; x++) { for (int z = 0; z < 9; z++) { for (int y = 0; y < 3; y++) { if (world.getBlockAt(block.getLocation().add(x - 4, y - 1, z - 4)).getType() == Material.VINE) { if (++vineCount >= 5) { return true; } } } } } return false; } }
@Override protected void pulsePhysics() { if (location.getBlock().getType().isSolid()) { setRawLocation(location.clone().add(0, 0.2, 0), false); } super.pulsePhysics(); }
private Location getTopLeftCorner() { BlockFace left = getLeftFace(); Location topLeft = artCenter.clone(); int topMod = (int) getArtHeight(); int widthMod = (int) getArtWidth(); topLeft.add(left.getModX() * widthMod, topMod, left.getModZ() * widthMod); return topLeft; }
/** * Determines the initial location of the fishing hook. * * @param player the player who is fishing * @return the initial location of the hook */ private Location calculateSpawnLocation(Player player) { Location loc = player.getEyeLocation(); Vector direction = loc.getDirection(); double dx = direction.getX() * player.getWidth() / 2; double dz = direction.getZ() * player.getWidth() / 2; loc.add(dx, 0, dz); return loc; } }
@Override public boolean onToolRightClick(GlowPlayer player, GlowBlock target, BlockFace face, ItemStack holding, Vector clickedLoc, EquipmentSlot hand) { if (target.getRelative(BlockFace.UP).getType() == Material.AIR && target.getType() == Material.GRASS && face != BlockFace.DOWN) { target.getWorld() .playSound(target.getLocation().add(0.5D, 0.5D, 0.5D), Sound.BLOCK_GRAVEL_STEP, 1, 0.8F); target.setType(Material.GRASS_PATH); return true; } return false; } }
private void calculateRay(Vector direction, Collection<BlockVector> result) { 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; } }
/** * Convert a TNT block into a primed TNT entity with the player who ignited the TNT. * * @param tntBlock The block to ignite. * @param ignitedByExplosion True if another explosion caused this ignition. * @param player The player who ignited the TNT. */ public static void igniteBlock( Block tntBlock, boolean ignitedByExplosion, GlowPlayer player) { tntBlock.setType(Material.AIR); World world = tntBlock.getWorld(); GlowTntPrimed tnt = (GlowTntPrimed) world .spawnEntity(tntBlock.getLocation().add(0.5, 0, 0.5), EntityType.PRIMED_TNT); tnt.setSource(player); tnt.setIgnitedByExplosion(ignitedByExplosion); world.playSound(tntBlock.getLocation(), Sound.ENTITY_TNT_PRIMED, 1, 1); }
@Override public void rightClickBlock(GlowPlayer player, GlowBlock target, BlockFace face, ItemStack holding, Vector clickedLoc, EquipmentSlot hand) { if (target == null || (target.getType() != Material.BEDROCK && target.getType() != Material.OBSIDIAN)) { return; } Location location = target.getRelative(BlockFace.UP).getLocation(); // Spawn the crystal in the center of the block location.add(0.5, 0, 0.5); EnderCrystal crystal = player.getWorld().spawn(location, EnderCrystal.class); // "Defaults to false when placing by hand [..] // http://minecraft.gamepedia.com/End_Crystal#Data_values crystal.setShowingBottom(false); super.rightClickBlock(player, target, face, holding, clickedLoc, hand); } }
@Override protected ItemStack dispenseStack(GlowBlock block, ItemStack stack) { GlowWorld world = block.getWorld(); GlowBlock target = block.getRelative(BlockDispenser.getFacing(block)); GlowTntPrimed tnt = (GlowTntPrimed) world .spawnEntity(target.getLocation().add(0.5, 0, 0.5), EntityType.PRIMED_TNT); world.playSound(tnt.getLocation(), Sound.ENTITY_TNT_PRIMED, 1, 1); stack.setAmount(stack.getAmount() - 1); return stack.getAmount() > 0 ? stack : null; } }
@Override public boolean isInside(Location location) { Location max = center.clone().add(size / 2, 0, size / 2); Location min = center.clone().subtract(size / 2, 0, size / 2); return location.getX() <= max.getX() && location.getZ() <= max.getZ() && location.getX() >= min.getX() && location.getZ() >= min.getZ(); }
protected void transformToFallingEntity(GlowBlock me) { //Force block to update otherwise it can sometimes duplicate me = me.getWorld().getBlockAt(me.getX(), me.getY(), me.getZ()); if (!me.isEmpty()) { byte data = me.getData(); me.setType(Material.AIR); me.getWorld().spawnFallingBlock(me.getLocation().add(0.50, 0.00, 0.50), drop, data); } }
private void kill(boolean dropArmorStand) { active = false; ((GlowWorld) location.getWorld()) .showParticle(location.clone().add(0, 1.317, 0), Effect.TILE_DUST, Material.WOOD.getId(), 0, 0.125f, 0.494f, 0.125f, 0.1f, 10, 10); for (ItemStack stack : equipment.getArmorContents()) { if (InventoryUtil.isEmpty(stack)) { continue; } getWorld().dropItemNaturally(location, stack); } if (dropArmorStand) { getWorld().dropItemNaturally(location, new ItemStack(Material.ARMOR_STAND)); } }
private void placeBoat(GlowPlayer player, ItemStack holding) { Block targetBlock = player.getTargetBlock((Set<Material>) null, 5); if (targetBlock != null && !targetBlock.isEmpty() && targetBlock.getRelative(BlockFace.UP).isEmpty()) { Location location = targetBlock.getRelative(BlockFace.UP).getLocation(); // center boat on cursor location location.add(0.6875f, 0, 0.6875f); location.setYaw(player.getLocation().getYaw()); Boat boat = targetBlock.getWorld().spawn(location, Boat.class); boat.setWoodType(woodType); if (player.getGameMode() != GameMode.CREATIVE) { player.getInventory().removeItem(holding); } } }