Jump to content

Weird behaviour when syncing TE [1.12.2]


ZigTheHedge

Recommended Posts

Hello!

 

I ran into very strange issue while trying to sync TE from server to client AGAIN. But this time it's really magic. When I call tsTE.activate() everything is in sync and works fine, but when tsTE.deactivate() is called - value on server side is changing, but it doesn't on client side, although received packet is fine. So, the client thinks "isMoving" equals "true" no matter what.

Here's some code:

Method from which I call my update method:

@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    if(!worldIn.isRemote)
    {
        ...
        TileEntity te = worldIn.getTileEntity(pos);
        if(te instanceof PistonVesselTE) {
            TimeSymbolTE tsTE = (TimeSymbolTE) worldIn.getTileEntity(((PistonVesselTE) te).getMainBlockPos());
            if (tsTE.isStructureComplete())
            {
                tsTE.activate();
            } else {
                if(tsTE.isMoving)
                    tsTE.deactivate();
            }
        }
    }
    return true;
}

 

TileEntity's methods:

public void activate()
{
    if(isMoving)return;
    if(world.isRemote)return;
    isMoving = true;

    ...
    markDirty();
    world.notifyBlockUpdate(pos, world.getBlockState(pos), world.getBlockState(pos), 3);
}

public void deactivate()
{
    if(!isMoving)return;
    if(world.isRemote)return;
    isMoving = false;
    
    ...
    markDirty();
    world.notifyBlockUpdate(pos, world.getBlockState(pos), world.getBlockState(pos), 3);
}

 

TileEntity's NBT methods:

@Override
public void readFromNBT(NBTTagCompound compound) {
    super.readFromNBT(compound);
    if(compound.hasKey("isMoving")) isMoving = compound.getBoolean("isMoving");
    if(compound.hasKey("structureChecked")) isMoving = compound.getBoolean("structureChecked");
}

@Override
public NBTTagCompound writeToNBT(NBTTagCompound compound) {
    compound = super.writeToNBT(compound);
    compound.setBoolean("isMoving", isMoving);
    compound.setBoolean("structureChecked", structureChecked);
    return compound;
}

 

TileEntity's Sync stuff:

@Override
public NBTTagCompound getUpdateTag() {
    return writeToNBT(new NBTTagCompound());
}

@Override
public SPacketUpdateTileEntity getUpdatePacket() {
    NBTTagCompound nbtTag = new NBTTagCompound();
    this.writeToNBT(nbtTag);
    return new SPacketUpdateTileEntity(getPos(), 1, nbtTag);
}

@Override
public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity packet) {
    super.onDataPacket(net, packet);
    this.readFromNBT(packet.getNbtCompound());
    ModMain.logger.info("Received packet: "+packet.getNbtCompound().toString()+", side: "+world.isRemote);
    world.notifyBlockUpdate(pos, world.getBlockState(pos), world.getBlockState(pos), 3);
}

 

In debug info, everything is fine. I get the correct isMoving=0b in NBT with world.isRemote=true

 

Edited by ZigTheHedge
Link to comment
Share on other sites

if(compound.hasKey("isMoving")) isMoving = compound.getBoolean("isMoving");
if(compound.hasKey("structureChecked")) isMoving = compound.getBoolean("structureChecked");

???????

Is this on purpose?

Edited by Afroman
  • Like 1
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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Discovering that a trusted colleague had accessed my Bitcoin account and transferred $30,000 worth of bitcoins was a devastating blow. It shattered the trust I had placed in them and left me feeling vulnerable and betrayed. However, in the face of adversity, I turned to MUYERN TRUST HACKER for assistance in reclaiming control over my finances and holding the perpetrators accountable for their actions. One of the standout features of MUYERN TRUST HACKER was its ability to provide real-time alerts and notifications, keeping me informed every step of the way. With the support of MUYERN TRUST HACKER, I was able to gather irrefutable evidence of the perpetrator's actions and hold them accountable for their crimes. Armed with the information provided by the platform, I pursued legal recourse and ensured that justice was served. The perpetrator faced severe consequences for their actions, including legal penalties and financial restitution. Beyond its role in facilitating the recovery process, MUYERN TRUST HACKER provided me with a sense of empowerment and resilience in the face of adversity. While the experience was undoubtedly challenging, it ultimately served as a testament to the importance of vigilance and the power of technology in safeguarding our digital assets. Thanks to MUYERN TRUST HACKER, I emerged stronger and more resilient, ready to face whatever challenges the future may hold. Mail; muyerntrusted[At] mail-me .c o m
    • Discovering that a trusted colleague had accessed my Bitcoin account and transferred $30,000 worth of bitcoins was a devastating blow. It shattered the trust I had placed in them and left me feeling vulnerable and betrayed. However, in the face of adversity, I turned to MUYERN TRUST HACKER web [ ht tps:// muyerntrusthack.solutions/ ] for assistance in reclaiming control over my finances and holding the perpetrators accountable for their actions. One of the standout features of MUYERN TRUST HACKER was its ability to provide real-time alerts and notifications, keeping me informed every step of the way. With the support of MUYERN TRUST HACKER, I was able to gather irrefutable evidence of the perpetrator's actions and hold them accountable for their crimes. Armed with the information provided by the platform, I pursued legal recourse and ensured that justice was served. The perpetrator faced severe consequences for their actions, including legal penalties and financial restitution. Beyond its role in facilitating the recovery process, MUYERN TRUST HACKER provided me with a sense of empowerment and resilience in the face of adversity. While the experience was undoubtedly challenging, it ultimately served as a testament to the importance of vigilance and the power of technology in safeguarding our digital assets. Thanks to MUYERN TRUST HACKER, I emerged stronger and more resilient, ready to face whatever challenges the future may hold. Mail; muyerntrusted[At] mail-me .c o m  
    • Do you have still this problem? (I have it too so I want to know if you did something with it)  
    • Thank you very much, the mod worked. I almost destroyed my computer out of anger because I couldn't find the error.
  • Topics

×
×
  • Create New...

Important Information

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