本文整理匯總了Java中org.bukkit.entity.FallingBlock.getLocation方法的典型用法代碼示例。如果您正苦於以下問題:Java FallingBlock.getLocation方法的具體用法?Java FallingBlock.getLocation怎麽用?Java FallingBlock.getLocation使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.bukkit.entity.FallingBlock
的用法示例。
在下文中一共展示了FallingBlock.getLocation方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: run
import org.bukkit.entity.FallingBlock; //導入方法依賴的package包/類
@Override
public void run()
{
int distance = 5;
Block block = null;
while (distance > 0) {
block = player.getDelegate().getTargetBlock((Set<Material>) null, distance);
if (block.getType().equals(Material.AIR)) {
break;
}
distance--;
}
if (currentBlock != null) {
currentBlock.remove();
currentBlock = null;
}
FallingBlock gravityBlock =
player.getWorld().spawnFallingBlock(block.getLocation(),
material,
data);
gravityBlock.setDropItem(false);
gravityBlock.setFallDistance(0f);
gravityBlock.setVelocity(new Vector(0, 0.1, 0));
dstLocation = gravityBlock.getLocation();
currentBlock = gravityBlock;
}
示例2: onBlockFall
import org.bukkit.entity.FallingBlock; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.HIGH)
public void onBlockFall(EntityChangeBlockEvent event) {
if (Zones.inNoDemigodsZone(event.getBlock().getLocation())) return;
if (event.getEntityType() != EntityType.FALLING_BLOCK || event.getBlock().getRelative(BlockFace.DOWN).getType().equals(Material.AIR))
return;
FallingBlock block = (FallingBlock) event.getEntity();
Location blockLocation = block.getLocation();
if (DemigodsStructureType.Util.isInRadiusWithFlag(DemigodsLocation.getFloorBelowLocation(block.getLocation()), DemigodsStructureType.Flag.NO_GRIEFING)) {
// Break the block
event.setCancelled(true);
event.getBlock().setType(Material.AIR);
blockLocation.getWorld().dropItemNaturally(blockLocation, new ItemStack(block.getMaterial()));
block.remove();
}
}