25 lines
812 B
Java
25 lines
812 B
Java
package pm.c7.scout.mixin;
|
|
|
|
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 net.minecraft.util.collection.DefaultedList;
|
|
import pm.c7.scout.ScoutUtil;
|
|
|
|
@Mixin(DefaultedList.class)
|
|
public class DefaultedListMixin {
|
|
@Inject(method = "get", at = @At("HEAD"), cancellable = true)
|
|
public void scout$fixIndexingSlots(int index, CallbackInfoReturnable<Object> cir) {
|
|
var playerScreenHandler = ScoutUtil.getPlayerScreenHandler();
|
|
if (ScoutUtil.isBagSlot(index)) {
|
|
if (playerScreenHandler != null) {
|
|
cir.setReturnValue(ScoutUtil.getBagSlot(index, playerScreenHandler));
|
|
} else {
|
|
cir.setReturnValue(null);
|
|
}
|
|
}
|
|
}
|
|
}
|