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

do the tile entity data packets need to use the custom data packet, or is it posible to use the Packet132TileEntityData to send and receive updates from client and server ? and if so how?

  • Author

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");
}
}

 

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.