Skip to content

Commit

Permalink
Crafting menu fix
Browse files Browse the repository at this point in the history
  • Loading branch information
paulevsGitch committed Nov 13, 2021
1 parent cae1d93 commit 5ad8752
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/main/java/ru/bclib/mixin/common/CraftingMenuMixin.java
Original file line number Diff line number Diff line change
@@ -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);
}
}
}
1 change: 1 addition & 0 deletions src/main/resources/bclib.mixins.common.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"WorldGenRegionMixin",
"DimensionTypeMixin",
"RecipeManagerMixin",
"CraftingMenuMixin",
"BoneMealItemMixin",
"shears.SheepMixin",
"PortalShapeMixin",
Expand Down

0 comments on commit 5ad8752

Please sign in to comment.