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

Hey,

 

some time ago ive started with modding in 1.7.

Now.. some months/years? later ill want to continue with 1.10.2.

 

Something changed .. but i want to use my existing "core"-classes,

which are written in 1.7.

With some changes everything works fine, but .. some of these changed are weird and confuse me.

 

I've started with a new tileentity and some gui stuff.

The problem is, if i code like i learned in 1.7, my gui does nothing (e.g. no progressbar).

 

---

 

readFromNBT gets called before writeToNBT:

The method call readFromNBT overrides the initial-values of my class attributes which are set in constructor.

I changed the readFromNBT: read only if the key exists in compound.

In 1.7 (i tried it) the writeFromNBT gets called before readFromNBT.

 

Now.. is it possible that my "base"-nbt methods in 1.10.2 are wrong?

@Override
public SPacketUpdateTileEntity getUpdatePacket () {
	// Sorry, ive added these in 1.10.2 .. do i need them?
                //NBTTagCompound nbtTag = new NBTTagCompound();
	//writeToNBT(nbtTag);
	return new SPacketUpdateTileEntity(this.pos, getBlockMetadata(), getUpdateTag());
}

@Override
public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity pkt){
	if(net.getDirection() == EnumPacketDirection.CLIENTBOUND){
		readFromNBT(pkt.getNbtCompound());
	}
}

 

Or in one of my base tileentities (TileEntityMachine) i need to comment some code out.. because it still not exists in 1.10:

@Override
public void update() {

	if (this.worldObj.isRemote)
		return;

	//if (this.hasWorldObj())
	//	this.getWorldObj().markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);

}

 

the "this.worldObj.isRemote .. return" only if there is no gui data in this class or?

 

If i should post my whole code.. ask.. buts its incomplete and wont confuse you with this :)

 

Thanks

 

 

 

Hi

 

TileEntities now need four methods to synchronise client<-->server

 

For example

 

	// When the world loads from disk, the server needs to send the TileEntity information to the client
//  it uses getUpdatePacket(), getUpdateTag(), onDataPacket(), and handleUpdateTag() to do this:
  //  getUpdatePacket() and onDataPacket() are used for one-at-a-time TileEntity updates
  //  getUpdateTag() and handleUpdateTag() are used by vanilla to collate together into a single chunk update packet
//  Not really required for this example since we only use the timer on the client, but included anyway for illustration
@Override
  @Nullable
  public SPacketUpdateTileEntity getUpdatePacket()
  {
	NBTTagCompound nbtTagCompound = new NBTTagCompound();
	writeToNBT(nbtTagCompound);
	int metadata = getBlockMetadata();
	return new SPacketUpdateTileEntity(this.pos, metadata, nbtTagCompound);
}

@Override
public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity pkt) {
	readFromNBT(pkt.getNbtCompound());
}

  /* Creates a tag containing the TileEntity information, used by vanilla to transmit from server to client
*/
  @Override
  public NBTTagCompound getUpdateTag()
  {
    NBTTagCompound nbtTagCompound = new NBTTagCompound();
    writeToNBT(nbtTagCompound);
    return nbtTagCompound;
  }

  /* Populates this TileEntity with information from the tag, used by vanilla to transmit from server to client
*/
  @Override
  public void handleUpdateTag(NBTTagCompound tag)
  {
    this.readFromNBT(tag);
  }

 

That might be contributing to your problem.

 

You can find a working example of TileEntities and GUI (Furnaces, chests) in this tutorial project

https://github.com/TheGreyGhost/MinecraftByExample/tree/master

see mbe20, mbe30, mbe31

 

-TGG

 

 

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.