本文整理汇总了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()));
}
示例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++;
}
示例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());
}
}
}
示例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;
}
示例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));
}
}
示例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();
}
}
);
}
}
示例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();
}
}
);
}
}
示例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();
}
}
);
}
}
示例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();
}
}
);
}
}
示例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);
}
示例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();
}
};
}
};
}
示例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;
}
示例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);
}
}
}
示例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;
}
示例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);
}