Jump to content

[1.8] Block State mysteriously resetting


Busti

Recommended Posts

Some of you should have already noticed that I'm struggeling with 1.8's new .json based Block State system. While updating my Rubbertree i've stumbled upon this weird issue.

When initially placing the Block its state is determined by the way it was placed to give it the correct direction. When printing its state when its placed this comes out to be correct. But right after placement the block the state is being set to be none causing the block to display incorrectly.

 

Here is the torn down log class im using. This is literally me trying to set the state correctly.

class BlockRubbertreeLog(id:String) extends BlockLog {
  GameRegistry.registerBlock(this, id)
  setUnlocalizedName(id)
  setCreativeTab(Technica.tabTechnica)

  //val STATE:PropertyEnum = PropertyEnum

  setDefaultState(blockState.getBaseState.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.Y))


  override def onBlockPlaced(worldIn: World, pos: BlockPos, facing: EnumFacing, hitX: Float, hitY: Float, hitZ: Float, meta: Int, placer: EntityLivingBase): IBlockState = {
    super.onBlockPlaced(worldIn, pos, facing, hitX, hitY, hitZ, meta, placer)
  }

  override def onBlockActivated(worldIn: World, pos: BlockPos, state: IBlockState, playerIn: EntityPlayer, side: EnumFacing, hitX: Float, hitY: Float, hitZ: Float): Boolean = {
    println(state)
    super.onBlockActivated(worldIn, pos, state, playerIn, side, hitX, hitY, hitZ)
  }

  override def createBlockState(): BlockState = new BlockState(this, BlockLog.LOG_AXIS)

  override def getStateFromMeta(meta: Int): IBlockState = getDefaultState

  override def getMetaFromState(state: IBlockState): Int = 0
}

 

Using breakpoints I found out that the issue lies somewhere in Chunk.class.setBlockState()

But I couldn't see what caused it.

PM's regarding modding questions should belong in the Modder Support sub-forum and won't be answered.

Link to comment
Share on other sites

Since I return the default state in getStateFromMeta which I set to hold the Y property shouldn't it return the correct State (just causing the block do display correctly. Im not aiming for any functionality here)

PM's regarding modding questions should belong in the Modder Support sub-forum and won't be answered.

Link to comment
Share on other sites

Also neither getStateFromMeta nor getMetaFromState get called during the placement of the block. I guess they are just used for information storage nowadays.

 

Each possible state of a

Block

is assigned an ID based on the

Block

's ID (automatically assigned) and the metadata value of that state (returned from

Block#getMetaFromState

). These IDs are used by

ExtendedBlockStorage

to store the contents of each chunk.

 

If two states share a metadata value,

ExtendedBlockStorage

won't distinguish between them.

 

If you want a property's value to be saved with the world, you need to store it in the metadata (just like 1.7.10 and earlier).

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

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