本文整理汇总了Java中org.bukkit.Location.getX方法的典型用法代码示例。如果您正苦于以下问题:Java Location.getX方法的具体用法?Java Location.getX怎么用?Java Location.getX使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.Location
的用法示例。
在下文中一共展示了Location.getX方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getLocationDifference
import org.bukkit.Location; //导入方法依赖的package包/类
private double getLocationDifference(Location first, Location second, String axis) {
double difference = 0.0;
switch (axis) {
case "X":
difference = first.getX() - second.getX();
break;
case "Y":
difference = first.getY() - second.getY();
break;
case "Z":
difference = first.getZ() - second.getZ();
break;
}
return Math.abs(difference);
}
示例2: getNearbyEntities
import org.bukkit.Location; //导入方法依赖的package包/类
public static List<Entity> getNearbyEntities(Location center, double radius, EntityType filter)
{
double chunkRadius = radius < 16 ? 1 : (radius - (radius % 16)) / 16;
List<Entity> entities = new ArrayList<>();
for (double chX = 0 - chunkRadius; chX <= chunkRadius; chX++)
{
for (double chZ = 0 - chunkRadius; chZ <= chunkRadius; chZ++)
{
double x = center.getX();
double y = center.getY();
double z = center.getZ();
for (Entity entity : new Location(center.getWorld(), x + (chX * 16), y, z + (chZ * 16)).getChunk().getEntities())
{
if (filter != null && entity.getType() != filter)
continue;
if (entity.getLocation().distance(center) <= radius && entity.getLocation().getBlock() != center.getBlock())
entities.add(entity);
}
}
}
return entities;
}
示例3: set
import org.bukkit.Location; //导入方法依赖的package包/类
public void set(String s, Object o) {
if (o instanceof Location) {
Location l = (Location) o;
String world = l.getWorld().getName();
double x = l.getX();
double y = l.getY();
double z = l.getZ();
double yaw = l.getYaw();
double pitch = l.getPitch();
config.set(s + ".world", world);
config.set(s + ".x", x);
config.set(s + ".y", y);
config.set(s + ".z", z);
config.set(s + ".yaw", yaw);
config.set(s + ".pitch", pitch);
}
else {
config.set(s, o);
}
}
示例4: setFlowerPotBlock
import org.bukkit.Location; //导入方法依赖的package包/类
@Override
public void setFlowerPotBlock(final Block block, final ItemStack itemStack) {
if (block.getType().equals(Material.FLOWER_POT)) {
Location loc = block.getLocation();
CraftWorld cw = (CraftWorld)block.getWorld();
BlockPosition bp = new BlockPosition(loc.getX(), loc.getY(), loc.getZ());
TileEntityFlowerPot te = (TileEntityFlowerPot)cw.getHandle().getTileEntity(bp);
//Bukkit.getLogger().info("Debug: flowerpot materialdata = " + (new ItemStack(potItem, 1,(short) potItemData).toString()));
net.minecraft.server.v1_12_R1.ItemStack cis = CraftItemStack.asNMSCopy(itemStack);
te.setContents(cis);
te.update();
}
}
示例5: Container
import org.bukkit.Location; //导入方法依赖的package包/类
Container(Location location, String server) {
super();
this.server = server;
this.world = location.getWorld().getName();
this.x = location.getX();
this.y = location.getY();
this.z = location.getZ();
}
示例6: locationToString
import org.bukkit.Location; //导入方法依赖的package包/类
public static String locationToString(Location loc, boolean yawAndPitch){
String str = loc.getWorld().getName() + ", " + loc.getX() + ", " + loc.getY() + ", " + loc.getZ();
if(yawAndPitch){
str += ", " + loc.getYaw() + ", " + loc.getPitch();
}
return str;
}
示例7: spawnPlayerPacket
import org.bukkit.Location; //导入方法依赖的package包/类
public static Packet spawnPlayerPacket(int entityId, UUID uuid, Location location, List<DataWatcher.Item<?>> metadata) {
return new PacketPlayOutNamedEntitySpawn(entityId,
uuid,
location.getX(), location.getY(), location.getZ(),
encodeAngle(location.getYaw()),
encodeAngle(location.getPitch()),
metadata);
}
示例8: clampToBorder
import org.bukkit.Location; //导入方法依赖的package包/类
public static boolean clampToBorder(Location location) {
WorldBorder border = location.getWorld().getWorldBorder();
Location center = border.getCenter();
double radius = border.getSize() / 2d;
double xMin = center.getX() - radius;
double xMax = center.getX() + radius;
double zMin = center.getZ() - radius;
double zMax = center.getZ() + radius;
boolean moved = false;
if(location.getX() < xMin) {
location.setX(xMin);
moved = true;
}
if(location.getX() > xMax) {
location.setX(xMax);
moved = true;
}
if(location.getZ() < zMin) {
location.setZ(zMin);
moved = true;
}
if(location.getZ() > zMax) {
location.setZ(zMax);
moved = true;
}
return moved;
}
示例9: LocationBuilder
import org.bukkit.Location; //导入方法依赖的package包/类
/**
* Initializes a new LocationBuilder from the given BukkitLocation
*
* @param location location
*/
public LocationBuilder(Location location) {
super();
if (location == null)
throw new IllegalArgumentException("Location cannot be null!");
this.world = location.getWorld().getName();
this.x = location.getX();
this.y = location.getY();
this.z = location.getZ();
this.yaw = location.getYaw();
this.pitch = location.getPitch();
}
示例10: LoggerEntityHuman
import org.bukkit.Location; //导入方法依赖的package包/类
private LoggerEntityHuman(Player player, WorldServer world) {
super(MinecraftServer.getServer(), world, new GameProfile(player.getUniqueId(), player.getName()), new PlayerInteractManager((World)world));
Location location = player.getLocation();
double x = location.getX();
double y = location.getY();
double z = location.getZ();
float yaw = location.getYaw();
float pitch = location.getPitch();
new FakePlayerConnection(this);
this.playerConnection.a(x, y, z, yaw, pitch);
EntityPlayer originPlayer = ((CraftPlayer)player).getHandle();
this.lastDamager = originPlayer.lastDamager;
this.invulnerableTicks = originPlayer.invulnerableTicks;
this.combatTracker = originPlayer.combatTracker;
}
示例11: ignite
import org.bukkit.Location; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
public boolean ignite(Player igniter, Location loc, IgniteCause cause) {
Random rand = new Random();
loc.add(0.5, 0.5, 0.5);
BlockIgniteEvent igniteEvent = new BlockIgniteEvent(loc.getBlock(),
cause, (org.bukkit.entity.Entity) igniter);
Bukkit.getServer().getPluginManager().callEvent(igniteEvent);
if (igniteEvent.isCancelled()) {
return false;
}
List<Location> locations = new ArrayList<Location>();
for(double x = loc.getX() - 2;x <= loc.getX() + 2;x++)
{
for(double y = loc.getY() - 1;y <= loc.getY() + 1;y++)
{
for(double z = loc.getZ() - 2;z <= loc.getZ() + 2;z++)
{
locations.add(new Location(loc.getWorld(),x,y,z));
}
}
}
for(Location l : locations)
{
BlockIgniteEvent igniteEvent2 = new BlockIgniteEvent(l.getBlock(),
cause, (org.bukkit.entity.Entity) igniter);
Bukkit.getServer().getPluginManager().callEvent(igniteEvent2);
if (igniteEvent2.isCancelled()) {
continue;
}
BlockState blockState = l.getBlock().getState();
BlockPlaceEvent placeEvent = new BlockPlaceEvent(l.getBlock(),
blockState, l.getBlock(), igniter.getItemInHand(), igniter, true);
Bukkit.getServer().getPluginManager().callEvent(placeEvent);
if (placeEvent.isCancelled() || !placeEvent.canBuild()) {
continue;
}
if(l.getBlock() == null || l.getBlock().getType() == Material.AIR)
l.getBlock().setType(Material.FIRE);
}
loc.getWorld().playSound(loc, Sound.ITEM_FIRECHARGE_USE, 1.0F, rand.nextFloat() * 0.4F + 0.8F);
return true;
}
示例12: createNPC
import org.bukkit.Location; //导入方法依赖的package包/类
public static void createNPC(String name, Player creator) {
Location location = creator.getLocation();
double x = location.getX();
double y = location.getY();
double z = location.getZ();
String world = location.getWorld().getName();
try {
File file = plugin.getPath().getAbsoluteFile();
JSONParser parser = new JSONParser();
Object parsed = parser.parse(new FileReader(file.getPath()));
JSONObject jsonObject = (JSONObject) parsed;
JSONArray npcsArray = (JSONArray) jsonObject.get("npcs");
JSONObject locationObject = new JSONObject();
locationObject.put("x", x);
locationObject.put("y", y);
locationObject.put("z", z);
locationObject.put("world", world);
JSONArray loreArray = new JSONArray();
JSONObject loreLineObject = new JSONObject();
loreLineObject.put("line", "Example");
loreArray.add(loreLineObject);
JSONArray enchantArray = new JSONArray();
JSONObject enchantObject = new JSONObject();
enchantObject.put("enchant", "sharpness");
enchantObject.put("level", 1);
enchantArray.add(enchantObject);
JSONObject itemObject = new JSONObject();
itemObject.put("itemname", "example");
itemObject.put("material", "coal");
itemObject.put("lore", loreArray);
itemObject.put("enchants", enchantArray);
JSONObject npcObject = new JSONObject();
npcObject.put("location", locationObject);
npcObject.put("price", 10);
npcObject.put("item", itemObject);
npcObject.put("denial", "You can not afford this item!");
npcObject.put("success", "Successfully purchased item!");
npcObject.put("colorcode", "&f");
JSONObject mainObject = new JSONObject();
mainObject.put("name", name);
mainObject.put(name, npcObject);
npcsArray.add(mainObject);
} catch (ParseException | IOException e) {
e.printStackTrace();
}
}
示例13: frezeplayer
import org.bukkit.Location; //导入方法依赖的package包/类
public void frezeplayer(Player p, Player damager){
Location pl = p.getLocation();
pl.setX( ( pl.getBlockX()) + 0.5 );
pl.setZ( ( pl.getBlockZ()) + 0.5 );
// set ice blocks
Location locs[] = new Location[7]; // actual locations
Location bla[] = new Location[7]; // before locations added
bla[0] = new Location(p.getWorld(), pl.getX(), pl.getY(), pl.getZ());
bla[1] = new Location(p.getWorld(), pl.getX()+1, pl.getY(), pl.getZ());
bla[2] = new Location(p.getWorld(), pl.getX()-1, pl.getY(), pl.getZ());
bla[3] = new Location(p.getWorld(), pl.getX(), pl.getY(), pl.getZ()+1);
bla[4] = new Location(p.getWorld(), pl.getX(), pl.getY(), pl.getZ()-1);
bla[5] = new Location(p.getWorld(), pl.getX(), pl.getY()+1, pl.getZ());
bla[6] = new Location(p.getWorld(), pl.getX(), pl.getY()+2, pl.getZ());
int arrl = 0;
for(int k = 0; k < 7; k++){
if(bla[k].getBlock().getType() == Material.AIR){
locs[k] = bla[k];
arrl++;
}else{
damager.sendMessage(ChatColor.RED + "Could not freeze player, they are too close to a wall");
return;
}
}
p.teleport(pl);
final int arrl2 = arrl;
final Location flocs[] = locs; // locations, finalled
Bukkit.getScheduler().runTaskLater(this, new Runnable(){
public void run() {
// remove ice blocks
for(int j = 0; j < arrl2; j++){
flocs[j].getBlock().setType(Material.AIR);
}
}
}, 40L
);
for(int i = 0; i < arrl2; i++){
locs[i].getBlock().setType(Material.PACKED_ICE);
}
p.teleport(pl);
}
示例14: encode
import org.bukkit.Location; //导入方法依赖的package包/类
@Override
public String encode(Location type) {
return type.getX() + ":" + type.getY() + ":" + type.getZ() + ":" + type.getYaw() + ":" + type.getPitch() + ":" + type.getWorld().getName();
}
示例15: locationToString
import org.bukkit.Location; //导入方法依赖的package包/类
public static String locationToString(Location loc) {
return loc.getWorld().getName() + "%" + loc.getX() + "%" + loc.getY() + "%" + loc.getZ();
}