本文整理匯總了Java中org.bukkit.entity.FallingBlock.setMetadata方法的典型用法代碼示例。如果您正苦於以下問題:Java FallingBlock.setMetadata方法的具體用法?Java FallingBlock.setMetadata怎麽用?Java FallingBlock.setMetadata使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.bukkit.entity.FallingBlock
的用法示例。
在下文中一共展示了FallingBlock.setMetadata方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: fragBallExplode
import org.bukkit.entity.FallingBlock; //導入方法依賴的package包/類
@EventHandler
public void fragBallExplode(EntityExplodeEvent e) {
e.setCancelled(true);
for(Block block : e.blockList()) {
if(block.getRelative(BlockFace.UP).getType() == Material.AIR && block.getType().isSolid()) {
FallingBlock fallingBlock = block.getWorld().spawnFallingBlock(block.getLocation().add(0, 1, 0), block.getType(), block.getData());
double x = (block.getLocation().getX() - e.getLocation().getX()) / 3,
y = 1,
z = (block.getLocation().getZ() - e.getLocation().getZ()) / 3;
fallingBlock.setVelocity(new Vector(x, y, z).normalize());
fallingBlock.setMetadata("explode", new FixedMetadataValue(plugin, false));
fallingBlock.setDropItem(false);
e.setYield(0F);
}
}
}
示例2: spawnCrate
import org.bukkit.entity.FallingBlock; //導入方法依賴的package包/類
@Override
@SuppressWarnings("deprecation")
public Crate spawnCrate(CratePlayer p, Crate crate, Location loc) {
if(p.hasCrate()) {
return crate;
}
if(canFall(loc)) {
if(getConfiguration().isCrateMessagesEnabled()) {
if(crate.getType() == CrateType.RARE) {
Bukkit.broadcastMessage(getConfiguration().getRareCrateDropMessage().replaceAll("%p", p.getPlayer().getName()).replaceAll("%crate", crate.getCrateName()));
} else if(crate.getType() == CrateType.NORMAL) {
Bukkit.broadcastMessage(getConfiguration().getNormalCrateDropMessage().replaceAll("%p", p.getPlayer().getName()).replaceAll("%crate", crate.getCrateName()));
}
}
FallingBlock fall = p.getPlayer().getWorld().spawnFallingBlock(loc.add(0, 1, 0), Material.CHEST, (byte)0);
fall.setMetadata("crate_serie", new FixedMetadataValue(this, crate.getCrateName()));
fall.setMetadata("crate_owner", new FixedMetadataValue(this, p.getPlayer().getName()));
getCrateOwners().add(p.getPlayer().getName());
}
return crate;
}
示例3: bounceBlock
import org.bukkit.entity.FallingBlock; //導入方法依賴的package包/類
@SuppressWarnings("deprecation")
public void bounceBlock(BlockState b) {
if(b == null) return;
if(fallingBlocks.size() > 1500) {
return;
}
for(Material mat : allowedMaterials()) {
if(b.getType() == mat) {
FallingBlock fb = b.getWorld().spawnFallingBlock(b.getLocation(), b.getData().getItemType(), b.getData().getData());
float x = (float) -1 + (float) (Math.random() * ((1 - -1) + 1));
float y = 2;//(float) -5 + (float)(Math.random() * ((5 - -5) + 1));
float z = (float) -0.3 + (float)(Math.random() * ((0.3 - -0.3) + 1));
fb.setDropItem(false);
fb.setVelocity(new Vector(x, y, z));
fallingBlocks.add(fb);
fb.setMetadata("xe:explosion", new FixedMetadataValue(pl, ""));
}
}
}
示例4: onLeaveDecay
import org.bukkit.entity.FallingBlock; //導入方法依賴的package包/類
@SuppressWarnings("deprecation")
@EventHandler
public void onLeaveDecay(LeavesDecayEvent e) {
if(e.isCancelled()) {
return;
}
byte sub = e.getBlock().getData();
Material mat = e.getBlock().getType();
FallingBlock fall = e.getBlock().getWorld().spawnFallingBlock(e.getBlock().getLocation(), mat.getId(), sub);
fall.setMetadata("tree", new FixedMetadataValue(pl, "a tree"));
e.getBlock().setType(Material.AIR);
}