mirror of
https://github.com/Sollace/Unicopia.git
synced 2025-02-21 12:24:22 +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);
|
return new Pony((PlayerEntity)(Object)this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "createPlayerAttributes()Lnet/minecraft/entity/attribute/DefaultAttributeContainer$Builder;", at = @At("RETURN"))
|
@ModifyReturnValue(method = "createPlayerAttributes()Lnet/minecraft/entity/attribute/DefaultAttributeContainer$Builder;", at = @At("RETURN"))
|
||||||
private static void onCreateAttributes(CallbackInfoReturnable<DefaultAttributeContainer.Builder> info) {
|
private static DefaultAttributeContainer.Builder onCreateAttributes(DefaultAttributeContainer.Builder builder) {
|
||||||
Pony.registerAttributes(info.getReturnValue());
|
Pony.registerAttributes(builder);
|
||||||
|
return builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ModifyVariable(method = "applyDamage(Lnet/minecraft/entity/damage/DamageSource;F)V", at = @At("HEAD"), ordinal = 0, argsOnly = true)
|
@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)
|
@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);
|
return get().onEat(stack, food);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "trySleep(Lnet/minecraft/util/math/BlockPos;)Lcom/mojang/datafixers/util/Either;",
|
@Inject(method = "trySleep(Lnet/minecraft/util/math/BlockPos;)Lcom/mojang/datafixers/util/Either;", at = @At("HEAD"), cancellable = true)
|
||||||
at = @At("HEAD"),
|
|
||||||
cancellable = true)
|
|
||||||
private void onTrySleep(BlockPos pos, CallbackInfoReturnable<Either<PlayerEntity.SleepFailureReason, Unit>> info) {
|
private void onTrySleep(BlockPos pos, CallbackInfoReturnable<Either<PlayerEntity.SleepFailureReason, Unit>> info) {
|
||||||
if (!getWorld().isClient) {
|
if (!getWorld().isClient) {
|
||||||
get().trySleep(pos).ifPresent(reason -> {
|
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.ModifyVariable;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
|
|
||||||
|
import com.llamalad7.mixinextras.sugar.Local;
|
||||||
import com.minelittlepony.unicopia.entity.Equine;
|
import com.minelittlepony.unicopia.entity.Equine;
|
||||||
|
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
|
@ -32,15 +33,24 @@ abstract class MixinPlayerEntity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ModifyArg(method = { "adjustMovementForSneaking", "method_30263" }, at = @At(
|
@ModifyArg(method = "isSpaceAroundPlayerEmpty",
|
||||||
value = "INVOKE",
|
at = @At(value = "INVOKE", target = "net/minecraft/util/math/Box.<init>(DDDDDD)V"),
|
||||||
target = "net/minecraft/util/math/Box.offset(DDD)Lnet/minecraft/util/math/Box;"),
|
|
||||||
index = 1)
|
index = 1)
|
||||||
private double invertStepHeight(double stepHeight) {
|
private double invertStepHeightCheckBoxBottom(double bottom) {
|
||||||
if (this instanceof Equine.Container eq && eq.get().getPhysics().isGravityNegative()) {
|
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",
|
@ModifyArg(method = "canChangeIntoPose",
|
||||||
|
|
Loading…
Reference in a new issue