Jump to content

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


Recommended Posts

Posted

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.

Posted

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.

Posted

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.

Posted

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.

Posted

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.

Posted

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.

Posted

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.

Posted

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.

Posted

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.

Posted

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.

Posted

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.

Posted

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.

Posted

Glad I could help! Sorry about the confusion earlier, happy modding!

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.

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • When I first heard about Bitcoin back in 2018, I was skeptical. The idea of a decentralized, digital currency seemed too good to be true. But I was intrigued as I learned more about the technology behind it and its potential. I started small, investing just a few hundred dollars, dipping my toes into the cryptocurrency waters. At first, it was exhilarating to watch the value of my investment grow exponentially. I felt like I was part of the future, an early adopter of this revolutionary new asset. But that euphoria was short-lived. One day, I logged into my digital wallet only to find it empty - my Bitcoin had vanished without a trace. It turned out that the online exchange I had trusted had been hacked, and my funds were stolen. I was devastated, both financially and emotionally. All the potential I had seen in Bitcoin was tainted by the harsh reality that with decentralization came a lack of regulation and oversight. My hard-earned money was gone, lost to the ether of the digital world. This experience taught me a painful lesson about the price of trust in the uncharted territory of cryptocurrency. While the technology holds incredible promise, the risks can be catastrophic if you don't approach it with extreme caution. My Bitcoin investment gamble had failed, and I was left to pick up the pieces, wiser but poorer for having placed my faith in the wrong hands. My sincere appreciation goes to MUYERN TRUST HACKER. You are my hero in recovering my lost funds. Send a direct m a i l ( muyerntrusted ( @ ) mail-me ( . )c o m ) or message on whats app : + 1 ( 4-4-0 ) ( 3 -3 -5 ) ( 0-2-0-5 )
    • You could try posting a log (if there is no log at all, it may be the launcher you are using, the FAQ may have info on how to enable the log) as described in the FAQ, however this will probably need to be reported to/remedied by the mod author.
    • So me and a couple of friends are playing with a shitpost mod pack and one of the mods in the pack is corail tombstone and for some reason there is a problem with it, where on death to fire the player will get kicked out of the server and the tombstone will not spawn basically deleting an entire inventory, it doesn't matter what type of fire it is, whether it's from vanilla fire/lava, or from modded fire like ice&fire/lycanites and it's common enough to where everyone on the server has experienced at least once or twice and it doesn't give any crash log. a solution to this would be much appreciated thank you!
    • It is 1.12.2 - I have no idea if there is a 1.12 pack
  • Topics

×
×
  • Create New...

Important Information

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