2021-08-04 15:38:03 +02:00
|
|
|
package com.minelittlepony.unicopia.mixin;
|
|
|
|
|
2023-11-08 13:58:31 +01:00
|
|
|
import java.util.Set;
|
|
|
|
|
2024-02-15 00:57:01 +01:00
|
|
|
import org.jetbrains.annotations.Nullable;
|
2021-08-04 15:38:03 +02:00
|
|
|
import org.spongepowered.asm.mixin.Mixin;
|
|
|
|
import org.spongepowered.asm.mixin.gen.Accessor;
|
2022-09-11 15:42:26 +02:00
|
|
|
import org.spongepowered.asm.mixin.injection.At;
|
|
|
|
import org.spongepowered.asm.mixin.injection.Inject;
|
2022-12-25 19:36:43 +01:00
|
|
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
2022-09-11 15:42:26 +02:00
|
|
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
|
|
|
|
2022-09-11 16:58:42 +02:00
|
|
|
import com.minelittlepony.unicopia.entity.duck.LavaAffine;
|
2023-10-09 23:05:41 +02:00
|
|
|
import com.minelittlepony.unicopia.EquinePredicates;
|
|
|
|
import com.minelittlepony.unicopia.Race;
|
2024-02-15 00:57:01 +01:00
|
|
|
import com.minelittlepony.unicopia.ability.magic.Caster;
|
2023-10-09 23:05:41 +02:00
|
|
|
import com.minelittlepony.unicopia.entity.Equine;
|
2022-12-25 19:36:43 +01:00
|
|
|
import com.minelittlepony.unicopia.entity.Living;
|
2022-09-11 16:58:42 +02:00
|
|
|
import com.minelittlepony.unicopia.entity.duck.EntityDuck;
|
2022-09-11 15:42:26 +02:00
|
|
|
|
2021-08-04 15:38:03 +02:00
|
|
|
import net.minecraft.entity.Entity;
|
2024-02-27 01:01:22 +01:00
|
|
|
import net.minecraft.entity.EntityType;
|
2024-02-15 00:57:01 +01:00
|
|
|
import net.minecraft.entity.ItemEntity;
|
2022-12-25 19:36:43 +01:00
|
|
|
import net.minecraft.entity.Entity.PositionUpdater;
|
2021-08-04 15:38:03 +02:00
|
|
|
import net.minecraft.entity.Entity.RemovalReason;
|
2023-11-08 13:58:31 +01:00
|
|
|
import net.minecraft.fluid.Fluid;
|
2024-02-15 00:57:01 +01:00
|
|
|
import net.minecraft.item.ItemStack;
|
2023-11-08 13:58:31 +01:00
|
|
|
import net.minecraft.registry.tag.TagKey;
|
2024-02-27 01:01:22 +01:00
|
|
|
import net.minecraft.world.World;
|
2021-08-04 15:38:03 +02:00
|
|
|
|
|
|
|
@Mixin(Entity.class)
|
2022-09-11 16:58:42 +02:00
|
|
|
abstract class MixinEntity implements EntityDuck {
|
2024-02-15 00:57:01 +01:00
|
|
|
@Nullable
|
|
|
|
private transient Caster<?> host;
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Nullable
|
|
|
|
public Caster<?> getHost() {
|
|
|
|
return host;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void setHost(Caster<?> host) {
|
|
|
|
this.host = host;
|
|
|
|
}
|
|
|
|
|
2023-11-08 13:58:31 +01:00
|
|
|
@Override
|
|
|
|
@Accessor("submergedFluidTag")
|
|
|
|
public abstract Set<TagKey<Fluid>> getSubmergedFluidTags();
|
|
|
|
|
2022-09-11 15:42:26 +02:00
|
|
|
@Override
|
2021-08-04 15:38:03 +02:00
|
|
|
@Accessor
|
2022-09-11 15:42:26 +02:00
|
|
|
public abstract void setRemovalReason(RemovalReason reason);
|
|
|
|
|
2022-12-25 19:36:43 +01:00
|
|
|
@Override
|
|
|
|
@Accessor
|
|
|
|
public abstract void setVehicle(Entity vehicle);
|
|
|
|
|
2023-08-11 19:51:35 +02:00
|
|
|
@Override
|
|
|
|
@Accessor
|
|
|
|
public abstract float getNextStepSoundDistance();
|
|
|
|
|
2022-10-15 11:52:00 +02:00
|
|
|
@Override
|
|
|
|
public boolean isLavaAffine() {
|
|
|
|
Entity self = (Entity)(Object)this;
|
2023-05-29 11:14:57 +02:00
|
|
|
return self.hasVehicle() && self.getVehicle() instanceof LavaAffine affine && affine.isLavaAffine();
|
2022-10-15 11:52:00 +02:00
|
|
|
}
|
|
|
|
|
2024-02-27 01:01:22 +01:00
|
|
|
|
|
|
|
@Inject(method = "<init>", at = @At(value = "INVOKE", target = "net/minecraft/entity/Entity.initDataTracker()V"))
|
|
|
|
private void onInstanceInit(EntityType<?> type, World world, CallbackInfo info) {
|
|
|
|
if (this instanceof Equine.Container c) {
|
|
|
|
c.get().initDataTracker();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-11 15:42:26 +02:00
|
|
|
@Inject(method = "isFireImmune", at = @At("HEAD"), cancellable = true)
|
|
|
|
private void onIsFireImmune(CallbackInfoReturnable<Boolean> info) {
|
2023-10-09 23:05:41 +02:00
|
|
|
if (isLavaAffine() || (this instanceof Equine.Container c) && c.get().getCompositeRace().includes(Race.KIRIN)) {
|
|
|
|
info.setReturnValue(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Inject(method = "isSneaky", at = @At("HEAD"), cancellable = true)
|
|
|
|
private void onIsSneaky(CallbackInfoReturnable<Boolean> info) {
|
2023-10-09 23:10:18 +02:00
|
|
|
if (EquinePredicates.PLAYER_KIRIN.test((Entity)(Object)this) && !EquinePredicates.RAGING.test((Entity)(Object)this)) {
|
2023-10-09 23:05:41 +02:00
|
|
|
info.setReturnValue(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Inject(method = "getMaxAir", at = @At("HEAD"), cancellable = true)
|
|
|
|
private void onGetMaxAir(CallbackInfoReturnable<Integer> info) {
|
|
|
|
if (EquinePredicates.PLAYER_KIRIN.test((Entity)(Object)this)) {
|
|
|
|
info.setReturnValue(150);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Inject(method = "doesRenderOnFire", at = @At("HEAD"), cancellable = true)
|
|
|
|
private void onDoesRenderOnFire(CallbackInfoReturnable<Boolean> info) {
|
|
|
|
if (EquinePredicates.RAGING.test((Entity)(Object)this)) {
|
2022-09-11 15:42:26 +02:00
|
|
|
info.setReturnValue(true);
|
|
|
|
}
|
|
|
|
}
|
2022-12-25 19:36:43 +01:00
|
|
|
|
|
|
|
@Inject(method = "updatePassengerPosition(Lnet/minecraft/entity/Entity;Lnet/minecraft/entity/Entity$PositionUpdater;)V",
|
|
|
|
at = @At("HEAD"),
|
|
|
|
cancellable = true
|
|
|
|
)
|
|
|
|
private void updatePassengerPosition(Entity passenger, PositionUpdater positionUpdater, CallbackInfo info) {
|
|
|
|
if (Living.getOrEmpty((Entity)(Object)this).filter(l -> l.onUpdatePassengerPosition(passenger, positionUpdater)).isPresent()) {
|
|
|
|
info.cancel();
|
|
|
|
}
|
|
|
|
}
|
2024-02-15 00:57:01 +01:00
|
|
|
|
|
|
|
@Inject(method = "dropStack(Lnet/minecraft/item/ItemStack;F)Lnet/minecraft/entity/ItemEntity;", at = @At("HEAD"), cancellable = true)
|
|
|
|
private void onDropStack(ItemStack stack, float yOffset, CallbackInfoReturnable<ItemEntity> info) {
|
|
|
|
if (getHost() != null) {
|
|
|
|
info.setReturnValue(null);
|
|
|
|
}
|
|
|
|
}
|
2021-08-04 15:38:03 +02:00
|
|
|
}
|