Skip to content

Commit

Permalink
Backport fakeLevel updates
Browse files Browse the repository at this point in the history
Closes #688
  • Loading branch information
Nightenom committed Sep 29, 2024
1 parent 63ce1f3 commit a2614df
Show file tree
Hide file tree
Showing 5 changed files with 504 additions and 75 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,32 @@
import java.util.function.Supplier;

/**
* Fake level fake chunk :D all data related methods must redirect to fake level
* Updating procedure is same as fake leve
* Fake level fake chunk :D all data related methods must redirect to fake level Updating procedure is same as fakeLevel Porting info:
* <ol>
* <li>uncomment last method section</li>
* <li>fix compile errors</li>
* <li>add override for remaining methods and sort/implement them accordingly</li>
* <li>comment last method section</li>
* </ol>
* <p>
*/
public class FakeChunk extends LevelChunk
{
private final FakeLevel fakeLevel;

// section cache
int lastY;
LevelChunkSection lastSection = null;

public FakeChunk(final FakeLevel worldIn, final int x, final int z)
{
super(worldIn, new ChunkPos(x, z));
this.fakeLevel = worldIn;

// set itself to cache
fakeLevel.lastX = x;
fakeLevel.lastZ = z;
fakeLevel.lastChunk = this;
}

// ========================================
Expand Down Expand Up @@ -210,9 +225,20 @@ public boolean isYSpaceEmpty(int p_62075_, int p_62076_)
@Override
public LevelChunkSection[] getSections()
{
// don't cache them
return new LevelChunkSection[0];
}

@Override
public LevelChunkSection getSection(int yIdx)
{
if (lastY == yIdx && lastSection != null)
{
return lastSection;
}
return new FakeLevelChunkSection(this, yIdx);
}

// ========================================
// ============= NOOP METHODS =============
// ========================================
Expand Down
Loading

0 comments on commit a2614df

Please sign in to comment.