当前位置: 首页>>代码示例>>Java>>正文


Java Material.AIR属性代码示例

本文整理汇总了Java中org.bukkit.Material.AIR属性的典型用法代码示例。如果您正苦于以下问题:Java Material.AIR属性的具体用法?Java Material.AIR怎么用?Java Material.AIR使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.bukkit.Material的用法示例。


在下文中一共展示了Material.AIR属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onBlockPlace

@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockPlace(BlockPlaceEvent event)
{
    int x = event.getBlock().getX() + this.data.length / 2;
    int z = event.getBlock().getZ() + this.data.length / 2;
    if (x >= 0 && z >= 0 && x < this.data.length && z < this.data.length)
    {
        byte high = this.data[x][z];
        if (event.getBlock().getY() > high + 15
                && event.getBlock().getRelative(BlockFace.EAST).getType() == Material.AIR
                && event.getBlock().getRelative(BlockFace.WEST).getType() == Material.AIR
                && event.getBlock().getRelative(BlockFace.SOUTH).getType() == Material.AIR
                && event.getBlock().getRelative(BlockFace.NORTH).getType() == Material.AIR)
        {
            event.setCancelled(true);
            event.getPlayer().sendMessage(ChatColor.RED + "Les towers sont interdites.");
        }
    }
}
 
开发者ID:SamaGames,项目名称:SurvivalAPI,代码行数:19,代码来源:AntiTowerListener.java

示例2: nameItem

private static ItemStack nameItem(ItemStack item, String name, String[] lore) {
    if (item.getType() != Material.AIR) {
        final ItemMeta im = item.getItemMeta();
        if (name != null) {
            im.setDisplayName(name);
        }
        if (lore != null) {
            im.setLore(Arrays.asList(lore));
        } else {
            im.setLore(new ArrayList<>());
        }
        item.setItemMeta(im);
        return item;
    }
    return item;
}
 
开发者ID:Shynixn,项目名称:PetBlocks,代码行数:16,代码来源:PetBlockHelper.java

示例3: canDropAt

public boolean canDropAt(Location location) {
    if(!match.getWorld().equals(location.getWorld())) return false;

    Block block = location.getBlock();
    Block below = block.getRelative(BlockFace.DOWN);
    if(!canDropOn(below.getState())) return false;
    if(block.getRelative(BlockFace.UP).getType() != Material.AIR) return false;

    switch(block.getType()) {
        case AIR:
        case LONG_GRASS:
            return true;
        default:
            return false;
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:16,代码来源:Flag.java

示例4: playSound

public static void playSound(InventoryClickEvent event) {
    if (event.getSlot() == -999) {
        return;
    }

    HumanEntity human = event.getWhoClicked();
    if (!(human instanceof Player)) {
        return;
    }

    ItemStack clicked = event.getCurrentItem();
    if (clicked == null || clicked.getType() == Material.AIR) {
        return;
    }

    if (clicked.getType() == Material.BARRIER) {
        ((Player) human).playSound(human.getLocation(), Sound.BLOCK_ANVIL_PLACE, 1, 1);
    } else if (clicked != null && !clicked.equals(PLACEHOLDER)) {
        ((Player) human).playSound(human.getLocation(), Sound.UI_BUTTON_CLICK, 1, 1);
    }
}
 
开发者ID:DRE2N,项目名称:FactionsXL,代码行数:21,代码来源:PageGUI.java

示例5: onClick

@EventHandler
public void onClick(InventoryClickEvent evt){
    if(evt.getCurrentItem() == null || evt.getCurrentItem().getType() == Material.AIR){
        return;
    }
    if(evt.getClickedInventory().getTitle() == null || !evt.getClickedInventory().getTitle().equals(name)){
        return;
    }

    evt.setCancelled(true);
    for(KitType type : KitType.values()){
        if(type.getDisplayNameWithColor().equals(evt.getCurrentItem().getItemMeta().getDisplayName())){
            if(!KitCallBack.isCallingBack(evt.getWhoClicked().getName()))
                lobby_Statistics.getInstance().getApi().getData(evt.getWhoClicked().getName(), DataType.walls, new KitCallBack(evt.getWhoClicked().getName(), type));
            break;

        }
    }
    evt.getWhoClicked().closeInventory();
}
 
开发者ID:JHXSMatthew,项目名称:CSGO_lobby,代码行数:20,代码来源:KitController.java

示例6: onInventoryClick

@EventHandler
public void onInventoryClick(InventoryClickEvent event) {
	Player p = (Player) event.getWhoClicked();
	Inventory inv = event.getInventory();

	if (p.getGameMode() != GameMode.CREATIVE)
		event.setCancelled(true);
	
	if (Chat.stripColor(inv.getTitle()).equalsIgnoreCase("MC Zone Games")) {
		if (event.getRawSlot() > 9 || event.getCurrentItem() == null || event.getCurrentItem().getType() == Material.AIR)
			return;
		GameIcon game = GameIcon.get(event.getCurrentItem());
		if (game != null) {
			p.teleport(game.getTo());
			p.closeInventory();
		}
	}
}
 
开发者ID:thekeenant,项目名称:mczone,代码行数:18,代码来源:CompassEvents.java

示例7: setPlaying

@Override
public void setPlaying(Material record) {
    if (record == null || CraftMagicNumbers.getItem(record) == null) {
        record = Material.AIR;
        jukebox.func_145857_a(null);
    } else {
        jukebox.func_145857_a(new ItemStack(CraftMagicNumbers.getItem(record), 1));
    }
    jukebox.markDirty();
    if (record == Material.AIR) {
        world.getHandle().setBlockMetadataWithNotify(getX(), getY(), getZ(), 0, 3);
    } else {
        world.getHandle().setBlockMetadataWithNotify(getX(), getY(), getZ(), 1, 3);
    }
    world.playEffect(getLocation(), Effect.RECORD_PLAY, record.getId());
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:16,代码来源:CraftJukebox.java

示例8: asBukkitCopy

/**
 * Copies the NMS stack to return as a strictly-Bukkit stack
 */
public static ItemStack asBukkitCopy(net.minecraft.item.ItemStack original) {
    if (original == null) {
        return new ItemStack(Material.AIR);
    }

    // Cauldron start - return non-strictly-Bukkit stack in order to preserve full NBT tags
    return asCraftMirror(copyNMSStack(original, original.stackSize));

    /*
    ItemStack stack = new ItemStack(original.itemID, original.stackSize, (short) original.getItemDamage());
    if (hasItemMeta(original)) {
        stack.setItemMeta(getItemMeta(original)); // Cauldron - TODO: wrap arbitrary mod NBT in ItemMeta
    }
    return stack;
    */
    // Cauldron end
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:20,代码来源:CraftItemStack.java

示例9: DisplayArmorstand

/**
 * Initializes the armorstand
 *
 * @param player   player
 * @param location location
 * @param id       id
 * @param data     data
 * @param watchers watchers
 */
public DisplayArmorstand(Player player, Location location, int id, byte data, Set<Player> watchers) {
    super();
    this.watchers = watchers;
    this.player = player;
    this.armorStand = new EntityArmorStand(((CraftWorld) player.getWorld()).getHandle());
    final NBTTagCompound compound = new NBTTagCompound();
    compound.setBoolean("invulnerable", true);
    compound.setBoolean("Invisible", true);
    compound.setBoolean("PersistenceRequired", true);
    compound.setBoolean("NoBasePlate", true);
    this.armorStand.a(compound);
    this.armorStand.setLocation(location.getX(), location.getY(), location.getZ(), 0, 0);
    this.storedId = id;
    this.storedData = data;

    ItemStackBuilder stackBuilder = new ItemStackBuilder(Material.getMaterial(id), 1, data);
    this.getCraftEntity().setHelmet(stackBuilder.build());
    this.getCraftEntity().setBodyPose(new EulerAngle(3.15, 0, 0));
    this.getCraftEntity().setLeftLegPose(new EulerAngle(3.15, 0, 0));
    this.getCraftEntity().setRightLegPose(new EulerAngle(3.15, 0, 0));
    this.getCraftEntity().setGlowing(true);

    if (((ArmorStand) this.armorStand.getBukkitEntity()).getHelmet().getType() == Material.AIR) {
        stackBuilder = new ItemStackBuilder(Material.SKULL_ITEM, 1, (short) 3);
        if (id == Material.WATER.getId() || id == Material.STATIONARY_WATER.getId()) {
            stackBuilder.setSkin(NMSRegistry.WATER_HEAD);
        } else if (id == Material.LAVA.getId() || id == Material.STATIONARY_LAVA.getId()) {
            stackBuilder.setSkin(NMSRegistry.LAVA_HEAD);
        } else {
            stackBuilder.setSkin(NMSRegistry.NOT_FOUND);
        }
        ((ArmorStand) this.armorStand.getBukkitEntity()).setHelmet(stackBuilder.build());
    }
}
 
开发者ID:Shynixn,项目名称:AstralEdit,代码行数:43,代码来源:DisplayArmorstand.java

示例10: DisplayArmorstand

/**
 * Initializes the armorstand
 *
 * @param player   player
 * @param location location
 * @param id       id
 * @param data     data
 * @param watchers watchers
 */
public DisplayArmorstand(Player player, Location location, int id, byte data, Set<Player> watchers) {
    super();
    this.watchers = watchers;
    this.player = player;
    this.armorStand = new EntityArmorStand(((CraftWorld) player.getWorld()).getHandle());
    final NBTTagCompound compound = new NBTTagCompound();
    compound.setBoolean("invulnerable", true);
    compound.setBoolean("Invisible", true);
    compound.setBoolean("PersistenceRequired", true);
    compound.setBoolean("NoBasePlate", true);
    this.armorStand.a(compound);
    this.armorStand.setLocation(location.getX(), location.getY(), location.getZ(), 0, 0);
    this.storedId = id;
    this.storedData = data;

    ItemStackBuilder stackBuilder = new ItemStackBuilder(Material.getMaterial(id), 1, data);
    this.getCraftEntity().setHelmet(stackBuilder.build());
    this.getCraftEntity().setBodyPose(new EulerAngle(3.15, 0, 0));
    this.getCraftEntity().setLeftLegPose(new EulerAngle(3.15, 0, 0));
    this.getCraftEntity().setRightLegPose(new EulerAngle(3.15, 0, 0));

    if (((ArmorStand) this.armorStand.getBukkitEntity()).getHelmet().getType() == Material.AIR) {
        stackBuilder = new ItemStackBuilder(Material.SKULL_ITEM, 1, (short) 3);
        if (id == Material.WATER.getId() || id == Material.STATIONARY_WATER.getId()) {
            stackBuilder.setSkin(NMSRegistry.WATER_HEAD);
        } else if (id == Material.LAVA.getId() || id == Material.STATIONARY_LAVA.getId()) {
            stackBuilder.setSkin(NMSRegistry.LAVA_HEAD);
        } else {
            stackBuilder.setSkin(NMSRegistry.NOT_FOUND);
        }
        ((ArmorStand) this.armorStand.getBukkitEntity()).setHelmet(stackBuilder.build());
    }
}
 
开发者ID:Shynixn,项目名称:AstralEdit,代码行数:42,代码来源:DisplayArmorstand.java

示例11: onPrepareAnvilRepair

@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
public void onPrepareAnvilRepair(PrepareAnvilRepairEvent event) {
    // TODO: Fix anvils
     ItemStack first = event.getInventory().getItem(0);
     ItemStack second = event.getResult();
    
    //  Some NMS to make sure that if the player is using the respective ingot to repair,
     // the player will be allowed to repair.
     if (first != null && first.getType() != Material.AIR && second != null && second.getType() != Material.AIR) {
     Object firstItemObj = net.minecraft.server.v1_7_R4.Item.REGISTRY.a(first.getTypeId());
     if (firstItemObj instanceof net.minecraft.server.v1_7_R4.Item) { // better safe than sorry
     net.minecraft.server.v1_7_R4.Item nmsFirstItem = (net.minecraft.server.v1_7_R4.Item) firstItemObj;
     if (nmsFirstItem instanceof ItemTool) {
     if (ITEM_TOOL_MAPPING.get(second.getType()) == ((ItemTool) nmsFirstItem).i()) {
     return;
     }
      //ItemSwords don't extend ItemTool, NMS </3
     } else if (nmsFirstItem instanceof ItemSword) {
     EnumToolMaterial comparison = ITEM_TOOL_MAPPING.get(second.getType());
     if (comparison != null && comparison.e() == nmsFirstItem.c()) {
     return;
     }
     } else if (nmsFirstItem instanceof ItemArmor) {
     if (ITEM_ARMOUR_MAPPING.get(second.getType()) == ((ItemArmor) nmsFirstItem).m_()) {
     return;
     }
     }
     }
     }
    
     HumanEntity repairer = event.getRepairer();
     if (repairer instanceof Player) {
     validateIllegalEnchants(event.getResult());
   }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:35,代码来源:EnchantLimitListener.java

示例12: clearLore

public ItemStackBuilder clearLore() {
    if (itemStack.getType() == Material.AIR) return this;
    final ItemMeta meta = itemStack.getItemMeta();
    meta.setLore(new ArrayList<>());
    itemStack.setItemMeta(meta);
    return this;
}
 
开发者ID:MinecraftMarket,项目名称:MinecraftMarket-Plugin,代码行数:7,代码来源:ItemStackBuilder.java

示例13: grow

public static void grow(Player p, int radius) {
    Block target = p.getTargetBlock((HashSet<Byte>) null, 100);
    int radius_squared = radius * radius;
    Block toHandle;
    SchematicUserConfig cfg = getConfig(p);
    ArrayList<Block> list = new ArrayList<Block>();
    for (int x = -radius; x <= radius; x++) {
        for (int z = -radius; z <= radius; z++) {
            toHandle = target.getWorld().getHighestBlockAt(target.getX() + x, target.getZ() + z);
            if (toHandle.getType() == Material.AIR && toHandle.getRelative(BlockFace.DOWN).getType() == Material.GRASS) { // Block beneath is grass
                if (target.getLocation().distanceSquared(toHandle.getLocation()) <= radius_squared) { // Block is in radius
                    double rand = Math.random();
                    if (rand < cfg.growDensity * 5 / 6) {
                        toHandle.setType(Material.LONG_GRASS);
                        toHandle.setData((byte) 1);
                        list.add(toHandle);
                    } else if (rand < cfg.growDensity) {
                        toHandle.setType(Material.RED_ROSE); //0 4 5 6 7 8
                        byte data = (byte) (Math.random() * 6);
                        if (data > 0)
                            data += 3; //1 + 3 = 4, 2 + 3 = 5, ..., 5 + 3 = 8
                        toHandle.setData(data);
                        list.add(toHandle);
                    }
                }
            }
        }
    }
    cfg.lastGrow.add(list);
    if (SchematicManager.getConfig(p).verbose)
        p.sendMessage("Grew with radius " + radius + ".");
}
 
开发者ID:edasaki,项目名称:ZentrelaRPG,代码行数:32,代码来源:SchematicManager.java

示例14: generate

public LinkedHashMap<Location, VisualBlockData> generate(Player player, Iterable<Location> locations, VisualType visualType, boolean canOverwrite) {
    synchronized (storedVisualises) {
        LinkedHashMap<Location, VisualBlockData> results = new LinkedHashMap<>();

        ArrayList<VisualBlockData> filled = visualType.blockFiller().bulkGenerate(player, locations);
        if (filled != null) {
            int count = 0;
            for (Location location : locations) {
                if (!canOverwrite && storedVisualises.contains(player.getUniqueId(), location)) {
                    continue;
                }

                Material previousType = location.getBlock().getType();
                if (previousType.isSolid() || previousType != Material.AIR) {
                    continue;
                }

                VisualBlockData visualBlockData = filled.get(count++);
                results.put(location, visualBlockData);
                player.sendBlockChange(location, visualBlockData.getBlockType(), visualBlockData.getData());
                storedVisualises.put(player.getUniqueId(), location, new VisualBlock(visualType, visualBlockData, location));
            }
        }

        return results;
    }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:27,代码来源:VisualiseHandler.java

示例15: getRandomFieldPosition

@Override
public Location getRandomFieldPosition(Random random) {
    boolean accepted;
    int maxRounds = 0;
    int x;
    int y;
    int z;
    do {
        accepted = true;
        x = this.getDownCornerLocation().getBlockX() + random.nextInt(this.getXWidth()) - 2;
        z = this.getDownCornerLocation().getBlockZ() + random.nextInt(this.getZWidth()) - 2;
        if (x < this.getDownCornerLocation().getBlockX())
            x += 4;
        if (z < this.getDownCornerLocation().getBlockZ())
            z += 4;
        for (y = this.getDownCornerLocation().getBlockY(); accepted && new Location(this.getDownCornerLocation().getWorld(), x, y, z).getBlock().getType() != Material.AIR; y++) {
            if (y > this.getUpCornerLocation().getBlockY()) {
                accepted = false;
            }
        }
        maxRounds++;
        if (maxRounds > 10) {
            Bukkit.getServer().getConsoleSender().sendMessage(BlockBallPlugin.PREFIX_CONSOLE + ChatColor.RED + "Warning! The item spawner " + this.getId() + " takes too long to calculate a valid position!");
            throw new RuntimeException("Cannot calculate item position!");
        }
    } while (!accepted);
    return new Location(this.getDownCornerLocation().getWorld(), x, y, z);
}
 
开发者ID:Shynixn,项目名称:BlockBall,代码行数:28,代码来源:ArenaEntity.java


注:本文中的org.bukkit.Material.AIR属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。