当前位置: 首页>>代码示例>>Java>>正文


Java Location.getX方法代码示例

本文整理汇总了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);
}
 
开发者ID:davidm98,项目名称:Crescent,代码行数:18,代码来源:KillauraB.java

示例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;
}
 
开发者ID:SamaGames,项目名称:SamaGamesAPI,代码行数:27,代码来源:ProximityUtils.java

示例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);
	}
}
 
开发者ID:thekeenant,项目名称:mczone,代码行数:23,代码来源:ConfigAPI.java

示例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();
    }
}
 
开发者ID:tastybento,项目名称:bskyblock,代码行数:14,代码来源:NMSHandler.java

示例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();
}
 
开发者ID:Shynixn,项目名称:BlockBall,代码行数:9,代码来源:BungeeCordSignInfo.java

示例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;
}
 
开发者ID:benNek,项目名称:AsgardAscension,代码行数:8,代码来源:Convert.java

示例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);
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:9,代码来源:NMSHacks.java

示例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;
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:34,代码来源:WorldBorderUtils.java

示例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();
}
 
开发者ID:Shynixn,项目名称:AstralEdit,代码行数:17,代码来源:LocationBuilder.java

示例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;
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:16,代码来源:LoggerEntityHuman.java

示例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;
}
 
开发者ID:FattyMieo,项目名称:SurvivalPlus,代码行数:54,代码来源:BlazeSword.java

示例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();
    }
}
 
开发者ID:Warvale,项目名称:Locked,代码行数:55,代码来源:MerchantManager.java

示例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);
}
 
开发者ID:OverloadedCore,项目名称:chaoticWeapons,代码行数:42,代码来源:Core.java

示例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();
}
 
开发者ID:AlphaHelixDev,项目名称:AlphaLibary,代码行数:5,代码来源:LocationSerializer.java

示例15: locationToString

import org.bukkit.Location; //导入方法依赖的package包/类
public static String locationToString(Location loc) {
    return loc.getWorld().getName() + "%" + loc.getX() + "%" + loc.getY() + "%" + loc.getZ();
}
 
开发者ID:cadox8,项目名称:WC,代码行数:4,代码来源:Parsers.java


注:本文中的org.bukkit.Location.getX方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。