Advertisement
supersaiyansubtlety

AbstractFurnaceBlockEntityMixin.java

Dec 16th, 2020
918
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.90 KB | None | 0 0
  1. public abstract class AbstractFurnaceBlockEntityMixin extends LockableContainerBlockEntity implements SidedInventory, RecipeUnlocker, RecipeInputProvider, Tickable {
  2.     @Shadow protected @Final RecipeType<? extends AbstractCookingRecipe> recipeType;
  3.  
  4.     protected AbstractFurnaceBlockEntityMixin(BlockEntityType<?> blockEntityType) {
  5.         super(blockEntityType);
  6.         throw new IllegalStateException("AbstractFurnaceBlockEntityMixin's dummy constructor called! ");
  7.     }
  8.  
  9.     @Inject(method = "isValid", at = @At("RETURN"), cancellable = true)
  10.     void onIsValidReturn(int slot, ItemStack stack, CallbackInfoReturnable<Boolean> cir) {
  11.         if (cir.getReturnValue() || slot == 0) return;
  12.  
  13.         if (this.world != null &&
  14.                 !this.world.getRecipeManager().getFirstMatch(recipeType, new SimpleInventory(stack), this.world).isPresent())
  15.             cir.setReturnValue(false);
  16.     }
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement