Advertisement
hownottowin

Untitled

Oct 8th, 2016
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.80 KB | None | 0 0
  1. 1) Create custom IModel with IModelSimpleProperties with IModelUVLock class
  2. This implementation, for you, should probably be very simple, as it will just delegate to the two submodels.
  3. getTextures() - Return ImmutableList.of() (empty list)
  4. getDependencies() - Return an ImmutableList containing the RLs of the other two models
  5. getDefaultState() - Return some dummy value like ModelRotation.X0_Y0
  6. gui3d() - Store given value for later
  7. smoothLighting() - Ditto
  8. uvLock() - Ditto
  9. bake() - The complicated one
  10. Load the other two models with ModelLoaderRegistry.getModel
  11. For both of them, do some instanceof checks and call gui3d, smoothLighting, and uvLock on them with the stored values
  12. Two new IModels go into local vars
  13. Bake both models with the given IModelState, VertexFormat, and textureGetter
  14. Use IPerspectiveAwareModel.MapWrapper.getTransforms on the IModelState to get an ImmutableMap
  15. Create an instance of your custom IPerspectiveAwareModel containing the other two IBakedModels, the ImmutableMap, gui3d, smoothLighting, and uvLock and return it.
  16.  
  17. 2) Create custom IPerspectiveAwareModel class
  18. Also very simple for you, as this thing is basically dispatches to the other two IBakedModels depending on a boolean expression.
  19. getOverrides() - Dummy out; probably return ItemOverrideList.NONE.
  20. isAmbientOcclusion() - Return the value of smoothLighting stored earlier.
  21. isGui3d() - Ditto but with the gui3d value
  22. isBuiltinRenderer() - false unless you want breakage
  23. getItemCameraTransforms() - Dummy out; probably return ItemCameraTransforms.DEFAULT.
  24. getQuads() - Dummy out with empty list or delegate to one of the contained models.
  25. getParticleTexture() - Dummy out with new ResourceLocation("missingno") (magenta + black checkerboard) or delegate to one of the contained models.
  26. handlePerspective() - Real meat here
  27. Depending on the TransformType, choose the IBakedModel to return
  28. If that model is also an IPerspectiveAwareModel (instanceof), use handlePerspective and store the returned Pair
  29. Otherwise:
  30. Use getItemCameraTransforms().getTransforms() to get ItemTransformVec3f
  31. Convert that to TRSRTransformation with the TRSRT constructor
  32. Use TRSRT.blockCenterToCorner on it
  33. Then convert THAT into a Matrix4f with getMatrix
  34. Pair the model and matrix with Pair.of
  35. From the stored ImmutableMap<TransformType, TRSRTransformation>, get the relevant transform and get its matrix
  36. Multiply the matrix in the pair with the matrix from the map
  37. Return a pair of the model and the new matrix
  38.  
  39. 3) Create custom ICustomModelLoader class
  40. Super simple, just a dummy.
  41. accepts() - Pick one special ResourceLocation to be the entry point to all this that your item will use as its model, and check for equality.
  42. loadModel() - Also a dummy, just instantiate the custom IModel and return it.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement