當前位置: 首頁>>代碼示例>>Java>>正文


Java MaterialData類代碼示例

本文整理匯總了Java中org.bukkit.material.MaterialData的典型用法代碼示例。如果您正苦於以下問題:Java MaterialData類的具體用法?Java MaterialData怎麽用?Java MaterialData使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


MaterialData類屬於org.bukkit.material包,在下文中一共展示了MaterialData類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testBlockState

import org.bukkit.material.MaterialData; //導入依賴的package包/類
@Test
public void testBlockState() {
    MaterialData data = new MaterialData(Material.DIAMOND, (byte) 12);
    byte lightLevel = 5;
    Location loc = TestLocation.LOC_ZERO;

    BlockState blockState = new TestBlockState(data, lightLevel, loc);

    String out = OutputFormatter.getOutput(blockState);

    assertNotNull(out);
    assertTrue(out.contains(data.toString()));
    assertTrue(out.contains(String.valueOf(data.getItemTypeId())));
    assertTrue(out.contains(String.valueOf(lightLevel)));
    assertTrue(out.contains(loc.toString()));
}
 
開發者ID:zachbr,項目名稱:Debuggery,代碼行數:17,代碼來源:OutputFormatterTest.java

示例2: fireCannon

import org.bukkit.material.MaterialData; //導入依賴的package包/類
private void fireCannon(Location cannon, Location target) {
    FallingBlock entity = cannon.getWorld().spawnFallingBlock(cannon, new MaterialData(Material.COAL_BLOCK));
    this.playParticles(entity.getLocation());
    entity.setGravity(true);
    entity.setDropItem(false);
    entity.setHurtEntities(false);
    entity.setInvulnerable(true);
    this.moveToward(entity, target, 2D);
    new BukkitRunnable() {
        public void run() {
            if(entity.isDead()) {
                this.cancel();
            } else {
                entity.setTicksLived(1);
            }
        }
    }.runTaskTimer(this.getAPI().getPlugin(), 0, 20L);
    totalCannonShots++;
}
 
開發者ID:ArcadiaPlugins,項目名稱:Arcadia-Spigot,代碼行數:20,代碼來源:BombardmentGame.java

示例3: shuffleColors

import org.bukkit.material.MaterialData; //導入依賴的package包/類
public void shuffleColors() {
    for (int x = 0; x < squaresPerSide; x++) {
        for (int z = 0; z < squaresPerSide; z++) {
            colors[x][z] = fetchRandomColor();
        }
    }
    for (int x = 0; x < squaresPerSide * squareSizes; x++) {
        int offsetX = location.getBlockX() + x;
        int squareX = x / 3;
        for (int z = 0; z < squaresPerSide * squareSizes; z++) {
            int offsetZ = location.getBlockZ() + z;
            int squareZ = z / 3;
            MaterialData materialData = colors[squareX][squareZ];
            Block block = new Location(location.getWorld(), offsetX, location.getY(), offsetZ).getBlock();
            block.setType(materialData.getItemType());
            block.setData(materialData.getData());
        }
    }
}
 
開發者ID:ArcadiaPlugins,項目名稱:Arcadia-Spigot,代碼行數:20,代碼來源:ColorShuffleGame.java

示例4: CoreFactoryImpl

import org.bukkit.material.MaterialData; //導入依賴的package包/類
public CoreFactoryImpl(String name,
                       @Nullable Boolean required,
                       boolean visible,
                       TeamFactory owner,
                       ProximityMetric proximityMetric,
                       Region region,
                       MaterialData material,
                       int leakLevel,
                       boolean modeChanges) {

    super(name, required, visible, Optional.of(owner), proximityMetric);
    this.region = region;
    this.material = material;
    this.leakLevel = leakLevel;
    this.modeChanges = modeChanges;
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:17,代碼來源:CoreFactory.java

示例5: onEndermanDeath

import org.bukkit.material.MaterialData; //導入依賴的package包/類
/**
 * Drops the Enderman's block when he dies if he has one
 *
 * @param e
 */
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onEndermanDeath(final EntityDeathEvent e) {
    if (DEBUG) {
        plugin.getLogger().info(e.getEventName());
    }
    if (!Settings.endermanDeathDrop)
        return;
    if (!Util.inWorld(e.getEntity())) {
        return;
    }
    if (!(e.getEntity() instanceof Enderman)) {
        // plugin.getLogger().info("Not an Enderman!");
        return;
    }
    // Get the block the enderman is holding
    Enderman ender = (Enderman) e.getEntity();
    MaterialData m = ender.getCarriedMaterial();
    if (m != null && !m.getItemType().equals(Material.AIR)) {
        // Drop the item
        // plugin.getLogger().info("Dropping item " + m.toString());
        e.getEntity().getWorld().dropItemNaturally(e.getEntity().getLocation(), m.toItemStack(1));
    }
}
 
開發者ID:tastybento,項目名稱:bskyblock,代碼行數:29,代碼來源:IslandGuard.java

示例6: constructMenu

import org.bukkit.material.MaterialData; //導入依賴的package包/類
protected void constructMenu(BlockMenuPreset preset)
    {
        int ai[];
        int k = (ai = border).length;
        for(int j = 0; j < k; j++)
        {
            int i = ai[j];
            preset.addItem(i, new CustomItem(new MaterialData(Material.STAINED_GLASS_PANE, (byte)10), " ", new String[0]), new me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu.MenuClickHandler() {

                final XPCollector this$0;

                public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction clickaction)
                {
                    return false;
                }

            
            {
                this$0 = XPCollector.this;
                super();
            }
            }
);
        }

    }
 
開發者ID:StarWishsama,項目名稱:Slimefun4-Chinese-Version,代碼行數:27,代碼來源:XPCollector.java

示例7: constructMenu

import org.bukkit.material.MaterialData; //導入依賴的package包/類
protected void constructMenu(BlockMenuPreset preset)
    {
        int ai[];
        int k = (ai = border).length;
        for(int j = 0; j < k; j++)
        {
            int i = ai[j];
            preset.addItem(i, new CustomItem(new MaterialData(Material.STAINED_GLASS_PANE, (byte)9), " ", new String[0]), new me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu.MenuClickHandler() {

                final CropGrowthAccelerator this$0;

                public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction clickaction)
                {
                    return false;
                }

            
            {
                this$0 = CropGrowthAccelerator.this;
                super();
            }
            }
);
        }

    }
 
開發者ID:StarWishsama,項目名稱:Slimefun4-Chinese-Version,代碼行數:27,代碼來源:CropGrowthAccelerator.java

示例8: constructMenu

import org.bukkit.material.MaterialData; //導入依賴的package包/類
protected void constructMenu(BlockMenuPreset preset)
    {
        int ai[];
        int k = (ai = border).length;
        for(int j = 0; j < k; j++)
        {
            int i = ai[j];
            preset.addItem(i, new CustomItem(new MaterialData(Material.STAINED_GLASS_PANE, (byte)9), " ", new String[0]), new me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu.MenuClickHandler() {

                final AutoBreeder this$0;

                public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction clickaction)
                {
                    return false;
                }

            
            {
                this$0 = AutoBreeder.this;
                super();
            }
            }
);
        }

    }
 
開發者ID:StarWishsama,項目名稱:Slimefun4-Chinese-Version,代碼行數:27,代碼來源:AutoBreeder.java

示例9: constructMenu

import org.bukkit.material.MaterialData; //導入依賴的package包/類
private void constructMenu(BlockMenuPreset preset)
    {
        int ai[];
        int k = (ai = border).length;
        for(int j = 0; j < k; j++)
        {
            int i = ai[j];
            preset.addItem(i, new CustomItem(new MaterialData(Material.STAINED_GLASS_PANE, (byte)14), " ", new String[0]), new me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu.MenuClickHandler() {

                final TrashCan this$0;

                public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction clickaction)
                {
                    return false;
                }

            
            {
                this$0 = TrashCan.this;
                super();
            }
            }
);
        }

    }
 
開發者ID:StarWishsama,項目名稱:Slimefun4-Chinese-Version,代碼行數:27,代碼來源:TrashCan.java

示例10: onBlockPunch

import org.bukkit.material.MaterialData; //導入依賴的package包/類
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockPunch(BlockPunchEvent event) {
    final MatchPlayer player = getMatch().getPlayer(event.getPlayer());
    if(player == null) return;

    RayBlockIntersection hit = event.getIntersection();

    BlockDrops drops = getRuleSet().getDrops(event, hit.getBlock().getState(), player.getParticipantState());
    if(drops == null) return;

    MaterialData oldMaterial = hit.getBlock().getState().getData();
    replaceBlock(drops, hit.getBlock(), player);

    // Play a fake punching effect if the block is punchable. Use raw particles instead of
    // playBlockBreakEffect so the position is precise rather than in the block center.
    Object packet = NMSHacks.blockCrackParticlesPacket(oldMaterial, false, hit.getPosition(), new Vector(), 0, 5);
    for(MatchPlayer viewer : getMatch().getPlayers()) {
        if(viewer.getBukkit().getEyeLocation().toVector().distanceSquared(hit.getPosition()) < 16 * 16) {
            NMSHacks.sendPacket(viewer.getBukkit(), packet);
        }
    }
    NMSHacks.playBlockPlaceSound(hit.getBlock().getWorld(), hit.getPosition(), oldMaterial.getItemType(), 1);

    dropObjects(drops, player, hit.getPosition().toLocation(hit.getBlock().getWorld()), 1d, false);
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:26,代碼來源:BlockDropsMatchModule.java

示例11: materials

import org.bukkit.material.MaterialData; //導入依賴的package包/類
public Iterable<MaterialData> materials() {
    return new Iterable<MaterialData>() {
        @Override
        public Iterator<MaterialData> iterator() {
            return new Iterator<MaterialData>() {
                final TIntIterator iter = counts.keySet().iterator();

                @Override
                public boolean hasNext() {
                    return iter.hasNext();
                }

                @Override
                public MaterialData next() {
                    return decodeMaterial(iter.next());
                }

                @Override
                public void remove() {
                    iter.remove();
                }
            };
        }
    };
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:26,代碼來源:MaterialCounter.java

示例12: renew

import org.bukkit.material.MaterialData; //導入依賴的package包/類
boolean renew(BlockVector pos) {
    MaterialData material;
    if(isOriginalShuffleable(pos)) {
        // If position is shuffled, first try to find a nearby shuffleable block to swap with.
        // This helps to make shuffling less predictable when the material deficit is small or
        // out of proportion to the original distribution of materials.
        material = sampleShuffledMaterial(pos);

        // If that fails, choose a random material, weighted by the current material deficits.
        if(material == null) material = chooseShuffledMaterial();
    } else {
        material = snapshot().getOriginalMaterial(pos);
    }

    if(material != null) {
        return renew(pos, material);
    }

    return false;
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:21,代碼來源:Renewable.java

示例13: processBlockDamage

import org.bukkit.material.MaterialData; //導入依賴的package包/類
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void processBlockDamage(BlockDamageEvent event) {
    if(this.match.getWorld() != event.getBlock().getWorld()) return;

    Block block = event.getBlock();
    MaterialData material = block.getState().getData();
    MatchPlayer player = this.match.getPlayer(event.getPlayer());

    for(Destroyable destroyable : this.destroyables) {
        if(player != null &&
           player.getParty() == destroyable.getOwner() &&
           !destroyable.isDestroyed() &&
           destroyable.getBlockRegion().contains(block) &&
           destroyable.hasMaterial(material)) {

            event.setCancelled(true);
            player.sendWarning(new TranslatableComponent("match.destroyable.damageOwn"), true);
        }
    }
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:21,代碼來源:DestroyableMatchModule.java

示例14: isAffectedByBlockReplacementRules

import org.bukkit.material.MaterialData; //導入依賴的package包/類
protected boolean isAffectedByBlockReplacementRules() {
    if (this.blockDropsRuleSet.getRules().isEmpty()) {
        return false;
    }

    for(Block block : this.blockRegion.getBlocks(match.getWorld())) {
        for(MaterialData material : this.materials) {
            BlockDrops drops = this.blockDropsRuleSet.getDrops(block.getState(), material);
            if(drops != null && drops.replacement != null && this.hasMaterial(drops.replacement)) {
                return true;
            }
        }
    }

    return false;
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:17,代碼來源:Destroyable.java

示例15: onPreStart

import org.bukkit.material.MaterialData; //導入依賴的package包/類
@Override
public void onPreStart() {
    Location spawnLocation = Utils.parseLocation((String) this.getGameMap().fetchSetting("startPosition"));
    for(Player player : Bukkit.getOnlinePlayers()) {
        if(!this.getAPI().getGameManager().isAlive(player)) continue;
        player.teleport(spawnLocation);
        player.setGameMode(GameMode.ADVENTURE);
    }
    List<MaterialData> floorData = new ArrayList<MaterialData>();
    for(String temp : ((String) this.getGameMap().fetchSetting("blocks")).split(",")) {
        floorData.add(Utils.parseMaterialData(temp));
    }
    this.floorOrder = new FloorOrder(floorData);
}
 
開發者ID:ArcadiaPlugins,項目名稱:Arcadia-Spigot,代碼行數:15,代碼來源:ElectricFloorGame.java


注:本文中的org.bukkit.material.MaterialData類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。