[Fix] Boookshelf not recognized

This commit is contained in:
Frank 2022-06-30 08:04:55 +02:00
parent 4367babec5
commit b37399523a

View file

@ -1,12 +1,10 @@
package org.betterx.bclib.mixin.common;
import org.betterx.bclib.util.MethodReplace;
import org.betterx.worlds.together.tag.v3.CommonBlockTags;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.EnchantmentTableBlock;
import org.spongepowered.asm.mixin.Mixin;
@ -23,10 +21,13 @@ public abstract class EnchantingTableBlockMixin extends Block {
@Inject(method = "isValidBookShelf(Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Lnet/minecraft/core/BlockPos;)Z", at = @At("HEAD"), cancellable = true)
private static void bclib_isBookshelf(
Level level,
BlockPos blockPos,
BlockPos blockPos2,
BlockPos tablePos,
BlockPos delta,
CallbackInfoReturnable<Boolean> info
) {
MethodReplace.addBlockReplace(Blocks.BOOKSHELF, state -> state.is(CommonBlockTags.BOOKSHELVES));
if (level.getBlockState(tablePos.offset(delta)).is(CommonBlockTags.BOOKSHELVES)
&& level.isEmptyBlock(tablePos.offset(delta.getX() / 2, delta.getY(), delta.getZ() / 2))) {
info.setReturnValue(true);
}
}
}