Slope Inventory Rendering
Mineshopper opened this issue ยท 19 comments
Need the baked model for slopes to be called for rendering in inventory. I have tried following guides but am a little stuck on this part. Evidently getQuads in my baked model class should be called with blockstate as null, but I am not seeing this happen. Perhaps I am not registering block rendering properly for itemblocks?
Any help on this would be appreciated!
@Mineshopper Where are you registering the ItemBlock(s)? Are you registering a custom model location for them?
Method doing the actual registering is at bottom of class.
@Mineshopper Zidane and I have lots of experience with this type of issue. Feel free to join our Discord if you want a faster more direct answer to problems such as this.
Your blockstate file found here:
Defines a "normal" variant but your ItemBlock ties to an "inventory" variant. Here would be a correct blockstate:
{
"forge_marker": 1,
"defaults": {
"model": "carpentersblocks:carpenters_block",
"transform": "forge:default-block"
},
"variants": {
"inventory": [ { } ],
"normal": [ { } ]
}
...except the new issue you are going to hit is I believe the ModelLoader will not use your BakedModel implementation (unless you have code set elsewhere that is taking over the pipeline for your modid from Vanilla. If so, link :p ?).
Excellent, thank you! This change and modifying the custom loader finally is hitting getQuads for items.
Okay, so I'm passing the slope's baked quads to the inventory variant just fine. However, it is not rotating or scaling and appears as a full block in the player's hand (not to mention inventory and ground appearance).
Anybody know what is missing?
Sounds like the perspectives are off. Try adding this to your IBakedModel implementation:
@Override
public Pair<? extends IBakedModel, Matrix4f> handlePerspective(final ItemCameraTransforms.TransformType cameraTransformType) {
return PerspectiveMapWrapper.handlePerspective(this, this.state, cameraTransformType);
}
If that isn't it and you've verified your Quads are indeed in-use then verify the composition of your quads to make sure they really aren't just cuboids :p.
Thinking some more on this, are you transforming your quads when baking the POSITION element of the VertexFormat?
Here is some pseudo-code from my mod Almura. Should be understandable. Notice me grabbing the TRSRTransformation and using it to transform the quads.
final TRSRTransformation transformation = this.state.apply(Optional.empty()).orElse(null);
for (final Face face : group.getFaces()) {
final UnpackedBakedQuad.Builder quadBuilder = new UnpackedBakedQuad.Builder(this.format);
for (final VertexDefinition vertexDef : face.getVertices()) {
for (int e = 0; e < this.format.getElementCount(); e++) {
switch (this.format.getElement(e).getUsage()) {
case POSITION:
final Vertex vertex = vertexDef.getVertex();
if (transformation != null) {
final Matrix4f transform = transformation.getMatrix();
final Vector4f position = new Vector4f(vertex.getX(), vertex.getY(), vertex.getZ(), 1f);
final Vector4f transformed = new Vector4f();
transform.transform(position, transformed);
quadBuilder.put(e, transformed.getX(), transformed.getY(), transformed.getZ());
} else {
quadBuilder.put(e, vertex.getX(), vertex.getY(), vertex.getZ());
}
break;
I'm not applying any transformations currently. I will try your suggestions later today and report back. Thanks!
I tried your suggestions, but appearance is the same. Do I need to define the transformations somewhere? Where would the IModelState get those details?
In the BlockState json I gave above, we defined the Transformation as Forge's default:block.
I transform each vertex here.
Pushed to new branch, entry to code is here:
@Mineshopper May I ask why you do all the rendering classes and code that you currently do? One thing I'd do is completely remove all your render classes (I'm having a hard time following it all), create a baked model implementation and build some test slope quads and pass the texture via the model file (as you already do). Apply the transformations and see how it renders in the world.
We need to get to what works then build on top of that.
I haven't been working on it. I don't know how to proceed for the inventory rendering portion. Plus, been busy with many other things.
If anyone is able to provide input without involving stripping out tons of code, that would give me some hope. Basically, I need the BakedQuads to render with perspective 'awareness.' I've dug around online, but it's rather hopeless as not many mods do what this one does. I could dig deeper but it would eat up all my free time.
If the slope rendering in inventory could be fixed, I could easily push forward! I just don't like being stuck, nor skipping things I am stuck on.
Just chatting with a streamer about how much we love your mod. Sorry to see it stuck, wish I knew more about Java and Transforms to help you. I was showing off some pictures of amazing things I've done with this mod. A Dragon Head as the entrance to my Castle / Tower. Skyblock base lit by Nickel blocks from Thermal Expansion contrasted against Treated wood. The Community loves you. Thats all I can really say. Thanks for the many great years of work you put into this.