Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-19 04:50:06 +01:00
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.VehicleBlockCollisionEvent;
|
||||||
import org.bukkit.event.vehicle.VehicleExitEvent;
|
import org.bukkit.event.vehicle.VehicleExitEvent;
|
||||||
import org.bukkit.craftbukkit.CraftServer;
|
import org.bukkit.craftbukkit.CraftServer;
|
||||||
|
import org.bukkit.craftbukkit.CraftWorld;
|
||||||
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
||||||
import org.bukkit.event.entity.EntityCombustEvent;
|
import org.bukkit.event.entity.EntityCombustEvent;
|
||||||
import org.bukkit.event.entity.EntityDamageByBlockEvent;
|
import org.bukkit.event.entity.EntityDamageByBlockEvent;
|
||||||
@ -750,7 +751,13 @@ public abstract class Entity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void a(World world) {
|
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) {
|
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) {
|
public void e(NBTTagCompound nbttagcompound) {
|
||||||
|
// CraftBukkit - reset world
|
||||||
|
a(((CraftWorld)Bukkit.getServer().getWorld(nbttagcompound.getString("World"))).getHandle());
|
||||||
NBTTagList nbttaglist = nbttagcompound.l("Pos");
|
NBTTagList nbttaglist = nbttagcompound.l("Pos");
|
||||||
NBTTagList nbttaglist1 = nbttagcompound.l("Motion");
|
NBTTagList nbttaglist1 = nbttagcompound.l("Motion");
|
||||||
NBTTagList nbttaglist2 = nbttagcompound.l("Rotation");
|
NBTTagList nbttaglist2 = nbttagcompound.l("Rotation");
|
||||||
|
@ -38,6 +38,7 @@ public abstract class EntityHuman extends EntityLiving {
|
|||||||
// CraftBukkit start
|
// CraftBukkit start
|
||||||
public boolean sleeping;
|
public boolean sleeping;
|
||||||
public boolean fauxSleeping;
|
public boolean fauxSleeping;
|
||||||
|
public String spawnWorld;
|
||||||
// CraftBukkit end
|
// CraftBukkit end
|
||||||
public ChunkCoordinates A;
|
public ChunkCoordinates A;
|
||||||
public int sleepTicks; // CraftBukkit - private -> public
|
public int sleepTicks; // CraftBukkit - private -> public
|
||||||
@ -340,6 +341,8 @@ public abstract class EntityHuman extends EntityLiving {
|
|||||||
this.a(true, true, false);
|
this.a(true, true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.spawnWorld = nbttagcompound.getString("SpawnWorld"); // CraftBukkit
|
||||||
|
|
||||||
if (nbttagcompound.hasKey("SpawnX") && nbttagcompound.hasKey("SpawnY") && nbttagcompound.hasKey("SpawnZ")) {
|
if (nbttagcompound.hasKey("SpawnX") && nbttagcompound.hasKey("SpawnY") && nbttagcompound.hasKey("SpawnZ")) {
|
||||||
this.b = new ChunkCoordinates(nbttagcompound.e("SpawnX"), nbttagcompound.e("SpawnY"), nbttagcompound.e("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("SpawnX", this.b.x);
|
||||||
nbttagcompound.a("SpawnY", this.b.y);
|
nbttagcompound.a("SpawnY", this.b.y);
|
||||||
nbttagcompound.a("SpawnZ", this.b.z);
|
nbttagcompound.a("SpawnZ", this.b.z);
|
||||||
|
nbttagcompound.setString("SpawnWorld", this.spawnWorld); // CraftBukkit
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@ import java.util.Set;
|
|||||||
|
|
||||||
// CraftBukkit start
|
// CraftBukkit start
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
@ -62,6 +63,26 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
|
|||||||
|
|
||||||
public void a(World world) {
|
public void a(World world) {
|
||||||
super.a(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 = new ItemInWorldManager((WorldServer) world);
|
||||||
this.itemInWorldManager.player = this;
|
this.itemInWorldManager.player = this;
|
||||||
}
|
}
|
||||||
|
@ -83,9 +83,9 @@ public class NetLoginHandler extends NetHandler {
|
|||||||
|
|
||||||
if (entityplayer != null) {
|
if (entityplayer != null) {
|
||||||
this.server.serverConfigurationManager.b(entityplayer);
|
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 + ")");
|
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();
|
ChunkCoordinates chunkcoordinates = worldserver.getSpawn();
|
||||||
NetServerHandler netserverhandler = new NetServerHandler(this.server, this.networkManager, entityplayer);
|
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 end
|
||||||
}
|
}
|
||||||
|
|
||||||
// CraftBukkit start
|
// CraftBukkit start
|
||||||
public EntityPlayer a(EntityPlayer entityplayer, int i) {
|
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).trackPlayer(entityplayer);
|
||||||
this.server.b(entityplayer.dimension).untrackEntity(entityplayer);
|
|
||||||
this.a(entityplayer.dimension).removePlayer(entityplayer);
|
this.a(entityplayer.dimension).removePlayer(entityplayer);
|
||||||
this.players.remove(entityplayer);
|
this.players.remove(entityplayer);
|
||||||
this.server.a(entityplayer.dimension).removeEntity(entityplayer);
|
this.server.a(entityplayer.dimension).removeEntity(entityplayer);
|
||||||
|
if (location == null) {
|
||||||
ChunkCoordinates chunkcoordinates = entityplayer.M();
|
ChunkCoordinates chunkcoordinates = entityplayer.M();
|
||||||
|
CraftWorld cw = (CraftWorld) this.server.server.getWorld(entityplayer.spawnWorld);
|
||||||
entityplayer.dimension = i;
|
if(cw != null && chunkcoordinates != null) {
|
||||||
EntityPlayer entityplayer1 = new EntityPlayer(this.server, this.server.a(entityplayer.dimension), entityplayer.name, new ItemInWorldManager(this.server.a(entityplayer.dimension)));
|
ChunkCoordinates chunkcoordinates1 = EntityHuman.getBed(cw.getHandle(), chunkcoordinates);
|
||||||
|
|
||||||
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 (chunkcoordinates1 != null) {
|
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);
|
location = new Location(cw, chunkcoordinates.x, chunkcoordinates.y, chunkcoordinates.z);
|
||||||
entityplayer1.a(chunkcoordinates);
|
|
||||||
} else {
|
} 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);
|
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, location);
|
||||||
|
|
||||||
PlayerRespawnEvent respawnEvent = new PlayerRespawnEvent(respawnPlayer, respawnLocation);
|
|
||||||
cserver.getPluginManager().callEvent(respawnEvent);
|
cserver.getPluginManager().callEvent(respawnEvent);
|
||||||
|
location = respawnEvent.getRespawnLocation();
|
||||||
worldserver = ((CraftWorld)respawnEvent.getRespawnLocation().getWorld()).getHandle();
|
entityplayer.health = 20;
|
||||||
entityplayer1.locX = respawnEvent.getRespawnLocation().getX();
|
} else {
|
||||||
entityplayer1.locY = respawnEvent.getRespawnLocation().getY();
|
location.setWorld(this.server.a(i).getWorld());
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
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(entityplayer, entityplayer.boundingBox).size() != 0) {
|
||||||
|
entityplayer.setPosition(entityplayer.locX, entityplayer.locY + 1.0D, entityplayer.locZ);
|
||||||
while (worldserver.getEntities(entityplayer1, entityplayer1.boundingBox).size() != 0) {
|
|
||||||
entityplayer1.setPosition(entityplayer1.locX, entityplayer1.locY + 1.0D, entityplayer1.locZ);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
byte actualDimension = (byte) (worldserver.getWorld().getEnvironment().getId());
|
byte actualDimension = (byte) (worldserver.getWorld().getEnvironment().getId());
|
||||||
entityplayer1.netServerHandler.sendPacket(new Packet9Respawn((byte) (actualDimension >= 0 ? -1 : 0))); // CraftBukkit
|
entityplayer.netServerHandler.sendPacket(new Packet9Respawn((byte) (actualDimension >= 0 ? -1 : 0)));
|
||||||
entityplayer1.netServerHandler.sendPacket(new Packet9Respawn(actualDimension)); // CraftBukkit
|
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
|
// 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
|
// CraftBukkit - changed signature
|
||||||
@ -295,8 +273,6 @@ public class ServerConfigurationManager {
|
|||||||
|
|
||||||
// entityplayer.netServerHandler.sendPacket(new Packet9Respawn((byte) ((WorldServer)entityplayer.world).getWorld().getEnvironment().getId()));
|
// entityplayer.netServerHandler.sendPacket(new Packet9Respawn((byte) ((WorldServer)entityplayer.world).getWorld().getEnvironment().getId()));
|
||||||
// Craftbukkit end
|
// Craftbukkit end
|
||||||
worldserver.removeEntity(entityplayer);
|
|
||||||
entityplayer.dead = false;
|
|
||||||
double d0 = entityplayer.locX;
|
double d0 = entityplayer.locX;
|
||||||
double d1 = entityplayer.locZ;
|
double d1 = entityplayer.locZ;
|
||||||
double d2 = 8.0D;
|
double d2 = 8.0D;
|
||||||
@ -332,7 +308,8 @@ public class ServerConfigurationManager {
|
|||||||
this.a(entityplayer, worldserver1);
|
this.a(entityplayer, worldserver1);
|
||||||
this.g(entityplayer);
|
this.g(entityplayer);
|
||||||
*/ // CraftBukkit end
|
*/ // 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() {
|
public void b() {
|
||||||
|
@ -170,12 +170,13 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|||||||
WorldServer newWorld = ((CraftWorld)location.getWorld()).getHandle();
|
WorldServer newWorld = ((CraftWorld)location.getWorld()).getHandle();
|
||||||
ServerConfigurationManager manager = server.getHandle();
|
ServerConfigurationManager manager = server.getHandle();
|
||||||
EntityPlayer entity = getHandle();
|
EntityPlayer entity = getHandle();
|
||||||
boolean successfulTeleport = entity.netServerHandler.teleport(location);
|
|
||||||
|
|
||||||
if (oldWorld != newWorld && successfulTeleport) {
|
if (oldWorld != newWorld) {
|
||||||
this.entity = manager.a(entity, newWorld.dimension, false);
|
manager.a(entity, newWorld.dimension, location);
|
||||||
|
return true; //best guess
|
||||||
|
} else {
|
||||||
|
return entity.netServerHandler.teleport(location);
|
||||||
}
|
}
|
||||||
return successfulTeleport;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSneaking(boolean sneak) {
|
public void setSneaking(boolean sneak) {
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren