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


Java Location类代码示例

本文整理汇总了Java中cn.nukkit.level.Location的典型用法代码示例。如果您正苦于以下问题:Java Location类的具体用法?Java Location怎么用?Java Location使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Location类属于cn.nukkit.level包,在下文中一共展示了Location类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: SignsConfig

import cn.nukkit.level.Location; //导入依赖的package包/类
public SignsConfig(PluginBase plugin) {
    super(plugin, "signs");

    for (String key : config.getKeys(false)) {
        if (Utils.isInt(key)) {
            Set<DonorSign> signs = new HashSet<>();
            for (Location loc : stringsToLocArray(config.getStringList(key))) {
                if (loc != null) {
                    BlockEntity block = loc.getLevel().getBlockEntity(loc);
                    if (block != null && block instanceof BlockEntitySign) {
                        signs.add(new DonorSign(Utils.getInt(key), block.getBlock()));
                    }
                }
            }
            donorSigns.put(Utils.getInt(key), signs);
        }
    }
}
 
开发者ID:MinecraftMarket,项目名称:MinecraftMarket-Plugin,代码行数:19,代码来源:SignsConfig.java

示例2: teleportImmediate

import cn.nukkit.level.Location; //导入依赖的package包/类
public void teleportImmediate(Location location, TeleportCause cause) {
    if (super.teleport(location, cause)) {

        for (Inventory window : new ArrayList<>(this.windowIndex.values())) {
            if (window == this.inventory) {
                continue;
            }
            this.removeWindow(window);
        }

        this.forceMovement = new Vector3(this.x, this.y, this.z);
        this.sendPosition(this, this.yaw, this.pitch, MovePlayerPacket.MODE_RESET);

        this.resetFallDistance();
        this.orderChunks();
        this.nextChunkOrderRun = 0;
        this.newPosition = null;

        //Weather
        this.getLevel().sendWeather(this);
        //Update time
        this.getLevel().sendTime(this);
    }
}
 
开发者ID:FrontierDevs,项目名称:Jenisys3,代码行数:25,代码来源:Player.java

示例3: teleport

import cn.nukkit.level.Location; //导入依赖的package包/类
public boolean teleport(Location location, PlayerTeleportEvent.TeleportCause cause) {
    double yaw = location.yaw;
    double pitch = location.pitch;

    Location from = this.getLocation();
    Location to = location;
    if (cause != null) {
        EntityTeleportEvent ev = new EntityTeleportEvent(this, from, to);
        this.server.getPluginManager().callEvent(ev);
        if (ev.isCancelled()) {
            return false;
        }
        to = ev.getTo();
    }

    this.ySize = 0;

    this.setMotion(this.temporalVector.setComponents(0, 0, 0));

    if (this.setPositionAndRotation(to, yaw, pitch)) {
        this.resetFallDistance();
        this.onGround = true;

        this.updateMovement();

        return true;
    }

    return false;
}
 
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:31,代码来源:Entity.java

示例4: countBookshelf

import cn.nukkit.level.Location; //导入依赖的package包/类
public int countBookshelf() {
    int count = 0;
    Location loc = this.getHolder().getLocation();
    Level level = loc.getLevel();

    for (int y = 0; y <= 1; y++) {
        for (int x = -1; x <= 1; x++) {
            for (int z = -1; z <= 1; z++) {
                if (z == 0 && x == 0) continue;
                if (level.getBlock(loc.add(x, 0, z)).isTransparent()) {
                    if (level.getBlock(loc.add(0, 1, 0)).isTransparent()) {
                        //diagonal and straight
                        if (level.getBlock(loc.add(x << 1, y, z << 1)).getId() == Block.BOOKSHELF) {
                            count++;
                        }

                        if (x != 0 && z != 0) {
                            //one block diagonal and one straight
                            if (level.getBlock(loc.add(x << 1, y, z)).getId() == Block.BOOKSHELF) {
                                ++count;
                            }

                            if (level.getBlock(loc.add(x, y, z << 1)).getId() == Block.BOOKSHELF) {
                                ++count;
                            }
                        }
                    }
                }
            }
        }
    }

    return count;
}
 
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:35,代码来源:EnchantInventory.java

示例5: sleepOn

import cn.nukkit.level.Location; //导入依赖的package包/类
public boolean sleepOn(Vector3 pos) {
    if (!this.isOnline()) {
        return false;
    }

    for (Entity p : this.level.getNearbyEntities(this.boundingBox.grow(2, 1, 2), this)) {
        if (p instanceof Player) {
            if (((Player) p).sleeping != null && pos.distance(((Player) p).sleeping) <= 0.1) {
                return false;
            }
        }
    }

    PlayerBedEnterEvent ev;
    this.server.getPluginManager().callEvent(ev = new PlayerBedEnterEvent(this, this.level.getBlock(pos)));
    if (ev.isCancelled()) {
        return false;
    }

    this.sleeping = pos.clone();
    this.teleport(new Location(pos.x + 0.5, pos.y + 0.5, pos.z + 0.5, this.yaw, this.pitch, this.level), null);

    this.setDataProperty(new IntPositionEntityData(DATA_PLAYER_BED_POSITION, (int) pos.x, (int) pos.y, (int) pos.z));
    this.setDataFlag(DATA_PLAYER_FLAGS, DATA_PLAYER_FLAG_SLEEP, true);

    this.setSpawn(pos);

    this.level.sleepTicks = 60;

    return true;
}
 
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:32,代码来源:Player.java

示例6: teleportImmediate

import cn.nukkit.level.Location; //导入依赖的package包/类
public void teleportImmediate(Location location, TeleportCause cause) {
    Location from = this.getLocation();
    if (super.teleport(location, cause)) {

        for (Inventory window : new ArrayList<>(this.windowIndex.values())) {
            if (window == this.inventory) {
                continue;
            }
            this.removeWindow(window);
        }

        if (from.getLevel().getId() != location.getLevel().getId()) { //Different level, update compass position
            SetSpawnPositionPacket pk = new SetSpawnPositionPacket();
            pk.spawnType = SetSpawnPositionPacket.TYPE_WORLD_SPAWN;
            Position spawn = location.getLevel().getSpawnLocation();
            pk.x = spawn.getFloorX();
            pk.y = spawn.getFloorY();
            pk.z = spawn.getFloorZ();
            dataPacket(pk);
        }

        this.forceMovement = new Vector3(this.x, this.y, this.z);
        this.sendPosition(this, this.yaw, this.pitch, MovePlayerPacket.MODE_RESET);

        this.resetFallDistance();
        this.orderChunks();
        this.nextChunkOrderRun = 0;
        this.newPosition = null;

        //Weather
        this.getLevel().sendWeather(this);
        //Update time
        this.getLevel().sendTime(this);
    }
}
 
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:36,代码来源:Player.java

示例7: playerMove

import cn.nukkit.level.Location; //导入依赖的package包/类
/**
 * @param pos Location
 * @param eid EntityId
 * @return MoveEntityPacket
 */
public static MoveEntityPacket playerMove(Location pos, long eid) {
    MoveEntityPacket pk = new MoveEntityPacket();
    pk.x = pos.x;
    pk.y = pos.y;
    pk.z = pos.z;
    pk.eid = eid;
    pk.yaw = pk.pitch = pk.headYaw = 0;
    return pk;
}
 
开发者ID:WetABQ,项目名称:BossBarAPI-Nukkit,代码行数:15,代码来源:BossBarAPI.java

示例8: stringsToLocArray

import cn.nukkit.level.Location; //导入依赖的package包/类
private List<Location> stringsToLocArray(List<String> strings) {
    List<Location> locs = new ArrayList<>();
    for (String string : strings) {
        locs.add(stringToLoc(string));
    }
    return locs;
}
 
开发者ID:MinecraftMarket,项目名称:MinecraftMarket-Plugin,代码行数:8,代码来源:SignsConfig.java

示例9: sleepOn

import cn.nukkit.level.Location; //导入依赖的package包/类
public boolean sleepOn(Vector3 pos) {
    if (!this.isOnline()) {
        return false;
    }

    for (Entity p : this.level.getNearbyEntities(this.boundingBox.grow(2, 1, 2), this)) {
        if (p instanceof Player) {
            if (((Player) p).sleeping != null && pos.distance(((Player) p).sleeping) <= 0.1) {
                return false;
            }
        }
    }

    PlayerBedEnterEvent ev;
    this.server.getPluginManager().callEvent(ev = new PlayerBedEnterEvent(this, this.level.getBlock(pos)));
    if (ev.isCancelled()) {
        return false;
    }

    this.sleeping = pos.clone();
    this.teleport(new Location(pos.x + 0.5, pos.y - 0.5, pos.z + 0.5, this.yaw, this.pitch, this.level), null);

    this.setDataProperty(new IntPositionEntityData(DATA_PLAYER_BED_POSITION, (int) pos.x, (int) pos.y, (int) pos.z));
    this.setDataFlag(DATA_PLAYER_FLAGS, DATA_PLAYER_FLAG_SLEEP, true);

    this.setSpawn(pos);

    this.level.sleepTicks = 60;

    return true;
}
 
开发者ID:JupiterDevelopmentTeam,项目名称:Jupiter,代码行数:32,代码来源:Player.java

示例10: teleportImmediate

import cn.nukkit.level.Location; //导入依赖的package包/类
public void teleportImmediate(Location location, TeleportCause cause) {
    Location from = this.getLocation();
    if (super.teleport(location, cause)) {

        for (Inventory window : new ArrayList<>(this.windowIndex.values())) {
            if (window == this.inventory) {
                continue;
            }
            this.removeWindow(window);
        }

        if (from.getLevel().getId() != location.getLevel().getId()) {
            SetSpawnPositionPacket pk = new SetSpawnPositionPacket();
            pk.spawnType = SetSpawnPositionPacket.TYPE_WORLD_SPAWN;
            Position spawn = location.getLevel().getSpawnLocation();
            pk.x = spawn.getFloorX();
            pk.y = spawn.getFloorY();
            pk.z = spawn.getFloorZ();
            dataPacket(pk);
        }

        this.forceMovement = new Vector3(this.x, this.y, this.z);
        this.sendPosition(this, this.yaw, this.pitch, MovePlayerPacket.MODE_RESET);

        this.resetFallDistance();
        this.orderChunks();
        this.nextChunkOrderRun = 0;
        this.newPosition = null;

        //Weather
        this.getLevel().sendWeather(this);
        //Update time
        this.getLevel().sendTime(this);
    }
}
 
开发者ID:JupiterDevelopmentTeam,项目名称:Jupiter,代码行数:36,代码来源:Player.java

示例11: gungun

import cn.nukkit.level.Location; //导入依赖的package包/类
@EventHandler
public void gungun(PlayerMoveEvent event){
	if(gunsys.hgun.containsKey(event.getPlayer().getName())){
		Location from = event.getFrom();
		Location to = event.getTo();
		if(Math.abs(from.x-to.x) >0.1 || Math.abs(from.z-to.z) >0.1){
			event.setCancelled(true);
		}

	}
}
 
开发者ID:haniokasai,项目名称:NuclearGunWars-plugin,代码行数:12,代码来源:events.java

示例12: onUpdate

import cn.nukkit.level.Location; //导入依赖的package包/类
@Override
public boolean onUpdate(int currentTick) {
    if (this.closed) {
        return false;
    }

    int tickDiff = currentTick - this.lastUpdate;

    if (tickDiff <= 0 && !this.justCreated) {
        return true;
    }

    this.lastUpdate = currentTick;

    boolean hasUpdate = this.entityBaseTick(tickDiff);

    if (this.isAlive()) {
        super.onUpdate(currentTick);

        this.motionY = (this.level.getBlock(new Vector3(this.x, this.y, this.z)).getBoundingBox() != null || this.isInsideOfWater()) ? getGravity() : -0.08;

        if (this.checkObstruction(this.x, this.y, this.z)) {
            hasUpdate = true;
        }

        this.move(this.motionX, this.motionY, this.motionZ);

        double friction = 1 - this.getDrag();

        if (this.onGround && (Math.abs(this.motionX) > 0.00001 || Math.abs(this.motionZ) > 0.00001)) {
            friction *= this.getLevel().getBlock(this.temporalVector.setComponents((int) Math.floor(this.x), (int) Math.floor(this.y - 1), (int) Math.floor(this.z) - 1)).getFrictionFactor();
        }

        this.motionX *= friction;
        this.motionY *= 1 - this.getDrag();
        this.motionZ *= friction;

        if (this.onGround) {
            this.motionY *= -0.5;
        }

        Location from = new Location(lastX, lastY, lastZ, lastYaw, lastPitch, level);
        Location to = new Location(this.x, this.y, this.z, this.yaw, this.pitch, level);

        this.getServer().getPluginManager().callEvent(new VehicleUpdateEvent(this));

        if (!from.equals(to)) {
            this.getServer().getPluginManager().callEvent(new VehicleMoveEvent(this, from, to));
        }

        this.updateMovement();
    }

    return hasUpdate || !this.onGround || Math.abs(this.motionX) > 0.00001 || Math.abs(this.motionY) > 0.00001 || Math.abs(this.motionZ) > 0.00001;
}
 
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:56,代码来源:EntityBoat.java

示例13: getLocation

import cn.nukkit.level.Location; //导入依赖的package包/类
public Location getLocation() {
    return new Location(this.x, this.y, this.z, this.yaw, this.pitch, this.level);
}
 
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:4,代码来源:Entity.java

示例14: teleport

import cn.nukkit.level.Location; //导入依赖的package包/类
@Override
public boolean teleport(Location location, TeleportCause cause) {
    if (!this.isOnline()) {
        return false;
    }

    Location from = this.getLocation();
    Location to = location;

    if (cause != null) {
        PlayerTeleportEvent event = new PlayerTeleportEvent(this, from, to, cause);
        this.server.getPluginManager().callEvent(event);
        if (event.isCancelled()) return false;
        to = event.getTo();
        if (from.getLevel().getId() != to.getLevel().getId()) { //Different level, update compass position
            SetSpawnPositionPacket pk = new SetSpawnPositionPacket();
            pk.spawnType = SetSpawnPositionPacket.TYPE_WORLD_SPAWN;
            Position spawn = to.getLevel().getSpawnLocation();
            pk.x = spawn.getFloorX();
            pk.y = spawn.getFloorY();
            pk.z = spawn.getFloorZ();
            dataPacket(pk);
        }
    }

    //TODO Remove it! A hack to solve the client-side teleporting bug! (inside into the block)
    if (super.teleport(to.getY() == to.getFloorY() ? to.add(0, 0.00001, 0) : to, null)) { // null to prevent fire of duplicate EntityTeleportEvent
        this.removeAllWindows();

        this.teleportPosition = new Vector3(this.x, this.y, this.z);
        this.forceMovement = this.teleportPosition;
        this.sendPosition(this, this.yaw, this.pitch, MovePlayerPacket.MODE_TELEPORT);

        this.checkTeleportPosition();

        this.resetFallDistance();
        this.nextChunkOrderRun = 0;
        this.newPosition = null;

        //DummyBossBar
        this.getDummyBossBars().values().forEach(DummyBossBar::reshow);
        //Weather
        this.getLevel().sendWeather(this);
        //Update time
        this.getLevel().sendTime(this);
        return true;
    }

    return false;
}
 
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:51,代码来源:Player.java

示例15: EntityTeleportEvent

import cn.nukkit.level.Location; //导入依赖的package包/类
public EntityTeleportEvent(Entity entity, Location from, Location to) {
    this.entity = entity;
    this.from = from;
    this.to = to;
}
 
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:6,代码来源:EntityTeleportEvent.java


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