Fix chunk loading at one chunk render distance

This commit is contained in:
PeytonPlayz595 2024-04-16 19:16:08 -04:00
parent d19de81370
commit b88e61c52f
5 changed files with 32088 additions and 32079 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -190,6 +190,8 @@ public class RenderGlobal implements IWorldAccess, IResourceManagerReloadListene
private double prevRenderSortZ; private double prevRenderSortZ;
boolean displayListEntitiesDirty = true; boolean displayListEntitiesDirty = true;
private RenderEnv renderEnv = new RenderEnv(Blocks.air.getDefaultState(), new BlockPos(0, 0, 0)); private RenderEnv renderEnv = new RenderEnv(Blocks.air.getDefaultState(), new BlockPos(0, 0, 0));
private int renderDistance = 0;
private int renderDistanceSq = 0;
public RenderGlobal(Minecraft mcIn) { public RenderGlobal(Minecraft mcIn) {
this.mc = mcIn; this.mc = mcIn;
@ -411,6 +413,8 @@ public class RenderGlobal implements IWorldAccess, IResourceManagerReloadListene
} }
this.renderDistanceChunks = this.mc.gameSettings.renderDistanceChunks; this.renderDistanceChunks = this.mc.gameSettings.renderDistanceChunks;
this.renderDistance = this.renderDistanceChunks * 16;
this.renderDistanceSq = this.renderDistance * this.renderDistance;
if (this.viewFrustum != null) { if (this.viewFrustum != null) {
this.viewFrustum.deleteGlResources(); this.viewFrustum.deleteGlResources();
@ -1056,20 +1060,21 @@ public class RenderGlobal implements IWorldAccess, IResourceManagerReloadListene
} }
private RenderChunk func_181562_a(BlockPos p_181562_1_, RenderChunk p_181562_2_, EnumFacing p_181562_3_) { private RenderChunk func_181562_a(BlockPos p_181562_1_, RenderChunk p_181562_2_, EnumFacing p_181562_3_) {
BlockPos blockpos = p_181562_2_.func_181701_a(p_181562_3_); if(this.mc.gameSettings.renderDistanceChunks >= 2) { //Breaks at one chunk render distance...
BlockPos blockpos = p_181562_2_.getPositionOffset16(p_181562_3_);
if (blockpos.getY() >= 0 && blockpos.getY() < 256) { if (blockpos.getY() >= 0 && blockpos.getY() < 256) {
int i = MathHelper.abs_int(p_181562_1_.getX() - blockpos.getX()); int i = MathHelper.abs_int(p_181562_1_.getX() - blockpos.getX());
int j = MathHelper.abs_int(p_181562_1_.getZ() - blockpos.getZ()); int j = MathHelper.abs_int(p_181562_1_.getZ() - blockpos.getZ());
if (Config.isFogOff()) { if (Config.isFogOff()) {
if (i > this.renderDistanceChunks * 16 || j > this.renderDistanceChunks * 16) { if (i > this.renderDistance || j > this.renderDistance) {
return null; return null;
} }
} else { } else {
int k = i * i + j * j; int k = i * i + j * j;
if (k > ((this.renderDistanceChunks * 16) * (this.renderDistanceChunks * 16))) { if (k > this.renderDistanceSq) {
return null; return null;
} }
} }
@ -1078,6 +1083,10 @@ public class RenderGlobal implements IWorldAccess, IResourceManagerReloadListene
} else { } else {
return null; return null;
} }
} else {
BlockPos blockpos = p_181562_2_.getPositionOffset16(p_181562_3_);
return MathHelper .abs_int(p_181562_1_.getX() - blockpos.getX()) > this.renderDistanceChunks * 16 ? null : (blockpos.getY() >= 0 && blockpos.getY() < 256 ? (MathHelper.abs_int(p_181562_1_.getZ() - blockpos.getZ()) > this.renderDistanceChunks * 16 ? null : this.viewFrustum.getRenderChunk(blockpos)) : null);
}
} }
private void fixTerrainFrustum(double x, double y, double z) { private void fixTerrainFrustum(double x, double y, double z) {
@ -2709,7 +2718,7 @@ public class RenderGlobal implements IWorldAccess, IResourceManagerReloadListene
if (p_getRenderChunk_1_ == null) { if (p_getRenderChunk_1_ == null) {
return null; return null;
} else { } else {
BlockPos blockpos = p_getRenderChunk_1_.func_181701_a(p_getRenderChunk_2_); BlockPos blockpos = p_getRenderChunk_1_.getPositionOffset16(p_getRenderChunk_2_);
return this.viewFrustum.getRenderChunk(blockpos); return this.viewFrustum.getRenderChunk(blockpos);
} }
} }

View File

@ -73,7 +73,7 @@ public class RenderChunk {
public ShadowFrustumState shadowLOD0InFrustum = ShadowFrustumState.OUTSIDE; public ShadowFrustumState shadowLOD0InFrustum = ShadowFrustumState.OUTSIDE;
public ShadowFrustumState shadowLOD1InFrustum = ShadowFrustumState.OUTSIDE; public ShadowFrustumState shadowLOD1InFrustum = ShadowFrustumState.OUTSIDE;
public ShadowFrustumState shadowLOD2InFrustum = ShadowFrustumState.OUTSIDE; public ShadowFrustumState shadowLOD2InFrustum = ShadowFrustumState.OUTSIDE;
private EnumMap<EnumFacing, BlockPos> field_181702_p = Maps.newEnumMap(EnumFacing.class); private BlockPos[] positionOffsets16 = new BlockPos[EnumFacing.VALUES.length];
public RenderChunk(World worldIn, RenderGlobal renderGlobalIn, BlockPos blockPosIn, int indexIn) { public RenderChunk(World worldIn, RenderGlobal renderGlobalIn, BlockPos blockPosIn, int indexIn) {
this.world = worldIn; this.world = worldIn;
@ -98,13 +98,11 @@ public class RenderChunk {
this.stopCompileTask(); this.stopCompileTask();
this.position = pos; this.position = pos;
this.boundingBox = new AxisAlignedBB(pos, pos.add(16, 16, 16)); this.boundingBox = new AxisAlignedBB(pos, pos.add(16, 16, 16));
EnumFacing[] facings = EnumFacing._VALUES;
for (int i = 0; i < facings.length; ++i) {
this.field_181702_p.put(facings[i], pos.offset(facings[i], 16));
}
this.initModelviewMatrix(); this.initModelviewMatrix();
for (int i = 0; i < this.positionOffsets16.length; ++i) {
this.positionOffsets16[i] = null;
}
} }
public void resortTransparency(float x, float y, float z, ChunkCompileTaskGenerator generator) { public void resortTransparency(float x, float y, float z, ChunkCompileTaskGenerator generator) {
@ -321,7 +319,15 @@ public class RenderChunk {
return this.needsUpdate; return this.needsUpdate;
} }
public BlockPos func_181701_a(EnumFacing parEnumFacing) { public BlockPos getPositionOffset16(EnumFacing p_getPositionOffset16_1_) {
return (BlockPos) this.field_181702_p.get(parEnumFacing); int i = p_getPositionOffset16_1_.getIndex();
BlockPos blockpos = this.positionOffsets16[i];
if (blockpos == null) {
blockpos = this.getPosition().offset(p_getPositionOffset16_1_, 16);
this.positionOffsets16[i] = blockpos;
}
return blockpos;
} }
} }

View File

@ -585,12 +585,6 @@ public abstract class MinecraftServer implements Runnable, ICommandSender, IThre
public void startServerThread() { public void startServerThread() {
this.serverThread = new Thread(this, "Server thread"); this.serverThread = new Thread(this, "Server thread");
this.serverThread.start(); this.serverThread.start();
//Lmao ¯\_()_/¯
Thread.currentThread().setPriority(10);
//Possible TPS fix!?!?
this.serverThread.setPriority(10);
} }
/**+ /**+