Advertisement
Katrix

Untitled

Feb 10th, 2016
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.27 KB | None | 0 0
  1. <tterrag> need to add a way for a chisel block to say "use this model as a template"
  2. <gigaherz> heh
  3. <tterrag> currently I just use one hardcoded model
  4. <tterrag> which is still better than before
  5. <gigaherz> ICustomModelLoader?
  6. <tterrag> where we used no models and generated quads on the fly
  7. <tterrag> no need for that
  8. <gigaherz> heh
  9. <tterrag> it works off the vanilla format
  10. <gigaherz> ah
  11. <gigaherz> hmm
  12. <gigaherz> vanilla model files
  13. <tterrag> currently I use
  14. <tterrag> chisel_block.json -> {"parent":"block/cube"}
  15. <gigaherz> have a "parent":"minecraft:block/cube"
  16. <tterrag> :D
  17. <tterrag> too slow
  18. <gigaherz> yep ninja'd
  19. <gigaherz> that's probably the best option
  20. <tterrag> was just changing that to block/stairs or block/fence_ns for testing
  21. <gigaherz> are chisel blocks separate?
  22. <tterrag> separate...from...?
  23. <gigaherz> as in
  24. <gigaherz> different ids for the full blocks, stairs and such
  25. <gigaherz> like vanilla
  26. <gigaherz> or single-id blocks with TE-based actual state?
  27. <tterrag> no TEs that would be awful
  28. <tterrag> we pack the variants into 16s
  29. <tterrag> and use basically 1.7-style meta for that
  30. <gigaherz> aha
  31. <tterrag> just a PropertyInteger
  32. <gigaherz> so full blocks are grouped in packs of 16 each
  33. <gigaherz> and stairs have one id each?
  34. <tterrag> yes
  35. <tterrag> 2 stairs per ID
  36. <tterrag> since a stair has 3 bits of states
  37. <gigaherz> ah right
  38. <tterrag> chisel has always been ID concious, it has to be with so many dang blocks
  39. <gigaherz> 4 facings + up/down
  40. <gigaherz> yeah makes sense
  41. <gigaherz> that's why I didn't assume ;P
  42. <tterrag> variable-length metadata would be a godsend for chisel
  43. <tterrag> but it's a pipe dream for now :P
  44. <gigaherz> that's sortof akin to using a TE
  45. <gigaherz> if only we could store the TE data in a compact format instead of NBT
  46. <gigaherz> ;P
  47. <tterrag> not really
  48. <tterrag> variable-length metadata would mean that there really is NO metadata
  49. <gigaherz> well yeah
  50. <tterrag> instead a block just marks out how many states it has and the world allots it that many IDs
  51. <gigaherz> just
  52. <gigaherz> provide a list of "persistent" blockstate properties
  53. <tterrag> this would actually lead to a huge increase in ID availability as most blocks don't use meta at all
  54. <gigaherz> and MC could just save those as separate IDs
  55. <PaleoCrafter> Mojang is sorta preparing for that
  56. <gigaherz> in fact
  57. <gigaherz> that'd be the ideal case
  58. <tterrag> PaleoCrafter: yes, that's my hope
  59. <gigaherz> full 16 bits for blockstate ID
  60. <gigaherz> no meta
  61. <gigaherz> there's MANY blocks that don't make use of all 16 variants
  62. <tterrag> the IDEAL case is having separate ID maps per cubic chunk, meaning that ids could be integer based but only saved as 12 bits
  63. <gigaherz> all the blockstates using 3 bits for 6 values
  64. <tterrag> that's a bit nuts though ;)
  65. <gigaherz> no need for that
  66. <gigaherz> if you remove the "block id"
  67. <gigaherz> and assign each blockstate an ID instead
  68. <tterrag> right that's what I'm talking about
  69. <gigaherz> then you have 12+4 bits total without changing the save format
  70. <tterrag> but that still limits to 16 bits
  71. <gigaherz> since metadata bits become meaningless
  72. <tterrag> which is a lot, but not infinite
  73. <gigaherz> yes
  74. <tterrag> 32 bits of ids is virtually infinite
  75. <gigaherz> but for the purpose of chisel, that alone would be perfect
  76. <tterrag> actually I take back the cubic chunk thing
  77. <gigaherz> you'd move from having "packs of 16"
  78. <tterrag> one ID map per chunk = 16 bits of IDs per chunk
  79. <tterrag> then just save an int->int map with the chunk and bam
  80. <gigaherz> that'd be annoying
  81. <tterrag> not really
  82. <gigaherz> suppose the case where someone has a large base
  83. <gigaherz> with like, one floor per mod
  84. <tterrag> uh...ok
  85. <gigaherz> all the way from bedrock to build limit
  86. <gigaherz> all packed with 65537 distinct blockstates
  87. <gigaherz> ;P
  88. <tterrag> and?
  89. <tterrag> what's bad about that?
  90. <gigaherz> [22:25] (tterrag): one ID map per chunk = 16 bits of IDs per chunk
  91. <gigaherz> hmm no wait
  92. <tterrag> 16*16*256 = 65535
  93. <tterrag> I can math
  94. <gigaherz> a chunk is 16x16x256
  95. <gigaherz> can't possibly overflow
  96. <tterrag> (yes that's off-by-one but I'm counting 0)
  97. <gigaherz> yeah
  98. <gigaherz> even if you literally packed each cell with a different blockstate
  99. <gigaherz> you'd still be able to fit it in 16 bits
  100. <gigaherz> so a chunk header with an array of IDs
  101. <gigaherz> (32bit IDs)
  102. <gigaherz> and then each block cell would just blockstates[ids[cell_idx]]
  103. <gigaherz> yeah that'd work
  104. <tterrag> bingo
  105. <tterrag> only a small increase in world size to save the id maps
  106. <tterrag> I'm guessing the id map would generally be less than 16 bits of data total
  107. <PaleoCrafter> if you're having a map from every 16bit id to a 32bit id, woudldn't it be more efficient to just store 32 bit IDs then? :P
  108. <diesieben07> no, that would mean 32 bit per block pos
  109. <tterrag> sorry, 5000 bits, 5kb
  110. <diesieben07> not 16 bits
  111. <tterrag> diesieben07: why
  112. <diesieben07> @paleo
  113. <diesieben07> theoretically you could figure out how many bits you need per chunk
  114. <tterrag> PaleoCrafter: it's much less expensive to store ONE map of 32b->16b than it is to store 32b 65k times
  115. <diesieben07> and potentially even have a versino where you just map 32b->8b
  116. <diesieben07> if there's just 16 different blocks in the chunk
  117. <PaleoCrafter> well, but if you have a chunk where all blockstates are distinct?
  118. <diesieben07> then you need 16 bits per pos
  119. <diesieben07> and then a map to tell what those 16 bits mean in the 32 bit versions
  120. <PaleoCrafter> then you have a 32bit mapping for every 16bit ID
  121. <diesieben07> oh
  122. <diesieben07> right.
  123. <PaleoCrafter> + the 16bits per blockpos
  124. <diesieben07> haha
  125. <diesieben07> true
  126. <PaleoCrafter> :P
  127. <PaleoCrafter> so you essentially store double the amount you would if you just stored the 32bit ID
  128. <diesieben07> there'd have to be a cutoff value where you say "screw the map, use 32 bit everywhere"
  129. <tterrag> that's the worst case scenario
  130. <PaleoCrafter> guess so
  131. <tterrag> 99.9% of chunks will have waayyyy less blocks than that
  132. <diesieben07> overall its not as simple as you think
  133. <PaleoCrafter> I guess that threshold can be calculated
  134. <tterrag> but yes, there could be a backing map fallback
  135. <gigaherz> PaleoCrafter: that's the WORST case
  136. <gigaherz> XD
  137. <diesieben07> the problem si if you cross the threshold you have to recompute everything
  138. <PaleoCrafter> yeah, but you have to plan for everything :P
  139. <gigaherz> worst case is you store 32 bits per cell effective
  140. <diesieben07> unless there is some fancy math you can do to avoid that
  141. <gigaherz> best case you store only 16 bits of "0" (full air)
  142. <gigaherz> average case would be only a slight overhead
  143. <tterrag> recomputing a whole chunk in a batch isn't that expensive
  144. <gigaherz> recomputing what?
  145. <gigaherz> the ID is only needed for storage in the save format
  146. <tterrag> yes but the map is gone
  147. <gigaherz> for networking, the actual blockstate ID would make most sense
  148. <diesieben07> the chunk itself already stores the IDs
  149. <tterrag> you've passed the threshold where the map is more efficient
  150. <gigaherz> I'd have it as 32bit in memory
  151. <diesieben07> thats not a good idea :P
  152. <diesieben07> you'd double the ram usage
  153. <tterrag> er...except no
  154. <tterrag> because java doesn't use less memory for shorts
  155. <PaleoCrafter> let's just drop the topic and let Mojang deal with it when the time comes? :P
  156. <diesieben07> uhm yes it does
  157. <diesieben07> in arrays at least
  158. <gigaherz> most programming languages use struct padding
  159. <diesieben07> not on the stack
  160. <gigaherz> ah right
  161. <tterrag> in arrays maybe
  162. <gigaherz> hmm
  163. <diesieben07> nt maybe ;D
  164. <gigaherz> actually
  165. <tterrag> so yeah, you'd have to remap the whole chunk
  166. <gigaherz> is it an array?
  167. <gigaherz> does it store
  168. <gigaherz> blockids[]
  169. <tterrag> yes, the chunk IDs are packed into an array
  170. <gigaherz> lightlevels[]
  171. <gigaherz> etc
  172. <diesieben07> if byte / short arrays would use 4 bytes per element that would be crazyness :D
  173. <gigaherz> in separate arrays?
  174. <tterrag> private final ExtendedBlockStorage[] storageArrays;
  175. <diesieben07> they use a char[] now i think
  176. <diesieben07> unsigned 16 bit
  177. <gigaherz> diesieben07: yes but if you store classes/structs, then padding DOES take effect
  178. <tterrag> seems so
  179. <tterrag> private char[] data;
  180. <gigaherz> aha
  181. <gigaherz> so iew.
  182. <diesieben07> yes but only if need be
  183. <gigaherz> ew.
  184. <gigaherz> it sounds slow XD
  185. <tterrag> public IBlockState get(int x, int y, int z) { IBlockState iblockstate = (IBlockState)Block.BLOCK_STATE_IDS.getByValue(this.data[y << 8 | z << 4 | x]);
  186. <tterrag> what a strange packing method
  187. <tterrag> yzx
  188. <tterrag> .-.
  189. <diesieben07> its for a reason
  190. <diesieben07> they changed it because it apparently improves the compression
  191. <tterrag> probably, since most blocks are lower down
  192. <tterrag> that means less msb
  193. <tterrag> most of the time y is < 128 which means you can lop off a bit
  194. <gigaherz> for compression
  195. <gigaherz> you want the least changing bits first
  196. <gigaherz> simple matter of probability: if you make the most significant bits change less
  197. <gigaherz> thne the chances of finding "near repetitions" are higher
  198. <gigaherz> which means you can compress better
  199. <tterrag> that as well
  200. <gigaherz> and in a chunk, Y changes the least
  201. <gigaherz> all compression formats work more or less on the idea of locality: nearby data has a higher chance of being similar
  202. <gigaherz> that's why you don't normally store all the history since the beginning of the compression stream
  203. <gigaherz> you use windowed dictionaries or similar
  204. <tterrag> what about middle-out compression
  205. <tterrag> :>
  206. <gigaherz> what's that?
  207. <gigaherz> XD
  208. <tterrag> go watch silicon valley :P
  209. <Drullkus> tterrag: So that means compression gets much worse with modded worlds with 3000 taken block ID's? :P
  210. <tterrag> no
  211. <tterrag> unless that mod is adding random blocks to y>128
  212. * kroeser|away is now known as kroeser
  213. <Drullkus> Wait
  214. <Drullkus> OH
  215. <Drullkus> The y-level
  216. <Drullkus> ...like natura?
  217. <tterrag> natura probably doesn't help, no
  218. <diesieben07> keep in mind this compression stuff probably does nto do THAT much
  219. <diesieben07> and the price per GB for modern harddrives is miniscule
  220. <Pennyw95> Is it possible to combine booleans in a blockstate json? Like, place one inside another?
  221. <tterrag> on a large world it could be significant though
  222. <diesieben07> nobody should have storage space probelms these days :D
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement