-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cae1d93
commit 5ad8752
Showing
2 changed files
with
32 additions
and
0 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
src/main/java/ru/bclib/mixin/common/CraftingMenuMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters