ZigTheHedge Posted July 26, 2019 Posted July 26, 2019 (edited) 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 July 26, 2019 by ZigTheHedge Quote
Afroman Posted July 28, 2019 Posted July 28, 2019 (edited) if(compound.hasKey("isMoving")) isMoving = compound.getBoolean("isMoving"); if(compound.hasKey("structureChecked")) isMoving = compound.getBoolean("structureChecked"); ??????? Is this on purpose? Edited July 28, 2019 by Afroman 1 Quote
ZigTheHedge Posted July 28, 2019 Author Posted July 28, 2019 Oh my... Thanks!!! That was the issue! Quote
Recommended Posts
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.