From 01238b890a3f86dfa294c7859f8fdfadaa7936e7 Mon Sep 17 00:00:00 2001 From: Sergey Shatunov Date: Tue, 2 Feb 2016 15:39:23 +0700 Subject: [PATCH] Better handling of out of sync --- .../world/NextTickListEntry.java.patch | 2 +- .../minecraft/world/WorldServer.java.patch | 36 ++++++++++++++----- 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/patches/net/minecraft/world/NextTickListEntry.java.patch b/patches/net/minecraft/world/NextTickListEntry.java.patch index 4345393..1f3022f 100644 --- a/patches/net/minecraft/world/NextTickListEntry.java.patch +++ b/patches/net/minecraft/world/NextTickListEntry.java.patch @@ -5,7 +5,7 @@ public int hashCode() { - return (this.xCoord * 1024 * 1024 + this.zCoord * 1024 + this.yCoord) * 256; -+ return ((yCoord * 31 + xCoord) * 31 + zCoord) * 17 + yCoord; ++ return (((yCoord * 31 + xCoord) * 17 + zCoord) * 13 + yCoord) * 7 + Block.getIdFromBlock(field_151352_g); } public NextTickListEntry setScheduledTime(long p_77176_1_) diff --git a/patches/net/minecraft/world/WorldServer.java.patch b/patches/net/minecraft/world/WorldServer.java.patch index 964742d..d6c1d04 100644 --- a/patches/net/minecraft/world/WorldServer.java.patch +++ b/patches/net/minecraft/world/WorldServer.java.patch @@ -380,15 +380,34 @@ } public boolean isBlockTickScheduledThisTick(int p_147477_1_, int p_147477_2_, int p_147477_3_, Block p_147477_4_) -@@ -451,6 +631,7 @@ +@@ -447,10 +627,11 @@ + nextticklistentry.setPriority(p_147454_6_); + } + +- if (!this.pendingTickListEntriesHashSet.contains(nextticklistentry)) ++ if (this.pendingTickListEntriesHashSet.add(nextticklistentry)) { - this.pendingTickListEntriesHashSet.add(nextticklistentry); - this.pendingTickListEntriesTreeSet.add(nextticklistentry); -+ getChunkFromBlockCoords(p_147454_1_, p_147454_3_).blockUpdates.add(nextticklistentry); // KCauldron +- this.pendingTickListEntriesHashSet.add(nextticklistentry); +- this.pendingTickListEntriesTreeSet.add(nextticklistentry); ++ ++ if (!this.pendingTickListEntriesTreeSet.add(nextticklistentry)) pendingTickListEntriesHashSet.remove(nextticklistentry); else { ++ Chunk chunk = getChunkIfLoaded(p_147454_1_ >> 4, p_147454_3_ >> 4); if (chunk != null) chunk.blockUpdates.add(nextticklistentry); } // KCauldron } } } -@@ -474,7 +655,7 @@ +@@ -465,16 +646,16 @@ + nextticklistentry.setScheduledTime((long)p_147446_5_ + this.worldInfo.getWorldTotalTime()); + } + +- if (!this.pendingTickListEntriesHashSet.contains(nextticklistentry)) ++ if (this.pendingTickListEntriesHashSet.add(nextticklistentry)) + { +- this.pendingTickListEntriesHashSet.add(nextticklistentry); +- this.pendingTickListEntriesTreeSet.add(nextticklistentry); ++ if (!this.pendingTickListEntriesTreeSet.add(nextticklistentry)) pendingTickListEntriesHashSet.remove(nextticklistentry); else { ++ Chunk chunk = getChunkIfLoaded(p_147446_1_ >> 4, p_147446_3_ >> 4); if (chunk != null) chunk.blockUpdates.add(nextticklistentry); } + } + } public void updateEntities() { @@ -655,7 +674,7 @@ } protected int func_152379_p() -@@ -1069,4 +1361,65 @@ +@@ -1069,4 +1361,64 @@ this(); } } @@ -714,9 +733,8 @@ + 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); ++ if (this.pendingTickListEntriesHashSet.add(nextticklistentry)) { ++ if (!this.pendingTickListEntriesTreeSet.add(nextticklistentry)) pendingTickListEntriesHashSet.remove(nextticklistentry); + } + return nextticklistentry; + }