CubicChunks

CubicChunks

840k Downloads

Render issue with LittleTiles

CreativeMD opened this issue ยท 6 comments

commented

Hey there,
i'm the author of LittleTiles and recently somebody an issue:

LittleTiles blocks don't render above 256 or below 0:

LittleTiles uses a rather hacky way to save performance. It hooks into the ChunkRenderDispatcher and adds the render data once minecraft uploads the buffer to the graphic card. Source.

Maybe we can figure out a solution together. How does CubicChunks render its chunks? Is there a way for me to hook in?

In Regards
CreativeMD

commented

CubicChunks renders chunks exactly the same way as vanilla Minecraft does. It's close enough that optifine required only one patch to get entity rendering working and everythinbg else worked fine.

After looking at the code, I belive this is the issue: https://github.com/CreativeMD/LittleTiles/blob/6a58ecc7506c3d29616fabbe62748372a8c67113/src/main/java/com/creativemd/littletiles/client/render/RenderUploader.java#L258-L308
specifically: https://github.com/CreativeMD/LittleTiles/blob/6a58ecc7506c3d29616fabbe62748372a8c67113/src/main/java/com/creativemd/littletiles/client/render/RenderUploader.java#L288

Cubic chunks modifies the way it's calculated:

@Inject(method = "getRenderChunk", at = @At(value = "HEAD"), cancellable = true, require = 1)
private void getRenderChunkInject(BlockPos pos, CallbackInfoReturnable<RenderChunk> cbi) {
if (!((ICubicWorld) world).isCubicWorld()) {
return;
}
// treat the y dimension the same as all the rest
int x = MathHelper.intFloorDiv(pos.getX(), Cube.SIZE);
int y = MathHelper.intFloorDiv(pos.getY(), Cube.SIZE);
int z = MathHelper.intFloorDiv(pos.getZ(), Cube.SIZE);
x %= this.countChunksX;
if (x < 0) {
x += this.countChunksX;
}
y %= this.countChunksY;
if (y < 0) {
y += this.countChunksY;
}
z %= this.countChunksZ;
if (z < 0) {
z += this.countChunksZ;
}
final int index = (z * this.countChunksY + y) * this.countChunksX + x;
RenderChunk renderChunk = this.renderChunks[index];
cbi.cancel();
cbi.setReturnValue(renderChunk);
}

You should be able to fix the issue by reflectively calling that viewfrustum method, instead of (stil half- reflectively) reimplementing it yourself

commented

Oh, the RenderUploader is inactive, it was just a test to modify the render data after it has been uploaded, but i threw away this idea.

commented

Well then I will have to look at the code again

commented

Or is it really inactive?

This method is used here, which is used:

  • here which is used in enough places that if it's all dead code, I'm going to seriously question the quality of your code
  • here, no idea what it's for
  • here, also no idea what it's for

That seems to be far from dead code

commented

Oh sorry ... i was not really paying attention to be honest. I will try to fix it. Thanks for all your help and again sorry :(

commented

Unfortunately things are not fixed, but it's better already.

So everything between 0 and 527 renders correctly. No idea why this is the case, but maybe you have an idea?

EDIT
Maybe because i was still using the old method ... i created a fix for it, but forgot to link to the new method.
Anyway it is fixed now! Thank you very very much for your help!!!