Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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.

  • Author

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.

  • Author

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

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

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.

  • Author

Well I found my mistake. The assignment Choonster is talking about is done while the game is loading. I was not checking for prints during the games loading time.

Thanks

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

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.