package com.thebrokenrail.slightlyvanilla.mixin; import com.thebrokenrail.slightlyvanilla.SlightlyVanilla; import net.minecraft.entity.EntityType; import net.minecraft.entity.passive.AbstractTraderEntity; import net.minecraft.entity.passive.PassiveEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.world.World; 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.CallbackInfoReturnable; @SuppressWarnings("unused") @Mixin(AbstractTraderEntity.class) public abstract class MixinAbstractTraderEntity extends PassiveEntity { protected MixinAbstractTraderEntity(EntityType entityType, World world) { super(entityType, world); } @Inject(at = @At("HEAD"), method = "canBeLeashedBy", cancellable = true) public void canBeLeashedBy(PlayerEntity player, CallbackInfoReturnable info) { if (SlightlyVanilla.getConfig().allowLeashingVillagers) { info.setReturnValue(super.canBeLeashedBy(player)); } } }