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

Hi,

I'm currently working on a block that stores it's orientation in a TileEntity (metadata hs not enough states). This is quite simple, I have two enum fields that store the orientation and save those with NBT.

public class TileEntityCablecarTrack extends TileEntity {
    private EnumFacingExtended first_end = EnumFacingExtended.NORTH;
    private EnumFacingExtended second_end = EnumFacingExtended.SOUTH;

    @Override
    public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
        nbt.setInteger("first_end", first_end.getID());
        nbt.setInteger("second_end", second_end.getID());
        System.out.println("Serialize first_end: " + first_end + " second_end: " + second_end);
        return super.writeToNBT(nbt);
    }

    @Override
    public void readFromNBT(NBTTagCompound nbt) {
        super.readFromNBT(nbt);
        this.first_end = EnumFacingExtended.fromID(nbt.getInteger("first_end"));
        this.second_end = EnumFacingExtended.fromID(nbt.getInteger("second_end"));
        System.out.println("Deserialize first_end: " + first_end + " second_end: " + second_end);
    }
}

But this does not work for the client on load:
 

[14:26:04] [Server thread/INFO] [STDOUT]: [techmod.cablecar.TileEntityCablecarTrack:readFromNBT:23]: Deserialize first_end: EAST second_end: WEST
[14:26:04] [Server thread/INFO] [STDOUT]: [techmod.cablecar.TileEntityCablecarTrack:readFromNBT:23]: Deserialize first_end: EAST second_end: WEST
[14:26:04] [Server thread/INFO] [STDOUT]: [techmod.cablecar.TileEntityCablecarTrack:readFromNBT:23]: Deserialize first_end: NORTH second_end: SOUTH
[14:26:04] [Server thread/INFO] [STDOUT]: [techmod.cablecar.TileEntityCablecarTrack:readFromNBT:23]: Deserialize first_end: EAST second_end: WEST
[14:26:04] [Server thread/INFO] [STDOUT]: [techmod.cablecar.TileEntityCablecarTrack:readFromNBT:23]: Deserialize first_end: NORTH second_end: SOUTH
[14:26:04] [Server thread/INFO] [STDOUT]: [techmod.cablecar.TileEntityCablecarTrack:readFromNBT:23]: Deserialize first_end: EAST second_end: WEST
[14:26:04] [Server thread/INFO] [STDOUT]: [techmod.cablecar.TileEntityCablecarTrack:readFromNBT:23]: Deserialize first_end: NORTH second_end: SOUTH
[14:26:04] [Server thread/INFO] [STDOUT]: [techmod.cablecar.TileEntityCablecarTrack:readFromNBT:23]: Deserialize first_end: NORTH second_end: SOUTH
[14:26:04] [Server thread/INFO]: Changing view distance to 12, from 10
[14:26:04] [Netty Local Client IO #3/INFO] [FML]: Server protocol version 2
[14:26:04] [Netty Server IO #7/INFO] [FML]: Client protocol version 2
[14:26:04] [Netty Server IO #7/INFO] [FML]: Client attempting to join with 5 mods : [email protected],[email protected],[email protected],[email protected],[email protected]
[14:26:04] [Netty Local Client IO #3/INFO] [FML]: [Netty Local Client IO #3] Client side modded connection established
[14:26:04] [Server thread/INFO] [FML]: [Server thread] Server side modded connection established
[14:26:04] [Server thread/INFO]: Player317[local:E:b50b1f90] logged in with entity id 90 at (240.36660389147244, 52.0, 343.8283291103376)
[14:26:04] [Server thread/INFO]: Player317 joined the game
[14:26:04] [Server thread/INFO]: Saving and pausing game...
[14:26:04] [Server thread/INFO]: Saving chunks for level 'Superflat'/overworld
[14:26:04] [Server thread/INFO] [STDOUT]: [techmod.cablecar.TileEntityCablecarTrack:writeToNBT:14]: Serialize first_end: EAST second_end: WEST
[14:26:04] [Server thread/INFO] [STDOUT]: [techmod.cablecar.TileEntityCablecarTrack:writeToNBT:14]: Serialize first_end: EAST second_end: WEST
[14:26:04] [Server thread/INFO] [STDOUT]: [techmod.cablecar.TileEntityCablecarTrack:writeToNBT:14]: Serialize first_end: NORTH second_end: SOUTH
[14:26:04] [Server thread/INFO] [STDOUT]: [techmod.cablecar.TileEntityCablecarTrack:writeToNBT:14]: Serialize first_end: EAST second_end: WEST
[14:26:04] [Server thread/INFO] [STDOUT]: [techmod.cablecar.TileEntityCablecarTrack:writeToNBT:14]: Serialize first_end: NORTH second_end: SOUTH
[14:26:04] [Server thread/INFO] [STDOUT]: [techmod.cablecar.TileEntityCablecarTrack:writeToNBT:14]: Serialize first_end: EAST second_end: WEST
[14:26:04] [Server thread/INFO] [STDOUT]: [techmod.cablecar.TileEntityCablecarTrack:writeToNBT:14]: Serialize first_end: NORTH second_end: SOUTH
[14:26:04] [Server thread/INFO] [STDOUT]: [techmod.cablecar.TileEntityCablecarTrack:writeToNBT:14]: Serialize first_end: NORTH second_end: SOUTH
[14:26:04] [Server thread/INFO]: Saving chunks for level 'Superflat'/the_nether
[14:26:04] [Server thread/INFO]: Saving chunks for level 'Superflat'/the_end
[14:26:04] [main/INFO]: Loaded 5 advancements
[14:26:04] [main/INFO] [STDOUT]: [techmod.cablecar.TileEntityCablecarTrack:readFromNBT:23]: Deserialize first_end: NORTH second_end: NORTH
[14:26:04] [main/INFO] [STDOUT]: [techmod.cablecar.TileEntityCablecarTrack:readFromNBT:23]: Deserialize first_end: NORTH second_end: NORTH
[14:26:04] [main/INFO] [STDOUT]: [techmod.cablecar.TileEntityCablecarTrack:readFromNBT:23]: Deserialize first_end: NORTH second_end: NORTH
[14:26:04] [main/INFO] [STDOUT]: [techmod.cablecar.TileEntityCablecarTrack:readFromNBT:23]: Deserialize first_end: NORTH second_end: NORTH
[14:26:04] [main/INFO] [STDOUT]: [techmod.cablecar.TileEntityCablecarTrack:readFromNBT:23]: Deserialize first_end: NORTH second_end: NORTH
[14:26:04] [main/INFO] [STDOUT]: [techmod.cablecar.TileEntityCablecarTrack:readFromNBT:23]: Deserialize first_end: NORTH second_end: NORTH
[14:26:04] [main/INFO] [STDOUT]: [techmod.cablecar.TileEntityCablecarTrack:readFromNBT:23]: Deserialize first_end: NORTH second_end: NORTH
[14:26:04] [main/INFO] [STDOUT]: [techmod.cablecar.TileEntityCablecarTrack:readFromNBT:23]: Deserialize first_end: NORTH second_end: NORTH

 

Why doesnt the client load these values correctly?

Edited by SuperManitu

  • Author

Thanks, I solved the problem by overwriting getUpdateTag

@Override
public NBTTagCompound getUpdateTag()
{
    NBTTagCompound tag = super.getUpdateTag();
    this.writeToNBT(tag);
    return tag;
}

as I dont need dynamic behavior (yet) I do not use the other methods

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.