-
Notifications
You must be signed in to change notification settings - Fork 487
Armor Renderer Upgrades #4916
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
modmuss50
merged 11 commits into
FabricMC:1.21.10
from
8s2:1.21.10-armor-renderer-upgrades
Nov 4, 2025
Merged
Armor Renderer Upgrades #4916
Changes from 10 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
979b718
Add EquipmentModelData to EntityModelLayerRegistry
8s2 9a1926c
Add TransformCopyingModel
8s2 f6f64fb
Upgrade ArmorRenderer
8s2 814cf9e
Update tests
8s2 c9f084b
Mark FabricModel as NonExtendable
8s2 557e828
Fix FabricModel doc
8s2 d10ba49
Make ModelMixin package-private
8s2 b710382
Make EntityRenderManagerMixin package-private
8s2 efc24eb
Remove try-catch block in ArmorRendererRegistryImpl
8s2 66a75c9
Make TransformCopyingModel final
8s2 d85a5f4
Use spaces for alignment in ArmorRenderer
8s2 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
49 changes: 49 additions & 0 deletions
49
...rendering-v1/src/client/java/net/fabricmc/fabric/api/client/rendering/v1/FabricModel.java
This file contains hidden or 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,49 @@ | ||
| /* | ||
| * Copyright (c) 2016, 2017, 2018, 2019 FabricMC | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package net.fabricmc.fabric.api.client.rendering.v1; | ||
|
|
||
| import org.jetbrains.annotations.ApiStatus; | ||
| import org.jetbrains.annotations.Nullable; | ||
|
|
||
| import net.minecraft.client.model.Model; | ||
| import net.minecraft.client.model.ModelPart; | ||
|
|
||
| /** | ||
| * General purpose Fabric extensions to the {@link Model} class. | ||
| * | ||
| * <p>Note: This interface is automatically implemented on all {@link Model} instances via Mixin and interface injection. | ||
| */ | ||
| @ApiStatus.NonExtendable | ||
| public interface FabricModel<S> { | ||
| /** | ||
| * Returns a child model part of the given name, or {@code null} if one is not found. | ||
| * @param name the name of the child model part | ||
| * @return the child model part that corresponds to the name parameter, or {@code null} if it is not found. | ||
| */ | ||
| @Nullable | ||
| default ModelPart getChildPart(String name) { | ||
| throw new UnsupportedOperationException("Implemented via mixin"); | ||
| } | ||
|
|
||
| /** | ||
| * Copies transforms of child model parts of the model to child model parts of this model whose names match. | ||
| * @param model the model to copy transforms from | ||
| */ | ||
| default void copyTransforms(Model<?> model) { | ||
| throw new UnsupportedOperationException("Implemented via mixin"); | ||
| } | ||
| } |
62 changes: 62 additions & 0 deletions
62
...v1/src/client/java/net/fabricmc/fabric/api/client/rendering/v1/TransformCopyingModel.java
This file contains hidden or 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,62 @@ | ||
| /* | ||
| * Copyright (c) 2016, 2017, 2018, 2019 FabricMC | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package net.fabricmc.fabric.api.client.rendering.v1; | ||
|
|
||
| import com.mojang.datafixers.util.Pair; | ||
|
|
||
| import net.minecraft.client.model.Model; | ||
|
|
||
| /** | ||
| * A model that copies transforms from a source model to a delegate model. | ||
| * | ||
| * <p>Useful in cases where an overlay model may not be a subclass of its base model. | ||
| * @param <S> type of the source model state | ||
| * @param <D> type of the delegate model state | ||
| */ | ||
| public final class TransformCopyingModel<S, D> extends Model<Pair<S, D>> { | ||
| private final Model<? super S> source; | ||
| private final Model<? super D> delegate; | ||
| private final boolean setDelegateAngles; | ||
|
|
||
| /** | ||
| * @param source the model whose transforms will be copied | ||
| * @param delegate the model that will be rendered with transforms copied from the source model | ||
| * @param setDelegateAngles {@code true} if the {@link Model#setAngles(Object)} method should be called for the | ||
| * delegate model after it is called for the source model | ||
| */ | ||
| public static <S, D> TransformCopyingModel<S, D> create(Model<? super S> source, Model<? super D> delegate, boolean setDelegateAngles) { | ||
| return new TransformCopyingModel<>(source, delegate, setDelegateAngles); | ||
| } | ||
|
|
||
| private TransformCopyingModel(Model<? super S> source, Model<? super D> delegate, boolean setDelegateAngles) { | ||
| super(delegate.getRootPart(), delegate::getLayer); | ||
| this.source = source; | ||
| this.delegate = delegate; | ||
| this.setDelegateAngles = setDelegateAngles; | ||
| } | ||
|
|
||
| @Override | ||
| public void setAngles(Pair<S, D> state) { | ||
| resetTransforms(); | ||
| source.setAngles(state.getFirst()); | ||
| delegate.copyTransforms(source); | ||
|
|
||
| if (setDelegateAngles) { | ||
| delegate.setAngles(state.getSecond()); | ||
| } | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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
37 changes: 37 additions & 0 deletions
37
.../src/client/java/net/fabricmc/fabric/mixin/client/rendering/EntityRenderManagerMixin.java
This file contains hidden or 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,37 @@ | ||
| /* | ||
| * Copyright (c) 2016, 2017, 2018, 2019 FabricMC | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package net.fabricmc.fabric.mixin.client.rendering; | ||
|
|
||
| import com.llamalad7.mixinextras.sugar.Local; | ||
| import org.spongepowered.asm.mixin.Mixin; | ||
| import org.spongepowered.asm.mixin.injection.At; | ||
| import org.spongepowered.asm.mixin.injection.Inject; | ||
| import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
|
||
| import net.minecraft.client.render.entity.EntityRenderManager; | ||
| import net.minecraft.client.render.entity.EntityRendererFactory; | ||
| import net.minecraft.resource.ResourceManager; | ||
|
|
||
| import net.fabricmc.fabric.impl.client.rendering.ArmorRendererRegistryImpl; | ||
|
|
||
| @Mixin(EntityRenderManager.class) | ||
| class EntityRenderManagerMixin { | ||
| @Inject(method = "reload", at = @At("TAIL")) | ||
| private void createArmorRenderers(ResourceManager manager, CallbackInfo ci, @Local EntityRendererFactory.Context context) { | ||
| ArmorRendererRegistryImpl.createArmorRenderers(context); | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.