From f03c2d709f9956f5ffff7338a8ca9a46cc0b275c Mon Sep 17 00:00:00 2001 From: Sollace Date: Sat, 12 Oct 2019 12:03:16 +0200 Subject: [PATCH] Bat ponies and changelings can now wear saddlebags, but they use a built in texture for it --- .../client/model/gear/IRenderContext.java | 7 +++++++ .../client/model/gear/SaddleBags.java | 7 ++++++- .../client/model/races/ModelBatpony.java | 10 ---------- .../client/model/races/ModelChangeling.java | 10 ---------- .../render/entities/player/RenderPonyPlayer.java | 13 +++++++++++++ .../java/com/minelittlepony/pony/meta/Race.java | 7 +++++++ .../textures/models/saddlebags.png | Bin 0 -> 4387 bytes 7 files changed, 33 insertions(+), 21 deletions(-) create mode 100644 src/main/resources/assets/minelittlepony/textures/models/saddlebags.png diff --git a/src/main/java/com/minelittlepony/client/model/gear/IRenderContext.java b/src/main/java/com/minelittlepony/client/model/gear/IRenderContext.java index 9eca7d00..039d8222 100644 --- a/src/main/java/com/minelittlepony/client/model/gear/IRenderContext.java +++ b/src/main/java/com/minelittlepony/client/model/gear/IRenderContext.java @@ -6,6 +6,8 @@ import net.minecraft.util.Identifier; import com.minelittlepony.model.IModel; import com.minelittlepony.model.gear.IGear; +import javax.annotation.Nullable; + public interface IRenderContext { IRenderContext NULL = (e, g) -> null; @@ -14,5 +16,10 @@ public interface IRenderContext { return gear.canRender(model, entity); } + @Nullable + default IModel getEntityModel() { + return null; + } + Identifier getDefaultTexture(T entity, IGear gear); } diff --git a/src/main/java/com/minelittlepony/client/model/gear/SaddleBags.java b/src/main/java/com/minelittlepony/client/model/gear/SaddleBags.java index 837940ba..e31aa9f8 100644 --- a/src/main/java/com/minelittlepony/client/model/gear/SaddleBags.java +++ b/src/main/java/com/minelittlepony/client/model/gear/SaddleBags.java @@ -4,6 +4,7 @@ import com.minelittlepony.client.util.render.plane.PlaneRenderer; import com.minelittlepony.model.BodyPart; import com.minelittlepony.model.IModel; import com.minelittlepony.model.IPegasus; +import com.minelittlepony.pony.meta.Race; import com.minelittlepony.pony.meta.Wearable; import com.mojang.blaze3d.platform.GlStateManager; @@ -15,6 +16,8 @@ import net.minecraft.util.math.MathHelper; public class SaddleBags extends AbstractGear { + public static final Identifier TEXTURE = new Identifier("minelittlepony", "textures/models/saddlebags.png"); + private PlaneRenderer leftBag; private PlaneRenderer rightBag; @@ -137,7 +140,9 @@ public class SaddleBags extends AbstractGear { @Override public Identifier getTexture(T entity, IRenderContext context) { + if (context.getEntityModel() != null && context.getEntityModel().getMetadata().getRace().isEquivalentTo(Race.CHANGELING)) { + return TEXTURE; + } return context.getDefaultTexture(entity, this); } - } diff --git a/src/main/java/com/minelittlepony/client/model/races/ModelBatpony.java b/src/main/java/com/minelittlepony/client/model/races/ModelBatpony.java index 8c2ff36c..1e6a2c8f 100644 --- a/src/main/java/com/minelittlepony/client/model/races/ModelBatpony.java +++ b/src/main/java/com/minelittlepony/client/model/races/ModelBatpony.java @@ -5,7 +5,6 @@ import net.minecraft.entity.LivingEntity; import com.minelittlepony.client.model.components.BatWings; import com.minelittlepony.client.model.components.PonyEars; import com.minelittlepony.client.util.render.PonyRenderer; -import com.minelittlepony.pony.meta.Wearable; public class ModelBatpony extends ModelPegasus { @@ -23,13 +22,4 @@ public class ModelBatpony extends ModelPegasus { ears = new PonyEars(head, true); ears.init(yOffset, stretch); } - - @Override - public boolean isWearing(Wearable wearable) { - if (wearable == Wearable.SADDLE_BAGS) { - return false; - } - - return super.isWearing(wearable); - } } diff --git a/src/main/java/com/minelittlepony/client/model/races/ModelChangeling.java b/src/main/java/com/minelittlepony/client/model/races/ModelChangeling.java index 5195f176..69b453ed 100644 --- a/src/main/java/com/minelittlepony/client/model/races/ModelChangeling.java +++ b/src/main/java/com/minelittlepony/client/model/races/ModelChangeling.java @@ -4,7 +4,6 @@ import net.minecraft.entity.LivingEntity; import net.minecraft.util.math.MathHelper; import com.minelittlepony.client.model.components.BugWings; -import com.minelittlepony.pony.meta.Wearable; public class ModelChangeling extends ModelAlicorn { @@ -29,13 +28,4 @@ public class ModelChangeling extends ModelAlicorn { } return WING_ROT_Z_SNEAK; } - - @Override - public boolean isWearing(Wearable wearable) { - if (wearable == Wearable.SADDLE_BAGS) { - return false; - } - - return super.isWearing(wearable); - } } diff --git a/src/main/java/com/minelittlepony/client/render/entities/player/RenderPonyPlayer.java b/src/main/java/com/minelittlepony/client/render/entities/player/RenderPonyPlayer.java index 016ce369..35ecba16 100644 --- a/src/main/java/com/minelittlepony/client/render/entities/player/RenderPonyPlayer.java +++ b/src/main/java/com/minelittlepony/client/render/entities/player/RenderPonyPlayer.java @@ -3,6 +3,7 @@ package com.minelittlepony.client.render.entities.player; import com.minelittlepony.client.MineLittlePony; import com.minelittlepony.client.model.ClientPonyModel; import com.minelittlepony.client.model.ModelWrapper; +import com.minelittlepony.client.model.gear.SaddleBags; import com.minelittlepony.client.render.DebugBoundingBoxRenderer; import com.minelittlepony.client.render.IPonyRender; import com.minelittlepony.client.render.RenderPony; @@ -14,7 +15,9 @@ import com.minelittlepony.client.render.layer.LayerPonyArmor; import com.minelittlepony.client.render.layer.LayerPonyCape; import com.minelittlepony.client.render.layer.LayerPonyCustomHead; import com.minelittlepony.client.render.layer.LayerPonyElytra; +import com.minelittlepony.model.gear.IGear; import com.minelittlepony.pony.IPony; +import com.minelittlepony.pony.meta.Race; import com.mojang.blaze3d.platform.GlStateManager; import java.util.List; @@ -186,4 +189,14 @@ public class RenderPonyPlayer extends PlayerEntityRenderer implements IPonyRende return MineLittlePony.getInstance().getManager().getPony(entity); } + @Override + public Identifier getDefaultTexture(AbstractClientPlayerEntity entity, IGear gear) { + if (gear == LayerGear.SADDLE_BAGS) { + if (getInternalRenderer().getModel().getMetadata().getRace() == Race.BATPONY) { + return SaddleBags.TEXTURE; + } + } + + return IPonyRender.super.getDefaultTexture(entity, gear); + } } diff --git a/src/main/java/com/minelittlepony/pony/meta/Race.java b/src/main/java/com/minelittlepony/pony/meta/Race.java index a6823c36..f1f807ca 100644 --- a/src/main/java/com/minelittlepony/pony/meta/Race.java +++ b/src/main/java/com/minelittlepony/pony/meta/Race.java @@ -87,6 +87,13 @@ public enum Race implements ITriggerPixelMapped { return getAlias() != this; } + /** + * Returns true if both races resolve to the same value. + */ + public boolean isEquivalentTo(Race other) { + return getAlias() == other.getAlias(); + } + /** * Gets the actual race determined by the given pony level. * PonyLevel.HUMANS would force all races to be humans. diff --git a/src/main/resources/assets/minelittlepony/textures/models/saddlebags.png b/src/main/resources/assets/minelittlepony/textures/models/saddlebags.png new file mode 100644 index 0000000000000000000000000000000000000000..d1a9395388cfa704dcfbad246bb2e8b01140cdcc GIT binary patch literal 4387 zcmV+;5!~*HP)uJ@VVD_UC<6{NG_fI~0ue<-1QkJoA_k0xBC#Thg@9ne9*`iQ#9$Or zQF$}6R&?d%y_c8YA7_1QpS|}zXYYO1x&V;8{kgn!SPFnNo`4_X6{c}T{8k*B#$jdxfFg<9uYy1K45IaYvHg`_dOZM)Sy63ve6hvv z1)yUy0P^?0*fb9UASvow`@mQCp^4`uNg&9uGcn1|&Nk+9SjOUl{-OWr@Hh0;_l(8q z{wNRKos+;6rV8ldy0Owz(}jF`W(JeRp&R{qi2rfmU!TJ;gp(Kmm5I1s5m_f-n#TRsj}B0%?E`vOzxB2#P=n*a3EfYETOrKoe*ICqM@{4K9Go;5xVgZi5G4 z1dM~{UdP6d+Yd3o?MrAqM0Kc|iV92owdyL5UC#5<>aVCa44|hpM4E zs0sQWIt5*Tu0n&*J!lk~f_{hI!w5`*sjxDv4V%CW*ah~3!{C*0BD@;TgA3v9a1~q+ zAA{TB3-ERLHar49hi4Ih5D^-ph8Q6X#0?2VqLBoIkE}zAkxHZUgRb+f=nat zP#6>iMMoK->`~sRLq)(kHo*Vn{;LcG6+edD1=7D>9j^O?D{Qg|tCDK{ym)H7&wDr6*;uGTJg8GHjVbnL{!cWyUB7MT6o-VNo_w8Yq`2<5Ub)hw4L3rj}5@qxMs0 zWMyP6Wy582WNT#4$d1qunl{acmP#w5ouJ*Jy_Zv#bCKi7ZIf$}8d zZdVy&)L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