Fixed tiny silly ponies reverting to normal villagers when they grow up

# Conflicts:
#	src/main/java/com/minelittlepony/client/render/entity/npc/textures/SillyPonyTextureSupplier.java
This commit is contained in:
Sollace 2023-10-05 20:28:29 +01:00
parent fa0c903c0f
commit 9f77999baf
No known key found for this signature in database
GPG key ID: E52FACE7B5C773DB
2 changed files with 9 additions and 18 deletions

View file

@ -27,7 +27,7 @@ abstract class AbstractNpcRenderer<T extends MobEntity & VillagerDataContainer>
private final NpcClothingFeature<T, ClientPonyModel<T>, AbstractNpcRenderer<T>> clothing;
public AbstractNpcRenderer(EntityRendererFactory.Context context, String type, TextureSupplier<T> textureSupplier, TextureSupplier<String> formatter) {
super(context, ModelType.getPlayerModel(Race.EARTH).getKey(false), new SillyPonyTextureSupplier<>(textureSupplier, formatter));
super(context, ModelType.getPlayerModel(Race.EARTH).getKey(false), SillyPonyTextureSupplier.create(textureSupplier, formatter));
entityType = type;
clothing = new NpcClothingFeature<>(this, entityType);
addFeature(clothing);

View file

@ -4,22 +4,13 @@ import net.minecraft.entity.LivingEntity;
import net.minecraft.util.Identifier;
import net.minecraft.village.VillagerDataContainer;
public class SillyPonyTextureSupplier<T extends LivingEntity & VillagerDataContainer> implements TextureSupplier<T> {
private final TextureSupplier<T> fallback;
private final Identifier egg;
private final Identifier egg2;
public SillyPonyTextureSupplier(TextureSupplier<T> fallback, TextureSupplier<String> formatter) {
this.fallback = fallback;
this.egg = formatter.apply("silly_pony");
this.egg2 = formatter.apply("tiny_silly_pony");
}
@Override
public Identifier apply(T entity) {
return isBestPony(entity) ? (entity.isBaby() ? egg2 : egg) : fallback.apply(entity);
public class SillyPonyTextureSupplier {
public static <T extends LivingEntity & VillagerDataContainer> TextureSupplier<T> create(TextureSupplier<T> fallback, TextureSupplier<String> formatter) {
Identifier egg = formatter.apply("silly_pony");
Identifier egg2 = formatter.apply("tiny_silly_pony");
return entity -> {
return isBestPony(entity) ? ("Dinky".equals(entity.getCustomName().getString()) ? egg2 : egg) : fallback.apply(entity);
};
}
public static boolean isBestPony(LivingEntity entity) {
@ -27,7 +18,7 @@ public class SillyPonyTextureSupplier<T extends LivingEntity & VillagerDataConta
return false;
}
String name = entity.getCustomName().getString();
return "Derpy".equals(name) || (entity.isBaby() && "Dinky".equals(name));
return "Derpy".equals(name) || "Dinky".equals(name);
}
public static boolean isCrownPony(LivingEntity entity) {