-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Patch]: Baked model selection rewrite (#873)
## Baked model selection rewrite Closes #870 Closes #865 **Goal**: Rebuild the model selection process to be more flexible and easier to maintain ## Changes * Removes the old monolith class that handled everything before * Removed itemstack cache keys * Removed the old * Removed dependency on the deprecated Fabric Model selection api * Adds a new 1-1 binding between items and the Unbaked model class * Implemented using Fabric's new ModelLoadingPlugin * Adds a system of decorator strategies to be able to quickly set up and build a BakedModel selection process * Added the following selectors: AsyncStrategy, SingleCachedStrategy, LayeredCachedStrategy, DefaultedBakedModelStrategy, ModelBakerStrategy ## Compatibility * Adds compat for Modernfix * Adds compat for Emissive Textures plugin ## Further work - [ ] #890
- Loading branch information
1 parent
5735cfc
commit 0b26f09
Showing
80 changed files
with
2,210 additions
and
678 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
...pat/src/main/java/com/sigmundgranaas/forgero/fabric/mixins/EmissiveOverlayModelMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package com.sigmundgranaas.forgero.fabric.mixins; | ||
|
||
import static net.minecraft.client.render.model.json.ModelTransformationMode.GROUND; | ||
|
||
import com.sigmundgranaas.forgero.minecraft.common.client.model.QuadProviderPreparer; | ||
import io.github.moremcmeta.emissiveplugin.fabric.model.OverlayBakedModel; | ||
import org.jetbrains.annotations.Nullable; | ||
import org.spongepowered.asm.mixin.Final; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
||
import net.minecraft.client.render.VertexConsumerProvider; | ||
import net.minecraft.client.render.item.ItemModels; | ||
import net.minecraft.client.render.item.ItemRenderer; | ||
import net.minecraft.client.render.model.BakedModel; | ||
import net.minecraft.client.render.model.json.ModelTransformationMode; | ||
import net.minecraft.client.util.math.MatrixStack; | ||
import net.minecraft.client.world.ClientWorld; | ||
import net.minecraft.entity.LivingEntity; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.world.World; | ||
|
||
@Mixin(ItemRenderer.class) | ||
public class EmissiveOverlayModelMixin { | ||
@Shadow | ||
@Final | ||
private ItemModels models; | ||
|
||
@Inject(at = @At("HEAD"), method = "getModel") | ||
public void forgero$preparOverlayModel(ItemStack stack, @Nullable World world, @Nullable LivingEntity entity, int seed, CallbackInfoReturnable<BakedModel> ci) { | ||
BakedModel bakedModel = this.models.getModel(stack); | ||
if (bakedModel instanceof OverlayBakedModel overlay) { | ||
if (overlay.getWrappedModel() instanceof QuadProviderPreparer preparer && world instanceof ClientWorld clientWorld) { | ||
preparer.provideContext(stack, clientWorld, entity, seed); | ||
} | ||
} | ||
} | ||
|
||
@Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/client/util/math/MatrixStack;translate(FFF)V"), method = "renderItem(Lnet/minecraft/item/ItemStack;Lnet/minecraft/client/render/model/json/ModelTransformationMode;ZLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;IILnet/minecraft/client/render/model/BakedModel;)V") | ||
private void forgero$applyGroundTransformationToOverlayModel(ItemStack stack, ModelTransformationMode renderMode, boolean leftHanded, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay, BakedModel model, CallbackInfo ci) { | ||
if (renderMode.equals(GROUND) && model instanceof OverlayBakedModel overlayBakedModel && overlayBakedModel.getWrappedModel() instanceof QuadProviderPreparer) { | ||
// The ground model is scaled down by half to make sure it's the same size as other models | ||
// Investigate why it's doing this. This mixin should not be needed. | ||
matrices.scale(0.5f, 0.5f, 0.5f); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,5 +9,8 @@ | |
], | ||
"injectors": { | ||
"defaultRequire": 1 | ||
} | ||
}, | ||
"client": [ | ||
"EmissiveOverlayModelMixin" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.