Jump to content

tile entity data packets


etopsirhc

Recommended Posts

for some reason it only wants to send to the client and never get the info from the client.

 

the on activated function in the block:

 

public boolean onBlockActivated(World world, int par2, int par3, int par4,EntityPlayer player, int par6, float par7, float par8,float par9) {
	TileEntityLightBuilding t = (TileEntityLightBuilding)world.getBlockTileEntity(par2, par3, par4);
	t.processActivate(player, world, par6);
	if (!world.isRemote)
	{
		FMLCommonHandler.instance().getMinecraftServerInstance().getConfigurationManager().sendPacketToAllPlayers(t.getDescriptionPacket());
	}else{
		try{
			((EntityClientPlayerMP)player).sendQueue.handleTileEntityData((Packet132TileEntityData)t.getDescriptionPacket());
		}catch (Exception e){

		}
	}
	return true;
}

 

 

and almost all the TE class

 

public class TileEntityLightBuilding extends TileEntity {
public int tBlock[] = new int[6];
public int tMeta[] = new int[6];
public int tSide[] = new int[6];
public int tRotate[] = new int[6];
Side mSide = FMLCommonHandler.instance().getEffectiveSide();
static {
	addMapping(TileEntityLightBuilding.class,"LightBuilding");
}

public void processActivate(EntityPlayer player, World world,int aSide) {
	ItemStack iStack = player.inventory.getCurrentItem();
	int held;
	if (player.getHeldItem()!=null){
		held = iStack.getItem().itemID;
	}else{
		held = 0;
	}
	int bSide = -1;
	if (held == MPBaseMod.instance.mallet.itemID && iStack.hasTagCompound()){
		NBTTagCompound tag = iStack.getTagCompound();
		int block = tag.getInteger("Block");
		int meta = tag.getInteger("Meta");
		int side = tag.getInteger("Side");
		try{
			((EntityPlayerMP)player).sendChatToPlayer("Server info BMS:"+block+","+meta+","+side+" rotate"+this.tRotate[aSide]);
		}catch (Exception e){

		}
		try{
			((EntityClientPlayerMP)player).sendChatToPlayer("Client info BMS:"+block+","+meta+","+side+" rotate"+this.tRotate[aSide]);
		}catch (Exception e){

		}
		if (block != tBlock[aSide]&& side!=this.tSide[aSide]&&meta!=tMeta[aSide]){
			this.tBlock[aSide]=block;
			this.tSide[aSide]=side;
			this.tRotate[aSide]=0;
		}else if (held == MPBaseMod.instance.mallet.itemID){
			this.tRotate[aSide] = (this.tRotate[aSide] + 1) % 4;
		}
	}	
	try{
		((EntityPlayerMP)player).sendChatToPlayer("Server info BMS:"+this.tBlock[aSide]+","+tMeta[aSide]+","+tSide[aSide]+" rotate"+this.tRotate[aSide]);
	}catch (Exception e){

	}
	try{
		((EntityPlayerSP)player).sendChatToPlayer("Client info BMS:"+this.tBlock[aSide]+","+tMeta[aSide]+","+tSide[aSide]+" rotate"+this.tRotate[aSide]);
	}catch (Exception e){

	}
	world.markBlockForUpdate(xCoord, yCoord, zCoord);
}

@Override
public Packet getDescriptionPacket()
{
	NBTTagCompound var1 = new NBTTagCompound();
	this.writeToNBT(var1);
	return new Packet132TileEntityData(this.xCoord, this.yCoord, this.zCoord, 0, var1);
}

@Override
public void onDataPacket(INetworkManager net, Packet132TileEntityData pkt) {
	NBTTagCompound nbt = pkt.customParam1;
	this.readFromNBT(nbt);
}

@Override
public void writeToNBT(NBTTagCompound nbt)
{
	super.writeToNBT(nbt);
	nbt.setIntArray("BlockID", this.tBlock);
	nbt.setIntArray("BlockMeta", this.tMeta);
	nbt.setIntArray("BlockSide", this.tSide);
	nbt.setIntArray("TextureRotation", this.tRotate);
}
@Override
public void readFromNBT(NBTTagCompound nbt)
{
	super.readFromNBT(nbt);
	this.tBlock = nbt.getIntArray("BlockID");
	this.tMeta = nbt.getIntArray("BlockMeta");
	this.tSide = nbt.getIntArray("BlockSide");
	this.tRotate = nbt.getIntArray("TextureRotation");
}
}

 

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.



×
×
  • Create New...

Important Information

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