/** * Returns true if the Piston in the event is sticky. * * @return stickiness of the piston */ public boolean isSticky() { return block.getType() == Material.PISTON_STICKY_BASE; }
@Override public boolean isValid(Block block) { return validMaterials.contains(block.getType()); }
private boolean isNearWater(Block block) { for (BlockFace face : SIDES) { switch (block.getRelative(face).getType()) { case WATER: case STATIONARY_WATER: return true; default: break; } } return false; }
@Override public boolean canSpawn(World world, int x, int z) { Block block = world.getHighestBlockAt(x, z).getRelative(BlockFace.DOWN); return block.getType() == Material.NETHERRACK; }
@Override public boolean canSpawn(World world, int x, int z) { Block block = world.getHighestBlockAt(x, z).getRelative(BlockFace.DOWN); return block.getType() == Material.ENDER_STONE; }
/** * Returns true if the player is inside a water block. * * @return True if entity is in water. */ public boolean isInWater() { Material mat = getLocation().getBlock().getType(); return mat == Material.WATER || mat == Material.STATIONARY_WATER; }
@Override public void populate(World world, Random random, Chunk chunk) { int sourceX = chunk.getX() << 4; int sourceZ = chunk.getZ() << 4; for (int i = 0; i < random.nextInt(6) + 3; i++) { int x = sourceX + random.nextInt(16); int z = sourceZ + random.nextInt(16); int y = random.nextInt(28) + 4; if (world.getBlockAt(x, y, z).getType() == Material.STONE) { world.getBlockAt(x, y, z).setType(Material.EMERALD_ORE); } } } }
@Override public boolean canSpawn(World world, int x, int z) { Block block = world.getHighestBlockAt(x, z).getRelative(BlockFace.DOWN); return !block.isLiquid() && !block.isEmpty() && !noSpawnFloors.contains(block.getType()); }
@Override public void pulse() { super.pulse(); // TODO: Particles // TODO: Bopper movement if (location.getBlock().getType() == Material.WATER) { increaseTimeLived(); } }
/** * Returns whether the entity's eye location is within a solid block. * * @return true if the entity is in a solid block; false otherwise */ public boolean isWithinSolidBlock() { return getEyeLocation().getBlock().getType().isOccluding(); }
@Override public void pulse() { super.pulse(); // seems like every hanging entity only checks every 5 Seconds if it can still survive if (ticksLived % (5 * 20) == 0) { Block block = location.getBlock(); BlockType blockType = ItemTable.instance().getBlock(block.getType()); if (!(blockType instanceof BlockFence)) { getExistingLeashHitches(block).forEach(Entity::remove); } } }
@Override public void pulse() { super.pulse(); // "While in the End, [..] will continually generate fire, [..] replacing any other block" if (world.getEnvironment() == Environment.THE_END) { Block block = location.getBlock(); if (block.getType() != Material.FIRE) { block.setType(Material.FIRE); } } }
@Override public InventoryView openEnchanting(Location location, boolean force) { if (location == null) { location = getLocation(); } if (!force && location.getBlock().getType() != Material.ENCHANTMENT_TABLE) { return null; } return openInventory(new GlowEnchantingInventory(location, (GlowPlayer) this)); }
private boolean isPistonExtended(Block block) { // TODO: check direction of piston_extension to make sure that the extension is attached to // piston Block pistonHead = block .getRelative(((PistonBaseMaterial) block.getState().getData()).getFacing()); return pistonHead.getType() == Material.PISTON_EXTENSION; }
@Override public InventoryView openWorkbench(Location location, boolean force) { if (location == null) { location = getLocation(); } if (!force && location.getBlock().getType() != Material.WORKBENCH) { return null; } return openInventory(new GlowCraftingInventory(this, InventoryType.WORKBENCH)); }
@Override protected void pulsePhysics() { if (location.getBlock().getType().isSolid()) { setRawLocation(location.clone().add(0, 0.2, 0), false); } super.pulsePhysics(); }
private static byte colorFor(Block block, int worldX, int worldZ) { // TODO: Some blocks vary in map color based on block states (e.g. wood species) ValueCollection materialValues; materialValues = block instanceof GlowBlock ? ((GlowBlock) block).getMaterialValues() : ((GlowServer) ServerProvider.getServer()).getMaterialValueManager() .getValues(block.getType()); byte baseColor = materialValues.getBaseMapColor(); return (byte) (baseColor | pseudoRandomShade(worldX, worldZ)); } }
@Override public void updatePhysicsAfterEvent(GlowBlock me) { super.updatePhysicsAfterEvent(me); Block below = me.getRelative(BlockFace.DOWN); if (!supportingBlock(below.getType())) { //Simulates real Minecraft delay on block fall //If possible should be changed to 2.5 ticks me.getWorld().getServer().getScheduler() .runTaskLater(null, () -> transformToFallingEntity(me), 2); } }