Added an event to allow mods to change the state of pony models before render

This commit is contained in:
Sollace 2021-02-26 10:11:03 +02:00
parent e2fc9df53a
commit 37f03edd2c
5 changed files with 30 additions and 1 deletions

View file

@ -1,6 +1,8 @@
package com.minelittlepony.client.model;
import com.minelittlepony.client.model.armour.PonyArmourModel;
import com.minelittlepony.client.render.EquineRenderManager;
import com.minelittlepony.model.capabilities.fabric.PonyModelPrepareCallback;
import com.minelittlepony.api.pony.meta.Race;
import com.minelittlepony.client.model.armour.ArmourWrapper;
import com.minelittlepony.client.transform.PonyTransformation;
@ -67,6 +69,7 @@ public abstract class AbstractPonyModel<T extends LivingEntity> extends ClientPo
@Override
public void setAngles(T entity, float move, float swing, float ticks, float headYaw, float headPitch) {
attributes.checkRainboom(entity, swing, canFly());
PonyModelPrepareCallback.EVENT.invoker().onPonyModelPrepared(entity, this, EquineRenderManager.Mode.OTHER);
super.setAngles(entity, move, swing, ticks, headYaw, headPitch);

View file

@ -5,6 +5,7 @@ import net.minecraft.client.render.entity.model.BipedEntityModel;
import net.minecraft.entity.LivingEntity;
import net.minecraft.util.Arm;
import com.minelittlepony.model.capabilities.fabric.PonyModelPrepareCallback;
import com.minelittlepony.api.pony.IPony;
import com.minelittlepony.api.pony.IPonyData;
import com.minelittlepony.api.pony.meta.Size;
@ -36,6 +37,7 @@ public abstract class ClientPonyModel<T extends LivingEntity> extends MsonPlayer
public void updateLivingState(T entity, IPony pony, EquineRenderManager.Mode mode) {
child = entity.isBaby();
attributes.updateLivingState(entity, pony, mode);
PonyModelPrepareCallback.EVENT.invoker().onPonyModelPrepared(entity, this, mode);
sneaking = attributes.isCrouching;
riding = attributes.isSitting;
}

View file

@ -198,6 +198,7 @@ public class EquineRenderManager<T extends LivingEntity, M extends EntityModel<T
public enum Mode {
FIRST_PERSON,
THIRD_PERSON
THIRD_PERSON,
OTHER
}
}

View file

@ -0,0 +1,19 @@
package com.minelittlepony.model.capabilities.fabric;
import net.fabricmc.fabric.api.event.Event;
import net.fabricmc.fabric.api.event.EventFactory;
import net.minecraft.entity.Entity;
import com.minelittlepony.client.render.EquineRenderManager;
import com.minelittlepony.model.IModel;
public interface PonyModelPrepareCallback {
Event<PonyModelPrepareCallback> EVENT = EventFactory.createArrayBacked(PonyModelPrepareCallback.class, listeners -> (entity, model, mode) -> {
for (PonyModelPrepareCallback event : listeners) {
event.onPonyModelPrepared(entity, model, mode);
}
});
void onPonyModelPrepared(Entity entity, IModel model, EquineRenderManager.Mode mode);
}

View file

@ -0,0 +1,4 @@
@ParametersAreNonnullByDefault
package com.minelittlepony.model.capabilities.fabric;
import javax.annotation.ParametersAreNonnullByDefault;