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

Greetings! It's been a while since I've asked a question here.

 

I was wondering if it's necessary to save the metadata in the NBT data of the TileEntity of a block.

 

BlockFurnace does not do that, yet it managas to save the direction it's facing.

 

I took a look at the Transposer from Redpower, it uses NBT. (link to redpower TileMachine)

 

This is my current code:

 

 

 

public class BlockItemRelay extends BlockSingularityBlock{

 

public static final String NAME = "ItemRelay";

 

private IIcon topIcon,bottomIcon,sideIcon;

 

public BlockItemRelay() {

super();

setBlockName(NAME);

setBlockTextureName(Singularity.MODID + ":" + NAME);

}

 

@Override

public TileEntity createNewTileEntity(World world, int meta) {

return new TileEntityItemRelay();

}

 

@Override

public void registerBlockIcons(IIconRegister register) {

topIcon=register.registerIcon(getTextureName()+"_top");

bottomIcon=register.registerIcon(getTextureName()+"_bottom");

sideIcon=register.registerIcon(getTextureName()+"_side");

}

 

@Override

        public IIcon getIcon(int side, int meta){

                if(meta==side) return bottomIcon;

                if(meta/2==side/2) return topIcon;

                return sideIcon;

        }

 

@Override

public void onBlockPlacedBy(World world, int x,int y, int z, EntityLivingBase entity,ItemStack stack){

super.onBlockPlacedBy(world,x,y,z,entity,stack);

world.setBlockMetadataWithNotify(x,y,z,Utils.getMetaFromDirection(entity.rotationYaw,entity.rotationPitch),1);

}

}

 

 

 

The metadata returned from Utils.getMetaFromDirection(yaw,pitch) is correct, and I added a line to the TileEntity of this block that prints the metadata of the block. It has the correct value.

 

Now, when I exit the world and enter again, it prints -1. What. Am I really supposed to use NBT data here? I thought metadata was something saved automatically?

 

Thanks in advance,

Pancake

Yes, metadata is saved automatically. But what Eloraam has done there is not metadata, but rather just a simple field in TileMachine that has to be saved to NBT. The vanilla furnace does use metadata to store it's rotation.

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/

  • Author

I just figured it out!

 

I was using the TileEntity's blockMetadata. It said -1, but worldObj.getBlockMetadata(xCoord,yCoord,zCoord) gave me the correct metadata.

 

I know I have to use the getBlockMetadata method now, which initialises the blockMetadata if it's -1. My bad! :3

 

It's weird that that field isn't initialised from the start though.

 

[sOLVED]

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.