1
0
forked from xjboss/KCauldronX

Do fully player cloning to avoid duping of items (probably related to #301)

This commit is contained in:
Sergey 2016-01-31 20:08:36 +07:00
parent 201b43272f
commit 8c5b2f7229
3 changed files with 50 additions and 32 deletions

View File

@ -380,7 +380,7 @@
public EntityPlayerMP createPlayerForUser(GameProfile p_148545_1_) public EntityPlayerMP createPlayerForUser(GameProfile p_148545_1_)
{ {
UUID uuid = EntityPlayer.func_146094_a(p_148545_1_); UUID uuid = EntityPlayer.func_146094_a(p_148545_1_);
@@ -410,80 +619,200 @@ @@ -410,80 +619,204 @@
return new EntityPlayerMP(this.mcServer, this.mcServer.worldServerForDimension(0), p_148545_1_, (ItemInWorldManager)object); return new EntityPlayerMP(this.mcServer, this.mcServer.worldServerForDimension(0), p_148545_1_, (ItemInWorldManager)object);
} }
@ -487,7 +487,7 @@
+ Bukkit.getServer().getPluginManager().callEvent(event); + Bukkit.getServer().getPluginManager().callEvent(event);
+ if (event.isCancelled() || event.getTo() == null) + if (event.isCancelled() || event.getTo() == null)
+ { + {
+ return null; + return par1EntityPlayerMP;
+ } + }
+ } + }
+ +
@ -501,12 +501,16 @@
+ // Phase 4 - handle bed spawn + // Phase 4 - handle bed spawn
+ ChunkCoordinates bedSpawnChunkCoords = par1EntityPlayerMP.getBedLocation(targetDimension); + ChunkCoordinates bedSpawnChunkCoords = par1EntityPlayerMP.getBedLocation(targetDimension);
+ boolean spawnForced = par1EntityPlayerMP.isSpawnForced(targetDimension); + boolean spawnForced = par1EntityPlayerMP.isSpawnForced(targetDimension);
+ par1EntityPlayerMP.dimension = targetDimension;
+ // CraftBukkit start + // CraftBukkit start
+ EntityPlayerMP entityplayermp1 = par1EntityPlayerMP; + 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, returnFromEnd); // KCauldron - clone player + entityplayermp1.clonePlayer(par1EntityPlayerMP, returnFromEnd); // KCauldron - clone player
+ entityplayermp1.setWorld(this.mcServer.worldServerForDimension(par1EntityPlayerMP.dimension)); // make sure to update reference for bed spawn logic + entityplayermp1.setWorld(mcServer.worldServerForDimension(targetDimension));;
+ entityplayermp1.playerConqueredTheEnd = false; + entityplayermp1.playerConqueredTheEnd = false;
+ entityplayermp1.setEntityId(par1EntityPlayerMP.getEntityId());
+ func_72381_a(entityplayermp1, par1EntityPlayerMP, mcServer.worldServerForDimension(targetDimension));
ChunkCoordinates chunkcoordinates1; ChunkCoordinates chunkcoordinates1;
+ boolean isBedSpawn = false; + boolean isBedSpawn = false;
+ org.bukkit.World toWorld = entityplayermp1.getBukkitEntity().getWorld(); + org.bukkit.World toWorld = entityplayermp1.getBukkitEntity().getWorld();
@ -621,7 +625,7 @@
return entityplayermp1; return entityplayermp1;
} }
@@ -492,34 +821,112 @@ @@ -492,34 +825,112 @@
transferPlayerToDimension(p_72356_1_, p_72356_2_, mcServer.worldServerForDimension(p_72356_2_).getDefaultTeleporter()); transferPlayerToDimension(p_72356_1_, p_72356_2_, mcServer.worldServerForDimension(p_72356_2_).getDefaultTeleporter());
} }
@ -753,7 +757,7 @@
} }
public void transferEntityToWorld(Entity p_82448_1_, int p_82448_2_, WorldServer p_82448_3_, WorldServer p_82448_4_, Teleporter teleporter) public void transferEntityToWorld(Entity p_82448_1_, int p_82448_2_, WorldServer p_82448_3_, WorldServer p_82448_4_, Teleporter teleporter)
@@ -605,6 +1012,109 @@ @@ -605,6 +1016,109 @@
p_82448_1_.setWorld(p_82448_4_); p_82448_1_.setWorld(p_82448_4_);
} }
@ -863,7 +867,7 @@
public void sendPlayerInfoToAllPlayers() public void sendPlayerInfoToAllPlayers()
{ {
if (++this.playerPingIndex > 600) if (++this.playerPingIndex > 600)
@@ -612,11 +1122,13 @@ @@ -612,11 +1126,13 @@
this.playerPingIndex = 0; this.playerPingIndex = 0;
} }
@ -877,7 +881,7 @@
} }
public void sendPacketToAllPlayers(Packet p_148540_1_) public void sendPacketToAllPlayers(Packet p_148540_1_)
@@ -877,13 +1389,24 @@ @@ -877,13 +1393,24 @@
for (int j = 0; j < this.playerEntityList.size(); ++j) for (int j = 0; j < this.playerEntityList.size(); ++j)
{ {
EntityPlayerMP entityplayermp = (EntityPlayerMP)this.playerEntityList.get(j); EntityPlayerMP entityplayermp = (EntityPlayerMP)this.playerEntityList.get(j);
@ -904,7 +908,7 @@
if (d4 * d4 + d5 * d5 + d6 * d6 < p_148543_8_ * p_148543_8_) if (d4 * d4 + d5 * d5 + d6 * d6 < p_148543_8_ * p_148543_8_)
{ {
entityplayermp.playerNetServerHandler.sendPacket(p_148543_11_); entityplayermp.playerNetServerHandler.sendPacket(p_148543_11_);
@@ -941,13 +1464,16 @@ @@ -941,13 +1468,16 @@
p_72354_1_.playerNetServerHandler.sendPacket(new S2BPacketChangeGameState(1, 0.0F)); 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(7, p_72354_2_.getRainStrength(1.0F)));
p_72354_1_.playerNetServerHandler.sendPacket(new S2BPacketChangeGameState(8, p_72354_2_.getWeightedThunderStrength(1.0F))); p_72354_1_.playerNetServerHandler.sendPacket(new S2BPacketChangeGameState(8, p_72354_2_.getWeightedThunderStrength(1.0F)));
@ -922,7 +926,7 @@
p_72385_1_.playerNetServerHandler.sendPacket(new S09PacketHeldItemChange(p_72385_1_.inventory.currentItem)); p_72385_1_.playerNetServerHandler.sendPacket(new S09PacketHeldItemChange(p_72385_1_.inventory.currentItem));
} }
@@ -961,9 +1487,17 @@ @@ -961,9 +1491,17 @@
return this.maxPlayers; return this.maxPlayers;
} }
@ -941,7 +945,7 @@
} }
public void setWhiteListEnabled(boolean p_72371_1_) public void setWhiteListEnabled(boolean p_72371_1_)
@@ -1032,12 +1566,30 @@ @@ -1032,12 +1570,30 @@
public void removeAllPlayers() public void removeAllPlayers()
{ {

View File

@ -388,13 +388,7 @@
} }
} }
} }
@@ -469,12 +650,13 @@ @@ -474,7 +655,7 @@
{
this.pendingTickListEntriesHashSet.add(nextticklistentry);
this.pendingTickListEntriesTreeSet.add(nextticklistentry);
+ getChunkFromBlockCoords(p_147446_1_, p_147446_3_).blockUpdates.add(nextticklistentry); // KCauldron
}
}
public void updateEntities() public void updateEntities()
{ {
@ -403,7 +397,7 @@
{ {
if (this.updateEntityTick++ >= 1200) if (this.updateEntityTick++ >= 1200)
{ {
@@ -487,6 +669,7 @@ @@ -487,6 +668,7 @@
} }
super.updateEntities(); super.updateEntities();
@ -411,7 +405,7 @@
} }
public void resetUpdateEntityTick() public void resetUpdateEntityTick()
@@ -506,7 +689,16 @@ @@ -506,7 +688,16 @@
{ {
if (i > 1000) if (i > 1000)
{ {
@ -429,7 +423,7 @@
} }
this.theProfiler.startSection("cleaning"); this.theProfiler.startSection("cleaning");
@@ -523,6 +715,7 @@ @@ -523,6 +714,7 @@
this.pendingTickListEntriesTreeSet.remove(nextticklistentry); this.pendingTickListEntriesTreeSet.remove(nextticklistentry);
this.pendingTickListEntriesHashSet.remove(nextticklistentry); this.pendingTickListEntriesHashSet.remove(nextticklistentry);
@ -437,7 +431,7 @@
this.pendingTickListEntriesThisTick.add(nextticklistentry); this.pendingTickListEntriesThisTick.add(nextticklistentry);
} }
@@ -651,7 +844,37 @@ @@ -651,7 +843,37 @@
protected IChunkProvider createChunkProvider() protected IChunkProvider createChunkProvider()
{ {
IChunkLoader ichunkloader = this.saveHandler.getChunkLoader(this.provider); IChunkLoader ichunkloader = this.saveHandler.getChunkLoader(this.provider);
@ -476,7 +470,7 @@
return this.theChunkProviderServer; return this.theChunkProviderServer;
} }
@@ -659,29 +882,31 @@ @@ -659,29 +881,31 @@
{ {
ArrayList arraylist = new ArrayList(); ArrayList arraylist = new ArrayList();
@ -523,7 +517,7 @@
return arraylist; return arraylist;
} }
@@ -733,7 +958,28 @@ @@ -733,7 +957,28 @@
int i = 0; int i = 0;
int j = this.provider.getAverageGroundLevel(); int j = this.provider.getAverageGroundLevel();
int k = 0; int k = 0;
@ -552,7 +546,7 @@
if (chunkposition != null) if (chunkposition != null)
{ {
i = chunkposition.chunkPosX; i = chunkposition.chunkPosX;
@@ -876,6 +1122,20 @@ @@ -876,6 +1121,20 @@
public boolean addWeatherEffect(Entity p_72942_1_) public boolean addWeatherEffect(Entity p_72942_1_)
{ {
@ -573,7 +567,7 @@
if (super.addWeatherEffect(p_72942_1_)) if (super.addWeatherEffect(p_72942_1_))
{ {
this.mcServer.getConfigurationManager().sendToAllNear(p_72942_1_.posX, p_72942_1_.posY, p_72942_1_.posZ, 512.0D, this.provider.dimensionId, new S2CPacketSpawnGlobalEntity(p_72942_1_)); this.mcServer.getConfigurationManager().sendToAllNear(p_72942_1_.posX, p_72942_1_.posY, p_72942_1_.posZ, 512.0D, this.provider.dimensionId, new S2CPacketSpawnGlobalEntity(p_72942_1_));
@@ -894,13 +1154,23 @@ @@ -894,13 +1153,23 @@
public Explosion newExplosion(Entity p_72885_1_, double p_72885_2_, double p_72885_4_, double p_72885_6_, float p_72885_8_, boolean p_72885_9_, boolean p_72885_10_) public Explosion newExplosion(Entity p_72885_1_, double p_72885_2_, double p_72885_4_, double p_72885_6_, float p_72885_8_, boolean p_72885_9_, boolean p_72885_10_)
{ {
@ -598,7 +592,7 @@
if (!p_72885_10_) if (!p_72885_10_)
{ {
explosion.affectedBlockPositions.clear(); explosion.affectedBlockPositions.clear();
@@ -977,7 +1247,7 @@ @@ -977,7 +1246,7 @@
{ {
boolean flag = this.isRaining(); boolean flag = this.isRaining();
super.updateWeather(); super.updateWeather();
@ -607,7 +601,7 @@
if (this.prevRainingStrength != this.rainingStrength) if (this.prevRainingStrength != this.rainingStrength)
{ {
this.mcServer.getConfigurationManager().sendPacketToAllPlayersInDimension(new S2BPacketChangeGameState(7, this.rainingStrength), this.provider.dimensionId); this.mcServer.getConfigurationManager().sendPacketToAllPlayersInDimension(new S2BPacketChangeGameState(7, this.rainingStrength), this.provider.dimensionId);
@@ -988,10 +1258,6 @@ @@ -988,10 +1257,6 @@
this.mcServer.getConfigurationManager().sendPacketToAllPlayersInDimension(new S2BPacketChangeGameState(8, this.thunderingStrength), this.provider.dimensionId); this.mcServer.getConfigurationManager().sendPacketToAllPlayersInDimension(new S2BPacketChangeGameState(8, this.thunderingStrength), this.provider.dimensionId);
} }
@ -618,7 +612,7 @@
if (flag != this.isRaining()) if (flag != this.isRaining())
{ {
if (flag) if (flag)
@@ -1006,6 +1272,33 @@ @@ -1006,6 +1271,33 @@
this.mcServer.getConfigurationManager().sendPacketToAllPlayersInDimension(new S2BPacketChangeGameState(7, this.rainingStrength), this.provider.dimensionId); this.mcServer.getConfigurationManager().sendPacketToAllPlayersInDimension(new S2BPacketChangeGameState(7, this.rainingStrength), this.provider.dimensionId);
this.mcServer.getConfigurationManager().sendPacketToAllPlayersInDimension(new S2BPacketChangeGameState(8, this.thunderingStrength), this.provider.dimensionId); this.mcServer.getConfigurationManager().sendPacketToAllPlayersInDimension(new S2BPacketChangeGameState(8, this.thunderingStrength), this.provider.dimensionId);
} }
@ -652,7 +646,7 @@
} }
protected int func_152379_p() protected int func_152379_p()
@@ -1069,4 +1362,51 @@ @@ -1069,4 +1361,65 @@
this(); this();
} }
} }
@ -703,4 +697,18 @@
+ return this.getBlock(x, y, z); + return this.getBlock(x, y, z);
+ } + }
+ // CraftBukkit end + // CraftBukkit end
+
+ // KCauldron start
+ public NextTickListEntry allocateEntry(int x, int y, int z, Block block, int time, int priority)
+ {
+ NextTickListEntry nextticklistentry = new NextTickListEntry(x, y, z, block);
+ nextticklistentry.setPriority(priority);
+ if (block.getMaterial() != Material.air)
+ nextticklistentry.setScheduledTime((long)time + this.worldInfo.getWorldTotalTime());
+ if (!this.pendingTickListEntriesHashSet.contains(nextticklistentry)) {
+ this.pendingTickListEntriesHashSet.add(nextticklistentry);
+ this.pendingTickListEntriesTreeSet.add(nextticklistentry);
+ }
+ return nextticklistentry;
+ }
} }

View File

@ -227,7 +227,13 @@
if (p_75823_2_.hasKey("TileTicks", 9)) if (p_75823_2_.hasKey("TileTicks", 9))
{ {
NBTTagList nbttaglist3 = p_75823_2_.getTagList("TileTicks", 10); NBTTagList nbttaglist3 = p_75823_2_.getTagList("TileTicks", 10);
@@ -515,6 +568,7 @@ @@ -511,10 +564,12 @@
for (int j1 = 0; j1 < nbttaglist3.tagCount(); ++j1)
{
NBTTagCompound nbttagcompound5 = nbttaglist3.getCompoundTagAt(j1);
- p_75823_1_.func_147446_b(nbttagcompound5.getInteger("x"), nbttagcompound5.getInteger("y"), nbttagcompound5.getInteger("z"), Block.getBlockById(nbttagcompound5.getInteger("i")), nbttagcompound5.getInteger("t"), nbttagcompound5.getInteger("p"));
+ NextTickListEntry entry = ((net.minecraft.world.WorldServer) p_75823_1_).allocateEntry(nbttagcompound5.getInteger("x"), nbttagcompound5.getInteger("y"), nbttagcompound5.getInteger("z"), Block.getBlockById(nbttagcompound5.getInteger("i")), nbttagcompound5.getInteger("t"), nbttagcompound5.getInteger("p"));
+ chunk.blockUpdates.add(entry);
} }
} }
} }