mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2024-11-22 04:27:59 +01:00
Added an event to allow mods to change the state of pony models before render
This commit is contained in:
parent
e2fc9df53a
commit
37f03edd2c
5 changed files with 30 additions and 1 deletions
|
@ -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);
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -198,6 +198,7 @@ public class EquineRenderManager<T extends LivingEntity, M extends EntityModel<T
|
|||
|
||||
public enum Mode {
|
||||
FIRST_PERSON,
|
||||
THIRD_PERSON
|
||||
THIRD_PERSON,
|
||||
OTHER
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
@ParametersAreNonnullByDefault
|
||||
package com.minelittlepony.model.capabilities.fabric;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
Loading…
Reference in a new issue