Crafting menu fix

This commit is contained in:
paulevsGitch 2021-11-13 11:33:04 +03:00
parent cae1d932a1
commit 5ad8752e00
2 changed files with 32 additions and 0 deletions

View file

@ -0,0 +1,31 @@
package ru.bclib.mixin.common;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.inventory.ContainerLevelAccess;
import net.minecraft.world.inventory.CraftingMenu;
import net.minecraft.world.level.block.CraftingTableBlock;
import net.minecraft.world.level.block.state.BlockState;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import ru.bclib.api.TagAPI;
@Mixin(CraftingMenu.class)
public abstract class CraftingMenuMixin {
@Final
@Shadow
private ContainerLevelAccess access;
@Inject(method = "stillValid", at = @At("HEAD"), cancellable = true)
private void bclib_stillValid(Player player, CallbackInfoReturnable<Boolean> info) {
if (access.evaluate((world, pos) -> {
BlockState state = world.getBlockState(pos);
return state.getBlock() instanceof CraftingTableBlock || state.is(TagAPI.BLOCK_WORKBENCHES);
}, true)) {
info.setReturnValue(true);
}
}
}

View file

@ -22,6 +22,7 @@
"WorldGenRegionMixin", "WorldGenRegionMixin",
"DimensionTypeMixin", "DimensionTypeMixin",
"RecipeManagerMixin", "RecipeManagerMixin",
"CraftingMenuMixin",
"BoneMealItemMixin", "BoneMealItemMixin",
"shears.SheepMixin", "shears.SheepMixin",
"PortalShapeMixin", "PortalShapeMixin",