Jump to content

[Solved][1.8] b1543 - breaking a block with IProperty causes crash


Recommended Posts

Posted

Crash Report: http://pastebin.com/b4ArCdj6

 

Source: https://github.com/kreezxil/Compressed-Blocks-by-Kreezxil

 

Source folder where errors appear when the PropertyInt is referenced when a block is broken (harvested): https://github.com/kreezxil/Compressed-Blocks-by-Kreezxil/tree/master/src/main/java/com/kreezxil/compressedblocks/blocks

 

I've been working on a Compressed Blocks mod for 1.8 that uses Forge B1543. Recently at the advisement of another modder I reduced my code complexity by using blockstates. The blocks are supposed to have a PropertyInteger called TIER that helps the block class determine which blocktype is to be dropped when a block is harvested.

 

I have my mod setup to return the compressed block that is one tier below the block being harvested.

 

The error it says in short is:

java.lang.IllegalArgumentException: Cannot get property PropertyInteger{name=tier, clazz=class java.lang.Integer, values=[0, 1, 2, 3, 4, 5, 6, 7]} as it does not exist in BlockState{block=minecraft:air, properties=[]}

 

It must be noted that I didn't actually add the property to my classes, The_Fireplace was the one that suggested I go with blockstates, and for the one block that he recoded as an example, the PropertingInteger line was in there, and I migrated it to my other block classes. That line being:

 

		int tier = ((Integer) world.getBlockState(pos).getValue(TIER))
			.intValue();

 

He says he is stumped by the error and suggested that I post it here to get some insight as to what the solution should be.

 

Notes:

I am noob when it comes to Java.

I can follow directions, most of my code structure is based on _Bedrock_Miner_'s tutorials.

I am definitely a noob when comes to most things Forge or Minecraft in regards to coding.

If there is a better structure or format for some of what I have done, suggest it, I'll implement it.

 

Thanks for any and all help.

 

- Kreezxil

Posted

It's caused because the blockstate is not always that of the block whose method was called, even though it should be.

 

In my particular case, I was handling explosion resistance; for some reason vanilla adds the entity's eyeHeight:

public float getExplosionResistance(Explosion explosionIn, World worldIn, BlockPos pos, IBlockState blockStateIn)
    {
        return blockStateIn.getBlock().getExplosionResistance(worldIn, pos.add(0, getEyeHeight(), 0), this, explosionIn);
    }

0.o Very weird.

 

Anyway, the trick is to make sure the blockstate is actually for your block before trying to access any of your custom properties:

IBlockState state = world.getBlockState(pos);
if (state.getBlock() != this) {
  return;
}
// safe to access your custom properties now

Posted

Wow, that well.. a dumb bug. Kreezxil's issue is that Blood's initial patch in that area did not sync up client and server. So the server is calling item.onBlockDestoyed after the Block.onBlockDestroyed, and the server is calling it before. So fixed that.

Also, I have no idea where that eyeheight came from. So fixed that up as well. Next build incoming with those changes.

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

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.

×
×
  • Create New...

Important Information

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