diff --git a/src/main/java/com/minelittlepony/client/render/entity/feature/GearFeature.java b/src/main/java/com/minelittlepony/client/render/entity/feature/GearFeature.java index dca8d303..da0607a5 100644 --- a/src/main/java/com/minelittlepony/client/render/entity/feature/GearFeature.java +++ b/src/main/java/com/minelittlepony/client/render/entity/feature/GearFeature.java @@ -3,7 +3,6 @@ package com.minelittlepony.client.render.entity.feature; import net.minecraft.client.render.*; import net.minecraft.client.render.entity.model.EntityModel; import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.entity.Entity; import net.minecraft.entity.LivingEntity; import net.minecraft.util.math.random.Random; @@ -35,13 +34,13 @@ public class GearFeature & IPon MOD_GEARS.stream().map(e -> new Entry(e.get(), Wearable.NONE)) ).collect(Collectors.toList()); - private final LoadingCache> randomisedGearCache = CacheBuilder.newBuilder() + private final LoadingCache> randomisedGearCache = CacheBuilder.newBuilder() .expireAfterAccess(3, TimeUnit.MINUTES) - .build(CacheLoader.from(entity -> { + .build(CacheLoader.from(uuid -> { List randomizedOrder = new ArrayList<>(); List pool = new ArrayList<>(gears); - Random rng = Random.create(entity.getUuid().getLeastSignificantBits()); + Random rng = Random.create(uuid.getLeastSignificantBits()); while (!pool.isEmpty()) { randomizedOrder.add(pool.remove(rng.nextInt(pool.size() + 1) % pool.size())); @@ -63,7 +62,7 @@ public class GearFeature & IPon final Map renderStackingOffsets = new HashMap<>(); - randomisedGearCache.getUnchecked(entity) + randomisedGearCache.getUnchecked(entity.getUuid()) .stream() .filter(entry -> getContext().shouldRender(model, entity, entry.wearable, entry.gear)) .forEach(entry -> { diff --git a/src/main/java/com/minelittlepony/client/render/entity/npc/AbstractNpcRenderer.java b/src/main/java/com/minelittlepony/client/render/entity/npc/AbstractNpcRenderer.java index 4d54c29d..657509e9 100644 --- a/src/main/java/com/minelittlepony/client/render/entity/npc/AbstractNpcRenderer.java +++ b/src/main/java/com/minelittlepony/client/render/entity/npc/AbstractNpcRenderer.java @@ -13,6 +13,7 @@ import com.minelittlepony.api.pony.meta.Race; import com.minelittlepony.api.pony.meta.Wearable; import com.minelittlepony.client.model.*; import com.minelittlepony.client.render.entity.PonyRenderer; +import com.minelittlepony.client.render.entity.feature.*; import com.minelittlepony.client.render.entity.npc.textures.*; import java.util.HashMap; @@ -36,6 +37,12 @@ abstract class AbstractNpcRenderer addFeature(clothing); } + @Override + protected void addLayers(EntityRendererFactory.Context context) { + addFeature(createItemHoldingLayer()); + addFeature(new GearFeature<>(this)); + } + @Override public boolean shouldRender(ClientPonyModel model, T entity, Wearable wearable, IGear gear) { @@ -58,6 +65,7 @@ abstract class AbstractNpcRenderer return super.shouldRender(model, entity, wearable, gear); } + @Override public void render(T entity, float entityYaw, float tickDelta, MatrixStack stack, VertexConsumerProvider renderContext, int lightUv) { model = manager.setModel(models.computeIfAbsent(getEntityPony(entity).race(), this::createModel)).body();