|
1 | 1 | package carpet.mixins;
|
2 | 2 |
|
3 | 3 | import carpet.CarpetSettings;
|
| 4 | +import net.minecraft.core.Direction; |
4 | 5 | import org.spongepowered.asm.mixin.Mixin;
|
5 | 6 | import org.spongepowered.asm.mixin.Shadow;
|
6 | 7 | import org.spongepowered.asm.mixin.injection.At;
|
@@ -29,22 +30,26 @@ protected HopperBlockEntity_counterMixin(BlockEntityType<?> blockEntityType, Blo
|
29 | 30 | super(blockEntityType, blockPos, blockState);
|
30 | 31 | }
|
31 | 32 |
|
32 |
| - @Shadow public abstract int getContainerSize(); |
| 33 | + //@Shadow public abstract int getContainerSize(); |
33 | 34 |
|
34 |
| - @Shadow public abstract void setItem(int slot, ItemStack stack); |
| 35 | + //@Shadow public abstract void setItem(int slot, ItemStack stack); |
| 36 | + |
| 37 | + @Shadow private Direction facing; |
35 | 38 |
|
36 | 39 | /**
|
37 | 40 | * A method to remove items from hoppers pointing into wool and count them via {@link HopperCounter#add} method
|
38 | 41 | */
|
39 | 42 | @Inject(method = "ejectItems", at = @At("HEAD"), cancellable = true)
|
40 |
| - private static void onInsert(Level world, BlockPos blockPos, BlockState blockState, Container inventory, CallbackInfoReturnable<Boolean> cir) |
| 43 | + private static void onInsert(Level world, BlockPos blockPos, HopperBlockEntity hopperBlockEntity, CallbackInfoReturnable<Boolean> cir) |
41 | 44 | {
|
42 | 45 | if (CarpetSettings.hopperCounters) {
|
| 46 | + Direction hopperFacing = world.getBlockState(blockPos).getValue(HopperBlock.FACING); |
43 | 47 | DyeColor woolColor = WoolTool.getWoolColorAtPosition(
|
44 | 48 | world,
|
45 |
| - blockPos.relative(blockState.getValue(HopperBlock.FACING))); |
| 49 | + blockPos.relative(hopperFacing)); |
46 | 50 | if (woolColor != null)
|
47 | 51 | {
|
| 52 | + Container inventory = HopperBlockEntity.getContainerAt(world, blockPos); |
48 | 53 | for (int i = 0; i < inventory.getContainerSize(); ++i)
|
49 | 54 | {
|
50 | 55 | if (!inventory.getItem(i).isEmpty())
|
|
0 commit comments