当前位置: 首页>>代码示例>>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;未经允许,请勿转载。