Java Code Examples for org.bukkit.Material#isBlock()
The following examples show how to use
org.bukkit.Material#isBlock() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EntitySpawnHandler.java From EntityAPI with GNU Lesser General Public License v3.0 | 6 votes |
@Override public <T extends ControllableEntityHandle<? extends LivingEntity>> T createHandle(ControllableEntity entity, Location location) { SafeConstructor<ControllableEntityHandle> entityConstructor = new Reflection().reflect(entity.getEntityType().getHandleClass()).getSafeConstructor(World.class, entity.getEntityType().getControllableInterface()); EntityRegistrationEntry oldEntry = GameRegistry.get(IEntityRegistry.class).getDefaultEntryFor(entity.getEntityType()); GameRegistry.get(IEntityRegistry.class).register(new EntityRegistrationEntry( entity.getEntityType().getName(), entity.getEntityType().getId(), entity.getEntityType().getHandleClass() )); WorldServer worldServer = ((CraftWorld) location.getWorld()).getHandle(); T handle = (T) entityConstructor.getAccessor().invoke(worldServer, entity); handle.setPositionRotation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch()); worldServer.addEntity((net.minecraft.server.v1_7_R1.Entity) handle, CreatureSpawnEvent.SpawnReason.CUSTOM); GameRegistry.get(IEntityRegistry.class).register(oldEntry); Material beneath = location.getBlock().getRelative(BlockFace.DOWN).getType(); if (beneath.isBlock()) { // What lies beneath ((Entity) handle).onGround = true; } return handle; }
Example 2
Source File: EntitySpawnHandler.java From EntityAPI with GNU Lesser General Public License v3.0 | 6 votes |
@Override public <T extends ControllableEntityHandle<? extends LivingEntity>> T createEntityHandle(ControllableEntity entity, Location location) { SafeConstructor<ControllableEntityHandle> entityConstructor = getConstructorFor(entity.getEntityType()); EntityRegistrationEntry oldEntry = GameRegistry.get(IEntityRegistry.class).getDefaultEntryFor(entity.getEntityType()); GameRegistry.get(IEntityRegistry.class).register(new EntityRegistrationEntry( entity.getEntityType().getName(), entity.getEntityType().getId(), entity.getEntityType().getHandleClass() )); WorldServer worldServer = ((CraftWorld) location.getWorld()).getHandle(); T handle = (T) entityConstructor.getAccessor().invoke(worldServer, entity); handle.setPositionRotation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch()); worldServer.addEntity((net.minecraft.server.v1_8_R1.Entity) handle, CreatureSpawnEvent.SpawnReason.CUSTOM); GameRegistry.get(IEntityRegistry.class).register(oldEntry); Material beneath = location.getBlock().getRelative(BlockFace.DOWN).getType(); if (beneath.isBlock()) { // What lies beneath ((Entity) handle).onGround = true; } return handle; }
Example 3
Source File: ImportManager.java From Statz with GNU General Public License v3.0 | 6 votes |
private void importBlocksBroken(PlayerInfo playerInfo, String worldName) { Optional<JSONObject> object = getCustomSection(playerInfo.getUUID(), worldName); if (!object.isPresent()) { return; } Optional<JSONObject> minedSection = getMinedSection(playerInfo.getUUID(), worldName); if (!minedSection.isPresent()) return; for (Material material : Material.values()) { if (material.isBlock()) { long broken = (Long) getStatistic(minedSection.get(), material.getKey().toString()).orElse(0L); if (broken <= 0) continue; playerInfo.addRow(PlayerStat.BLOCKS_BROKEN, StatzUtil.makeQuery(playerInfo.getUUID(), "value", broken, "world", worldName, "block", material)); } } }
Example 4
Source File: EntitySpawnHandler.java From EntityAPI with GNU Lesser General Public License v3.0 | 6 votes |
@Override public <T extends ControllableEntityHandle<? extends LivingEntity>> T createEntityHandle(ControllableEntity entity, Location location) { SafeConstructor<ControllableEntityHandle> entityConstructor = getConstructorFor(entity.getEntityType()); EntityRegistrationEntry oldEntry = GameRegistry.get(IEntityRegistry.class).getDefaultEntryFor(entity.getEntityType()); GameRegistry.get(IEntityRegistry.class).register(new EntityRegistrationEntry( entity.getEntityType().getName(), entity.getEntityType().getId(), entity.getEntityType().getHandleClass() )); WorldServer worldServer = ((CraftWorld) location.getWorld()).getHandle(); T handle = (T) entityConstructor.getAccessor().invoke(worldServer, entity); handle.setPositionRotation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch()); worldServer.addEntity((net.minecraft.server.v1_7_R1.Entity) handle, CreatureSpawnEvent.SpawnReason.CUSTOM); GameRegistry.get(IEntityRegistry.class).register(oldEntry); Material beneath = location.getBlock().getRelative(BlockFace.DOWN).getType(); if (beneath.isBlock()) { // What lies beneath ((Entity) handle).onGround = true; } return handle; }
Example 5
Source File: NewBlockCompat.java From Skript with GNU General Public License v3.0 | 5 votes |
@Override @Nullable public BlockValues getBlockValues(ItemStack stack) { Material type = stack.getType(); if (type.isBlock()) { // Block has data // Create default block data for the type return new NewBlockValues(type, Bukkit.createBlockData(type), true); } return null; }
Example 6
Source File: MaterialAPI.java From ProtocolSupport with GNU Affero General Public License v3.0 | 5 votes |
/** * Returns block material network id * @param material block material * @return network id */ @SuppressWarnings("deprecation") public static int getBlockNetworkId(Material material) { if (material.isLegacy()) { throw new IllegalArgumentException(MessageFormat.format("Material {0} is legacy", material)); } if (!material.isBlock()) { throw new IllegalArgumentException(MessageFormat.format("Material {0} is not a block", material)); } return ServerPlatform.get().getMiscUtils().getBlockNetworkId(material); }
Example 7
Source File: MaterialAPI.java From ProtocolSupport with GNU Affero General Public License v3.0 | 5 votes |
/** * Returns all possible block data states for this material * @param material block material * @return all possible block data states */ @SuppressWarnings("deprecation") public static List<BlockData> getBlockDataList(Material material) { if (material.isLegacy()) { throw new IllegalArgumentException(MessageFormat.format("Material {0} is legacy", material)); } if (!material.isBlock()) { throw new IllegalArgumentException(MessageFormat.format("Material {0} is not a block", material)); } return ServerPlatform.get().getMiscUtils().getBlockDataList(material); }
Example 8
Source File: BlockStateVariable.java From NBTEditor with GNU General Public License v3.0 | 5 votes |
@Override public boolean set(String value, Player player) { Material material = MaterialMap.getByName(value); if (material == null) { material = MaterialMap.getByName("minecraft:" + value); } if (material != null && material.isBlock()) { NBTTagCompound data = new NBTTagCompound(); data.setString("Name", MaterialMap.getName(material)); data().setCompound(_key, data); return true; } return false; }
Example 9
Source File: ConfigurationHelper.java From WorldEditSelectionVisualizer with MIT License | 5 votes |
@NotNull private Material getMaterial(String type, boolean needBlock) { Material material = Material.matchMaterial(type); if (material == null) { plugin.getLogger().warning("Invalid material for particle in the config: " + type); return Material.STONE; } if (needBlock && !material.isBlock()) { plugin.getLogger().warning("The material for particle in the config must be a block: " + type); return Material.STONE; } return material; }
Example 10
Source File: ItemUtils.java From Skript with GNU General Public License v3.0 | 5 votes |
/** * Gets a block material corresponding to given item material, which might * be the given material. If no block material is found, null is returned. * @param type Material. * @return Block version of material or null. */ @Nullable public static Material asBlock(Material type) { if (!damageMeta) { // Apply some hacks on 1.12 and older if (type == bedItem) { // BED and BED_BLOCK mess, issue #1856 return bedBlock; } } if (type.isBlock()) { return type; } else { return null; } }
Example 11
Source File: Materials.java From ProjectAres with GNU Affero General Public License v3.0 | 5 votes |
/** * Does the given {@link Material} support falling blocks placed on top of it? * * This only counts when the gravity block is placed directly on top of the given material, * not when it is already falling and lands on the material. */ public static boolean canSupportBlocks(Material material) { if(material == null || !material.isBlock() || isLiquid(material)) return false; switch(material) { case AIR: case FIRE: return false; } return true; }
Example 12
Source File: XMLUtils.java From ProjectAres with GNU Affero General Public License v3.0 | 5 votes |
public static Material parseBlockMaterial(Node node, String text) throws InvalidXMLException { Material material = parseMaterial(node, text); if(!material.isBlock()) { throw new InvalidXMLException("Material " + material.name() + " is not a block", node); } return material; }
Example 13
Source File: BlockVectors.java From PGM with GNU Affero General Public License v3.0 | 4 votes |
/** Block world that a player can stand on */ static boolean isSupportive(Material type) { if (type.isOccluding()) { return true; } // blocks that aren't listed as occluding but can support a player if (type.isBlock()) { if (type.name().endsWith("STAIRS")) return true; if (type.name().endsWith("STEP")) return true; switch (type) { case CHEST: case ENDER_CHEST: case TRAPPED_CHEST: case HOPPER: case ANVIL: case BEACON: case ENCHANTMENT_TABLE: case CAULDRON: case DAYLIGHT_DETECTOR: case DAYLIGHT_DETECTOR_INVERTED: case GLASS: case STAINED_GLASS: case GLOWSTONE: case ICE: case LEAVES: case LEAVES_2: case PISTON_BASE: case PISTON_STICKY_BASE: case REDSTONE_BLOCK: case SOIL: case TNT: case BARRIER: case CARPET: case WATER_LILY: case CAKE_BLOCK: case SLIME_BLOCK: return true; } } return false; }
Example 14
Source File: MaterialIs.java From ProjectAres with GNU Affero General Public License v3.0 | 4 votes |
@Override public void validate(Material material, @Nullable Node node) throws InvalidXMLException { if(!material.isBlock()) { throw new InvalidXMLException("Material " + material.name() + " is not a block", node); } }
Example 15
Source File: BlockMaterialMatcher.java From ProjectAres with GNU Affero General Public License v3.0 | 4 votes |
@Override public boolean matches(Material material) { return material.isBlock(); }
Example 16
Source File: BlockMaterialMatcher.java From ProjectAres with GNU Affero General Public License v3.0 | 4 votes |
@Override public boolean apply(Material input) { return input.isBlock(); }
Example 17
Source File: BlockMaterialMatcher.java From PGM with GNU Affero General Public License v3.0 | 4 votes |
@Override public boolean matches(Material material) { return material.isBlock(); }
Example 18
Source File: BlockMaterialMatcher.java From PGM with GNU Affero General Public License v3.0 | 4 votes |
@Override public boolean apply(Material input) { return input.isBlock(); }
Example 19
Source File: ParticleEffect.java From EffectLib with MIT License | 3 votes |
/** * Construct a new block data * * @param material Material of the block * @param data Data value of the block * @throws IllegalArgumentException If the material is not a block * @see ParticleData#ParticleData(Material, byte) */ @SuppressWarnings("deprecation") public BlockData(Material material, byte data) throws IllegalArgumentException { super(material, data); if (!material.isBlock()) { throw new IllegalArgumentException("The material is not a block"); } }
Example 20
Source File: ParticleEffect.java From Crazy-Crates with MIT License | 3 votes |
/** * Construct a new block data * * @param material Material of the block * @param data Data value of the block * @throws IllegalArgumentException If the material is not a block * @see ParticleData#ParticleData(Material, byte) */ public BlockData(Material material, byte data) throws IllegalArgumentException { super(material, data); if (!material.isBlock()) { throw new IllegalArgumentException("The material is not a block"); } }