diff --git a/src/main/java/com/plusls/carpet/mixin/rule/pcaSyncProtocol/block/MixinHopperBlockEntity.java b/src/main/java/com/plusls/carpet/mixin/rule/pcaSyncProtocol/block/MixinHopperBlockEntity.java index 09f1df7..b0d6265 100644 --- a/src/main/java/com/plusls/carpet/mixin/rule/pcaSyncProtocol/block/MixinHopperBlockEntity.java +++ b/src/main/java/com/plusls/carpet/mixin/rule/pcaSyncProtocol/block/MixinHopperBlockEntity.java @@ -9,7 +9,13 @@ import net.minecraft.block.entity.HopperBlockEntity; import net.minecraft.block.entity.LootableContainerBlockEntity; import net.minecraft.util.math.BlockPos; +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; + +import java.util.function.BooleanSupplier; @Mixin(HopperBlockEntity.class) public abstract class MixinHopperBlockEntity extends LootableContainerBlockEntity implements Hopper { @@ -18,6 +24,13 @@ protected MixinHopperBlockEntity(BlockEntityType blockEntityType, BlockPos bl super(blockEntityType, blockPos, blockState); } + @Inject(method = "insertAndExtract", at=@At(value = "INVOKE", target = "Lnet/minecraft/block/entity/HopperBlockEntity;markDirty(Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;)V")) + private static void onInsertAndExtract(World world, BlockPos pos, BlockState state, HopperBlockEntity blockEntity, BooleanSupplier booleanSupplier, CallbackInfoReturnable cir) { + if (PcaSettings.pcaSyncProtocol && PcaSyncProtocol.syncBlockEntityToClient(blockEntity)) { + PcaMod.LOGGER.debug("update HopperBlockEntity: {}", pos); + } + } + @Override public void markDirty() { super.markDirty();