mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2025-02-13 08:14:23 +01:00
Simplify armor rendering a little
This commit is contained in:
parent
4df9f5eece
commit
86fc15a59a
14 changed files with 98 additions and 127 deletions
|
@ -1,10 +1,12 @@
|
|||
package com.minelittlepony.api.model;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.equipment.EquipmentModel;
|
||||
import net.minecraft.util.Util;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import com.minelittlepony.client.model.AbstractPonyModel;
|
||||
import com.minelittlepony.client.model.PlayerModelKey;
|
||||
import com.minelittlepony.client.model.armour.*;
|
||||
import com.minelittlepony.mson.api.ModelKey;
|
||||
|
@ -17,7 +19,7 @@ import java.util.function.Function;
|
|||
* Container class for the various models and their associated piece of armour.
|
||||
*/
|
||||
public record Models<M extends PonyModel<?>> (
|
||||
Function<ModelKey<PonyArmourModel<?>>, PonyArmourModel<?>> armor,
|
||||
Function<ModelKey<AbstractPonyModel<?>>, AbstractPonyModel<?>> armor,
|
||||
M body
|
||||
) {
|
||||
|
||||
|
@ -32,9 +34,9 @@ public record Models<M extends PonyModel<?>> (
|
|||
this(Util.memoize(k -> k.createModel()), key.createModel());
|
||||
}
|
||||
|
||||
public Optional<PonyArmourModel<?>> getArmourModel(ItemStack stack, ArmourLayer layer, ArmourVariant variant) {
|
||||
return ArmorModelRegistry.getModelKey(stack.getItem(), layer)
|
||||
.or(() -> variant.getDefaultModel(layer))
|
||||
public Optional<AbstractPonyModel<?>> getArmourModel(ItemStack stack, EquipmentModel.LayerType layerType, ArmourVariant variant) {
|
||||
return ArmorModelRegistry.getModelKey(stack.getItem(), layerType)
|
||||
.or(() -> variant.getDefaultModel(layerType))
|
||||
.map(armor);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,10 +48,10 @@ public final class ModelType {
|
|||
public static final ModelKey<PonyElytra<?>> ELYTRA = register("elytra", PonyElytra::new);
|
||||
|
||||
public static final ModelKey<PonyArmourStandModel> ARMOUR_STAND = register("armour_stand", PonyArmourStandModel::new);
|
||||
public static final ModelKey<PonyArmourModel<?>> INNER_VANILLA_ARMOR = register("armor/inner_vanilla_armor", PonyArmourModel::new);
|
||||
public static final ModelKey<PonyArmourModel<?>> OUTER_VANILLA_ARMOR = register("armor/outer_vanilla_armor", PonyArmourModel::new);
|
||||
public static final ModelKey<PonyArmourModel<?>> INNER_PONY_ARMOR = register("armor/inner_pony_armor", PonyArmourModel::new);
|
||||
public static final ModelKey<PonyArmourModel<?>> OUTER_PONY_ARMOR = register("armor/outer_pony_armor", PonyArmourModel::new);
|
||||
public static final ModelKey<AbstractPonyModel<?>> INNER_VANILLA_ARMOR = register("armor/inner_vanilla_armor", PonyArmourModel::new);
|
||||
public static final ModelKey<AbstractPonyModel<?>> OUTER_VANILLA_ARMOR = register("armor/outer_vanilla_armor", PonyArmourModel::new);
|
||||
public static final ModelKey<AbstractPonyModel<?>> INNER_PONY_ARMOR = register("armor/inner_pony_armor", PonyArmourModel::new);
|
||||
public static final ModelKey<AbstractPonyModel<?>> OUTER_PONY_ARMOR = register("armor/outer_pony_armor", PonyArmourModel::new);
|
||||
|
||||
public static final GearModelKey<AbstractGearModel> STETSON = registerGear("stetson", Wearable.STETSON, t -> new WearableGear(t, Wearable.STETSON, BodyPart.HEAD, 0.15F));
|
||||
public static final GearModelKey<SaddleBags> SADDLEBAGS_BOTH = registerGear("saddlebags", Wearable.SADDLE_BAGS_BOTH, t -> new SaddleBags(t, Wearable.SADDLE_BAGS_BOTH));
|
||||
|
@ -83,7 +83,7 @@ public final class ModelType {
|
|||
@SuppressWarnings("unchecked")
|
||||
static <T extends Model & PonyModel<?>> PlayerModelKey<T> registerPlayer(String name, Race race,
|
||||
BiFunction<ModelPart, Boolean, T> constructor,
|
||||
MsonModel.Factory<PonyArmourModel<?>> armorFactory) {
|
||||
MsonModel.Factory<AbstractPonyModel<?>> armorFactory) {
|
||||
return (PlayerModelKey<T>)PLAYER_MODELS.computeIfAbsent(race, r -> new PlayerModelKey<T>(name, constructor, armorFactory));
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,6 @@ import org.jetbrains.annotations.Nullable;
|
|||
import com.minelittlepony.api.model.Models;
|
||||
import com.minelittlepony.api.model.PonyModel;
|
||||
import com.minelittlepony.client.MineLittlePony;
|
||||
import com.minelittlepony.client.model.armour.PonyArmourModel;
|
||||
import com.minelittlepony.mson.api.*;
|
||||
|
||||
import java.util.function.*;
|
||||
|
@ -16,11 +15,11 @@ import java.util.function.*;
|
|||
public record PlayerModelKey<M extends Model & PonyModel<?>> (
|
||||
ModelKey<M> steveKey,
|
||||
ModelKey<M> alexKey,
|
||||
MsonModel.Factory<PonyArmourModel<?>> armorFactory
|
||||
MsonModel.Factory<AbstractPonyModel<?>> armorFactory
|
||||
) {
|
||||
PlayerModelKey(String name,
|
||||
BiFunction<ModelPart, Boolean, M> modelFactory,
|
||||
MsonModel.Factory<PonyArmourModel<?>> armorFactory
|
||||
MsonModel.Factory<AbstractPonyModel<?>> armorFactory
|
||||
) {
|
||||
this(
|
||||
new ModelKeyImpl<>(MineLittlePony.id("races/steve/" + name), tree -> modelFactory.apply(tree, false)),
|
||||
|
|
|
@ -1,23 +1,25 @@
|
|||
package com.minelittlepony.client.model.armour;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.equipment.EquipmentModel;
|
||||
import net.minecraft.registry.Registries;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
import com.minelittlepony.client.model.AbstractPonyModel;
|
||||
import com.minelittlepony.mson.api.ModelKey;
|
||||
import com.minelittlepony.mson.api.Mson;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public interface ArmorModelRegistry {
|
||||
static final Map<Identifier, Optional<ModelKey<PonyArmourModel<?>>>> REGISTRY = new HashMap<>();
|
||||
static final Map<Identifier, Optional<ModelKey<AbstractPonyModel<?>>>> REGISTRY = new HashMap<>();
|
||||
|
||||
public static Optional<ModelKey<PonyArmourModel<?>>> getModelKey(Item item, ArmourLayer layer) {
|
||||
public static Optional<ModelKey<AbstractPonyModel<?>>> getModelKey(Item item, EquipmentModel.LayerType layerType) {
|
||||
Identifier id = Registries.ITEM.getId(item);
|
||||
if (id.getNamespace().equals("minecraft")) {
|
||||
return Optional.empty();
|
||||
}
|
||||
return REGISTRY.computeIfAbsent(id.withPath(p -> "armor/" + layer.name().toLowerCase(Locale.ROOT) + "_" + p + ".json"), i -> {
|
||||
return REGISTRY.computeIfAbsent(id.withPath(p -> "armor/" + layerType.name().toLowerCase(Locale.ROOT) + "_" + p + ".json"), i -> {
|
||||
return Optional.of(Mson.getInstance().registerModel(i, PonyArmourModel::new));
|
||||
}).filter(key -> key.getModelData().isPresent());
|
||||
}
|
||||
|
|
|
@ -1,23 +0,0 @@
|
|||
package com.minelittlepony.client.model.armour;
|
||||
|
||||
/**
|
||||
* The layer used to render a given armour piece.
|
||||
*/
|
||||
public enum ArmourLayer {
|
||||
/**
|
||||
* Hanging loose and sagging free
|
||||
*/
|
||||
OUTER,
|
||||
/**
|
||||
* Fits snugly to the player's model.
|
||||
*/
|
||||
INNER;
|
||||
|
||||
public int getLegacyId() {
|
||||
return ordinal() + 1;
|
||||
}
|
||||
|
||||
public boolean isInner() {
|
||||
return this == INNER;
|
||||
}
|
||||
}
|
|
@ -34,11 +34,11 @@ public interface ArmourRendererPlugin {
|
|||
return ArmourTextureResolver.INSTANCE;
|
||||
}
|
||||
|
||||
default void onArmourRendered(LivingEntityRenderState state, MatrixStack matrices, VertexConsumerProvider provider, EquipmentSlot armorSlot, ArmourLayer layer, ArmourType type) {
|
||||
default void onArmourRendered(LivingEntityRenderState state, MatrixStack matrices, VertexConsumerProvider provider, EquipmentSlot armorSlot, EquipmentModel.LayerType layerType, ArmourType type) {
|
||||
|
||||
}
|
||||
|
||||
default ItemStack[] getArmorStacks(BipedEntityRenderState state, EquipmentSlot armorSlot, ArmourLayer layer, ArmourType type) {
|
||||
default ItemStack[] getArmorStacks(BipedEntityRenderState state, EquipmentSlot armorSlot, EquipmentModel.LayerType layerType, ArmourType type) {
|
||||
return new ItemStack[] { switch (armorSlot) {
|
||||
case HEAD -> state.equippedHeadStack;
|
||||
case CHEST -> state.equippedChestStack;
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
package com.minelittlepony.client.model.armour;
|
||||
|
||||
import net.minecraft.item.equipment.EquipmentModel;
|
||||
|
||||
import com.minelittlepony.client.model.AbstractPonyModel;
|
||||
import com.minelittlepony.client.model.ModelType;
|
||||
import com.minelittlepony.mson.api.ModelKey;
|
||||
|
||||
|
@ -10,15 +13,15 @@ public enum ArmourVariant {
|
|||
LEGACY(ModelType.INNER_VANILLA_ARMOR, ModelType.OUTER_VANILLA_ARMOR),
|
||||
TRIM(ModelType.INNER_VANILLA_ARMOR, ModelType.OUTER_VANILLA_ARMOR);
|
||||
|
||||
private final Optional<ModelKey<PonyArmourModel<?>>> innerModel;
|
||||
private final Optional<ModelKey<PonyArmourModel<?>>> outerModel;
|
||||
private final Optional<ModelKey<AbstractPonyModel<?>>> innerModel;
|
||||
private final Optional<ModelKey<AbstractPonyModel<?>>> outerModel;
|
||||
|
||||
ArmourVariant(ModelKey<PonyArmourModel<?>> inner, ModelKey<PonyArmourModel<?>> outer) {
|
||||
ArmourVariant(ModelKey<AbstractPonyModel<?>> inner, ModelKey<AbstractPonyModel<?>> outer) {
|
||||
this.innerModel = Optional.of(inner);
|
||||
this.outerModel = Optional.of(outer);
|
||||
}
|
||||
|
||||
public Optional<ModelKey<PonyArmourModel<?>>> getDefaultModel(ArmourLayer layer) {
|
||||
return layer.isInner() ? innerModel : outerModel;
|
||||
public Optional<ModelKey<AbstractPonyModel<?>>> getDefaultModel(EquipmentModel.LayerType layerType) {
|
||||
return layerType == EquipmentModel.LayerType.HUMANOID_LEGGINGS ? innerModel : outerModel;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,6 @@ import net.minecraft.component.type.DyedColorComponent;
|
|||
import net.minecraft.entity.EquipmentSlot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.equipment.EquipmentModel;
|
||||
import net.minecraft.item.equipment.EquipmentModel.LayerType;
|
||||
import net.minecraft.item.equipment.trim.ArmorTrim;
|
||||
import net.minecraft.registry.tag.ItemTags;
|
||||
import net.minecraft.util.Colors;
|
||||
|
@ -21,7 +20,8 @@ import net.minecraft.util.math.ColorHelper;
|
|||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import com.minelittlepony.api.model.Models;
|
||||
import com.minelittlepony.api.model.PonyModel;
|
||||
import com.minelittlepony.client.model.AbstractPonyModel;
|
||||
import com.minelittlepony.client.model.ClientPonyModel;
|
||||
import com.minelittlepony.client.render.entity.state.PonyRenderState;
|
||||
|
||||
import java.util.*;
|
||||
|
@ -31,76 +31,87 @@ public class PonifiedEquipmentRenderer extends EquipmentRenderer {
|
|||
|
||||
private final EquipmentModelLoader modelLoader;
|
||||
|
||||
private @Nullable Set<EntityModel<?>> drawnModels;
|
||||
|
||||
public PonifiedEquipmentRenderer(EquipmentModelLoader modelLoader) {
|
||||
super(modelLoader, MinecraftClient.getInstance().getBakedModelManager().getAtlas(TexturedRenderLayers.ARMOR_TRIMS_ATLAS_TEXTURE));
|
||||
this.modelLoader = modelLoader;
|
||||
}
|
||||
|
||||
public <S extends PonyRenderState, V extends PonyArmourModel<S>> void render(
|
||||
public <S extends PonyRenderState, V extends ClientPonyModel<S>> void render(
|
||||
EquipmentSlot equipmentSlot,
|
||||
EquipmentModel.LayerType layerType,
|
||||
Identifier modelId,
|
||||
S entity,
|
||||
Models<? extends PonyModel<S>> models,
|
||||
Models<V> models,
|
||||
ItemStack stack,
|
||||
MatrixStack matrices,
|
||||
VertexConsumerProvider vertexConsumers,
|
||||
int light
|
||||
) {
|
||||
this.render(equipmentSlot, layerType, modelId, entity, models, stack, matrices, vertexConsumers, light, null);
|
||||
render(equipmentSlot, layerType, modelId, entity, models, stack, matrices, vertexConsumers, light, null);
|
||||
}
|
||||
|
||||
public <S extends PonyRenderState, V extends PonyArmourModel<S>> void render(
|
||||
public <S extends PonyRenderState, V extends ClientPonyModel<S>> void render(
|
||||
EquipmentSlot equipmentSlot,
|
||||
EquipmentModel.LayerType layerType,
|
||||
Identifier modelId,
|
||||
S entity,
|
||||
Models<? extends PonyModel<S>> models,
|
||||
Models<V> models,
|
||||
ItemStack stack,
|
||||
MatrixStack matrices,
|
||||
VertexConsumerProvider vertexConsumers,
|
||||
VertexConsumerProvider vertices,
|
||||
int light,
|
||||
@Nullable Identifier texture
|
||||
) {
|
||||
|
||||
List<EquipmentModel.Layer> layers = modelLoader.get(modelId).getLayers(layerType);
|
||||
if (!layers.isEmpty()) {
|
||||
ArmourRendererPlugin plugin = ArmourRendererPlugin.INSTANCE.get();
|
||||
int defaultColor = stack.isIn(ItemTags.DYEABLE) ? DyedColorComponent.getColor(stack, 0) : 0;
|
||||
float armorAlpha = plugin.getArmourAlpha(equipmentSlot, layerType);
|
||||
boolean hasGlint = plugin.getGlintAlpha(equipmentSlot, stack) > 0 && stack.hasGlint();
|
||||
|
||||
Set<EntityModel<?>> drawnModels = new HashSet<>();
|
||||
boolean hasGlint = plugin.getGlintAlpha(equipmentSlot, stack) > 0;
|
||||
|
||||
if (armorAlpha > 0) {
|
||||
for (EquipmentModel.Layer layer : layers) {
|
||||
int dyeColor = getDyeColor(layer, defaultColor);
|
||||
if (dyeColor != TRANSPARENT) {
|
||||
ArmourLayer armourLayer = layerType == LayerType.HUMANOID_LEGGINGS ? ArmourLayer.INNER : ArmourLayer.OUTER;
|
||||
ArmourTexture armorTexture = plugin.getTextureLookup().getTexture(stack, layerType, layer);
|
||||
Identifier layerTexture = layer.usePlayerTexture() && texture != null ? texture : armorTexture.texture();
|
||||
|
||||
VertexConsumer armorConsumer = getArmorVertexConsumer(plugin, equipmentSlot, vertexConsumers, layerTexture, layerType, hasGlint);
|
||||
@Nullable
|
||||
VertexConsumer armorConsumer = getArmorVertexConsumer(plugin, equipmentSlot, vertices, layerTexture, layerType, hasGlint);
|
||||
if (armorConsumer != null) {
|
||||
ArmourVariant variant = layer.usePlayerTexture() ? ArmourVariant.NORMAL : armorTexture.variant();
|
||||
models.getArmourModel(stack, armourLayer, variant).ifPresent(model -> {
|
||||
if (model.setAngles(entity, equipmentSlot, armourLayer, models.body())) {
|
||||
ArmourVariant variant = layer.usePlayerTexture() ? ArmourVariant.LEGACY : armorTexture.variant();
|
||||
AbstractPonyModel<?> model = models.getArmourModel(stack, layerType, variant).orElse(null);
|
||||
if (model != null) {
|
||||
model.setAngles(entity);
|
||||
models.body().copyTransforms(model);
|
||||
if (setVisibilities(model, equipmentSlot, layerType)) {
|
||||
model.render(matrices, armorConsumer, light, OverlayTexture.DEFAULT_UV, dyeColor);
|
||||
if (drawnModels == null) {
|
||||
drawnModels = new HashSet<>();
|
||||
}
|
||||
drawnModels.add(model);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ArmorTrim armorTrim = stack.get(DataComponentTypes.TRIM);
|
||||
if (armorTrim != null && plugin.getTrimAlpha(equipmentSlot, armorTrim, layerType) > 0) {
|
||||
VertexConsumer trimConsumer = plugin.getTrimConsumer(equipmentSlot, vertexConsumers, armorTrim, layerType, modelId);
|
||||
if (drawnModels != null) {
|
||||
@Nullable
|
||||
ArmorTrim armorTrim = stack.get(DataComponentTypes.TRIM);
|
||||
@Nullable
|
||||
VertexConsumer trimConsumer = armorTrim != null && plugin.getTrimAlpha(equipmentSlot, armorTrim, layerType) > 0 ? plugin.getTrimConsumer(equipmentSlot, vertices, armorTrim, layerType, modelId) : null;
|
||||
if (trimConsumer != null) {
|
||||
drawnModels.forEach(model -> model.render(matrices, trimConsumer, light, OverlayTexture.DEFAULT_UV));
|
||||
for (EntityModel<?> model : drawnModels) {
|
||||
model.render(matrices, trimConsumer, light, OverlayTexture.DEFAULT_UV);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
drawnModels = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -125,4 +136,19 @@ public class PonifiedEquipmentRenderer extends EquipmentRenderer {
|
|||
return Colors.WHITE;
|
||||
}
|
||||
|
||||
public static boolean setVisibilities(AbstractPonyModel<?> model, EquipmentSlot slot, EquipmentModel.LayerType layer) {
|
||||
model.setVisible(false);
|
||||
model.body.visible = slot == EquipmentSlot.CHEST;
|
||||
model.head.visible = layer == EquipmentModel.LayerType.HUMANOID && slot == EquipmentSlot.HEAD;
|
||||
|
||||
if (slot == (layer == EquipmentModel.LayerType.HUMANOID ? EquipmentSlot.FEET : EquipmentSlot.LEGS)) {
|
||||
model.rightArm.visible = true;
|
||||
model.leftArm.visible = true;
|
||||
model.rightLeg.visible = true;
|
||||
model.leftLeg.visible = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
return model.head.visible || model.body.visible;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,44 +1,13 @@
|
|||
package com.minelittlepony.client.model.armour;
|
||||
|
||||
import net.minecraft.client.model.ModelPart;
|
||||
import net.minecraft.client.render.entity.state.PlayerEntityRenderState;
|
||||
import net.minecraft.entity.EquipmentSlot;
|
||||
|
||||
import com.minelittlepony.api.model.PonyModel;
|
||||
import com.minelittlepony.client.model.AbstractPonyModel;
|
||||
import com.minelittlepony.client.model.ClientPonyModel;
|
||||
import com.minelittlepony.client.render.entity.state.PonyRenderState;
|
||||
|
||||
public class PonyArmourModel<S extends PonyRenderState> extends AbstractPonyModel<S> {
|
||||
|
||||
public class PonyArmourModel<T extends PonyRenderState> extends AbstractPonyModel<T> {
|
||||
public PonyArmourModel(ModelPart tree) {
|
||||
super(tree, false);
|
||||
}
|
||||
|
||||
public boolean setAngles(PlayerEntityRenderState state, EquipmentSlot slot, ArmourLayer layer, PonyModel<?> mainModel) {
|
||||
setAngles(state);
|
||||
if (!setVisibilities(slot, layer)) {
|
||||
return false;
|
||||
}
|
||||
if (mainModel instanceof ClientPonyModel abs) {
|
||||
abs.copyTransforms(this);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean setVisibilities(EquipmentSlot slot, ArmourLayer layer) {
|
||||
setVisible(false);
|
||||
body.visible = slot == EquipmentSlot.CHEST;
|
||||
head.visible = layer == ArmourLayer.OUTER && slot == EquipmentSlot.HEAD;
|
||||
|
||||
if (slot == (layer == ArmourLayer.OUTER ? EquipmentSlot.FEET : EquipmentSlot.LEGS)) {
|
||||
rightArm.visible = true;
|
||||
leftArm.visible = true;
|
||||
rightLeg.visible = true;
|
||||
leftLeg.visible = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
return head.visible || body.visible;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package com.minelittlepony.client.render.entity.feature;
|
||||
|
||||
import com.minelittlepony.api.model.Models;
|
||||
import com.minelittlepony.api.model.PonyModel;
|
||||
import com.minelittlepony.client.model.ClientPonyModel;
|
||||
import com.minelittlepony.client.model.armour.*;
|
||||
import com.minelittlepony.client.render.PonyRenderContext;
|
||||
|
@ -16,7 +15,6 @@ import net.minecraft.entity.EquipmentSlot;
|
|||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.item.*;
|
||||
import net.minecraft.item.equipment.EquipmentModel;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
|
@ -38,40 +36,36 @@ public class ArmourFeature<
|
|||
renderArmor(getModelWrapper(), matrices, provider, light, entity, limbDistance, limbAngle, equipmentRenderer);
|
||||
}
|
||||
|
||||
public static <S extends PonyRenderState, V extends PonyArmourModel<S>> void renderArmor(
|
||||
Models<? extends PonyModel<S>> pony, MatrixStack matrices,
|
||||
VertexConsumerProvider provider, int light, S entity,
|
||||
float limbDistance, float limbAngle, PonifiedEquipmentRenderer equipmentRenderer) {
|
||||
public static <S extends PonyRenderState, V extends ClientPonyModel<S>> void renderArmor(
|
||||
Models<V> pony, MatrixStack matrices,
|
||||
VertexConsumerProvider provider, int light, S entity,
|
||||
float limbDistance, float limbAngle, PonifiedEquipmentRenderer equipmentRenderer) {
|
||||
|
||||
for (EquipmentSlot i : EquipmentSlot.values()) {
|
||||
if (i.getType() == EquipmentSlot.Type.HUMANOID_ARMOR) {
|
||||
renderArmor(pony, matrices, provider, light, entity, limbDistance, limbAngle, i, ArmourLayer.INNER, equipmentRenderer);
|
||||
renderArmor(pony, matrices, provider, light, entity, limbDistance, limbAngle, i, ArmourLayer.OUTER, equipmentRenderer);
|
||||
renderArmor(pony, matrices, provider, light, entity, limbDistance, limbAngle, i, EquipmentModel.LayerType.HUMANOID_LEGGINGS, equipmentRenderer);
|
||||
renderArmor(pony, matrices, provider, light, entity, limbDistance, limbAngle, i, EquipmentModel.LayerType.HUMANOID, equipmentRenderer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static <S extends PonyRenderState, V extends PonyArmourModel<S>> void renderArmor(
|
||||
Models<? extends PonyModel<S>> models, MatrixStack matrices,
|
||||
private static <S extends PonyRenderState, V extends ClientPonyModel<S>> void renderArmor(
|
||||
Models<V> models, MatrixStack matrices,
|
||||
VertexConsumerProvider vertices, int light, S entity,
|
||||
float limbDistance, float limbAngle,
|
||||
EquipmentSlot armorSlot, ArmourLayer layer, PonifiedEquipmentRenderer equipmentRenderer) {
|
||||
EquipmentSlot armorSlot, EquipmentModel.LayerType layerType, PonifiedEquipmentRenderer equipmentRenderer) {
|
||||
|
||||
ArmourRendererPlugin plugin = ArmourRendererPlugin.INSTANCE.get();
|
||||
|
||||
for (ItemStack stack : plugin.getArmorStacks(entity, armorSlot, layer, ArmourRendererPlugin.ArmourType.ARMOUR)) {
|
||||
for (ItemStack stack : plugin.getArmorStacks(entity, armorSlot, layerType, ArmourRendererPlugin.ArmourType.ARMOUR)) {
|
||||
EquippableComponent equippableComponent = stack.get(DataComponentTypes.EQUIPPABLE);
|
||||
|
||||
if (hasModel(equippableComponent, armorSlot)) {
|
||||
EquipmentModel.LayerType layerType = layer == ArmourLayer.INNER
|
||||
? EquipmentModel.LayerType.HUMANOID_LEGGINGS
|
||||
: EquipmentModel.LayerType.HUMANOID;
|
||||
Identifier modelId = equippableComponent.model().orElseThrow();
|
||||
equipmentRenderer.render(armorSlot, layerType, modelId, entity, models, stack, matrices, vertices, light);
|
||||
equipmentRenderer.render(armorSlot, layerType, equippableComponent.model().orElseThrow(), entity, models, stack, matrices, vertices, light);
|
||||
}
|
||||
}
|
||||
|
||||
plugin.onArmourRendered(entity, matrices, vertices, armorSlot, layer, ArmourRendererPlugin.ArmourType.ARMOUR);
|
||||
plugin.onArmourRendered(entity, matrices, vertices, armorSlot, layerType, ArmourRendererPlugin.ArmourType.ARMOUR);
|
||||
}
|
||||
|
||||
private static boolean hasModel(@Nullable EquippableComponent component, EquipmentSlot slot) {
|
||||
|
|
|
@ -2,7 +2,6 @@ package com.minelittlepony.client.render.entity.feature;
|
|||
|
||||
import com.minelittlepony.api.model.BodyPart;
|
||||
import com.minelittlepony.client.model.ClientPonyModel;
|
||||
import com.minelittlepony.client.model.armour.ArmourLayer;
|
||||
import com.minelittlepony.client.model.armour.ArmourRendererPlugin;
|
||||
import com.minelittlepony.client.render.PonyRenderContext;
|
||||
import com.minelittlepony.client.render.entity.state.PlayerPonyRenderState;
|
||||
|
@ -16,6 +15,7 @@ import net.minecraft.client.render.entity.model.EntityModelLoader;
|
|||
import net.minecraft.client.render.entity.state.PlayerEntityRenderState;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.entity.EquipmentSlot;
|
||||
import net.minecraft.item.equipment.EquipmentModel;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
public class CapeFeature extends CapeFeatureRenderer {
|
||||
|
@ -63,7 +63,7 @@ public class CapeFeature extends CapeFeatureRenderer {
|
|||
matrices.pop();
|
||||
|
||||
if (rendered[0]) {
|
||||
plugin.onArmourRendered(player, matrices, vertices, EquipmentSlot.BODY, ArmourLayer.OUTER, ArmourRendererPlugin.ArmourType.CAPE);
|
||||
plugin.onArmourRendered(player, matrices, vertices, EquipmentSlot.BODY, EquipmentModel.LayerType.HUMANOID, ArmourRendererPlugin.ArmourType.CAPE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@ package com.minelittlepony.client.render.entity.feature;
|
|||
|
||||
import com.minelittlepony.api.model.BodyPart;
|
||||
import com.minelittlepony.client.model.*;
|
||||
import com.minelittlepony.client.model.armour.ArmourLayer;
|
||||
import com.minelittlepony.client.model.armour.ArmourRendererPlugin;
|
||||
import com.minelittlepony.client.render.PonyRenderContext;
|
||||
import com.minelittlepony.client.render.entity.state.PonyRenderState;
|
||||
|
@ -42,7 +41,7 @@ public class ElytraFeature<
|
|||
public void render(MatrixStack matrices, VertexConsumerProvider provider, int light, S state, float limbAngle, float limbDistance) {
|
||||
ArmourRendererPlugin plugin = ArmourRendererPlugin.INSTANCE.get();
|
||||
|
||||
for (ItemStack stack : plugin.getArmorStacks(state, EquipmentSlot.CHEST, ArmourLayer.OUTER, ArmourRendererPlugin.ArmourType.ELYTRA)) {
|
||||
for (ItemStack stack : plugin.getArmorStacks(state, EquipmentSlot.CHEST, EquipmentModel.LayerType.WINGS, ArmourRendererPlugin.ArmourType.ELYTRA)) {
|
||||
EquippableComponent equippable = stack.get(DataComponentTypes.EQUIPPABLE);
|
||||
|
||||
if (equippable != null && !equippable.model().isEmpty()) {
|
||||
|
@ -61,7 +60,7 @@ public class ElytraFeature<
|
|||
}
|
||||
}
|
||||
|
||||
plugin.onArmourRendered(state, matrices, provider, EquipmentSlot.BODY, ArmourLayer.OUTER, ArmourRendererPlugin.ArmourType.ELYTRA);
|
||||
plugin.onArmourRendered(state, matrices, provider, EquipmentSlot.BODY, EquipmentModel.LayerType.WINGS, ArmourRendererPlugin.ArmourType.ELYTRA);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
|
|
@ -8,6 +8,7 @@ import net.minecraft.client.util.math.MatrixStack;
|
|||
import net.minecraft.entity.EquipmentSlot;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.item.*;
|
||||
import net.minecraft.item.equipment.EquipmentModel;
|
||||
import net.minecraft.util.Colors;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.random.Random;
|
||||
|
@ -20,7 +21,6 @@ import com.minelittlepony.api.model.gear.Gear;
|
|||
import com.minelittlepony.api.pony.meta.Wearable;
|
||||
import com.minelittlepony.client.model.ClientPonyModel;
|
||||
import com.minelittlepony.client.model.ModelType;
|
||||
import com.minelittlepony.client.model.armour.ArmourLayer;
|
||||
import com.minelittlepony.client.model.armour.ArmourRendererPlugin;
|
||||
import com.minelittlepony.client.render.PonyRenderContext;
|
||||
import com.minelittlepony.client.render.entity.state.PonyRenderState;
|
||||
|
@ -65,7 +65,7 @@ public class GearFeature<
|
|||
}
|
||||
|
||||
boolean hasSkull = false;
|
||||
for (ItemStack skull : ArmourRendererPlugin.INSTANCE.get().getArmorStacks(entity, EquipmentSlot.HEAD, ArmourLayer.OUTER, ArmourRendererPlugin.ArmourType.SKULL)) {
|
||||
for (ItemStack skull : ArmourRendererPlugin.INSTANCE.get().getArmorStacks(entity, EquipmentSlot.HEAD, EquipmentModel.LayerType.HUMANOID, ArmourRendererPlugin.ArmourType.SKULL)) {
|
||||
if (skull.getItem() instanceof BlockItem b && (b.getBlock() instanceof SkullBlock || b.getBlock().getDefaultState().isSolidBlock(EmptyBlockView.INSTANCE, BlockPos.ORIGIN))) {
|
||||
hasSkull = true;
|
||||
break;
|
||||
|
|
|
@ -2,7 +2,6 @@ package com.minelittlepony.client.render.entity.feature;
|
|||
|
||||
import com.minelittlepony.api.model.BodyPart;
|
||||
import com.minelittlepony.client.model.ClientPonyModel;
|
||||
import com.minelittlepony.client.model.armour.ArmourLayer;
|
||||
import com.minelittlepony.client.model.armour.ArmourRendererPlugin;
|
||||
import com.minelittlepony.client.render.PonyRenderContext;
|
||||
import com.minelittlepony.client.render.blockentity.skull.PonySkullRenderer;
|
||||
|
@ -19,6 +18,7 @@ import net.minecraft.component.DataComponentTypes;
|
|||
import net.minecraft.component.type.EquippableComponent;
|
||||
import net.minecraft.entity.EquipmentSlot;
|
||||
import net.minecraft.item.*;
|
||||
import net.minecraft.item.equipment.EquipmentModel;
|
||||
|
||||
public class SkullFeature<
|
||||
S extends PonyRenderState,
|
||||
|
@ -42,7 +42,7 @@ public class SkullFeature<
|
|||
public void render(MatrixStack matrices, VertexConsumerProvider provider, int light, S state, float limbAngle, float limbDistance) {
|
||||
ArmourRendererPlugin plugin = ArmourRendererPlugin.INSTANCE.get();
|
||||
|
||||
for (ItemStack stack : plugin.getArmorStacks(state, EquipmentSlot.HEAD, ArmourLayer.OUTER, ArmourRendererPlugin.ArmourType.SKULL)) {
|
||||
for (ItemStack stack : plugin.getArmorStacks(state, EquipmentSlot.HEAD, EquipmentModel.LayerType.HUMANOID, ArmourRendererPlugin.ArmourType.SKULL)) {
|
||||
|
||||
BakedModel headModel = state.equippedHeadItemModel;
|
||||
|
||||
|
@ -83,6 +83,6 @@ public class SkullFeature<
|
|||
matrices.pop();
|
||||
}
|
||||
|
||||
plugin.onArmourRendered(state, matrices, provider, EquipmentSlot.BODY, ArmourLayer.OUTER, ArmourRendererPlugin.ArmourType.SKULL);
|
||||
plugin.onArmourRendered(state, matrices, provider, EquipmentSlot.BODY, EquipmentModel.LayerType.HUMANOID, ArmourRendererPlugin.ArmourType.SKULL);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue