本文整理汇总了Java中org.bukkit.entity.Player.getTargetBlock方法的典型用法代码示例。如果您正苦于以下问题:Java Player.getTargetBlock方法的具体用法?Java Player.getTargetBlock怎么用?Java Player.getTargetBlock使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.entity.Player
的用法示例。
在下文中一共展示了Player.getTargetBlock方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: grow
import org.bukkit.entity.Player; //导入方法依赖的package包/类
public static void grow(Player p, int radius) {
Block target = p.getTargetBlock((HashSet<Byte>) null, 100);
int radius_squared = radius * radius;
Block toHandle;
SchematicUserConfig cfg = getConfig(p);
ArrayList<Block> list = new ArrayList<Block>();
for (int x = -radius; x <= radius; x++) {
for (int z = -radius; z <= radius; z++) {
toHandle = target.getWorld().getHighestBlockAt(target.getX() + x, target.getZ() + z);
if (toHandle.getType() == Material.AIR && toHandle.getRelative(BlockFace.DOWN).getType() == Material.GRASS) { // Block beneath is grass
if (target.getLocation().distanceSquared(toHandle.getLocation()) <= radius_squared) { // Block is in radius
double rand = Math.random();
if (rand < cfg.growDensity * 5 / 6) {
toHandle.setType(Material.LONG_GRASS);
toHandle.setData((byte) 1);
list.add(toHandle);
} else if (rand < cfg.growDensity) {
toHandle.setType(Material.RED_ROSE); //0 4 5 6 7 8
byte data = (byte) (Math.random() * 6);
if (data > 0)
data += 3; //1 + 3 = 4, 2 + 3 = 5, ..., 5 + 3 = 8
toHandle.setData(data);
list.add(toHandle);
}
}
}
}
}
cfg.lastGrow.add(list);
if (SchematicManager.getConfig(p).verbose)
p.sendMessage("Grew with radius " + radius + ".");
}
示例2: cast
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Override
public boolean cast(final Player p, final PlayerDataRPG pd, final int level) {
int damage = pd.getDamage(true);
switch (level) {
case 1:
damage *= 1.2;
break;
case 2:
damage *= 1.4;
break;
case 3:
damage *= 1.6;
break;
case 4:
damage *= 1.9;
break;
case 5:
damage *= 2.2;
break;
case 6:
damage *= 2.6;
break;
case 7:
damage *= 3.0;
break;
case 8:
damage *= 3.5;
break;
}
Block b = p.getTargetBlock((Set<Material>) null, 20);
if (b == null) {
p.sendMessage(ChatColor.RED + "Point at a block to cast Lightning Bolt!");
return false;
}
Location loc = b.getLocation();
RParticles.sendLightning(p, loc);
Spell.damageNearby(damage, p, loc, 2.5, new ArrayList<Entity>());
Spell.notify(p, "You summon a bolt of lightning to strike the ground.");
return true;
}
示例3: tabComplete
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Override
public List<String> tabComplete(CommandSender sender, String[] args) {
Player player = (Player) sender;
Block block = player.getTargetBlock((Set<Material>) null, 100);
if(args.length == 0) {
return new ArrayList<>(block.getX());
} else if(args.length == 1){
return new ArrayList<>(block.getY());
} else if(args.length == 2){
return new ArrayList<>(block.getZ());
} else {
return new ArrayList<>();
}
}
示例4: onInventoryClose
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@EventHandler
public void onInventoryClose(InventoryCloseEvent e)
{
if (!(e.getPlayer() instanceof Player))
return;
final Player p = (Player) e.getPlayer();
if (!p.hasMetadata("shared_workbench"))
return;
if (e.getInventory().getType() == InventoryType.WORKBENCH)
{
// Workaround to get the accessed WorkBench
final Block workbench = p.getTargetBlock((Set<Material>) null, 8);
if (!workbench.hasMetadata("shared_players") || workbench.getType() != Material.WORKBENCH)
{
if (p.getOpenInventory().getTopInventory() != null)
p.getOpenInventory().getTopInventory().clear();
p.removeMetadata("shared_workbench", Survival.instance);
return;
}
@SuppressWarnings("unchecked")
List<UUID> list = (workbench.getMetadata("shared_players").get(0).value() instanceof List<?>) ? (List<UUID>)workbench.getMetadata("shared_players").get(0).value() : new ArrayList<UUID>();
list.remove(p.getUniqueId());
if (list.isEmpty())
workbench.removeMetadata("shared_players", Survival.instance);
else
{
e.getInventory().clear();
workbench.setMetadata("shared_players", new FixedMetadataValue(Survival.instance, list));
}
}
}
示例5: execute
import org.bukkit.entity.Player; //导入方法依赖的package包/类
public boolean execute(CommandSender sender, String[] args) {
if (args.length != 1) {
Chat.player(sender, "&cPlease include the name.");
return true;
}
Course c = Course.get(args[0]);
if (c == null) {
Chat.player(sender, "&7[Parkour] Couldn't find the course, " + args[0]);
return true;
}
Player p = (Player) sender;
Block b = p.getTargetBlock(null, 10);
if (b == null || b.getType() != Material.STONE_BUTTON) {
Chat.player(sender, "&2[SG] &cThat is not a button");
return true;
}
Parkour.getInstance().getConfigAPI().set(c.getName() + ".button.x", b.getX());
Parkour.getInstance().getConfigAPI().set(c.getName() + ".button.y", b.getY());
Parkour.getInstance().getConfigAPI().set(c.getName() + ".button.z", b.getZ());
Parkour.getInstance().getConfigAPI().set(c.getName() + ".button.world", b.getWorld().getName());
Chat.player(sender, "&7[Parkour] &aStart button added to " + c.getName());
Parkour.getInstance().saveConfig();
Parkour.getInstance().loadCourses();
return true;
}
示例6: execute
import org.bukkit.entity.Player; //导入方法依赖的package包/类
public boolean execute(CommandSender sender, String[] args) {
if (args.length != 1) {
Chat.player(sender, "&cPlease include the name.");
return true;
}
Course c = Course.get(args[0]);
if (c == null) {
Chat.player(sender, "&7[Parkour] Couldn't find the course, " + args[0]);
return true;
}
Player p = (Player) sender;
Block b = p.getTargetBlock(null, 10);
if (b == null || b.getType() != Material.STONE_BUTTON) {
Chat.player(sender, "&2[SG] &cThat is not a button");
return true;
}
Parkour.getInstance().getConfigAPI().set(c.getName() + ".end.x", b.getX());
Parkour.getInstance().getConfigAPI().set(c.getName() + ".end.y", b.getY());
Parkour.getInstance().getConfigAPI().set(c.getName() + ".end.z", b.getZ());
Parkour.getInstance().getConfigAPI().set(c.getName() + ".end.world", b.getWorld().getName());
Chat.player(sender, "&7[Parkour] &aEnd button added to " + c.getName());
Parkour.getInstance().saveConfig();
Parkour.getInstance().loadCourses();
return true;
}
示例7: commandLogic
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Override
protected boolean commandLogic(CommandSender sender, Command command, String label, String[] args) {
Player player = (Player) sender;
Block block = player.getTargetBlock(null, 50);
if (args.length == 0) {
player.sendMessage(block.toString());
return true;
}
return doReflectionLookups(sender, args, block);
}
示例8: handleLightning
import org.bukkit.entity.Player; //导入方法依赖的package包/类
private void handleLightning(Player player, Rune rune) {
@SuppressWarnings("deprecation")
Block block = player.getTargetBlock((HashSet<Byte>) null, 15);
if(!Utility.isPVPEnabled(block.getLocation())) {
return;
}
block.getWorld().strikeLightning(block.getLocation());
for(Entity e : block.getWorld().getEntities()) {
if(!(e instanceof Player)) {
continue;
}
Player target = (Player) e;
if(!Utility.canAttack(player, target)) {
continue;
}
double distance = target.getLocation().distance(block.getLocation());
double damage = 0;
if(distance < 1) {
damage = 16;
}
else if(distance <= 3) {
damage = 10;
}
if(damage < 1)
continue;
if(target.getHealth() > damage)
target.setHealth(target.getHealth() - damage);
else
target.damage(1000000, player);
target.sendMessage(Lang.HEADERS_TOKENS.toString() + Lang.TOKENS_LIGHTNING.toString()
.replaceAll("%s", player.getName()));
}
finish(player, false);
}
示例9: getSignLookat
import org.bukkit.entity.Player; //导入方法依赖的package包/类
public Sign getSignLookat(CommandSender sender) {
Player p = asPlayer(sender);
Block b = p.getTargetBlock((Set<Material>) null, 5);// TODO use nms rayTrace
if (b == null || !b.getType().isBlock() || (b.getType() != Material.WALL_SIGN && b.getType() != Material.SIGN_POST)) {
throw new BadCommandException("user.error.not_sign");
}
return (Sign)b.getState();
}
示例10: cast
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Override
public boolean cast(final Player p, final PlayerDataRPG pd, int level) {
int damage = pd.getDamage(true);
switch (level) {
case 1:
damage *= 1.1;
break;
case 2:
damage *= 1.2;
break;
case 3:
damage *= 1.3;
break;
case 4:
damage *= 1.4;
break;
case 5:
damage *= 1.5;
break;
case 6:
damage *= 1.6;
break;
case 7:
damage *= 1.7;
break;
case 8:
damage *= 1.8;
break;
case 9:
damage *= 1.9;
break;
case 10:
damage *= 2.0;
break;
}
final int fDamage = damage;
RSound.playSound(p, Sound.ENTITY_ARROW_SHOOT);
Block b = p.getTargetBlock((Set<Material>) null, 15);
Location loc = b.getLocation();
for (int x = -3; x <= 3; x++) {
for (int z = -3; z <= 3; z++) {
final Location currentLoc = loc.clone();
currentLoc.setX(loc.getX() + x - 1);
currentLoc.setZ(loc.getZ() + z);
currentLoc.setY(loc.getY() + RMath.randInt(4, 6));
Location loc2 = loc.clone();
loc2.setX(loc.getX() + x);
loc2.setZ(loc.getZ() + z);
final Vector v = loc2.toVector().subtract(currentLoc.toVector()).normalize();
int count = (int) (Math.random() * 3 + 1);
for (int k = 0; k < count; k++) {
if (Math.random() < 0.7) {
RScheduler.schedule(Spell.plugin, new Runnable() {
public void run() {
Projectile arrow = ((Projectile) (currentLoc.getWorld().spawnEntity(currentLoc, EntityType.ARROW)));
arrow.setVelocity(v);
arrow.setShooter(p);
arrow.setMetadata(RMetadata.META_DAMAGE, new FixedMetadataValue(Spell.plugin, fDamage));
}
}, (int) (Math.random() * RTicks.seconds(2)));
}
}
}
}
Spell.notify(p, "A rain of arrows showers down from the skies.");
return true;
}
示例11: getTargetBlockOfPlayer
import org.bukkit.entity.Player; //导入方法依赖的package包/类
Block getTargetBlockOfPlayer(Player player) {
return player.getTargetBlock((Set<Material>) null, 10);
}