Skip to content
This repository has been archived by the owner on Jan 26, 2019. It is now read-only.

Commit

Permalink
More cloning fixing
Browse files Browse the repository at this point in the history
  • Loading branch information
robotia committed Mar 3, 2016
1 parent 5cd48a6 commit 056ef30
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 33 deletions.
27 changes: 26 additions & 1 deletion patches/net/minecraft/entity/player/EntityPlayerMP.java.patch
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,32 @@
public void addChatComponentMessage(IChatComponent p_146105_1_)
{
this.playerNetServerHandler.sendPacket(new S02PacketChat(p_146105_1_));
@@ -1037,6 +1369,114 @@
@@ -882,7 +1214,24 @@
this.lastExperience = -1;
this.lastHealth = -1.0F;
this.lastFoodLevel = -1;
+ this.displayName = p_71049_1_.getDisplayName();
this.destroyedItemsNetCache.addAll(((EntityPlayerMP)p_71049_1_).destroyedItemsNetCache);
+
+ if(!p_71049_2_ || !(p_71049_1_ instanceof EntityPlayerMP))return;
+ //Thermos direct copy the right properties
+ EntityPlayerMP m = (EntityPlayerMP)p_71049_1_;
+ this.lastExperience = m.lastExperience;
+ this.lastHealth = m.lastHealth;
+ this.lastFoodLevel = m.lastFoodLevel;
+ this.listName = m.listName;
+ this.compassTarget = m.compassTarget;
+ this.newExp = m.newExp;
+ this.newLevel = m.newLevel;
+ this.newTotalExp = m.newTotalExp;
+ this.keepLevel = m.keepLevel;
+ this.maxHealthCache = m.maxHealthCache;
+ this.lastFoodLevel = m.lastFoodLevel;
+
}

protected void onNewPotionEffect(PotionEffect p_70670_1_)
@@ -1037,6 +1386,114 @@
return this.field_143005_bX;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@
public EntityPlayerMP createPlayerForUser(GameProfile p_148545_1_)
{
UUID uuid = EntityPlayer.func_146094_a(p_148545_1_);
@@ -410,80 +621,275 @@
@@ -410,80 +621,276 @@
return new EntityPlayerMP(this.mcServer, this.mcServer.worldServerForDimension(0), p_148545_1_, (ItemInWorldManager)object);
}

Expand Down Expand Up @@ -531,30 +531,6 @@
+ EntityPlayerMP entityplayermp1 = new EntityPlayerMP(this.mcServer, this.mcServer.worldServerForDimension(p_72368_1_.dimension), p_72368_1_.getGameProfile(), (ItemInWorldManager)object);
+ entityplayermp1.playerNetServerHandler = par1EntityPlayerMP.playerNetServerHandler;
+ entityplayermp1.playerNetServerHandler.playerEntity = entityplayermp1;
+ if(!isdeath)
+ {
+ entityplayermp1.clonePlayer(par1EntityPlayerMP, true);
+ entityplayermp1.activePotionsMap.clear();
+ entityplayermp1.activePotionsMap.putAll(par1EntityPlayerMP.activePotionsMap);
+ //Let Forge do the heavy lifting...
+ /*entityplayermp1.inventory.copyInventory(par1EntityPlayerMP.inventory);
+ entityplayermp1.experienceLevel = par1EntityPlayerMP.experienceLevel;
+ entityplayermp1.experienceTotal = par1EntityPlayerMP.experienceTotal;
+ entityplayermp1.experience = par1EntityPlayerMP.experience;
+ entityplayermp1.setHealth(par1EntityPlayerMP.getHealth());
+ entityplayermp1.foodStats = par1EntityPlayerMP.foodStats;
+ entityplayermp1.setScore(par1EntityPlayerMP.getScore());
+ entityplayermp1.teleportDirection = par1EntityPlayerMP.teleportDirection;
+ //Copy and re-init ExtendedProperties when switching dimensions.
+ entityplayermp1.extendedProperties = par1EntityPlayerMP.extendedProperties;
+ for (net.minecraftforge.common.IExtendedEntityProperties p : par1EntityPlayerMP.extendedProperties.values())
+ p.init(this, this.worldObj);
+
+ entityplayermp1.activePotionsMap.clear();
+ entityplayermp1.activePotionsMap.putAll(par1EntityPlayerMP.activePotionsMap);
+ entityplayermp1.setScore(par1EntityPlayerMP.getScore());*/
+ }
+ else entityplayermp1.clonePlayer(par1EntityPlayerMP, returnFromEnd);
+ // entityplayermp1.dimension = targetDimension; Thermos move this call to later when actualDimension is found
+ // HEY don't setWorld here either, that has to down to the bottom
+ entityplayermp1.setEntityId(par1EntityPlayerMP.getEntityId());
Expand Down Expand Up @@ -678,6 +654,31 @@
+ entityplayermp1.playerNetServerHandler.teleport(new Location(targetWorld.getWorld(), entityplayermp1.posX, entityplayermp1.posY, entityplayermp1.posZ, entityplayermp1.rotationYaw, entityplayermp1.rotationPitch));
+ entityplayermp1.setSneaking(false); // Um ok? just in case
+
+ if(!isdeath) // Thermos move data - cloning down here so properties are retained correctly
+ {
+ entityplayermp1.clonePlayer(par1EntityPlayerMP, true);
+ entityplayermp1.activePotionsMap.clear();
+ entityplayermp1.activePotionsMap.putAll(par1EntityPlayerMP.activePotionsMap);
+ //Let Forge do the heavy lifting...
+ /*entityplayermp1.inventory.copyInventory(par1EntityPlayerMP.inventory);
+ entityplayermp1.experienceLevel = par1EntityPlayerMP.experienceLevel;
+ entityplayermp1.experienceTotal = par1EntityPlayerMP.experienceTotal;
+ entityplayermp1.experience = par1EntityPlayerMP.experience;
+ entityplayermp1.setHealth(par1EntityPlayerMP.getHealth());
+ entityplayermp1.foodStats = par1EntityPlayerMP.foodStats;
+ entityplayermp1.setScore(par1EntityPlayerMP.getScore());
+ entityplayermp1.teleportDirection = par1EntityPlayerMP.teleportDirection;
+ //Copy and re-init ExtendedProperties when switching dimensions.
+ entityplayermp1.extendedProperties = par1EntityPlayerMP.extendedProperties;
+ for (net.minecraftforge.common.IExtendedEntityProperties p : par1EntityPlayerMP.extendedProperties.values())
+ p.init(this, this.worldObj);
+
+ entityplayermp1.activePotionsMap.clear();
+ entityplayermp1.activePotionsMap.putAll(par1EntityPlayerMP.activePotionsMap);
+ entityplayermp1.setScore(par1EntityPlayerMP.getScore());*/
+ }
+ else entityplayermp1.clonePlayer(par1EntityPlayerMP, returnFromEnd);
+
+ // CraftBukkit end
+ //Forge same
entityplayermp1.playerNetServerHandler.sendPacket(new S05PacketSpawnPosition(chunkcoordinates1.posX, chunkcoordinates1.posY, chunkcoordinates1.posZ));
Expand All @@ -703,7 +704,7 @@
return entityplayermp1;
}

@@ -492,34 +898,112 @@
@@ -492,34 +899,112 @@
transferPlayerToDimension(p_72356_1_, p_72356_2_, mcServer.worldServerForDimension(p_72356_2_).getDefaultTeleporter());
}

Expand Down Expand Up @@ -835,7 +836,7 @@
}

public void transferEntityToWorld(Entity p_82448_1_, int p_82448_2_, WorldServer p_82448_3_, WorldServer p_82448_4_, Teleporter teleporter)
@@ -605,6 +1089,109 @@
@@ -605,6 +1090,109 @@
p_82448_1_.setWorld(p_82448_4_);
}

Expand Down Expand Up @@ -945,7 +946,7 @@
public void sendPlayerInfoToAllPlayers()
{
if (++this.playerPingIndex > 600)
@@ -612,11 +1199,13 @@
@@ -612,11 +1200,13 @@
this.playerPingIndex = 0;
}

Expand All @@ -959,7 +960,7 @@
}

public void sendPacketToAllPlayers(Packet p_148540_1_)
@@ -877,13 +1466,24 @@
@@ -877,13 +1467,24 @@
for (int j = 0; j < this.playerEntityList.size(); ++j)
{
EntityPlayerMP entityplayermp = (EntityPlayerMP)this.playerEntityList.get(j);
Expand All @@ -986,7 +987,7 @@
if (d4 * d4 + d5 * d5 + d6 * d6 < p_148543_8_ * p_148543_8_)
{
entityplayermp.playerNetServerHandler.sendPacket(p_148543_11_);
@@ -941,13 +1541,16 @@
@@ -941,13 +1542,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)));
Expand All @@ -1004,7 +1005,7 @@
p_72385_1_.playerNetServerHandler.sendPacket(new S09PacketHeldItemChange(p_72385_1_.inventory.currentItem));
}

@@ -961,9 +1564,17 @@
@@ -961,9 +1565,17 @@
return this.maxPlayers;
}

Expand All @@ -1023,7 +1024,7 @@
}

public void setWhiteListEnabled(boolean p_72371_1_)
@@ -1032,12 +1643,30 @@
@@ -1032,12 +1644,30 @@

public void removeAllPlayers()
{
Expand Down

0 comments on commit 056ef30

Please sign in to comment.