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


Java Position.getFloorX方法代码示例

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


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

示例1: teleportImmediate

import cn.nukkit.level.Position; //导入方法依赖的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

示例2: teleportImmediate

import cn.nukkit.level.Position; //导入方法依赖的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

示例3: teleport

import cn.nukkit.level.Position; //导入方法依赖的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

示例4: teleport

import cn.nukkit.level.Position; //导入方法依赖的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()) {
            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);
        }
    }

    this.getPosition();
    if (super.teleport(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;

        //Weather
        this.getLevel().sendWeather(this);
        //Update time
        this.getLevel().sendTime(this);

        return true;
    }

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

示例5: onProjectileHit

import cn.nukkit.level.Position; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = false) //DON'T FORGET THE ANNOTATION @EventHandler
	    public void onProjectileHit(ProjectileHitEvent event) throws Exception
{
	        Entity snowball = event.getEntity();
	        Position loc = snowball.getLocation();
	        Integer kind = null;
	        String who = null;
	        snowball.getLevel().removeEntity(snowball);
	        if(whodi.containsKey((int)snowball.getId())){
				  for (Map.Entry<Integer, String> e : whodi.get((int)snowball.getId()).entrySet()) {
					    kind = e.getKey();
					    who = e.getValue();
				  }
			}
	        if(who !=null){
	        Player wdi =Server.getInstance().getPlayer(who);
	        if(kind == 1 || kind == 4 || kind == 8){

	        	int ds = 3;
	        	if(kind == 8){
	        		ds = 2;
	        	}
	        	if(kind == 4){
	        		ds = 5;
	        	}

	    		int x=loc.getFloorX();
	    		int y=loc.getFloorY();
	    		int z=loc.getFloorZ();

	    		ExplodeSound sound = new ExplodeSound(new Vector3(x,y,z));//サウンドオブジェクトの生成
	    		loc.getLevel().addSound(sound);//サウンドを再生
	    		ExplodeParticle particle = new ExplodeParticle(new Vector3(x,y,z));
	    		int count = 20;
	    		for(int i = 0;i < count; ++i){
	    			loc.getLevel().addParticle(particle);
	    		}
	    		for(Player playera : Server.getInstance().getOnlinePlayers().values()){
	   			 	if(Math.abs(playera.getX()-x)<=ds & Math.abs(playera.getY()-y)<=ds & Math.abs(playera.getZ()-z)<=ds & wdi != playera){
	   			 		EntityDamageByEntityEvent ev = new EntityDamageByEntityEvent(wdi,playera, EntityDamageEvent.CAUSE_ENTITY_EXPLOSION, 8);//EntityDamageEvent::CAUSE_MAGICを変えることでダメージの種類を、1を変えることでダメージの強さが変更できます
	   			 		playera.attack(ev);

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


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