Jump to content

Recommended Posts

Posted (edited)

Hello again!

 

I've been messing around with block properties.

I wanted to create a block with multiple properties so I've created a TileEntity for that block.

 

Code \/

  Reveal hidden contents

 

 

Everything compiles and runs ok, Even placing the block works, but whenever I F3 or destroy the block it crashes by throwing and IllegalArgumentException that It cannot set property.

 

What am I doing wrong here? I am new with tile entities so I am probably making some mistakes

 

 

 

 

 

 

Edited by ShowerManiac
Posted

The default state doesn't contain the FACING property.

 

  On 2/11/2018 at 12:02 PM, ShowerManiac said:

it crashes

Expand  

This time it was easy to discover the issue without logs. Next time, always post logs when you crash.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Posted (edited)

Now when I try to place a block it crashes.

 

Log

  Reveal hidden contents

 

Edited by ShowerManiac
Posted
  On 2/11/2018 at 1:22 PM, ShowerManiac said:

Caused by: java.lang.NullPointerException
    at com.test.tileentity.TileEntityTestBlock.writeToNBT(TileEntityTestBlock.java:60) ~[TileEntityTestBlock.class:?]

Expand  

One of the values used in writeToNBT is null.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Posted

How can it be null if the block has a default state?

 

I surrounded writeNBT with a try/catch block. Not a difference

 

crash log

  Reveal hidden contents

 

Posted (edited)
  On 2/11/2018 at 3:38 PM, ShowerManiac said:

How can it be null if the block has a default state?

Expand  

You need to add the FACING property to the container, eg:

https://github.com/Draco18s/ReasonableRealism/blob/master/src/main/java/com/draco18s/ores/block/BlockMillstone.java#L48-L51

https://github.com/Draco18s/ReasonableRealism/blob/master/src/main/java/com/draco18s/ores/block/BlockAxel.java#L60-L63

Edited by Draco18s

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted
  On 2/11/2018 at 5:06 PM, Draco18s said:
Expand  

there is 

protected BlockStateContainer createBlockState()
    {
        return new BlockStateContainer(this, new IProperty[] {VALUE, FACING, TYPE});
    }

 

Posted
  On 2/11/2018 at 12:02 PM, ShowerManiac said:

BlockContainer

Expand  

By the way, don't extend BlockContainer. It does nothing you want.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted (edited)
  On 2/11/2018 at 7:01 PM, Draco18s said:

By the way, don't extend BlockContainer. It does nothing you want.

Expand  

Okay. That actually was the problem. It works now.

 

One more question. Do I update/set the block state with regular 

world.setBlockState(pos, world.getBlockState(pos).withProperty(VALUE, Integer.valueOf(4)), 2);

Or do I do it somehow different? because this is happening (values should be the same as Val in the console)

Image

Edited by ShowerManiac
Posted

If your state is stored by the TE, you need to update the TE's value. SetBlockState only changes the metadata.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

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.