2021-02-23 22:49:14 +01:00
|
|
|
package com.minelittlepony.unicopia.mixin;
|
|
|
|
|
|
|
|
import org.spongepowered.asm.mixin.Mixin;
|
|
|
|
import org.spongepowered.asm.mixin.injection.At;
|
|
|
|
import org.spongepowered.asm.mixin.injection.Inject;
|
|
|
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
2022-09-11 16:58:42 +02:00
|
|
|
|
2021-02-23 22:49:14 +01:00
|
|
|
import com.minelittlepony.unicopia.entity.Equine;
|
|
|
|
import com.minelittlepony.unicopia.entity.Living;
|
2022-09-11 16:58:42 +02:00
|
|
|
import com.minelittlepony.unicopia.entity.duck.RotatedView;
|
2021-02-23 22:49:14 +01:00
|
|
|
|
|
|
|
import net.minecraft.entity.LivingEntity;
|
|
|
|
import net.minecraft.entity.ai.brain.Brain;
|
|
|
|
import net.minecraft.server.world.ServerWorld;
|
|
|
|
|
|
|
|
@Mixin(Brain.class)
|
|
|
|
abstract class MixinBrain<E extends LivingEntity> {
|
|
|
|
|
|
|
|
@Inject(method = "tick", at = @At("HEAD"))
|
|
|
|
public void beforeTickAi(ServerWorld world, E entity, CallbackInfo into) {
|
2021-03-06 22:11:17 +01:00
|
|
|
Equine<?> eq = Equine.of(entity).orElse(null);
|
2021-02-23 22:49:14 +01:00
|
|
|
|
|
|
|
if (eq instanceof Living<?> && eq.getPhysics().isGravityNegative()) {
|
|
|
|
((RotatedView)world).pushRotation((int)entity.getY());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Inject(method = "tick", at = @At("RETURN"))
|
|
|
|
public void afterTickAi(ServerWorld world, E entity, CallbackInfo into) {
|
|
|
|
((RotatedView)world).popRotation();
|
|
|
|
}
|
|
|
|
}
|