net.minecraft.inventory.CraftingInventory Java Examples
The following examples show how to use
net.minecraft.inventory.CraftingInventory.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CreateRecipe.java From EnderStorage with MIT License | 6 votes |
@Nonnull @Override public ItemStack getCraftingResult(CraftingInventory inv) { EnumColour colour = EnumColour.WHITE; finish: for (int x = 0; x < 3; x++) { for (int y = 0; y < 3; y++) { ItemStack stack = inv.getStackInSlot(x + y * inv.getWidth()); if (!stack.isEmpty()) { EnumColour c = EnumColour.fromWoolStack(stack); if (c != null) { colour = c; break finish; } } } } Frequency frequency = new Frequency(colour, colour, colour); return frequency.writeToStack(super.getCraftingResult(inv)); }
Example #2
Source File: RecipeBase.java From EnderStorage with MIT License | 6 votes |
@Override public boolean matches(CraftingInventory inv, World worldIn) { for (int i = 0; i < 3; ++i) { for (int j = 0; j < 3; ++j) { Ingredient ingredient = Ingredient.EMPTY; if (i >= 0 && j >= 0 && i < 3 && j < 3) { ingredient = this.input.get(i + j * 3); } if (!ingredient.test(inv.getStackInSlot(i + j * inv.getWidth()))) { return false; } } } return true; }
Example #3
Source File: RecipeBookEmulator.java From multiconnect with MIT License | 5 votes |
public static void setCraftingResultSlot(int syncId, CraftingInventory craftingInv) { ClientPlayNetworkHandler networkHandler = MinecraftClient.getInstance().getNetworkHandler(); assert networkHandler != null; ItemStack result = networkHandler.getRecipeManager().getFirstMatch(RecipeType.CRAFTING, craftingInv, MinecraftClient.getInstance().world) .map(recipe -> recipe.craft(craftingInv)) .orElse(ItemStack.EMPTY); networkHandler.onScreenHandlerSlotUpdate(new ScreenHandlerSlotUpdateS2CPacket(syncId, 0, result)); }
Example #4
Source File: AddBannerPatternRecipe.java From multiconnect with MIT License | 5 votes |
@Override public boolean matches(CraftingInventory inv, World world) { boolean foundBanner = false; for (int i = 0; i < inv.size(); i++) { ItemStack stack = inv.getStack(i); if (stack.getItem() instanceof BannerItem) { if (foundBanner) return false; if (BannerBlockEntity.getPatternCount(stack) >= 6) return false; foundBanner = true; } } return foundBanner && getBannerPattern(inv) != null; }
Example #5
Source File: DropperBlock_craftingMixin.java From carpet-extra with GNU Lesser General Public License v3.0 | 4 votes |
@Inject(method = "dispense", at = @At("HEAD"), cancellable = true) private void tryCraft(World world_1, BlockPos blockPos_1, CallbackInfo ci) { if (!CarpetExtraSettings.autoCraftingDropper) return; BlockPos front = blockPos_1.offset(world_1.getBlockState(blockPos_1).get(DispenserBlock.FACING)); if (world_1.getBlockState(front).getBlock() != Blocks.CRAFTING_TABLE) return; DispenserBlockEntity dispenserBlockEntity_1 = (DispenserBlockEntity) world_1.getBlockEntity(blockPos_1); if (dispenserBlockEntity_1 == null) return; CraftingInventory craftingInventory = new CraftingInventory(new VoidContainer(), 3, 3); for (int i=0; i < 9; i++) craftingInventory.setInvStack(i, dispenserBlockEntity_1.getInvStack(i)); CraftingRecipe recipe = world_1.getRecipeManager().getFirstMatch(RecipeType.CRAFTING, craftingInventory, world_1).orElse(null); if (recipe == null) return; // crafting it Vec3d target = new Vec3d(front).add(0.5, 0.2, 0.5); ItemStack result = recipe.craft(craftingInventory); spawn(world_1, target.x, target.y, target.z, result); // copied from CraftingResultSlot.onTakeItem() DefaultedList<ItemStack> defaultedList_1 = world_1.getRecipeManager().getRemainingStacks(RecipeType.CRAFTING, craftingInventory, world_1); for(int int_1 = 0; int_1 < defaultedList_1.size(); ++int_1) { ItemStack itemStack_2 = dispenserBlockEntity_1.getInvStack(int_1); ItemStack itemStack_3 = defaultedList_1.get(int_1); if (!itemStack_2.isEmpty()) { dispenserBlockEntity_1.takeInvStack(int_1, 1); itemStack_2 = dispenserBlockEntity_1.getInvStack(int_1); } if (!itemStack_3.isEmpty()) { if (itemStack_2.isEmpty()) { dispenserBlockEntity_1.setInvStack(int_1, itemStack_3); } else if (ItemStack.areItemsEqualIgnoreDamage(itemStack_2, itemStack_3) && ItemStack.areTagsEqual(itemStack_2, itemStack_3)) { itemStack_3.increment(itemStack_2.getCount()); dispenserBlockEntity_1.setInvStack(int_1, itemStack_3); } else { spawn(world_1, target.x, target.y, target.z, itemStack_3); } } } Vec3d vec = new Vec3d(blockPos_1).add(0.5, 0.5, 0.5); ServerWorld world = (ServerWorld) world_1; world.playSound(null, blockPos_1, SoundEvents.ENTITY_VILLAGER_WORK_MASON, SoundCategory.BLOCKS, 0.2f, 2.0f); ci.cancel(); }
Example #6
Source File: RecipeBase.java From EnderStorage with MIT License | 4 votes |
@Override public ItemStack getCraftingResult(CraftingInventory inv) { return output.copy(); }
Example #7
Source File: DummyRecipe.java From Survivalist with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public boolean matches(CraftingInventory inv, World worldIn) { return false; }
Example #8
Source File: DummyRecipe.java From Survivalist with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public ItemStack getCraftingResult(CraftingInventory inv) { return ItemStack.EMPTY; }