Bat ponies and changelings can now wear saddlebags, but they use a built in texture for it

This commit is contained in:
Sollace 2019-10-12 12:03:16 +02:00
parent f4b26bb5e6
commit f03c2d709f
7 changed files with 33 additions and 21 deletions

View file

@ -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<T extends Entity, M extends IModel> {
IRenderContext<?, ?> NULL = (e, g) -> null;
@ -14,5 +16,10 @@ public interface IRenderContext<T extends Entity, M extends IModel> {
return gear.canRender(model, entity);
}
@Nullable
default IModel getEntityModel() {
return null;
}
Identifier getDefaultTexture(T entity, IGear gear);
}

View file

@ -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 <T extends Entity> Identifier getTexture(T entity, IRenderContext<T, ?> context) {
if (context.getEntityModel() != null && context.getEntityModel().getMetadata().getRace().isEquivalentTo(Race.CHANGELING)) {
return TEXTURE;
}
return context.getDefaultTexture(entity, this);
}
}

View file

@ -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<T extends LivingEntity> extends ModelPegasus<T> {
@ -23,13 +22,4 @@ public class ModelBatpony<T extends LivingEntity> extends ModelPegasus<T> {
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);
}
}

View file

@ -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<T extends LivingEntity> extends ModelAlicorn<T> {
@ -29,13 +28,4 @@ public class ModelChangeling<T extends LivingEntity> extends ModelAlicorn<T> {
}
return WING_ROT_Z_SNEAK;
}
@Override
public boolean isWearing(Wearable wearable) {
if (wearable == Wearable.SADDLE_BAGS) {
return false;
}
return super.isWearing(wearable);
}
}

View file

@ -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);
}
}

View file

@ -87,6 +87,13 @@ public enum Race implements ITriggerPixelMapped<Race> {
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.

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB