@@ -131,7 +131,11 @@ public void resortTransparency(float x, float y, float z, ChunkCompileTaskGenera
131131 }
132132
133133 public void rebuildChunk (float x , float y , float z , ChunkCompileTaskGenerator generator ) {
134- CompiledChunk compiledchunk = new CompiledChunk ();
134+ if (compiledChunk == CompiledChunk .DUMMY ) {
135+ compiledChunk = new CompiledChunk (this );
136+ } else {
137+ compiledChunk .reset ();
138+ }
135139 boolean flag = true ;
136140 BlockPos blockpos = this .position ;
137141 BlockPos blockpos1 = blockpos .add (15 , 15 , 15 );
@@ -142,7 +146,7 @@ public void rebuildChunk(float x, float y, float z, ChunkCompileTaskGenerator ge
142146 }
143147
144148 regionrendercache = new RegionRenderCache (this .world , blockpos .add (-1 , -1 , -1 ), blockpos1 .add (1 , 1 , 1 ), 1 );
145- generator .setCompiledChunk (compiledchunk );
149+ generator .setCompiledChunk (compiledChunk );
146150
147151 VisGraph visgraph = new VisGraph ();
148152 HashSet hashset = Sets .newHashSet ();
@@ -163,7 +167,7 @@ public void rebuildChunk(float x, float y, float z, ChunkCompileTaskGenerator ge
163167 TileEntitySpecialRenderer tileentityspecialrenderer = TileEntityRendererDispatcher .instance
164168 .getSpecialRenderer (tileentity );
165169 if (tileentity != null && tileentityspecialrenderer != null ) {
166- compiledchunk .addTileEntity (tileentity );
170+ compiledChunk .addTileEntity (tileentity );
167171 if (tileentityspecialrenderer .func_181055_a ()) {
168172 hashset .add (tileentity );
169173 }
@@ -174,8 +178,8 @@ public void rebuildChunk(float x, float y, float z, ChunkCompileTaskGenerator ge
174178 int i = enumworldblocklayer1 .ordinal ();
175179 if (block .getRenderType () != -1 ) {
176180 WorldRenderer worldrenderer = generator .getRegionRenderCacheBuilder ().getWorldRendererByLayerId (i );
177- if (!compiledchunk .isLayerStarted (enumworldblocklayer1 )) {
178- compiledchunk .setLayerStarted (enumworldblocklayer1 );
181+ if (!compiledChunk .isLayerStarted (enumworldblocklayer1 )) {
182+ compiledChunk .setLayerStarted (enumworldblocklayer1 );
179183 this .preRenderBlocks (worldrenderer , blockpos );
180184 }
181185
@@ -186,8 +190,8 @@ public void rebuildChunk(float x, float y, float z, ChunkCompileTaskGenerator ge
186190 enumworldblocklayer1 = EnumWorldBlockLayer .GLASS_HIGHLIGHTS ;
187191 worldrenderer = generator .getRegionRenderCacheBuilder ()
188192 .getWorldRendererByLayerId (enumworldblocklayer1 .ordinal ());
189- if (!compiledchunk .isLayerStarted (enumworldblocklayer1 )) {
190- compiledchunk .setLayerStarted (enumworldblocklayer1 );
193+ if (!compiledChunk .isLayerStarted (enumworldblocklayer1 )) {
194+ compiledChunk .setLayerStarted (enumworldblocklayer1 );
191195 this .preRenderBlocks (worldrenderer , blockpos );
192196 }
193197
@@ -201,18 +205,18 @@ public void rebuildChunk(float x, float y, float z, ChunkCompileTaskGenerator ge
201205 for (int i = 0 ; i < layers .length ; ++i ) {
202206 EnumWorldBlockLayer enumworldblocklayer = layers [i ];
203207 if (aboolean [enumworldblocklayer .ordinal ()]) {
204- compiledchunk .setLayerUsed (enumworldblocklayer );
208+ compiledChunk .setLayerUsed (enumworldblocklayer );
205209 }
206210
207- if (compiledchunk .isLayerStarted (enumworldblocklayer )) {
211+ if (compiledChunk .isLayerStarted (enumworldblocklayer )) {
208212 this .postRenderBlocks (enumworldblocklayer , x , y , z ,
209213 generator .getRegionRenderCacheBuilder ().getWorldRendererByLayer (enumworldblocklayer ),
210- compiledchunk );
214+ compiledChunk );
211215 }
212216 }
213217 }
214218
215- compiledchunk .setVisibility (visgraph .computeVisibility ());
219+ compiledChunk .setVisibility (visgraph .computeVisibility ());
216220
217221 HashSet hashset1 = Sets .newHashSet (hashset );
218222 HashSet hashset2 = Sets .newHashSet (this .field_181056_j );
@@ -287,13 +291,13 @@ public CompiledChunk getCompiledChunk() {
287291 return this .compiledChunk ;
288292 }
289293
290- public void setCompiledChunk (CompiledChunk compiledChunkIn ) {
291- this .compiledChunk = compiledChunkIn ;
292- }
293-
294294 public void stopCompileTask () {
295295 this .finishCompileTask ();
296- this .compiledChunk = CompiledChunk .DUMMY ;
296+ if (this .compiledChunk != CompiledChunk .DUMMY ) {
297+ this .compiledChunk .setState (null );
298+ this .compiledChunk .setStateRealisticWater (null );
299+ this .compiledChunk = CompiledChunk .DUMMY ;
300+ }
297301 }
298302
299303 public void deleteGlResources () {
0 commit comments