Fix armour
|
@ -1,6 +1,5 @@
|
|||
package com.minelittlepony.api.model;
|
||||
|
||||
import net.minecraft.item.ArmorItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Util;
|
||||
|
||||
|
@ -35,7 +34,7 @@ public record Models<M extends PonyModel<?>> (
|
|||
|
||||
public Optional<PonyArmourModel<?>> getArmourModel(ItemStack stack, ArmourLayer layer, ArmourVariant variant) {
|
||||
return ArmorModelRegistry.getModelKey(stack.getItem(), layer)
|
||||
.or(() -> variant.getDefaultModel(layer).filter(l -> stack.getItem() instanceof ArmorItem))
|
||||
.or(() -> variant.getDefaultModel(layer))
|
||||
.map(armor);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ public record ArmourTexture(Identifier texture, ArmourVariant variant) {
|
|||
|
||||
public Stream<ArmourTexture> ponify() {
|
||||
if (!PonyConfig.getInstance().disablePonifiedArmour.get()) {
|
||||
return Stream.of(this, modern(texture().withPath(p -> p.replace("humanoid", "ponified"))));
|
||||
return Stream.of(modern(texture().withPath(p -> p.replace("humanoid", "ponified"))), this);
|
||||
}
|
||||
return Stream.of(this);
|
||||
}
|
||||
|
|
|
@ -77,6 +77,7 @@ public class ArmourTextureResolver implements ArmourTextureLookup, IdentifiableR
|
|||
|
||||
@Override
|
||||
public ArmourTexture getTexture(ItemStack stack, EquipmentModel.LayerType layerType, EquipmentModel.Layer layer) {
|
||||
layerCache.invalidateAll();
|
||||
return layerCache.getUnchecked(new ArmourParameters(layer, layerType, getCustom(stack)));
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ import net.minecraft.client.MinecraftClient;
|
|||
import net.minecraft.client.render.*;
|
||||
import net.minecraft.client.render.entity.equipment.EquipmentModelLoader;
|
||||
import net.minecraft.client.render.entity.equipment.EquipmentRenderer;
|
||||
import net.minecraft.client.render.entity.model.EntityModel;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.component.DataComponentTypes;
|
||||
import net.minecraft.component.type.DyedColorComponent;
|
||||
|
@ -13,6 +14,7 @@ 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;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.ColorHelper;
|
||||
|
||||
|
@ -25,6 +27,7 @@ import com.minelittlepony.client.render.entity.state.PonyRenderState;
|
|||
import java.util.*;
|
||||
|
||||
public class PonifiedEquipmentRenderer extends EquipmentRenderer {
|
||||
private static final int TRANSPARENT = 0;
|
||||
|
||||
private final EquipmentModelLoader modelLoader;
|
||||
|
||||
|
@ -63,30 +66,27 @@ public class PonifiedEquipmentRenderer extends EquipmentRenderer {
|
|||
List<EquipmentModel.Layer> layers = modelLoader.get(modelId).getLayers(layerType);
|
||||
if (!layers.isEmpty()) {
|
||||
ArmourRendererPlugin plugin = ArmourRendererPlugin.INSTANCE.get();
|
||||
int i = stack.isIn(ItemTags.DYEABLE) ? DyedColorComponent.getColor(stack, 0) : 0;
|
||||
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<V> drawnModels = new HashSet<>();
|
||||
Set<EntityModel<?>> drawnModels = new HashSet<>();
|
||||
|
||||
if (armorAlpha > 0) {
|
||||
for (EquipmentModel.Layer layer : layers) {
|
||||
int j = getDyeColor(layer, i);
|
||||
if (j != 0) {
|
||||
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();
|
||||
Identifier layerTexture = layer.usePlayerTexture() && texture != null ? texture : armorTexture.texture();
|
||||
|
||||
VertexConsumer armorConsumer = plugin.getArmourConsumer(equipmentSlot, vertexConsumers, layerTexture, layerType);
|
||||
VertexConsumer armorConsumer = getArmorVertexConsumer(plugin, equipmentSlot, vertexConsumers, layerTexture, layerType, hasGlint);
|
||||
if (armorConsumer != null) {
|
||||
ArmourVariant variant = layer.usePlayerTexture() ? ArmourVariant.NORMAL : armorTexture.variant();
|
||||
models.getArmourModel(stack, armourLayer, variant).ifPresent(model -> {
|
||||
VertexConsumer glintConsumer = hasGlint ? plugin.getGlintConsumer(equipmentSlot, vertexConsumers, layerType) : null;
|
||||
if (model.poseModel(equipmentSlot, armourLayer, models.body())) {
|
||||
model.setAngles(entity);
|
||||
model.render(matrices, glintConsumer != null ? VertexConsumers.union(plugin.getGlintConsumer(equipmentSlot, vertexConsumers, layerType), armorConsumer) : armorConsumer, light, OverlayTexture.DEFAULT_UV, j);
|
||||
if (model.setAngles(entity, equipmentSlot, armourLayer, models.body())) {
|
||||
model.render(matrices, armorConsumer, light, OverlayTexture.DEFAULT_UV, dyeColor);
|
||||
drawnModels.add(model);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -98,22 +98,31 @@ public class PonifiedEquipmentRenderer extends EquipmentRenderer {
|
|||
if (armorTrim != null && plugin.getTrimAlpha(equipmentSlot, armorTrim, layerType) > 0) {
|
||||
VertexConsumer trimConsumer = plugin.getTrimConsumer(equipmentSlot, vertexConsumers, armorTrim, layerType, modelId);
|
||||
if (trimConsumer != null) {
|
||||
drawnModels.forEach(model -> {
|
||||
model.render(matrices, trimConsumer, light, OverlayTexture.DEFAULT_UV);
|
||||
});
|
||||
drawnModels.forEach(model -> model.render(matrices, trimConsumer, light, OverlayTexture.DEFAULT_UV));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static VertexConsumer getArmorVertexConsumer(ArmourRendererPlugin plugin, EquipmentSlot slot, VertexConsumerProvider provider, Identifier texture, EquipmentModel.LayerType layerType, boolean glint) {
|
||||
VertexConsumer armorConsumer = plugin.getArmourConsumer(slot, provider, texture, layerType);
|
||||
if (armorConsumer != null) {
|
||||
VertexConsumer glintConsumer = glint ? plugin.getGlintConsumer(slot, provider, layerType) : null;
|
||||
if (glintConsumer != null) {
|
||||
return VertexConsumers.union(glintConsumer, armorConsumer);
|
||||
}
|
||||
}
|
||||
return armorConsumer;
|
||||
}
|
||||
|
||||
private static int getDyeColor(EquipmentModel.Layer layer, int dyeColor) {
|
||||
Optional<EquipmentModel.Dyeable> optional = layer.dyeable();
|
||||
if (optional.isPresent()) {
|
||||
int i = (Integer)((EquipmentModel.Dyeable)optional.get()).colorWhenUndyed().map(ColorHelper::fullAlpha).orElse(0);
|
||||
return dyeColor != 0 ? dyeColor : i;
|
||||
} else {
|
||||
return -1;
|
||||
int i = optional.get().colorWhenUndyed().map(ColorHelper::fullAlpha).orElse(0);
|
||||
return dyeColor != TRANSPARENT ? dyeColor : i;
|
||||
}
|
||||
return Colors.WHITE;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
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;
|
||||
|
@ -14,7 +15,8 @@ public class PonyArmourModel<S extends PonyRenderState> extends AbstractPonyMode
|
|||
super(tree, false);
|
||||
}
|
||||
|
||||
public boolean poseModel(EquipmentSlot slot, ArmourLayer layer, PonyModel<?> mainModel) {
|
||||
public boolean setAngles(PlayerEntityRenderState state, EquipmentSlot slot, ArmourLayer layer, PonyModel<?> mainModel) {
|
||||
setAngles(state);
|
||||
if (!setVisibilities(slot, layer)) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -18,6 +18,8 @@ import net.minecraft.item.*;
|
|||
import net.minecraft.item.equipment.EquipmentModel;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class ArmourFeature<
|
||||
T extends LivingEntity,
|
||||
S extends PonyRenderState,
|
||||
|
@ -60,7 +62,7 @@ public class ArmourFeature<
|
|||
for (ItemStack stack : plugin.getArmorStacks(entity, armorSlot, layer, ArmourRendererPlugin.ArmourType.ARMOUR)) {
|
||||
EquippableComponent equippableComponent = stack.get(DataComponentTypes.EQUIPPABLE);
|
||||
|
||||
if (equippableComponent != null && hasModel(equippableComponent, armorSlot)) {
|
||||
if (hasModel(equippableComponent, armorSlot)) {
|
||||
EquipmentModel.LayerType layerType = layer == ArmourLayer.INNER
|
||||
? EquipmentModel.LayerType.HUMANOID_LEGGINGS
|
||||
: EquipmentModel.LayerType.HUMANOID;
|
||||
|
@ -72,7 +74,7 @@ public class ArmourFeature<
|
|||
plugin.onArmourRendered(entity, matrices, vertices, armorSlot, layer, ArmourRendererPlugin.ArmourType.ARMOUR);
|
||||
}
|
||||
|
||||
private static boolean hasModel(EquippableComponent component, EquipmentSlot slot) {
|
||||
return component.model().isPresent() && component.slot() == slot;
|
||||
private static boolean hasModel(@Nullable EquippableComponent component, EquipmentSlot slot) {
|
||||
return component != null && component.model().isPresent() && component.slot() == slot;
|
||||
}
|
||||
}
|
||||
|
|
Before Width: | Height: | Size: 450 B After Width: | Height: | Size: 1 KiB |
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.6 KiB |
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 1 KiB After Width: | Height: | Size: 450 B |
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.7 KiB |
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.6 KiB |
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.1 KiB |