Jump to content

[Solved] [1.8.9] Custom slabs have incorrect lighting in world


Choonster

Recommended Posts

I've added some slabs that use the Stained Clay textures, but the half slabs are rendering completely black in the half they don't occupy (screenshot). The item models are fine.

 

Code:

[url=https://github.com/Choonster/TestMod3/blob/b21d2b20d006af0741ec94823f3675af44f1d068/src/main/java/com/choonster/testmod3/block/BlockColouredSlab.java]BlockColouredSlab[/url]

,

[url=https://github.com/Choonster/TestMod3/blob/b21d2b20d006af0741ec94823f3675af44f1d068/src/main/java/com/choonster/testmod3/block/BlockSlabTestMod3.java]BlockSlabTestMod3[/url]

Blockstates files: first colour group, second colour group

 

I've looked at the vanilla slab classes and it seems that

BlockSlab

determines whether the block is a full/opaque cube based on

BlockSlab#isDouble

and whether each side should be rendered based on the

HALF

property's value, so my slabs should render correctly without having to specify that.

 

Am I doing something wrong or missing something obvious?

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

Sounds like lighting is failing on opacity. Therefore, your face may be "rendered" but not illuminated.

Is the dark face always the "interior" face (halfway plane of the cube)? -- Interesting screenshot. Light is not getting into the empty part of the cube.

 

It could be tricky to fix because slabs themselves had a lighting bug for a while (the underside of a half-slab being as dark as the top face even if there was a light source right under it). There was a "fix" sometime between 1.8 and 1.8.8 that I haven't read yet. If you can find what changed, then you might find the problem.

 

Do vanilla slabs act differently? I wish I could be more help, but the more I think on it, the more it looks like something new and not a form of the bug I had seen before.

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

Link to comment
Share on other sites

I tried to trace the appearance and use of "isDouble", but I got lost. There's a constructor for BlockColouredSlab that takes an isDouble parameter but does not seem to use it. You might need to break out the debugger to see what is being returned from calls to isDouble() methods at various stages.

 

In what Vanilla code I can see (1.8 ), half stone slab and half wood slab (and the full slabs) are each a simple extension of BlockSlab. Yours is not so simple (seemingly combining all possibilities into one extension of BlockSlab), so there might be a timing problem during initialization. Set a breakpoint on the instantiation of a problem variant and trace its construction & initialization.

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

Link to comment
Share on other sites

Add this to your block class:

public EnumWorldBlockLayer getBlockLayer() {
return EnumWorldBlockLayer.TRANSLUCENT;
}

 

There are three of these Enums: SOLID, TRANSLUCENT, CUTOUT. (There is also CUTOUT_MIPPED, but I am not sure how that one works).

 

SOLID means the block has no transparency. TRANSLUCENT means the block is semi-transparent (stained glass, ice). And, CUTOUT means fully transparent (regular glass). This is all I needed to make my block see through (my block contains regular glass, so I use CUTOUT). Just don't forget this:

 

public boolean isOpaqueCube() {
return false;
}

 

This simply means the block is transparent. :P Block#getRenderType is required for slabs I believe, but you need that too when using the boolean above. Hope I helped!

I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.

Link to comment
Share on other sites

I tried to trace the appearance and use of "isDouble", but I got lost. There's a constructor for BlockColouredSlab that takes an isDouble parameter but does not seem to use it. You might need to break out the debugger to see what is being returned from calls to isDouble() methods at various stages.

 

In what Vanilla code I can see (1.8 ), half stone slab and half wood slab (and the full slabs) are each a simple extension of BlockSlab. Yours is not so simple (seemingly combining all possibilities into one extension of BlockSlab), so there might be a timing problem during initialization. Set a breakpoint on the instantiation of a problem variant and trace its construction & initialization.

 

I override

BlockSlab#isDouble

in an anonymous class created in

BlockColouredSlab.ColouredSlabGroup#createGroup

(this is the actual class used by my slabs, the others are abstract). The

isDouble

constructor argument was a leftover from my earlier attempts, I've removed it now.

 

Vanilla slabs are rendering without issue, it's only my slabs that have the lighting problem.

 

Add this to your block class:

...

 

I'm aware of block layers, but they're not the issue here. None of the vanilla slabs override

Block#getBlockLayer

and overriding that method does nothing to fix the problem regardless of which layer I return.

 

BlockSlab

overrides

Block#isOpaqueCube

to return the result of

BlockSlab#isDouble

, which I already override to return the appropriate value.

 

Block#getRenderType

only needs to be overridden if you want to use a different renderer to the parent class, which I don't. Both Vanilla slabs and my ones use the baked model system (blockstates file + models).

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

Well, I got my transparent block to work be returning CUTOUT, and a render type of 3. It's worth a try, even if you do not see it in vanilla classes.

I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.

Link to comment
Share on other sites

Well, I got my transparent block to work be returning CUTOUT, and a render type of 3. It's worth a try, even if you do not see it in vanilla classes.

 

My slabs aren't transparent, they use solid textures on a model that doesn't occupy the whole block. I did try returning each layer from

Block#getBlockLayer

, but nothing changed.

 

Block#getRenderType

already returns 3 and neither

BlockSlab

or my slab classes override it.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

Oh my God! I thought you were attempting to make Stained Glass slabs, not Stained Clay. :P Sorry on my part! Hm, have you tried setting your textures in your json manually? (instead of doing all, do north, south, east, west, up, and down). A little tip: you can add a line of code like this to your json file in order to call textures with ease:

"textures": {
        "particle": "texture path for particle",
        "0": "texture path 0",
        "1": "texture path 1",
        "2": "texture path 2",
        "3": "etc"
    }

 

Then, you just call it as "#[texture number]" (in quotations, if you didn't already know). It could perhaps be a UV error, but this is unlikely.

I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.

Link to comment
Share on other sites

Oh my God! I thought you were attempting to make Stained Glass slabs, not Stained Clay. :P Sorry on my part!

Haha, no worries.

 

Hm, have you tried setting your textures in your json manually? (instead of doing all, do north, south, east, west, up, and down). A little tip: you can add a line of code like this to your json file in order to call textures with ease:

"textures": {
        "particle": "texture path for particle",
        "0": "texture path 0",
        "1": "texture path 1",
        "2": "texture path 2",
        "3": "etc"
    }

 

Then, you just call it as "#[texture number]" (in quotations, if you didn't already know). It could perhaps be a UV error, but this is unlikely.

 

I tried manually specifying the

up

,

down

and

side

textures (the textures used by the slab models) but nothing changed. I also tried using the vanilla blockstates format with a vanilla model and the issue persisted, so I suspect it's something to do with the

Block

rather than the model.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

I was looking at some posts with similar issues, and they all said doing "this.useNeighborBrightness(true)" fixes the rendering issues. Haven't tested it, so I'm not sure. But it's worth a shot. :P

I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.

Link to comment
Share on other sites

There is a really nice tutorial I found here. They only use the neighboring block's brightness if it is not double, so that slightly confirms it will work. Also, they seem to setup their model file WAY differently than yours. Give it a look, and see if it helps!

I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.

Link to comment
Share on other sites

I was looking at some posts with similar issues, and they all said doing "this.useNeighborBrightness(true)" fixes the rendering issues. Haven't tested it, so I'm not sure. But it's worth a shot. :P

 

Thanks, that was indeed the issue. Vanilla sets this for its own slabs, but this is done in

Block.registerBlocks

before mods are loaded. You'd think it would do this in the constructor of the appropriate classes.

 

My slabs now render properly.

 

Edit: You can see the working code here: BlockSlabTestMod3, BlockColouredSlab

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.