本文整理汇总了Java中org.bukkit.Location.getBlockY方法的典型用法代码示例。如果您正苦于以下问题:Java Location.getBlockY方法的具体用法?Java Location.getBlockY怎么用?Java Location.getBlockY使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.Location
的用法示例。
在下文中一共展示了Location.getBlockY方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: drawCircle
import org.bukkit.Location; //导入方法依赖的package包/类
public List<Location> drawCircle(Location loc, Integer radius, Integer height, Boolean hollow, Boolean sphere,
int plus_y) {
List<Location> circleblocks = new ArrayList<Location>();
Integer r = radius;
Integer h = height;
int cx = loc.getBlockX();
int cy = loc.getBlockY();
int cz = loc.getBlockZ();
for (int x = cx - r.intValue(); x <= cx + r.intValue(); x++) {
for (int z = cz - r.intValue(); z <= cz + r.intValue(); z++) {
for (int y = sphere.booleanValue() ? cy - r.intValue() : cy; y < (sphere.booleanValue()
? cy + r.intValue() : cy + h.intValue()); y++) {
double dist = (cx - x) * (cx - x) + (cz - z) * (cz - z)
+ (sphere.booleanValue() ? (cy - y) * (cy - y) : 0);
if ((dist < r.intValue() * r.intValue())
&& ((!hollow.booleanValue()) || (dist >= (r.intValue() - 1) * (r.intValue() - 1)))) {
Location l = new Location(loc.getWorld(), x, y + plus_y, z);
circleblocks.add(l);
}
}
}
}
return circleblocks;
}
示例2: openFor
import org.bukkit.Location; //导入方法依赖的package包/类
@Override
public void openFor(Player player) throws InvocationTargetException {
if (AuthMeApi.getInstance().isAuthenticated(player)) {
return;
}
PacketContainer fakeBlockChange = new PacketContainer(PacketType.Play.Server.BLOCK_CHANGE);
PacketContainer updateEntity = new PacketContainer(PacketType.Play.Server.TILE_ENTITY_DATA);
PacketContainer sign = new PacketContainer(PacketType.Play.Server.OPEN_SIGN_EDITOR);
Location block = player.getLocation().getBlock().getLocation();
BlockPosition position = new BlockPosition(block.getBlockX(), block.getBlockY() + 1, block.getBlockZ());
fakeBlockChange.getBlockPositionModifier().write(0, position);
fakeBlockChange.getBlockData().write(0, WrappedBlockData.createData(Material.SIGN_POST));
protocolManager.sendServerPacket(player, fakeBlockChange);
updateEntity.getBlockPositionModifier().write(0, position);
updateEntity.getIntegers().write(0, 9);
NbtCompound signNbt = (NbtCompound) updateEntity.getNbtModifier().read(0);
signNbt = signNbt == null ? NbtFactory.ofCompound("") : signNbt;
List<String> lines = this.getInfoFor(player);
for (int i = 0; i < lines.size() || i < 4; i++) {
signNbt.put("Text" + (i + 1), "{\"text\":\"" + lines.get(i) + "\"}");
}
updateEntity.getNbtModifier().write(0, signNbt);
protocolManager.sendServerPacket(player, updateEntity);
sign.getBlockPositionModifier().write(0, position);
protocolManager.sendServerPacket(player, sign);
}
示例3: getBlocks
import org.bukkit.Location; //导入方法依赖的package包/类
public static double getBlocks(Location l){
double _tem=0;
int x=l.getBlockX()+2;
int y=l.getBlockY()+2;
int z=l.getBlockZ()+2;
for(int sx=x-4;sx<x;sx++)
for(int sy=y-4;sy<y;sy++)
for(int sz=z-4;sz<z;sz++){
Block temp=l.getWorld().getBlockAt(sx, sy, sz);
if(rs.getHeatSource().containsKey(temp.getType().name()))
_tem+=rs.getHeatSource().get(temp.getType().name())*Math.pow(
1-rs.getDistanceEffect(), Math.sqrt(Math.pow(sx-x, 2)+Math.pow(
sy-y, 2)+Math.pow(sz-z, 2)));
//System.out.println(sx+" "+sy+" "+sz+" "+temp.getType().name());
}
return _tem;
}
示例4: getAmountOfSelectedBlocks
import org.bukkit.Location; //导入方法依赖的package包/类
/**
* Returns the amount of selected blocks
*
* @return amount
*/
@Override
public int getAmountOfSelectedBlocks() {
int amount = 0;
final Location location = this.getDownCornerLocation().toLocation();
for (int i = 0; i < this.getXWidth(); i++) {
for (int j = 0; j < this.getYWidth(); j++) {
for (int k = 0; k < this.getZWidth(); k++) {
final Location loc = new Location(location.getWorld(), location.getBlockX() + i, location.getBlockY() + j, location.getBlockZ() + k);
if (loc.getBlock().getType() != Material.AIR) {
amount++;
}
}
}
}
return amount;
}
示例5: run
import org.bukkit.Location; //导入方法依赖的package包/类
@Override
public void run() {
Location location = player.getLocation();
// Check if the player moved or is AFK.
double x = location.getBlockX();
double y = location.getBlockY();
double z = location.getBlockZ();
if (this.lastX == x && this.lastY == y && this.lastZ == z) {
return;
}
this.lastX = x;
this.lastY = y;
this.lastZ = z;
this.listener.handlePositionChanged(player, player.getWorld(), (int) x, (int) y, (int) z);
}
示例6: calculateDownLocation
import org.bukkit.Location; //导入方法依赖的package包/类
/**
* Calculates the downLocation
*
* @param corner1 corner1
* @param corner2 corner2
*/
private void calculateDownLocation(Location corner1, Location corner2) {
final int x;
if (corner1.getBlockX() < corner2.getBlockX()) {
x = corner1.getBlockX();
} else {
x = corner2.getBlockX();
}
final int y;
if (corner1.getBlockY() < corner2.getBlockY()) {
y = corner1.getBlockY();
} else {
y = corner2.getBlockY();
}
final int z;
if (corner1.getBlockZ() < corner2.getBlockZ()) {
z = corner1.getBlockZ();
} else {
z = corner2.getBlockZ();
}
this.downCorner = new LocationBuilder(new Location(corner1.getWorld(), x, y, z));
}
示例7: destroyAllDuctsOnIsland
import org.bukkit.Location; //导入方法依赖的package包/类
private void destroyAllDuctsOnIsland(Location islandLoc) {
int dist = 200;
final Location min = islandLoc.clone().add(-dist, 0, -dist);
min.setY(0);
final Location max = islandLoc.clone().add(dist, 0, dist);
max.setY(max.getWorld().getMaxHeight());
com.wasteofplastic.acidisland.ASkyBlockAPI skyblockApi = com.wasteofplastic.acidisland.ASkyBlockAPI.getInstance();
Location tempLoc = new Location(min.getWorld(), 0, 0, 0);
for (int x = min.getBlockX(); x < max.getBlockX(); x++) {
for (int y = min.getBlockY(); y < max.getBlockY(); y++) {
for (int z = min.getBlockZ(); z < max.getBlockZ(); z++) {
tempLoc.setX(x);
tempLoc.setY(y);
tempLoc.setZ(z);
if (PipeAPI.isDuct(tempLoc, null) && !skyblockApi.islandAtLocation(tempLoc)) {
PipeAPI.destroyDuct(tempLoc);
}
}
}
}
}
示例8: surrendPlayer
import org.bukkit.Location; //导入方法依赖的package包/类
public static void surrendPlayer(Player player){
YamlConfiguration PlayerData = PVPAsWantedManager.onLoadData(player.getName());
int value = PlayerData.getInt("jail.times");
int times = PlayerData.getInt("wanted.points")*Integer.valueOf(Config.getConfig("timeTick.jailPlayerTimes").replace("min", "").replace("m", ""));
if(value > 0){
player.sendMessage(Message.getMsg("player.isAlreadyInJailMessage"));
return;
}
if(times <1){
player.sendMessage(Message.getMsg("player.notSurrendMessage"));
return;
}
Location location = player.getLocation();
int playerX = location.getBlockX();
int playerY = location.getBlockY();
int playerZ = location.getBlockZ();
String playerWorld = location.getWorld().getName();
PlayerData.set("attribute.X", playerX);
PlayerData.set("attribute.Y", playerY);
PlayerData.set("attribute.Z", playerZ);
PlayerData.set("attribute.World", playerWorld);
PlayerData.set("wanted.points", Integer.valueOf(0));
PlayerData.set("jail.times", times);
PVPAsWantedManager.onDeleteList(player.getName(), "WantedList");
PVPAsWantedManager.onCreateList(player.getName(), "JailedList");
PVPAsWantedManager.onSaveData(player.getName(), PlayerData);
JailManager.playerJoinJail(player,location);
player.sendMessage(Message.getMsg("player.surrendMessage",String.valueOf(times)));
}
示例9: spawnFallingBlock
import org.bukkit.Location; //导入方法依赖的package包/类
public FallingBlock spawnFallingBlock(Location location, org.bukkit.Material material, byte data) throws IllegalArgumentException {
Validate.notNull(location, "Location cannot be null");
Validate.notNull(material, "Material cannot be null");
Validate.isTrue(material.isBlock(), "Material must be a block");
double x = location.getBlockX() + 0.5;
double y = location.getBlockY() + 0.5;
double z = location.getBlockZ() + 0.5;
net.minecraft.entity.item.EntityFallingBlock entity = new net.minecraft.entity.item.EntityFallingBlock(world, x, y, z, net.minecraft.block.Block.getBlockById(material.getId()), data);
entity.field_145812_b = 1; // ticksLived
world.addEntity(entity, SpawnReason.CUSTOM);
return (FallingBlock) entity.getBukkitEntity();
}
示例10: isHoveringOverWater
import org.bukkit.Location; //导入方法依赖的package包/类
public static boolean isHoveringOverWater(Location player, int blocks) {
for (int i = player.getBlockY(); i > player.getBlockY() - blocks; i--) {
Block newloc = (new Location(player.getWorld(), player.getBlockX(), i, player.getBlockZ())).getBlock();
if (newloc.getType() != Material.AIR) {
return newloc.isLiquid();
}
}
return false;
}
示例11: getBungeeCordSignInfo
import org.bukkit.Location; //导入方法依赖的package包/类
private BungeeCordSignInfo getBungeeCordSignInfo(Location location2) {
for (final BungeeCordSignInfo info : this.controller.signs.toArray(new BungeeCordSignInfo[this.controller.signs.size()])) {
final Location location1 = info.getLocation();
if (location1.getBlockX() == location2.getBlockX()) {
if (location1.getBlockY() == location2.getBlockY()) {
if (location1.getBlockZ() == location2.getBlockZ()) {
return info;
}
}
}
}
return null;
}
示例12: restore
import org.bukkit.Location; //导入方法依赖的package包/类
public void restore(Location location)
{
Location finalLocation = new Location(location.getWorld(), location.getBlockX(), location.getBlockY(), location.getBlockZ());
if (this.blocksUsed.containsKey(finalLocation) && this.blocksBefore.containsKey(finalLocation))
{
this.blocksUsed.remove(finalLocation);
finalLocation.getBlock().setType(this.blocksBefore.get(finalLocation).getType());
finalLocation.getBlock().setData(this.blocksBefore.get(finalLocation).getData());
this.blocksBefore.remove(finalLocation);
}
}
示例13: getNearbyBlocks
import org.bukkit.Location; //导入方法依赖的package包/类
private static List<Block> getNearbyBlocks(Location location, int radius)
{
List<Block> blocks = new ArrayList<>();
for(int x = location.getBlockX() - radius; x <= location.getBlockX() + radius; x++)
for(int y = location.getBlockY() - radius; y <= location.getBlockY() + radius; y++)
for(int z = location.getBlockZ() - radius; z <= location.getBlockZ() + radius; z++)
blocks.add(location.getWorld().getBlockAt(x, y, z));
return blocks;
}
示例14: format
import org.bukkit.Location; //导入方法依赖的package包/类
public static String format(Location loc, boolean world) {
return (world ? (loc.getWorld().getName() + ":") : "") + loc.getBlockX() + ":" + loc.getBlockY() + ":" + loc.getBlockZ();
}
示例15: onJoinJail
import org.bukkit.Location; //导入方法依赖的package包/类
@PlayerCommand(cmd="joinJail",arg = " <player> <times>")
public void onJoinJail(CommandSender sender,String args[]){
if(sender instanceof Player){
if(!sender.hasPermission("pvpaswantedmanager." + args[0])) {
sender.sendMessage(Message.getMsg("player.noPermissionMessage"));
return;
}
}
if(args.length <=2 ){
sender.sendMessage(Message.getMsg("admin.joinJailCorrectionsMessage"));
return;
}
String playerName = args[1];
if(!Pattern.compile("[0-9]*").matcher(args[2]).matches()){
sender.sendMessage(Message.getMsg("admin.wrongFormatMessage"));
return;
}
int times = Integer.valueOf(args[2]);
if(isPlayerOnline(playerName)){
Player player = Bukkit.getPlayer(playerName);
YamlConfiguration PlayerData = PVPAsWantedManager.onLoadData(player.getName());
if(PlayerData ==null)return;
int value = PlayerData.getInt("jail.times");
if(value > 0){
sender.sendMessage(Message.getMsg("admin.playerIsAlreadyInJailMessage"));
return;
}
Location location = player.getLocation();
int playerX = location.getBlockX();
int playerY = location.getBlockY();
int playerZ = location.getBlockZ();
String playerWorld = location.getWorld().getName();
PlayerData.set("attribute.X", playerX);
PlayerData.set("attribute.Y", playerY);
PlayerData.set("attribute.Z", playerZ);
PlayerData.set("attribute.World", playerWorld);
PlayerData.set("jail.times", times);
onDeleteList(player.getName(), "WantedList");
onCreateList(player.getName(), "JailedList");
onSaveData(player.getName(), PlayerData);
JailManager.playerJoinJail(player,location);
sender.sendMessage(Message.getMsg("admin.joinJailPlayerMessage", args[1],args[2]));
player.sendMessage(Message.getMsg("player.jailedJoinMessage",args[2]));
}else{
sender.sendMessage(Message.getMsg("admin.playerOfflineMessage"));
}
}