Skip to content

Commit a5a11b1

Browse files
committed
method for working fawe (fast async world edit)
1 parent 1821e2f commit a5a11b1

1 file changed

Lines changed: 72 additions & 15 deletions

File tree

patches/minecraft/net/minecraft/world/gen/ChunkProviderServer.java.patch

Lines changed: 72 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161

6262
if (chunk != null)
6363
{
64-
@@ -79,33 +85,66 @@
64+
@@ -79,33 +85,76 @@
6565
return chunk;
6666
}
6767

@@ -124,6 +124,16 @@
124124
}
125125

126126
- @Override
127+
+ // FAWE fix start
128+
+ public Chunk getChunkAt(int i, int j, Runnable runnable) {
129+
+ return provideChunk(i, j, runnable);
130+
+ }
131+
+
132+
+ public Chunk getChunkAt(int x, int z, Runnable runnable, boolean generate) {
133+
+ return provideChunk(x, z, runnable, generate);
134+
+ }
135+
+ // FAWE fix end
136+
+
127137
public Chunk func_186025_d(int p_186025_1_, int p_186025_2_)
128138
{
129139
Chunk chunk = this.func_186028_c(p_186025_1_, p_186025_2_);
@@ -134,25 +144,72 @@
134144
long i = ChunkPos.func_77272_a(p_186025_1_, p_186025_2_);
135145

136146
try
137-
@@ -117,14 +156,15 @@
147+
@@ -117,18 +166,52 @@
138148
CrashReport crashreport = CrashReport.func_85055_a(throwable, "Exception generating new chunk");
139149
CrashReportCategory crashreportcategory = crashreport.func_85058_a("Chunk to be generated");
140150
crashreportcategory.func_71507_a("Location", String.format("%d,%d", p_186025_1_, p_186025_2_));
141151
- crashreportcategory.func_71507_a("Position hash", i);
142-
+ crashreportcategory.func_71507_a("Position hash", Long.valueOf(i));
143-
crashreportcategory.func_71507_a("Generator", this.field_186029_c);
144-
throw new ReportedException(crashreport);
145-
}
146-
147-
this.field_73244_f.put(i, chunk);
148-
chunk.func_76631_c();
152+
- crashreportcategory.func_71507_a("Generator", this.field_186029_c);
153+
- throw new ReportedException(crashreport);
154+
- }
155+
-
156+
- this.field_73244_f.put(i, chunk);
157+
- chunk.func_76631_c();
149158
- chunk.func_186030_a(this, this.field_186029_c);
159+
- }
160+
-
161+
- return chunk;
162+
- }
163+
+ crashreportcategory.func_71507_a("Position hash", Long.valueOf(i));
164+
+ crashreportcategory.func_71507_a("Generator", this.field_186029_c);
165+
+ throw new ReportedException(crashreport);
166+
+ }
167+
+
168+
+ this.field_73244_f.put(i, chunk);
169+
+ chunk.func_76631_c();
150170
+ chunk.populateCB(this, this.field_186029_c, true);
151171
+ field_73251_h.timings.syncChunkLoadTimer.stopTiming(); // Spigot
152-
}
172+
+ }
173+
+
174+
+ return chunk;
175+
+ }
176+
+
177+
+ // CatServer start
178+
+ public Chunk provideChunk(int x, int z, Runnable runnable) {
179+
+ return provideChunk(x, z, runnable, true);
180+
+ }
181+
+
182+
+ public Chunk provideChunk(int x, int z, Runnable runnable, boolean generate) {
183+
+ Chunk chunk = this.loadChunk(x, z, runnable);
184+
+
185+
+ if (chunk == null && generate) {
186+
+ field_73251_h.timings.syncChunkLoadTimer.startTiming(); // Spigot
187+
+ long i = ChunkPos.func_77272_a(x, z);
188+
+
189+
+ try {
190+
+ chunk = this.field_186029_c.func_185932_a(x, z);
191+
+ } catch (Throwable throwable) {
192+
+ CrashReport crashreport = CrashReport.func_85055_a(throwable, "Exception generating new chunk");
193+
+ CrashReportCategory crashreportcategory = crashreport.func_85058_a("Chunk to be generated");
194+
+ crashreportcategory.func_71507_a("Location", String.format("%d,%d", x, z));
195+
+ crashreportcategory.func_71507_a("Position hash", Long.valueOf(i));
196+
+ crashreportcategory.func_71507_a("Generator", this.field_186029_c);
197+
+ throw new ReportedException(crashreport);
198+
+ }
199+
+
200+
+ this.field_73244_f.put(i, chunk);
201+
+ chunk.func_76631_c();
202+
+ chunk.populateCB(this, this.field_186029_c, true);
203+
+ field_73251_h.timings.syncChunkLoadTimer.stopTiming(); // Spigot
204+
+ }
205+
+
206+
+ return chunk;
207+
+ }
208+
+ // CatServer end
153209

154-
return chunk;
155-
@@ -199,8 +239,9 @@
210+
@Nullable
211+
private Chunk func_73239_e(int p_73239_1_, int p_73239_2_)
212+
@@ -199,8 +282,9 @@
156213
{
157214
this.func_73242_b(chunk);
158215
chunk.func_177427_f(false);
@@ -163,7 +220,7 @@
163220
{
164221
return false;
165222
}
166-
@@ -215,30 +256,51 @@
223+
@@ -215,30 +299,51 @@
167224
this.field_73247_e.func_75818_b();
168225
}
169226

@@ -223,7 +280,7 @@
223280

224281
this.field_73247_e.func_75817_a();
225282
}
226-
@@ -246,12 +308,44 @@
283+
@@ -246,12 +351,44 @@
227284
return false;
228285
}
229286

@@ -269,7 +326,7 @@
269326
public String func_73148_d()
270327
{
271328
return "ServerChunkCache: " + this.field_73244_f.size() + " Drop: " + this.field_73248_b.size();
272-
@@ -283,7 +377,6 @@
329+
@@ -283,7 +420,6 @@
273330
return this.field_73244_f.containsKey(ChunkPos.func_77272_a(p_73149_1_, p_73149_2_));
274331
}
275332

0 commit comments

Comments
 (0)