use of net.minecraft.world.item.crafting.CraftingRecipe in project BCLib by paulevsGitch.
the class GridRecipe method build.
public void build() {
if (!exist) {
return;
}
int height = shape.length;
int width = shape[0].length();
ItemStack result = new ItemStack(output, count);
NonNullList<Ingredient> materials = this.getMaterials(width, height);
CraftingRecipe recipe = shaped ? new ShapedRecipe(id, group, width, height, materials, result) : new ShapelessRecipe(id, group, result, materials);
BCLRecipeManager.addRecipe(type, recipe);
}
use of net.minecraft.world.item.crafting.CraftingRecipe in project Cyclic by Lothrazar.
the class ContainerWorkbench method updateCraftingResult.
protected static void updateCraftingResult(int id, int stateId, Level world, Player player, CraftingContainer inventory, ResultContainer inventoryResult) {
if (!world.isClientSide) {
ServerPlayer sp = (ServerPlayer) player;
ItemStack itemstack = ItemStack.EMPTY;
Optional<CraftingRecipe> optional = world.getServer().getRecipeManager().getRecipeFor(RecipeType.CRAFTING, inventory, world);
if (optional.isPresent()) {
CraftingRecipe recipe = optional.get();
if (inventoryResult.setRecipeUsed(world, sp, recipe)) {
itemstack = recipe.assemble(inventory);
}
}
inventoryResult.setItem(0, itemstack);
sp.connection.send(new ClientboundContainerSetSlotPacket(id, stateId, 0, itemstack));
}
}
use of net.minecraft.world.item.crafting.CraftingRecipe in project Cyclic by Lothrazar.
the class CraftingStickContainer method slotsChanged.
@Override
public void slotsChanged(Container inventory) {
Level world = playerInventory.player.level;
if (!world.isClientSide) {
ServerPlayer player = (ServerPlayer) playerInventory.player;
ItemStack itemstack = ItemStack.EMPTY;
Optional<CraftingRecipe> optional = world.getServer().getRecipeManager().getRecipeFor(RecipeType.CRAFTING, craftMatrix, world);
if (optional.isPresent()) {
CraftingRecipe icraftingrecipe = optional.get();
if (craftResult.setRecipeUsed(world, player, icraftingrecipe)) {
itemstack = icraftingrecipe.assemble(craftMatrix);
}
}
craftResult.setItem(0, itemstack);
player.connection.send(new ClientboundContainerSetSlotPacket(containerId, this.getStateId(), 0, itemstack));
}
}
use of net.minecraft.world.item.crafting.CraftingRecipe in project The-Aether by Gilded-Games.
the class AccessoriesContainer method slotsChanged.
@Override
public void slotsChanged(@Nonnull Container inventoryIn) {
if (!this.player.level.isClientSide) {
ServerPlayer playerMP = (ServerPlayer) this.player;
ItemStack itemStack = ItemStack.EMPTY;
MinecraftServer server = this.player.level.getServer();
if (server == null) {
return;
}
Optional<CraftingRecipe> recipe = server.getRecipeManager().getRecipeFor(RecipeType.CRAFTING, this.craftMatrix, this.player.level);
if (recipe.isPresent()) {
CraftingRecipe craftingRecipe = recipe.get();
if (this.craftResult.setRecipeUsed(this.player.level, playerMP, craftingRecipe)) {
itemStack = craftingRecipe.assemble(this.craftMatrix);
}
}
this.craftResult.setItem(0, itemStack);
this.setRemoteSlot(0, itemStack);
playerMP.connection.send(new ClientboundContainerSetSlotPacket(this.containerId, this.incrementStateId(), 0, itemStack));
}
}
use of net.minecraft.world.item.crafting.CraftingRecipe in project LaserIO by Direwolf20-MC.
the class JEIIntegration method onRuntimeAvailable.
@Override
public void onRuntimeAvailable(IJeiRuntime jeiRuntime) {
IRecipeManager recipeRegistry = jeiRuntime.getRecipeManager();
RecipeManager recipeManager = Minecraft.getInstance().level.getRecipeManager();
List<CraftingRecipe> hiddenRecipes = new ArrayList<>();
hiddenRecipes.add((CraftingRecipe) recipeManager.byKey(new ResourceLocation(Registration.Card_Item.getId() + "_nbtclear")).get());
hiddenRecipes.add((CraftingRecipe) recipeManager.byKey(new ResourceLocation(Registration.Filter_Basic.getId() + "_nbtclear")).get());
hiddenRecipes.add((CraftingRecipe) recipeManager.byKey(new ResourceLocation(Registration.Filter_Count.getId() + "_nbtclear")).get());
hiddenRecipes.add((CraftingRecipe) recipeManager.byKey(new ResourceLocation(Registration.Filter_Tag.getId() + "_nbtclear")).get());
hiddenRecipes.add((CraftingRecipe) recipeManager.byKey(new ResourceLocation(Registration.Filter_Mod.getId() + "_nbtclear")).get());
recipeRegistry.hideRecipes(RecipeTypes.CRAFTING, hiddenRecipes);
}
Aggregations