mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-27 15:17:59 +01:00
Fix more mixins
This commit is contained in:
parent
5227d80c70
commit
214acef12c
2 changed files with 22 additions and 13 deletions
|
@ -41,9 +41,10 @@ abstract class MixinPlayerEntity extends LivingEntity implements Equine.Containe
|
|||
return new Pony((PlayerEntity)(Object)this);
|
||||
}
|
||||
|
||||
@Inject(method = "createPlayerAttributes()Lnet/minecraft/entity/attribute/DefaultAttributeContainer$Builder;", at = @At("RETURN"))
|
||||
private static void onCreateAttributes(CallbackInfoReturnable<DefaultAttributeContainer.Builder> info) {
|
||||
Pony.registerAttributes(info.getReturnValue());
|
||||
@ModifyReturnValue(method = "createPlayerAttributes()Lnet/minecraft/entity/attribute/DefaultAttributeContainer$Builder;", at = @At("RETURN"))
|
||||
private static DefaultAttributeContainer.Builder onCreateAttributes(DefaultAttributeContainer.Builder builder) {
|
||||
Pony.registerAttributes(builder);
|
||||
return builder;
|
||||
}
|
||||
|
||||
@ModifyVariable(method = "applyDamage(Lnet/minecraft/entity/damage/DamageSource;F)V", at = @At("HEAD"), ordinal = 0, argsOnly = true)
|
||||
|
@ -52,13 +53,11 @@ abstract class MixinPlayerEntity extends LivingEntity implements Equine.Containe
|
|||
}
|
||||
|
||||
@ModifyVariable(method = "eatFood(Lnet/minecraft/world/World;Lnet/minecraft/item/ItemStack;Lnet/minecraft/component/type/FoodComponent;)Lnet/minecraft/item/ItemStack;", at = @At("HEAD"), argsOnly = true)
|
||||
private FoodComponent onEatFood(FoodComponent initial, World world, ItemStack stack, FoodComponent food, CallbackInfoReturnable<ItemStack> info) {
|
||||
private FoodComponent onEatFood(FoodComponent initial, World world, ItemStack stack, FoodComponent food) {
|
||||
return get().onEat(stack, food);
|
||||
}
|
||||
|
||||
@Inject(method = "trySleep(Lnet/minecraft/util/math/BlockPos;)Lcom/mojang/datafixers/util/Either;",
|
||||
at = @At("HEAD"),
|
||||
cancellable = true)
|
||||
@Inject(method = "trySleep(Lnet/minecraft/util/math/BlockPos;)Lcom/mojang/datafixers/util/Either;", at = @At("HEAD"), cancellable = true)
|
||||
private void onTrySleep(BlockPos pos, CallbackInfoReturnable<Either<PlayerEntity.SleepFailureReason, Unit>> info) {
|
||||
if (!getWorld().isClient) {
|
||||
get().trySleep(pos).ifPresent(reason -> {
|
||||
|
|
|
@ -7,6 +7,7 @@ import org.spongepowered.asm.mixin.injection.ModifyArg;
|
|||
import org.spongepowered.asm.mixin.injection.ModifyVariable;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import com.llamalad7.mixinextras.sugar.Local;
|
||||
import com.minelittlepony.unicopia.entity.Equine;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
|
@ -32,15 +33,24 @@ abstract class MixinPlayerEntity {
|
|||
}
|
||||
}
|
||||
|
||||
@ModifyArg(method = { "adjustMovementForSneaking", "method_30263" }, at = @At(
|
||||
value = "INVOKE",
|
||||
target = "net/minecraft/util/math/Box.offset(DDD)Lnet/minecraft/util/math/Box;"),
|
||||
@ModifyArg(method = "isSpaceAroundPlayerEmpty",
|
||||
at = @At(value = "INVOKE", target = "net/minecraft/util/math/Box.<init>(DDDDDD)V"),
|
||||
index = 1)
|
||||
private double invertStepHeight(double stepHeight) {
|
||||
private double invertStepHeightCheckBoxBottom(double bottom) {
|
||||
if (this instanceof Equine.Container eq && eq.get().getPhysics().isGravityNegative()) {
|
||||
return -stepHeight;
|
||||
return eq.get().asEntity().getBoundingBox().maxY;
|
||||
}
|
||||
return stepHeight;
|
||||
return bottom;
|
||||
}
|
||||
|
||||
@ModifyArg(method = "isSpaceAroundPlayerEmpty",
|
||||
at = @At(value = "INVOKE", target = "net/minecraft/util/math/Box.<init>(DDDDDD)V"),
|
||||
index = 4)
|
||||
private double invertStepHeightCheckBoxTop(double top, @Local(argsOnly = true) float stepHeight) {
|
||||
if (this instanceof Equine.Container eq && eq.get().getPhysics().isGravityNegative()) {
|
||||
return eq.get().asEntity().getBoundingBox().maxY + stepHeight + 1.0E-5F;
|
||||
}
|
||||
return top;
|
||||
}
|
||||
|
||||
@ModifyArg(method = "canChangeIntoPose",
|
||||
|
|
Loading…
Reference in a new issue