Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 1) Create custom IModel with IModelSimpleProperties with IModelUVLock class
- This implementation, for you, should probably be very simple, as it will just delegate to the two submodels.
- getTextures() - Return ImmutableList.of() (empty list)
- getDependencies() - Return an ImmutableList containing the RLs of the other two models
- getDefaultState() - Return some dummy value like ModelRotation.X0_Y0
- gui3d() - Store given value for later
- smoothLighting() - Ditto
- uvLock() - Ditto
- bake() - The complicated one
- Load the other two models with ModelLoaderRegistry.getModel
- For both of them, do some instanceof checks and call gui3d, smoothLighting, and uvLock on them with the stored values
- Two new IModels go into local vars
- Bake both models with the given IModelState, VertexFormat, and textureGetter
- Use IPerspectiveAwareModel.MapWrapper.getTransforms on the IModelState to get an ImmutableMap
- Create an instance of your custom IPerspectiveAwareModel containing the other two IBakedModels, the ImmutableMap, gui3d, smoothLighting, and uvLock and return it.
- 2) Create custom IPerspectiveAwareModel class
- Also very simple for you, as this thing is basically dispatches to the other two IBakedModels depending on a boolean expression.
- getOverrides() - Dummy out; probably return ItemOverrideList.NONE.
- isAmbientOcclusion() - Return the value of smoothLighting stored earlier.
- isGui3d() - Ditto but with the gui3d value
- isBuiltinRenderer() - false unless you want breakage
- getItemCameraTransforms() - Dummy out; probably return ItemCameraTransforms.DEFAULT.
- getQuads() - Dummy out with empty list or delegate to one of the contained models.
- getParticleTexture() - Dummy out with new ResourceLocation("missingno") (magenta + black checkerboard) or delegate to one of the contained models.
- handlePerspective() - Real meat here
- Depending on the TransformType, choose the IBakedModel to return
- If that model is also an IPerspectiveAwareModel (instanceof), use handlePerspective and store the returned Pair
- Otherwise:
- Use getItemCameraTransforms().getTransforms() to get ItemTransformVec3f
- Convert that to TRSRTransformation with the TRSRT constructor
- Use TRSRT.blockCenterToCorner on it
- Then convert THAT into a Matrix4f with getMatrix
- Pair the model and matrix with Pair.of
- From the stored ImmutableMap<TransformType, TRSRTransformation>, get the relevant transform and get its matrix
- Multiply the matrix in the pair with the matrix from the map
- Return a pair of the model and the new matrix
- 3) Create custom ICustomModelLoader class
- Super simple, just a dummy.
- 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.
- loadModel() - Also a dummy, just instantiate the custom IModel and return it.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement