Jump to content

Recommended Posts

Posted (edited)

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?

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

Posted
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.

Posted
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

 

Posted
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.

Posted
Just now, Animefan8888 said:

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

13 hours ago, Animefan8888 said:

(do an instanceof check it can be null).

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

 

Posted
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.

Posted (edited)
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

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.