Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Non-Blockstate values in IBlockColor [1.15.1]


Jipthechip
 Share

Recommended Posts

27 minutes ago, Jipthechip said:

My BlockState became too complicated for the values I wanted to feed into my IBlockColor#getColor() implementation.

 

Is there any alternative to getting values from the BlockState, or will I have to use a TER/TESR?

I'm not sure if this still works, but you might be able to cast the ILightReader to a World(do an instanceof check it can be null). Then if it is use World::getTileEntity and store your colors in the TileEntity.

  • Like 1

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

6 hours ago, Animefan8888 said:

I'm not sure if this still works, but you might be able to cast the ILightReader to a World(do an instanceof check it can be null). Then if it is use World::getTileEntity and store your colors in the TileEntity.

No need for the cast, ILightReader extends IBlockReader, which has getTileEntity.

  • Like 1
Link to comment
Share on other sites

6 hours ago, diesieben07 said:

No need for the cast, ILightReader extends IBlockReader, which has getTileEntity.

Ah ok I didn't get that from the name, and didn't check either. Either way they still have to check for null.

  • Like 1

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

13 hours ago, Animefan8888 said:

I'm not sure if this still works, but you might be able to cast the ILightReader to a World(do an instanceof check it can be null). Then if it is use World::getTileEntity and store your colors in the TileEntity.

6 hours ago, diesieben07 said:

No need for the cast, ILightReader extends IBlockReader, which has getTileEntity.

 

Not casting it worked, but I tried casting it anyway just to see what would happen and it crashed. It gave the error:

java.lang.ClassCastException: net.minecraft.client.renderer.chunk.ChunkRenderCache cannot be cast to net.minecraft.world.World

 

Link to comment
Share on other sites

1 minute ago, Jipthechip said:

but I tried casting it anyway just to see what would happen and it crashed. It gave the error:

13 hours ago, Animefan8888 said:

(do an instanceof check

Also it can be null make sure it is not null before you use it.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

1 minute ago, Jipthechip said:

I did that, and it just ended up never getting to the code I wanted it to.

Which means I was wrong about it being a World instance when you need it to be.

13 hours ago, Animefan8888 said:

I'm not sure if this still works, but you might be able to cast the ILightReader to a World

 

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

1 hour ago, diesieben07 said:

Show your code.

My code was just this

assert lightReader != null;
assert pos != null;
if(lightReader instanceof World){
    // misc code never reached
}else{
    return MaterialColor.WATER.colorValue;
}

Like I said, not casting the ILightReader worked just fine. I was just curious if it could be cast to a World, and it doesn't seem like it can.

Edited by Jipthechip
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
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.

 Share



×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.