@@ -114,6 +114,11 @@ public static void drawEnchantmentGUIOverlay(DrawContext context) {
114114
115115 lines .add ("" );
116116
117+ if (enchantingTablePos != null ) {
118+ lines .add (I18n .translate ("enchCrack.bookshelfCount" , getEnchantPower (MinecraftClient .getInstance ().world , enchantingTablePos )));
119+ lines .add ("" );
120+ }
121+
117122 if (crackState == CrackState .CRACKED ) {
118123 lines .add (I18n .translate ("enchCrack.enchantments" ));
119124 } else {
@@ -451,13 +456,21 @@ public static boolean isEnchantingPredictionEnabled() {
451456 private static int getEnchantPower (World world , BlockPos tablePos ) {
452457 int power = 0 ;
453458
459+ int protocolVersion = MultiVersionCompat .INSTANCE .getProtocolVersion ();
460+
454461 for (BlockPos bookshelfOffset : EnchantingTableBlock .POWER_PROVIDER_OFFSETS ) {
455- if (MultiVersionCompat . INSTANCE . getProtocolVersion () <= MultiVersionCompat .V1_18 ) {
462+ if (protocolVersion <= MultiVersionCompat .V1_18 ) {
456463 // old bookshelf detection method
457464 BlockPos obstructionPos = tablePos .add (MathHelper .clamp (bookshelfOffset .getX (), -1 , 1 ), 0 , MathHelper .clamp (bookshelfOffset .getZ (), -1 , 1 ));
458465 if (world .getBlockState (tablePos .add (bookshelfOffset )).isOf (Blocks .BOOKSHELF ) && world .getBlockState (obstructionPos ).isAir ()) {
459466 power ++;
460467 }
468+ } else if (protocolVersion < MultiVersionCompat .V1_20 ) {
469+ // any non-air block used to obstruct bookshelves
470+ BlockPos obstructionPos = tablePos .add (bookshelfOffset .getX () / 2 , bookshelfOffset .getY (), bookshelfOffset .getZ () / 2 );
471+ if (world .getBlockState (tablePos .add (bookshelfOffset )).isOf (Blocks .BOOKSHELF ) && world .getBlockState (obstructionPos ).isAir ()) {
472+ power ++;
473+ }
461474 } else {
462475 if (EnchantingTableBlock .canAccessPowerProvider (world , tablePos , bookshelfOffset )) {
463476 power ++;
0 commit comments