org.bukkit.Material#isBlock ( )源码实例Demo

下面列出了org.bukkit.Material#isBlock ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: EntityAPI   文件: EntitySpawnHandler.java
@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;
}
 
源代码2 项目: Statz   文件: ImportManager.java
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));
        }
    }
}
 
源代码3 项目: EntityAPI   文件: EntitySpawnHandler.java
@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;
}
 
源代码4 项目: EntityAPI   文件: EntitySpawnHandler.java
@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;
}
 
源代码5 项目: ProjectAres   文件: XMLUtils.java
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;
}
 
源代码6 项目: ProjectAres   文件: Materials.java
/**
 * 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;
}
 
源代码7 项目: Skript   文件: ItemUtils.java
/**
 * 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;
	}
}
 
源代码8 项目: Skript   文件: NewBlockCompat.java
@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;
}
 
@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;
}
 
源代码10 项目: NBTEditor   文件: BlockStateVariable.java
@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;
}
 
源代码11 项目: ProtocolSupport   文件: MaterialAPI.java
/**
 * 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);
}
 
源代码12 项目: ProtocolSupport   文件: MaterialAPI.java
/**
 * 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);
}
 
源代码13 项目: PGM   文件: BlockVectors.java
/** 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;
}
 
源代码14 项目: PGM   文件: BlockMaterialMatcher.java
@Override
public boolean apply(Material input) {
  return input.isBlock();
}
 
源代码15 项目: PGM   文件: BlockMaterialMatcher.java
@Override
public boolean matches(Material material) {
  return material.isBlock();
}
 
源代码16 项目: ProjectAres   文件: BlockMaterialMatcher.java
@Override
public boolean apply(Material input) {
    return input.isBlock();
}
 
源代码17 项目: ProjectAres   文件: BlockMaterialMatcher.java
@Override
public boolean matches(Material material) {
    return material.isBlock();
}
 
源代码18 项目: ProjectAres   文件: MaterialIs.java
@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);
    }
}
 
源代码19 项目: EffectLib   文件: ParticleEffect.java
/**
 * 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");
    }
}
 
源代码20 项目: Crazy-Crates   文件: ParticleEffect.java
/**
 * 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");
    }
}
 
 方法所在类
 同类方法