mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-27 15:17:59 +01:00
Fixed changeling wing animations and posing
This commit is contained in:
parent
2b2fab2303
commit
5fb54aa2fd
2 changed files with 98 additions and 9 deletions
|
@ -6,6 +6,7 @@ import java.util.function.Predicate;
|
|||
|
||||
import com.minelittlepony.api.model.*;
|
||||
import com.minelittlepony.api.model.gear.IGear;
|
||||
import com.minelittlepony.api.pony.IPonyData;
|
||||
import com.minelittlepony.client.model.ClientPonyModel;
|
||||
import com.minelittlepony.client.model.ModelType;
|
||||
import com.minelittlepony.client.model.PlayerModelKey;
|
||||
|
@ -16,7 +17,7 @@ import com.minelittlepony.client.model.part.UnicornHorn;
|
|||
import com.minelittlepony.mson.api.MsonModel;
|
||||
import com.minelittlepony.unicopia.EquinePredicates;
|
||||
import com.minelittlepony.unicopia.FlightType;
|
||||
import com.minelittlepony.unicopia.Race;
|
||||
|
||||
import com.minelittlepony.unicopia.Unicopia;
|
||||
import com.minelittlepony.unicopia.entity.AmuletSelectors;
|
||||
|
||||
|
@ -27,6 +28,8 @@ import net.minecraft.entity.Entity;
|
|||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
import com.minelittlepony.api.pony.meta.Race;
|
||||
|
||||
class BodyPartGear<M extends ClientPonyModel<LivingEntity> & MsonModel & IModel> implements IGear {
|
||||
|
||||
private static final Predicate<LivingEntity> MINE_LP_HAS_NO_WINGS = e -> !MineLPDelegate.getInstance().getRace(e).canFly();
|
||||
|
@ -41,14 +44,14 @@ class BodyPartGear<M extends ClientPonyModel<LivingEntity> & MsonModel & IModel>
|
|||
public static final Predicate<LivingEntity> BAT_WINGS_PREDICATE = MINE_LP_HAS_NO_WINGS.and(AmuletSelectors.PEGASUS_AMULET.negate()).and(EquinePredicates.PLAYER_BAT);
|
||||
public static final Identifier BAT_WINGS = Unicopia.id("textures/models/wings/bat_pony.png");
|
||||
|
||||
public static final Predicate<LivingEntity> UNICORN_HORN_PREDICATE = MINE_LP_HAS_NO_HORN.and(AmuletSelectors.ALICORN_AMULET.or(EquinePredicates.raceMatches(Race::canCast)));
|
||||
public static final Predicate<LivingEntity> UNICORN_HORN_PREDICATE = MINE_LP_HAS_NO_HORN.and(AmuletSelectors.ALICORN_AMULET.or(EquinePredicates.raceMatches(com.minelittlepony.unicopia.Race::canCast)));
|
||||
public static final Identifier UNICORN_HORN = Unicopia.id("textures/models/horn/unicorn.png");
|
||||
|
||||
public static final Predicate<LivingEntity> PEGA_WINGS_PREDICATE = MINE_LP_HAS_NO_WINGS.and(AmuletSelectors.PEGASUS_AMULET.or(EquinePredicates.raceMatches(race -> race.flightType() == FlightType.AVIAN)));
|
||||
public static final Identifier PEGASUS_WINGS = Unicopia.id("textures/models/wings/pegasus_pony.png");
|
||||
|
||||
public static BodyPartGear<WingsGearModel> pegasusWings() {
|
||||
return new BodyPartGear<>(BodyPart.BODY, ModelType.PEGASUS, PEGA_WINGS_PREDICATE, WingsGearModel::new, WingsGearModel::getWings, e -> {
|
||||
return new BodyPartGear<>(Race.PEGASUS, BodyPart.BODY, ModelType.PEGASUS, PEGA_WINGS_PREDICATE, WingsGearModel::new, WingsGearModel::getWings, e -> {
|
||||
if (AmuletSelectors.PEGASUS_AMULET.test((LivingEntity)e)) {
|
||||
return e.getWorld().getDimension().ultrawarm() ? ICARUS_WINGS_CORRUPTED : ICARUS_WINGS;
|
||||
}
|
||||
|
@ -57,15 +60,15 @@ class BodyPartGear<M extends ClientPonyModel<LivingEntity> & MsonModel & IModel>
|
|||
}
|
||||
|
||||
public static BodyPartGear<WingsGearModel> batWings() {
|
||||
return new BodyPartGear<>(BodyPart.BODY, ModelType.BAT_PONY, BAT_WINGS_PREDICATE, WingsGearModel::new, IPegasus::getWings, e -> BAT_WINGS);
|
||||
return new BodyPartGear<>(Race.BATPONY, BodyPart.BODY, ModelType.BAT_PONY, BAT_WINGS_PREDICATE, WingsGearModel::new, IPegasus::getWings, e -> BAT_WINGS);
|
||||
}
|
||||
|
||||
public static BodyPartGear<BugWingsGearModel> bugWings() {
|
||||
return new BodyPartGear<>(BodyPart.BODY, ModelType.CHANGELING, BUG_WINGS_PREDICATE, BugWingsGearModel::new, IPegasus::getWings, e -> BUG_WINGS);
|
||||
return new BodyPartGear<>(Race.CHANGELING, BodyPart.BODY, ModelType.CHANGELING, BUG_WINGS_PREDICATE, BugWingsGearModel::new, IPegasus::getWings, e -> BUG_WINGS);
|
||||
}
|
||||
|
||||
public static BodyPartGear<HornGearModel> unicornHorn() {
|
||||
return new BodyPartGear<>(BodyPart.HEAD, ModelType.UNICORN, UNICORN_HORN_PREDICATE, HornGearModel::new, HornGearModel::getHorn, e -> UNICORN_HORN);
|
||||
return new BodyPartGear<>(Race.UNICORN, BodyPart.HEAD, ModelType.UNICORN, UNICORN_HORN_PREDICATE, HornGearModel::new, HornGearModel::getHorn, e -> UNICORN_HORN);
|
||||
}
|
||||
|
||||
private final M model;
|
||||
|
@ -73,14 +76,17 @@ class BodyPartGear<M extends ClientPonyModel<LivingEntity> & MsonModel & IModel>
|
|||
private final IPart part;
|
||||
private final Function<Entity, Identifier> textureSupplier;
|
||||
private final BodyPart gearLocation;
|
||||
private final UnicopiaPonyData ponyData;
|
||||
|
||||
public BodyPartGear(
|
||||
Race race,
|
||||
BodyPart gearLocation,
|
||||
PlayerModelKey<LivingEntity, ? super M> modelKey,
|
||||
Predicate<LivingEntity> renderTargetPredicate,
|
||||
MsonModel.Factory<M> modelFactory,
|
||||
Function<? super M, IPart> partExtractor,
|
||||
Function<Entity, Identifier> textureSupplier) {
|
||||
this.ponyData = new UnicopiaPonyData(race);
|
||||
this.gearLocation = gearLocation;
|
||||
this.model = modelKey.steveKey().createModel(modelFactory);
|
||||
this.part = partExtractor.apply(this.model);
|
||||
|
@ -107,9 +113,17 @@ class BodyPartGear<M extends ClientPonyModel<LivingEntity> & MsonModel & IModel>
|
|||
|
||||
@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);
|
||||
part.setPartAngles(this.model.getAttributes(), move, swing, bodySwing, ticks);
|
||||
public void pose(IModel model, Entity entity, boolean rainboom, UUID interpolatorId, float move, float swing, float bodySwing, float tickDelta) {
|
||||
final IPonyData data = this.model.getAttributes().metadata;
|
||||
try {
|
||||
ponyData.original = data;
|
||||
((ClientPonyModel)model).copyAttributes(this.model);
|
||||
this.model.getAttributes().metadata = ponyData;
|
||||
this.model.animateModel((LivingEntity)entity, move, swing, tickDelta);
|
||||
this.model.setAngles((LivingEntity)entity, move, swing, entity.age + tickDelta, 0, 0);
|
||||
} finally {
|
||||
this.model.getAttributes().metadata = data;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -0,0 +1,75 @@
|
|||
package com.minelittlepony.unicopia.client.minelittlepony;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.minelittlepony.api.pony.IPonyData;
|
||||
import com.minelittlepony.api.pony.TriggerPixelType;
|
||||
import com.minelittlepony.api.pony.meta.Gender;
|
||||
import com.minelittlepony.api.pony.meta.Race;
|
||||
import com.minelittlepony.api.pony.meta.Size;
|
||||
import com.minelittlepony.api.pony.meta.TailLength;
|
||||
import com.minelittlepony.api.pony.meta.TailShape;
|
||||
import com.minelittlepony.api.pony.meta.Wearable;
|
||||
import com.minelittlepony.common.util.animation.Interpolator;
|
||||
|
||||
public class UnicopiaPonyData implements IPonyData {
|
||||
|
||||
Race race;
|
||||
IPonyData original;
|
||||
|
||||
public UnicopiaPonyData(Race race) {
|
||||
this.race = race;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Race getRace() {
|
||||
return race;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TailLength getTailLength() {
|
||||
return original.getTailLength();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TailShape getTailShape() {
|
||||
return original.getTailShape();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Gender getGender() {
|
||||
return original.getGender();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Size getSize() {
|
||||
return original.getSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getGlowColor() {
|
||||
return original.getGlowColor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Wearable[] getGear() {
|
||||
return original.getGear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWearing(Wearable wearable) {
|
||||
return original.isWearing(wearable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Interpolator getInterpolator(UUID interpolatorId) {
|
||||
return original.getInterpolator(interpolatorId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, TriggerPixelType<?>> getTriggerPixels() {
|
||||
return original.getTriggerPixels();
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue