Skip to content

Commit

Permalink
fix hopper no sync in 1.17
Browse files Browse the repository at this point in the history
  • Loading branch information
plusls committed Sep 4, 2021
1 parent e1de14d commit 6180b7c
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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<Boolean> cir) {
if (PcaSettings.pcaSyncProtocol && PcaSyncProtocol.syncBlockEntityToClient(blockEntity)) {
PcaMod.LOGGER.debug("update HopperBlockEntity: {}", pos);
}
}

@Override
public void markDirty() {
super.markDirty();
Expand Down

0 comments on commit 6180b7c

Please sign in to comment.