Skip to content

Commit

Permalink
chore: improve crafting matrix sync #2
Browse files Browse the repository at this point in the history
  • Loading branch information
klikli-dev committed Jun 13, 2023
1 parent 48f314a commit e25e12e
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ public void slotsChanged(Container inventoryIn) {
//only allow matrix changes while we are not crafting
return;
}
this.updateCraftingSlots(true);
this.updateCraftingSlots(false);
this.broadcastChanges();
this.findRecipeForMatrix();
}

Expand Down Expand Up @@ -192,7 +193,10 @@ protected void setupOrderInventorySlot() {
protected void findRecipeForMatrixClient() {
Optional<CraftingRecipe> optional =
this.player.level().getRecipeManager().getRecipeFor(RecipeType.CRAFTING, this.matrix, this.player.level());
optional.ifPresent(iCraftingRecipe -> this.currentRecipe = iCraftingRecipe);
optional.ifPresentOrElse(iCraftingRecipe -> this.currentRecipe = iCraftingRecipe, () -> {
this.currentRecipe = null;
this.result.setItem(0, ItemStack.EMPTY);
});
}

protected void findRecipeForMatrix() {
Expand All @@ -215,6 +219,8 @@ protected void findRecipeForMatrix() {

this.result.setItem(0, itemstack);
serverplayerentity.connection.send(new ClientboundContainerSetSlotPacket(this.containerId, 0, 0, itemstack));
} else {
this.findRecipeForMatrixClient();
}
}

Expand Down

0 comments on commit e25e12e

Please sign in to comment.