Jump to content

[1.10.2][TileEntity][Client-Server] What replaced getDescriptionPacket?


Starless

Recommended Posts

I think what that link says is inverted

 

about the pair

getUpdateTag()

and

handleUpdateTarget

it is written:

 

Caveat: whatever tag you return must have the position of the TE in the "x" "y" and "z" tags. Otherwise MC doesn't know which TE to apply the packet to since we don't have anything like entity ID's. Any packets whose tags are missing "x" "y" and "z" are silently discarded.

 

The super class methods (in TileEntity) already deal with reading and writing x, y, z, id, and serialize some stuff.

 

About the pair

getUpdatePacket()

and

onDataPacket()

it is said:

Noncaveat: The position of the TE is in the packet, so this compound need not have the TE position

 

It really is, but we have to construct the packet ourselves, because the super method returns null.

 

After reading that short article, what I'm doing is this:

        @Override
public NBTTagCompound getUpdateTag()
{
	NBTTagCompound tag = super.getUpdateTag();
	tag.setString("Target", target);
	return tag;
}

@Override
public void handleUpdateTag(NBTTagCompound tag)
{
	super.handleUpdateTag(tag);
	target = tag.getString("Target");
}

@Override
public SPacketUpdateTileEntity getUpdatePacket()
{
	return new SPacketUpdateTileEntity(pos, getBlockMetadata(), getUpdateTag());
}

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

 

Is it correct?

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.