tterrag1098

Untitled

Jun 12th, 2018
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.87 KB | None | 0 0
  1. tterrag - Today at 6:41 PM
  2. lex: I'm trying to get to the bottom of all this hasCap/getCap nonsense and misunderstanding. so I'm going to ask this very directly, so it's clearly laid out, and then we can move forward:
  3.  
  4. 1. Is it expected that hasCap should always be called before getCap? Is it a failure to follow contract if it is not?
  5. 2. Is it required that if hasCap()==false then getCap() must be null?
  6. 3. Is it required that if hasCap()==true then getCap() must be nonnull?
  7. as far as I can tell, the javadocs are kinda vague on all these points
  8. I'm looking into clearing them up
  9.  
  10. LexManos - Today at 7:07 PM
  11. 1) No, 2) No, but it would be stupid. I don't see any case where a false would then lead to code that tries to use the cap... 3) Yes
  12. tterrag - Today at 7:07 PM
  13. okay
  14. so furthermore, can we discuss the implications of that answer to #3?
  15. what about this case?
  16.  
  17. It also has other implications: To support hasCap() for rendering purposes client-side means that you also have to support getCap() client-side, which means that you have to sync your complete data for the cap to the client---because people will bug-report client-side cap objects that do nothing.
  18. what's the solution?
  19. LexManos - Today at 7:08 PM
  20. has is LITERALLY a replacement for instanceof
  21. get is LITERALLY a replacement for (Cast)
  22. tterrag - Today at 7:08 PM
  23. sync all the data? or should the caller not rely on clientside info?
  24. LexManos - Today at 7:08 PM
  25. nothing should ever rely on clientside shit.
  26. tterrag - Today at 7:09 PM
  27. okay
  28. so the proper implementation is to just return a dummy capability with unsynced data
  29. LexManos - Today at 7:09 PM
  30. Thats a general design concept for anything server/client
  31. tterrag - Today at 7:09 PM
  32. am I understanding that right?
  33. LexManos - Today at 7:09 PM
  34. if you feel like it yes
  35. tterrag - Today at 7:09 PM
  36. the problem I see with that is something like a fluid pipe
  37. LexManos - Today at 7:09 PM
  38. its not 'proper'
  39. tterrag - Today at 7:09 PM
  40. might want to use extended states for rendering connections
  41. and you can't easily sync that data
  42. LexManos - Today at 7:09 PM
  43. the only defintion of 'proper' is to not return null if has returns true
  44. tterrag - Today at 7:10 PM
  45. well this is a real problem we are having, not a theory
  46. we have caps with large amounts of data that have no need to exist on the client
  47. LexManos - Today at 7:10 PM
  48. not really.. what are you doing on the client that requires real data?
  49. tterrag - Today at 7:10 PM
  50. it's not us, but the other mod using the cap clientside
  51. LexManos - Today at 7:10 PM
  52. what are they doing that requires real data?
  53. look at chests
  54. tterrag - Today at 7:11 PM
  55. I don't have a specific example
  56. LexManos - Today at 7:11 PM
  57. we return a cap on both client and server
  58. but the client's are empty
  59. as the data isnt synced
  60. tterrag - Today at 7:11 PM
  61. IE is doing this: https://github.com/BluSunrize/ImmersiveEngineering/blob/master/src/main/java/blusunrize/immersiveengineering/common/blocks/metal/TileEntityFluidPipe.java#L437-L439
  62. GitHub
  63. BluSunrize/ImmersiveEngineering
  64. ImmersiveEngineering - Wires, transformers, high voltage! Bzzzzt!
  65.  
  66. relies on the handler's tank properties existing
  67. which isn't hard to keep in sync (the amount of tanks rarely changes)
  68. but it's still something
  69. LexManos - Today at 7:12 PM
  70. all that seems to do is check if there is a tank
  71. it doesnt need to know that its lava and has 14mb
  72. tterrag - Today at 7:13 PM
  73. right but it does rely on the clientside cap returning some kind of IFluidTankProperties
  74. and this is just one example
  75. I just want to be clear that a "dummy" cap on the client is valid
  76. so we can justify it later
  77. LexManos - Today at 7:13 PM
  78. sure, if the client doesnt ahve shit it doesnt ahve shit
  79. thats on the API of the cap
  80. nothing to do with Forge/ICaprovider
  81. It WOULD be perfectly valid for someone to write a cap that REQUIRES valid data on the client.
  82. But that is up to the cap designer to explicitly state
Advertisement
Add Comment
Please, Sign In to add comment