2021-02-16 12:39:39 +01:00
|
|
|
package com.minelittlepony.unicopia.mixin;
|
|
|
|
|
|
|
|
import org.spongepowered.asm.mixin.Final;
|
|
|
|
import org.spongepowered.asm.mixin.Mixin;
|
|
|
|
import org.spongepowered.asm.mixin.Shadow;
|
|
|
|
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
|
|
|
|
|
|
|
import com.minelittlepony.unicopia.entity.*;
|
|
|
|
import com.minelittlepony.unicopia.entity.duck.RotatedView;
|
2021-02-22 22:12:08 +01:00
|
|
|
|
|
|
|
import net.minecraft.entity.EntityType;
|
2021-02-16 12:39:39 +01:00
|
|
|
import net.minecraft.entity.LivingEntity;
|
|
|
|
import net.minecraft.entity.ai.goal.GoalSelector;
|
|
|
|
import net.minecraft.entity.mob.MobEntity;
|
2021-02-22 22:12:08 +01:00
|
|
|
import net.minecraft.world.World;
|
2021-02-16 12:39:39 +01:00
|
|
|
|
|
|
|
@Mixin(MobEntity.class)
|
2022-12-25 16:01:12 +01:00
|
|
|
abstract class MixinMobEntity extends LivingEntity implements Equine.Container<Creature> {
|
2021-02-16 12:39:39 +01:00
|
|
|
private MixinMobEntity() { super(null, null); }
|
|
|
|
|
|
|
|
@Shadow
|
|
|
|
protected @Final GoalSelector goalSelector;
|
|
|
|
@Shadow
|
|
|
|
protected @Final GoalSelector targetSelector;
|
|
|
|
|
2021-02-22 22:12:08 +01:00
|
|
|
@Inject(method = "<init>(Lnet/minecraft/entity/EntityType;Lnet/minecraft/world/World;)V", at = @At("RETURN"))
|
|
|
|
private void init(EntityType<? extends MobEntity> entityType, World world, CallbackInfo info) {
|
2022-12-25 16:01:12 +01:00
|
|
|
get().initAi(goalSelector, targetSelector);
|
2021-02-16 12:39:39 +01:00
|
|
|
}
|
2021-02-23 17:08:50 +01:00
|
|
|
|
|
|
|
@Inject(method = "tickNewAi", at = @At("HEAD"))
|
|
|
|
public void beforeTickAi(CallbackInfo into) {
|
2022-12-25 16:01:12 +01:00
|
|
|
if (get().getPhysics().isGravityNegative()) {
|
2021-02-23 22:49:14 +01:00
|
|
|
((RotatedView)world).pushRotation((int)getY());
|
2021-02-23 17:08:50 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Inject(method = "tickNewAi", at = @At("RETURN"))
|
|
|
|
public void afterTickAi(CallbackInfo into) {
|
2021-02-23 22:49:14 +01:00
|
|
|
((RotatedView)world).popRotation();
|
2021-02-23 17:08:50 +01:00
|
|
|
}
|
2021-02-16 12:39:39 +01:00
|
|
|
}
|