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
  On 4/20/2020 at 12:52 AM, 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?

Expand  

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
  On 4/20/2020 at 7:47 AM, diesieben07 said:

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

Expand  

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
  On 4/20/2020 at 1:24 AM, 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.

Expand  
  On 4/20/2020 at 7:47 AM, diesieben07 said:

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

Expand  

 

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
  On 4/20/2020 at 2:50 PM, Jipthechip said:

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

Expand  
  On 4/20/2020 at 1:24 AM, Animefan8888 said:

(do an instanceof check

Expand  

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
  On 4/20/2020 at 2:56 PM, Jipthechip said:

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

Expand  

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

  On 4/20/2020 at 1:24 AM, Animefan8888 said:

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

Expand  

 

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)
  On 4/20/2020 at 2:59 PM, diesieben07 said:

Show your code.

Expand  

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.