Wings of icarus, bat pony, and pegasus wings now render on the pony model

This commit is contained in:
Sollace 2022-12-28 19:54:44 +01:00
parent 3b69c95ac5
commit 86039d4611
8 changed files with 112 additions and 7 deletions

View file

@ -2,11 +2,10 @@ package com.minelittlepony.unicopia.client.minelittlepony;
import java.util.Optional;
import com.minelittlepony.api.model.IModel;
import com.minelittlepony.api.model.ModelAttributes;
import com.minelittlepony.api.model.*;
import com.minelittlepony.api.model.fabric.PonyModelPrepareCallback;
import com.minelittlepony.api.model.gear.IGear;
import com.minelittlepony.client.MineLittlePony;
import com.minelittlepony.api.pony.IPony;
import com.minelittlepony.client.render.LevitatingItemRenderer;
import com.minelittlepony.unicopia.*;
import com.minelittlepony.unicopia.client.render.PlayerPoser.Animation;
@ -33,7 +32,8 @@ public class Main extends MineLPDelegate implements ClientModInitializer {
PonyModelPrepareCallback.EVENT.register(this::onPonyModelPrepared);
IGear.register(() -> new BangleGear(TrinketsDelegate.MAINHAND));
IGear.register(() -> new BangleGear(TrinketsDelegate.OFFHAND));
IGear.register(() -> new HeldEntityGear());
IGear.register(HeldEntityGear::new);
IGear.register(WingsGear::new);
IGear.register(AmuletGear::new);
IGear.register(GlassesGear::new);
}
@ -48,7 +48,7 @@ public class Main extends MineLPDelegate implements ClientModInitializer {
Pony pony = Pony.of((PlayerEntity)entity);
if (pony.getMotion().isFlying()) {
model.getAttributes().wingAngle = MathHelper.clamp(pony.getMotion().getWingAngle() / 3 - (float)Math.PI * 0.7F, -3, 0);
model.getAttributes().wingAngle = MathHelper.clamp(pony.getMotion().getWingAngle() / 3F - (float)Math.PI * 0.4F, -2, 0);
Vec3d motion = entity.getVelocity();
double zMotion = Math.sqrt(motion.x * motion.x + motion.z * motion.z);
@ -71,7 +71,16 @@ public class Main extends MineLPDelegate implements ClientModInitializer {
@Override
public Race getPlayerPonyRace(PlayerEntity player) {
switch (MineLittlePony.getInstance().getManager().getPony(player).race()) {
return toUnicopiaRace(IPony.getManager().getPony(player).race());
}
@Override
public Race getRace(Entity entity) {
return IPony.getManager().getPony(entity).map(IPony::race).map(Main::toUnicopiaRace).orElse(Race.HUMAN);
}
private static Race toUnicopiaRace(com.minelittlepony.api.pony.meta.Race race) {
switch (race) {
case ALICORN:
return Race.ALICORN;
case CHANGELING:

View file

@ -7,6 +7,7 @@ import com.minelittlepony.unicopia.Race;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.render.VertexConsumer;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.Identifier;
@ -28,6 +29,10 @@ public class MineLPDelegate {
return Race.HUMAN;
}
public Race getRace(Entity entity) {
return Race.HUMAN;
}
public Optional<VertexConsumer> getItemBuffer(VertexConsumerProvider vertexConsumers, Identifier texture) {
return Optional.empty();
}

View file

@ -0,0 +1,91 @@
package com.minelittlepony.unicopia.client.minelittlepony;
import java.util.UUID;
import com.minelittlepony.api.model.*;
import com.minelittlepony.api.model.gear.IGear;
import com.minelittlepony.api.pony.*;
import com.minelittlepony.client.model.ClientPonyModel;
import com.minelittlepony.client.model.ModelType;
import com.minelittlepony.client.model.entity.race.PegasusModel;
import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.Unicopia;
import com.minelittlepony.unicopia.entity.*;
import com.minelittlepony.unicopia.entity.player.Pony;
import net.minecraft.client.model.ModelPart;
import net.minecraft.client.render.VertexConsumer;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.util.Identifier;
class WingsGear implements IGear {
private static final Identifier ICARUS_WINGS = Unicopia.id("textures/models/wings/icarus_pony.png");
private static final Identifier ICARUS_WINGS_CORRUPTED = Unicopia.id("textures/models/wings/icarus_corrupted_pony.png");
private static final Identifier PEGASUS_WINGS = Unicopia.id("textures/models/wings/pegasus_pony.png");
private static final Identifier BAT_WINGS = Unicopia.id("textures/models/wings/bat_pony.png");
private final Model model = ModelType.PEGASUS.steveKey().createModel(Model::new);
@Override
public boolean canRender(IModel model, Entity entity) {
return entity instanceof LivingEntity l
&& !MineLPDelegate.getInstance().getRace(entity).canFly()
&& (AmuletSelectors.PEGASUS_AMULET.test(l) || Equine.of(entity).filter(this::canRender).isPresent());
}
protected boolean canRender(Equine<?> equine) {
if (equine instanceof Pony pony) {
return pony.getObservedSpecies().canInteractWithClouds();
}
return equine.getSpecies().canFly();
}
@Override
public BodyPart getGearLocation() {
return BodyPart.BODY;
}
@Override
public <T extends Entity> Identifier getTexture(T entity, Context<T, ?> context) {
Living<?> living = Living.living(entity);
if (living == null) {
return DefaultPonySkinHelper.STEVE;
}
if (AmuletSelectors.PEGASUS_AMULET.test(living.asEntity())) {
return entity.world.getDimension().ultrawarm() ? ICARUS_WINGS_CORRUPTED : ICARUS_WINGS;
}
Race race = living instanceof Pony pony ? pony.getObservedSpecies() : living.getSpecies();
if (race.canInteractWithClouds()) {
return PEGASUS_WINGS;
}
return BAT_WINGS;
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void pose(IModel model, Entity entity, boolean rainboom, UUID interpolatorId, float move, float swing, float bodySwing, float ticks) {
((ClientPonyModel)model).copyAttributes(this.model);
this.model.getWings().setRotationAndAngles(rainboom, interpolatorId, move, swing, bodySwing, ticks);
}
@Override
public void render(MatrixStack stack, VertexConsumer consumer, int light, int overlay, float red, float green, float blue, float alpha, UUID interpolatorId) {
model.getWings().renderPart(stack, consumer, light, overlay, red, green, blue, alpha, interpolatorId);
}
static class Model extends PegasusModel<LivingEntity> {
public Model(ModelPart tree) {
super(tree, false);
}
@Override
public boolean canFly() {
return true;
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB