From 532ee9d0330896f6ca10e8c062a11a7cfdabfd9f Mon Sep 17 00:00:00 2001 From: Rhys <98863820+rhysdh540@users.noreply.github.com> Date: Sun, 1 Sep 2024 23:16:08 -0400 Subject: [PATCH] use more stable ModifyArg --- .../interiors/foundation/mixin/SeatBlockMixin.java | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/common/src/main/java/com/sudolev/interiors/foundation/mixin/SeatBlockMixin.java b/common/src/main/java/com/sudolev/interiors/foundation/mixin/SeatBlockMixin.java index f0800a5..439dab4 100644 --- a/common/src/main/java/com/sudolev/interiors/foundation/mixin/SeatBlockMixin.java +++ b/common/src/main/java/com/sudolev/interiors/foundation/mixin/SeatBlockMixin.java @@ -1,7 +1,6 @@ package com.sudolev.interiors.foundation.mixin; import net.minecraft.core.BlockPos; -import net.minecraft.world.entity.Entity; import net.minecraft.world.item.DyeColor; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; @@ -24,7 +23,7 @@ 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.CallbackInfo; +import org.spongepowered.asm.mixin.injection.ModifyArg; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(SeatBlock.class) @@ -43,11 +42,9 @@ private static SeatEntity createCorrectSeatEntity(SeatEntity original, @Local(ar : new SeatEntity(level, pos); } - @Inject(method = "sitDown", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/Level;addFreshEntity(Lnet/minecraft/world/entity/Entity;)Z")) - private static void getFixedY(Level world, BlockPos pos, Entity entity, CallbackInfo ci, @Local SeatEntity seat) { - if(seat instanceof BigSeatEntity) { - seat.setPos(seat.getX(), seat.getY() + .34f, seat.getZ()); - } + @ModifyArg(method = "sitDown", at = @At(value = "INVOKE", target = "Lcom/simibubi/create/content/contraptions/actors/seat/SeatEntity;setPos(DDD)V"), index = 1) + private static double getFixedY(double y, @Local SeatEntity seat) { + return seat instanceof BigSeatEntity ? y + 0.34f : y; } @ModifyExpressionValue(method = "use", at = @At(value = "INVOKE", target = "Lcom/simibubi/create/foundation/block/DyedBlockList;get(Lnet/minecraft/world/item/DyeColor;)Lcom/tterrag/registrate/util/entry/BlockEntry;"))