Portal changes.
Dieser Commit ist enthalten in:
Ursprung
8b49a945c2
Commit
5296f97cde
@ -14,6 +14,7 @@ import org.bukkit.entity.Vehicle;
|
||||
import org.bukkit.event.vehicle.VehicleBlockCollisionEvent;
|
||||
import org.bukkit.event.vehicle.VehicleExitEvent;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.craftbukkit.CraftWorld;
|
||||
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
||||
import org.bukkit.event.entity.EntityCombustEvent;
|
||||
import org.bukkit.event.entity.EntityDamageByBlockEvent;
|
||||
@ -750,7 +751,13 @@ public abstract class Entity {
|
||||
}
|
||||
|
||||
public void a(World world) {
|
||||
this.world = world;
|
||||
// CraftBukkit start
|
||||
if(world == null) {
|
||||
this.die();
|
||||
this.world = ((CraftWorld)Bukkit.getServer().getWorlds().get(0)).getHandle();
|
||||
}
|
||||
else this.world = world;
|
||||
// CraftBukkit end
|
||||
}
|
||||
|
||||
public void setLocation(double d0, double d1, double d2, float f, float f1) {
|
||||
@ -909,6 +916,8 @@ public abstract class Entity {
|
||||
}
|
||||
|
||||
public void e(NBTTagCompound nbttagcompound) {
|
||||
// CraftBukkit - reset world
|
||||
a(((CraftWorld)Bukkit.getServer().getWorld(nbttagcompound.getString("World"))).getHandle());
|
||||
NBTTagList nbttaglist = nbttagcompound.l("Pos");
|
||||
NBTTagList nbttaglist1 = nbttagcompound.l("Motion");
|
||||
NBTTagList nbttaglist2 = nbttagcompound.l("Rotation");
|
||||
|
@ -38,6 +38,7 @@ public abstract class EntityHuman extends EntityLiving {
|
||||
// CraftBukkit start
|
||||
public boolean sleeping;
|
||||
public boolean fauxSleeping;
|
||||
public String spawnWorld;
|
||||
// CraftBukkit end
|
||||
public ChunkCoordinates A;
|
||||
public int sleepTicks; // CraftBukkit - private -> public
|
||||
@ -340,6 +341,8 @@ public abstract class EntityHuman extends EntityLiving {
|
||||
this.a(true, true, false);
|
||||
}
|
||||
|
||||
this.spawnWorld = nbttagcompound.getString("SpawnWorld"); // CraftBukkit
|
||||
|
||||
if (nbttagcompound.hasKey("SpawnX") && nbttagcompound.hasKey("SpawnY") && nbttagcompound.hasKey("SpawnZ")) {
|
||||
this.b = new ChunkCoordinates(nbttagcompound.e("SpawnX"), nbttagcompound.e("SpawnY"), nbttagcompound.e("SpawnZ"));
|
||||
}
|
||||
@ -355,6 +358,7 @@ public abstract class EntityHuman extends EntityLiving {
|
||||
nbttagcompound.a("SpawnX", this.b.x);
|
||||
nbttagcompound.a("SpawnY", this.b.y);
|
||||
nbttagcompound.a("SpawnZ", this.b.z);
|
||||
nbttagcompound.setString("SpawnWorld", this.spawnWorld); // CraftBukkit
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,7 @@ import java.util.Set;
|
||||
|
||||
// CraftBukkit start
|
||||
import java.util.ArrayList;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
@ -62,6 +63,26 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
|
||||
|
||||
public void a(World world) {
|
||||
super.a(world);
|
||||
// CraftBukkit - world fallback code, either respawn location or global spawn
|
||||
if(world == null) {
|
||||
dead = false;
|
||||
ChunkCoordinates position = null;
|
||||
if (!spawnWorld.isEmpty()) {
|
||||
CraftWorld cw = (CraftWorld)Bukkit.getServer().getWorld(spawnWorld);
|
||||
if (cw != null) {
|
||||
world = cw.getHandle();
|
||||
position = M();
|
||||
}
|
||||
}
|
||||
if (world == null) {
|
||||
world = ((CraftWorld)Bukkit.getServer().getWorlds().get(0)).getHandle();
|
||||
position = world.getSpawn();
|
||||
}
|
||||
this.world = world;
|
||||
setPosition(position.x, position.y, position.z);
|
||||
}
|
||||
this.dimension = ((WorldServer)this.world).dimension;
|
||||
// CraftBukkit end
|
||||
this.itemInWorldManager = new ItemInWorldManager((WorldServer) world);
|
||||
this.itemInWorldManager.player = this;
|
||||
}
|
||||
|
@ -83,9 +83,9 @@ public class NetLoginHandler extends NetHandler {
|
||||
|
||||
if (entityplayer != null) {
|
||||
this.server.serverConfigurationManager.b(entityplayer);
|
||||
entityplayer.a((World) this.server.a(entityplayer.dimension));
|
||||
// entityplayer.a((World) this.server.a(entityplayer.dimension)); // CraftBukkit - set by Entity
|
||||
a.info(this.b() + " logged in with entity id " + entityplayer.id + " at (" + entityplayer.locX + ", " + entityplayer.locY + ", " + entityplayer.locZ + ")");
|
||||
WorldServer worldserver = this.server.a(entityplayer.dimension);
|
||||
WorldServer worldserver = (WorldServer) entityplayer.world; // CraftBukkit
|
||||
ChunkCoordinates chunkcoordinates = worldserver.getSpawn();
|
||||
NetServerHandler netserverhandler = new NetServerHandler(this.server, this.networkManager, entityplayer);
|
||||
|
||||
|
@ -194,87 +194,65 @@ public class ServerConfigurationManager {
|
||||
}
|
||||
}
|
||||
|
||||
return new EntityPlayer(this.server, this.server.a(0), s, new ItemInWorldManager(this.server.a(0)));
|
||||
return entity;
|
||||
// CraftBukkit end
|
||||
}
|
||||
|
||||
// CraftBukkit start
|
||||
public EntityPlayer a(EntityPlayer entityplayer, int i) {
|
||||
return a(entityplayer, i, true);
|
||||
return a(entityplayer, i, null);
|
||||
}
|
||||
|
||||
public EntityPlayer a(EntityPlayer entityplayer, int i, boolean spawn) {
|
||||
public EntityPlayer a(EntityPlayer entityplayer, int i, Location location) {
|
||||
this.server.b(entityplayer.dimension).trackPlayer(entityplayer);
|
||||
this.server.b(entityplayer.dimension).untrackEntity(entityplayer);
|
||||
this.a(entityplayer.dimension).removePlayer(entityplayer);
|
||||
this.players.remove(entityplayer);
|
||||
this.server.a(entityplayer.dimension).removeEntity(entityplayer);
|
||||
ChunkCoordinates chunkcoordinates = entityplayer.M();
|
||||
|
||||
entityplayer.dimension = i;
|
||||
EntityPlayer entityplayer1 = new EntityPlayer(this.server, this.server.a(entityplayer.dimension), entityplayer.name, new ItemInWorldManager(this.server.a(entityplayer.dimension)));
|
||||
|
||||
entityplayer1.id = entityplayer.id;
|
||||
entityplayer1.netServerHandler = entityplayer.netServerHandler;
|
||||
entityplayer1.netServerHandler.player = entityplayer1;
|
||||
WorldServer worldserver = this.server.a(entityplayer.dimension);
|
||||
|
||||
entityplayer1.dimension = i;
|
||||
entityplayer1.displayName = entityplayer.displayName;
|
||||
entityplayer1.compassTarget = entityplayer.compassTarget;
|
||||
entityplayer1.fauxSleeping = entityplayer.fauxSleeping;
|
||||
|
||||
if (spawn) {
|
||||
if(chunkcoordinates != null) {
|
||||
ChunkCoordinates chunkcoordinates1 = EntityHuman.getBed(this.server.a(entityplayer.dimension), chunkcoordinates);
|
||||
|
||||
if (location == null) {
|
||||
ChunkCoordinates chunkcoordinates = entityplayer.M();
|
||||
CraftWorld cw = (CraftWorld) this.server.server.getWorld(entityplayer.spawnWorld);
|
||||
if(cw != null && chunkcoordinates != null) {
|
||||
ChunkCoordinates chunkcoordinates1 = EntityHuman.getBed(cw.getHandle(), chunkcoordinates);
|
||||
if (chunkcoordinates1 != null) {
|
||||
entityplayer1.setPositionRotation((double) ((float) chunkcoordinates1.x + 0.5F), (double) ((float) chunkcoordinates1.y + 0.1F), (double) ((float) chunkcoordinates1.z + 0.5F), 0.0F, 0.0F);
|
||||
entityplayer1.a(chunkcoordinates);
|
||||
location = new Location(cw, chunkcoordinates.x, chunkcoordinates.y, chunkcoordinates.z);
|
||||
} else {
|
||||
entityplayer1.netServerHandler.sendPacket(new Packet70Bed(0));
|
||||
entityplayer.netServerHandler.sendPacket(new Packet70Bed(0));
|
||||
}
|
||||
}
|
||||
if (location == null) {
|
||||
cw = (CraftWorld) this.server.server.getWorlds().get(0);
|
||||
chunkcoordinates = cw.getHandle().getSpawn();
|
||||
location = new Location(cw, chunkcoordinates.x, chunkcoordinates.y, chunkcoordinates.z);
|
||||
}
|
||||
Player respawnPlayer = cserver.getPlayer(entityplayer);
|
||||
Location respawnLocation = new Location(cserver.getPlayer(entityplayer1).getWorld(), entityplayer1.locX, entityplayer1.locY, entityplayer1.locZ, entityplayer1.yaw, entityplayer1.pitch);
|
||||
|
||||
PlayerRespawnEvent respawnEvent = new PlayerRespawnEvent(respawnPlayer, respawnLocation);
|
||||
PlayerRespawnEvent respawnEvent = new PlayerRespawnEvent(respawnPlayer, location);
|
||||
cserver.getPluginManager().callEvent(respawnEvent);
|
||||
|
||||
worldserver = ((CraftWorld)respawnEvent.getRespawnLocation().getWorld()).getHandle();
|
||||
entityplayer1.locX = respawnEvent.getRespawnLocation().getX();
|
||||
entityplayer1.locY = respawnEvent.getRespawnLocation().getY();
|
||||
entityplayer1.locZ = respawnEvent.getRespawnLocation().getZ();
|
||||
entityplayer1.yaw = respawnEvent.getRespawnLocation().getYaw();
|
||||
entityplayer1.pitch = respawnEvent.getRespawnLocation().getPitch();
|
||||
}
|
||||
else {
|
||||
entityplayer1.setPositionRotation(entityplayer.locX, entityplayer.locY, entityplayer.locZ, entityplayer.yaw, entityplayer.pitch);
|
||||
entityplayer1.inventory = entityplayer.inventory;
|
||||
entityplayer1.activeContainer = entityplayer.activeContainer;
|
||||
entityplayer1.defaultContainer = entityplayer.defaultContainer;
|
||||
entityplayer1.health = entityplayer.health;
|
||||
location = respawnEvent.getRespawnLocation();
|
||||
entityplayer.health = 20;
|
||||
} else {
|
||||
location.setWorld(this.server.a(i).getWorld());
|
||||
}
|
||||
WorldServer worldserver = ((CraftWorld)location.getWorld()).getHandle();
|
||||
worldserver.chunkProviderServer.getChunkAt((int) entityplayer.locX >> 4, (int) entityplayer.locZ >> 4);
|
||||
|
||||
worldserver.chunkProviderServer.getChunkAt((int) entityplayer1.locX >> 4, (int) entityplayer1.locZ >> 4);
|
||||
|
||||
while (worldserver.getEntities(entityplayer1, entityplayer1.boundingBox).size() != 0) {
|
||||
entityplayer1.setPosition(entityplayer1.locX, entityplayer1.locY + 1.0D, entityplayer1.locZ);
|
||||
while (worldserver.getEntities(entityplayer, entityplayer.boundingBox).size() != 0) {
|
||||
entityplayer.setPosition(entityplayer.locX, entityplayer.locY + 1.0D, entityplayer.locZ);
|
||||
}
|
||||
|
||||
byte actualDimension = (byte) (worldserver.getWorld().getEnvironment().getId());
|
||||
entityplayer1.netServerHandler.sendPacket(new Packet9Respawn((byte) (actualDimension >= 0 ? -1 : 0))); // CraftBukkit
|
||||
entityplayer1.netServerHandler.sendPacket(new Packet9Respawn(actualDimension)); // CraftBukkit
|
||||
entityplayer.netServerHandler.sendPacket(new Packet9Respawn((byte) (actualDimension >= 0 ? -1 : 0)));
|
||||
entityplayer.netServerHandler.sendPacket(new Packet9Respawn(actualDimension));
|
||||
entityplayer.a(worldserver);
|
||||
entityplayer.dead = false;
|
||||
entityplayer.netServerHandler.teleport(location);
|
||||
this.a(entityplayer, worldserver);
|
||||
this.a(entityplayer.dimension).addPlayer(entityplayer);
|
||||
worldserver.addEntity(entityplayer);
|
||||
this.players.add(entityplayer);
|
||||
this.g(entityplayer);
|
||||
entityplayer.w();
|
||||
return entityplayer;
|
||||
// CraftBukkit end
|
||||
entityplayer1.netServerHandler.a(entityplayer1.locX, entityplayer1.locY, entityplayer1.locZ, entityplayer1.yaw, entityplayer1.pitch);
|
||||
this.a(entityplayer1, worldserver);
|
||||
this.a(entityplayer1.dimension).addPlayer(entityplayer1);
|
||||
worldserver.addEntity(entityplayer1);
|
||||
this.players.add(entityplayer1);
|
||||
if (spawn) entityplayer1.syncInventory(); // CraftBukkit
|
||||
entityplayer1.a(entityplayer1.activeContainer);
|
||||
entityplayer1.w();
|
||||
return entityplayer1;
|
||||
}
|
||||
|
||||
// CraftBukkit - changed signature
|
||||
@ -295,8 +273,6 @@ public class ServerConfigurationManager {
|
||||
|
||||
// entityplayer.netServerHandler.sendPacket(new Packet9Respawn((byte) ((WorldServer)entityplayer.world).getWorld().getEnvironment().getId()));
|
||||
// Craftbukkit end
|
||||
worldserver.removeEntity(entityplayer);
|
||||
entityplayer.dead = false;
|
||||
double d0 = entityplayer.locX;
|
||||
double d1 = entityplayer.locZ;
|
||||
double d2 = 8.0D;
|
||||
@ -332,7 +308,8 @@ public class ServerConfigurationManager {
|
||||
this.a(entityplayer, worldserver1);
|
||||
this.g(entityplayer);
|
||||
*/ // CraftBukkit end
|
||||
return a(entityplayer, b0, false);
|
||||
// CraftBukkit - defer for actual teleportation
|
||||
return a(entityplayer, b0, new Location(null, entityplayer.locX, entityplayer.locY, entityplayer.locZ));
|
||||
}
|
||||
|
||||
public void b() {
|
||||
|
@ -170,12 +170,13 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
WorldServer newWorld = ((CraftWorld)location.getWorld()).getHandle();
|
||||
ServerConfigurationManager manager = server.getHandle();
|
||||
EntityPlayer entity = getHandle();
|
||||
boolean successfulTeleport = entity.netServerHandler.teleport(location);
|
||||
|
||||
if (oldWorld != newWorld && successfulTeleport) {
|
||||
this.entity = manager.a(entity, newWorld.dimension, false);
|
||||
if (oldWorld != newWorld) {
|
||||
manager.a(entity, newWorld.dimension, location);
|
||||
return true; //best guess
|
||||
} else {
|
||||
return entity.netServerHandler.teleport(location);
|
||||
}
|
||||
return successfulTeleport;
|
||||
}
|
||||
|
||||
public void setSneaking(boolean sneak) {
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren