OpenBlocks

OpenBlocks

56M Downloads

SkyBlocks doesn't render properly with newest Little Tiles

em411 opened this issue ยท 11 comments

commented

Hi,
With the Inverted SkyBlocks are not longer working with Little Tiles pre163 and Creative Core 1.9.66 on Minecraft 1.12.2

When im not in direction of SkyBlocks it's looking normal
https://cdn.discordapp.com/attachments/276752435869908993/628555610736033802/unknown.png

When im looking on SkyBlocks
https://cdn.discordapp.com/attachments/276752435869908993/628555710879498270/unknown.png

Everything was working before this LittleTiles update.

commented

Yeah, I used to have all of my mods in the src folder of MDKExample, until watched a tutorial of another modder. I made all of my mods OpenSource and added them separately to the project (basically my current setup).

I don't know how to launch a core mod differently than to put a jar file in the mods folder (containing the meta-inf folder). That confuses a lot of people and it's also the reason for the video.

Besides that, I still haven't figured out how other modders do it? The problem is that there are no real tutorials for a multi-project setup. Furthermore I'm very bad at this stuff :( .

I got it working in 1.12.2, but in 1.14 I struggle really hard to set things up. If you have any good advise I would be happy to hear it.

commented

I'm not sure how to fix it (never severed the stencil bits before). I thought I could do:

int bit = MinecraftForgeClient.reserveStencilBit();

GL11.glDisable(GL11.GL_STENCIL_TEST);
GL11.glStencilMask(~0);
GL11.glClear(GL11.GL_STENCIL_BUFFER_BIT);

GL11.glStencilFunc(GL11.GL_ALWAYS, 0x1, 0x1);
GL11.glStencilOp(GL11.GL_REPLACE, GL11.GL_REPLACE, GL11.GL_REPLACE);

GlStateManager.pushMatrix();

GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
gui.renderControl(GuiRenderHelper.instance, 1F, GuiControl.getScreenRect());
GlStateManager.popMatrix();
			
MinecraftForgeClient.releaseStencilBit(bit);

but it doesn't fix anything.

commented

Use reserved bit to create mask (1 << bit) and then use it in both glStencilMask and glStencilFunc. Other uses of stencil buffers also need to be aligned.

Also, GL11.glStencilMask(~0); + GL11.glClear clears all bits other than 0, so I'm not sure what's the idea here.

Hacky solution: load your mod before OpenBlocks reserves its bit, reserve your own (will be 0) and keep using it. Of course it will be incompatible with any other mod that uses fixed bits.

commented

To be honest I don't really know how the system works. I call the clear method to make sure I get rid of set bits (not sure if this makes sense).

I use stencil for my gui to make sure nothing is rendered beyond a component. I need it for scrollbox for example. Never had issues with it before. If it's too complicated to fix I can also disable stencil for the overlay gui completely, as it is not really necessary (I don't need scrollboxes in an overlay).

commented

Problem is, in this setup you are clearing everything else than what was just drawn.

Anyway, if it's simple rectangular shape you can just go with glScissor, though getting to window coordinates this function needs is bit complicated.

commented

Yeah I tried to use scissor, but it's indeed very difficult to get the coordinates right, though not impossible. The biggest problem is that it doesn't supports rotations.

If I do not clear the bits, it would result in some weird rendering glitches, wouldn't it?

commented

Yes, you should clear, but your mask is ~0, which means all bits, including ones reserved by other mods. glStencilFunc uses 1 as both op and mask, so they are only one written (and later read), therefore mask should be also just 1.

If you don't want to propagate proper mask based on value returned from Forge to all other places, at least reserve bit 0 as early as possible, so OpenBlocks gets bit 1 or later.

commented

Alternatively, for OpenBlocks you can just make sure that stencil buffer is clear before tile entities render (here). I guess calling clear after GUI might work.

commented

Ok, I have tried several things, but to be honest I don't know how to do it.

My current setup:

// Beginning of rendering code
GL11.glStencilMask(~0);

// For each control
// Prepare
GL11.glClear(GL11.GL_STENCIL_BUFFER_BIT);
GL11.glStencilOp(GL11.GL_REPLACE, GL11.GL_REPLACE, GL11.GL_REPLACE);
GL11.glStencilFunc(GL11.GL_EQUAL, 0x1, 0x1);
GlStateManager.colorMask(false, false, false, false);
maximumRect.renderRect(helper, new Color(0, 0, 0, 255));
// Renders rectangle which covers the entire control, it's basically the mask for the stencil
GlStateManager.colorMask(true, true, true, true);

// Render
GL11.glEnable(GL11.GL_STENCIL_TEST);
GL11.glStencilOp(GL11.GL_KEEP, GL11.GL_KEEP, GL11.GL_KEEP);
GL11.glStencilFunc(GL11.GL_EQUAL, 0x1, 0x1);
render();
GL11.glDisable(GL11.GL_STENCIL_TEST);

This code obviously doesn't take care of bits by other mods. I tried to find a tutorial online (including opengl documentation) and looked at our code, but I couldn't figure out how to work with a certain bit and not the entire stencil buffer.

commented

Just tested and adding GL11.glClear(GL11.GL_STENCIL_BUFFER_BIT); after everything (as mentioned above) works.

Sidenote: would be great if you considered proper multi-project Gradle setup, just having Youtube video on how to setup it in Eclipse is quite... unusual.