1
0
Fork 0

Okay, remove full cloning of player during respawn and just post forge's

event for required mods. Close #331
kcx-1614
Sergey Shatunov 2016-02-05 03:43:24 +07:00
parent 7b03a5c0d1
commit 30d7378fda
1 changed files with 27 additions and 30 deletions

View File

@ -9,7 +9,7 @@
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.io.File;
@@ -58,15 +60,37 @@
@@ -58,15 +60,38 @@
import net.minecraft.world.Teleporter;
import net.minecraft.world.World;
import net.minecraft.world.WorldProvider;
@ -20,6 +20,7 @@
import net.minecraft.world.storage.IPlayerFileData;
import net.minecraft.world.storage.SaveHandler;
+import net.minecraftforge.common.DimensionManager;
+import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.chunkio.ChunkIOExecutor;
+import net.minecraftforge.common.network.ForgeMessage;
+import net.minecraftforge.common.network.ForgeNetworkHandler;
@ -47,7 +48,7 @@
public abstract class ServerConfigurationManager
{
public static final File field_152613_a = new File("banned-players.json");
@@ -82,8 +106,8 @@
@@ -82,8 +107,8 @@
private final UserListOps ops;
private final UserListWhitelist whiteListedPlayers;
private final Map field_148547_k;
@ -58,7 +59,7 @@
protected int maxPlayers;
private int viewDistance;
private WorldSettings.GameType gameType;
@@ -91,8 +115,17 @@
@@ -91,8 +116,17 @@
private int playerPingIndex;
private static final String __OBFID = "CL_00001423";
@ -76,7 +77,7 @@
this.bannedPlayers = new UserListBans(field_152613_a);
this.bannedIPs = new BanList(field_152614_b);
this.ops = new UserListOps(field_152615_c);
@@ -131,12 +164,32 @@
@@ -131,12 +165,32 @@
s1 = p_72355_1_.getSocketAddress().toString();
}
@ -111,7 +112,7 @@
nethandlerplayserver.sendPacket(new S3FPacketCustomPayload("MC|Brand", this.getServerInstance().getServerModName().getBytes(Charsets.UTF_8)));
nethandlerplayserver.sendPacket(new S05PacketSpawnPosition(chunkcoordinates.posX, chunkcoordinates.posY, chunkcoordinates.posZ));
nethandlerplayserver.sendPacket(new S39PacketPlayerAbilities(p_72355_2_.capabilities));
@@ -145,6 +198,7 @@
@@ -145,6 +199,7 @@
p_72355_2_.func_147099_x().func_150884_b(p_72355_2_);
this.func_96456_a((ServerScoreboard)worldserver.getScoreboard(), p_72355_2_);
this.mcServer.func_147132_au();
@ -119,7 +120,7 @@
ChatComponentTranslation chatcomponenttranslation;
if (!p_72355_2_.getCommandSenderName().equalsIgnoreCase(s))
@@ -158,6 +212,7 @@
@@ -158,6 +213,7 @@
chatcomponenttranslation.getChatStyle().setColor(EnumChatFormatting.YELLOW);
this.sendChatMsg(chatcomponenttranslation);
@ -127,7 +128,7 @@
this.playerLoggedIn(p_72355_2_);
nethandlerplayserver.setPlayerLocation(p_72355_2_.posX, p_72355_2_.posY, p_72355_2_.posZ, p_72355_2_.rotationYaw, p_72355_2_.rotationPitch);
this.updateTimeAndWeatherForPlayer(p_72355_2_, worldserver);
@@ -192,7 +247,7 @@
@@ -192,7 +248,7 @@
}
}
@ -136,7 +137,7 @@
{
HashSet hashset = new HashSet();
Iterator iterator = p_96456_1_.getTeams().iterator();
@@ -225,6 +280,7 @@
@@ -225,6 +281,7 @@
public void setPlayerManager(WorldServer[] p_72364_1_)
{
@ -144,7 +145,7 @@
this.playerNBTManagerObj = p_72364_1_[0].getSaveHandler().getSaveHandler();
}
@@ -248,7 +304,7 @@
@@ -248,7 +305,7 @@
public NBTTagCompound readPlayerDataFromFile(EntityPlayerMP p_72380_1_)
{
@ -153,7 +154,7 @@
NBTTagCompound nbttagcompound1;
if (p_72380_1_.getCommandSenderName().equals(this.mcServer.getServerOwner()) && nbttagcompound != null)
@@ -294,18 +350,61 @@
@@ -294,18 +351,61 @@
public void playerLoggedIn(EntityPlayerMP p_72377_1_)
{
@ -219,7 +220,7 @@
}
public void updatePlayerPertinentChunks(EntityPlayerMP p_72358_1_)
@@ -313,14 +412,33 @@
@@ -313,14 +413,33 @@
p_72358_1_.getServerForPlayer().getPlayerManager().updatePlayerPertinentChunks(p_72358_1_);
}
@ -255,7 +256,7 @@
{
worldserver.removePlayerEntityDangerously(p_72367_1_.ridingEntity);
logger.debug("removing player mount");
@@ -329,9 +447,35 @@
@@ -329,9 +448,35 @@
worldserver.removeEntity(p_72367_1_);
worldserver.getPlayerManager().removePlayer(p_72367_1_);
this.playerEntityList.remove(p_72367_1_);
@ -294,7 +295,7 @@
}
public String allowUserToConnect(SocketAddress p_148542_1_, GameProfile p_148542_2_)
@@ -352,7 +496,7 @@
@@ -352,7 +497,7 @@
}
else if (!this.func_152607_e(p_148542_2_))
{
@ -303,7 +304,7 @@
}
else if (this.bannedIPs.func_152708_a(p_148542_1_))
{
@@ -368,10 +512,75 @@
@@ -368,10 +513,75 @@
}
else
{
@ -380,7 +381,7 @@
public EntityPlayerMP createPlayerForUser(GameProfile p_148545_1_)
{
UUID uuid = EntityPlayer.func_146094_a(p_148545_1_);
@@ -410,80 +619,204 @@
@@ -410,80 +620,200 @@
return new EntityPlayerMP(this.mcServer, this.mcServer.worldServerForDimension(0), p_148545_1_, (ItemInWorldManager)object);
}
@ -501,16 +502,12 @@
+ // Phase 4 - handle bed spawn
+ ChunkCoordinates bedSpawnChunkCoords = par1EntityPlayerMP.getBedLocation(targetDimension);
+ boolean spawnForced = par1EntityPlayerMP.isSpawnForced(targetDimension);
+ // CraftBukkit start
+ par1EntityPlayerMP.dimension = targetDimension;
+ EntityPlayerMP entityplayermp1 = new EntityPlayerMP(mcServer, mcServer.worldServerForDimension(targetDimension), par1EntityPlayerMP.getGameProfile(), new ItemInWorldManager(mcServer.worldServerForDimension(targetDimension)));
+ entityplayermp1.playerNetServerHandler = par1EntityPlayerMP.playerNetServerHandler;
+ entityplayermp1.playerNetServerHandler.playerEntity = entityplayermp1;
+ entityplayermp1.clonePlayer(par1EntityPlayerMP, cause != TeleportCause.DEATH); // KCauldron - clone player
+ entityplayermp1.setWorld(mcServer.worldServerForDimension(targetDimension));;
+ // CraftBukkit start
+ EntityPlayerMP entityplayermp1 = par1EntityPlayerMP;
+ entityplayermp1.setWorld(this.mcServer.worldServerForDimension(par1EntityPlayerMP.dimension)); // make sure to update reference for bed spawn logic
+ MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.player.PlayerEvent.Clone(entityplayermp1, entityplayermp1, !returnFromEnd));
+ entityplayermp1.playerConqueredTheEnd = false;
+ entityplayermp1.setEntityId(par1EntityPlayerMP.getEntityId());
+ func_72381_a(entityplayermp1, par1EntityPlayerMP, mcServer.worldServerForDimension(targetDimension));
ChunkCoordinates chunkcoordinates1;
+ boolean isBedSpawn = false;
+ org.bukkit.World toWorld = entityplayermp1.getBukkitEntity().getWorld();
@ -625,7 +622,7 @@
return entityplayermp1;
}
@@ -492,34 +825,112 @@
@@ -492,34 +822,112 @@
transferPlayerToDimension(p_72356_1_, p_72356_2_, mcServer.worldServerForDimension(p_72356_2_).getDefaultTeleporter());
}
@ -757,7 +754,7 @@
}
public void transferEntityToWorld(Entity p_82448_1_, int p_82448_2_, WorldServer p_82448_3_, WorldServer p_82448_4_, Teleporter teleporter)
@@ -605,6 +1016,109 @@
@@ -605,6 +1013,109 @@
p_82448_1_.setWorld(p_82448_4_);
}
@ -867,7 +864,7 @@
public void sendPlayerInfoToAllPlayers()
{
if (++this.playerPingIndex > 600)
@@ -612,11 +1126,13 @@
@@ -612,11 +1123,13 @@
this.playerPingIndex = 0;
}
@ -881,7 +878,7 @@
}
public void sendPacketToAllPlayers(Packet p_148540_1_)
@@ -877,13 +1393,24 @@
@@ -877,13 +1390,24 @@
for (int j = 0; j < this.playerEntityList.size(); ++j)
{
EntityPlayerMP entityplayermp = (EntityPlayerMP)this.playerEntityList.get(j);
@ -908,7 +905,7 @@
if (d4 * d4 + d5 * d5 + d6 * d6 < p_148543_8_ * p_148543_8_)
{
entityplayermp.playerNetServerHandler.sendPacket(p_148543_11_);
@@ -941,13 +1468,16 @@
@@ -941,13 +1465,16 @@
p_72354_1_.playerNetServerHandler.sendPacket(new S2BPacketChangeGameState(1, 0.0F));
p_72354_1_.playerNetServerHandler.sendPacket(new S2BPacketChangeGameState(7, p_72354_2_.getRainStrength(1.0F)));
p_72354_1_.playerNetServerHandler.sendPacket(new S2BPacketChangeGameState(8, p_72354_2_.getWeightedThunderStrength(1.0F)));
@ -926,7 +923,7 @@
p_72385_1_.playerNetServerHandler.sendPacket(new S09PacketHeldItemChange(p_72385_1_.inventory.currentItem));
}
@@ -961,9 +1491,17 @@
@@ -961,9 +1488,17 @@
return this.maxPlayers;
}
@ -945,7 +942,7 @@
}
public void setWhiteListEnabled(boolean p_72371_1_)
@@ -1032,12 +1570,30 @@
@@ -1032,12 +1567,30 @@
public void removeAllPlayers()
{