Skip to content

Commit

Permalink
Fix #327 - Pistons cannot be crafted
Browse files Browse the repository at this point in the history
  • Loading branch information
lt-name committed Oct 26, 2024
1 parent 95d5f1e commit 17c4697
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/main/java/cn/nukkit/inventory/CraftingManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,7 @@ private ArrayList<ShapedRecipe> createLegacyPlanksRecipe(Map<String, Object> rec
if (ingredient.getId() == Item.PLANKS) {
ingredient.setDamage(planksMeta);
}
ingredients.put(ingredientChar, ingredient);
ingredients.put(ingredientChar, Item.get(ingredient.getId(), ingredient.getDamage(), ingredient.getCount())); //使用Item.get()方法保证修改后的damage正常处理
}
Item result = Item.fromJson(first, true);
if (result == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public boolean canExecute() {
}
}
} else {
MultiRecipe multiRecipe = Server.getInstance().getCraftingManager().getMultiRecipe(this.source, this.getPrimaryOutput(), this.getInputList());
MultiRecipe multiRecipe = craftingManager.getMultiRecipe(this.source, this.getPrimaryOutput(), this.getInputList());
if (multiRecipe != null) {
setTransactionRecipe(multiRecipe.toRecipe(this.getPrimaryOutput(), this.getInputList()));
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/cn/nukkit/utils/BinaryStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -1216,14 +1216,14 @@ public Item getRecipeIngredient(int protocolId) {
public void putRecipeIngredient(int protocolId, Item item) {
if (item == null || item.getId() == 0) {
if (protocolId >= ProtocolInfo.v1_19_30_23) {
this.putBoolean(false); // isValid? - false
this.putByte((byte) 0); //ItemDescriptorType.INVALID
}
this.putVarInt(0); // item == null ? 0 : item.getCount()
return;
}

if (protocolId >= ProtocolInfo.v1_19_30_23) {
this.putBoolean(true); // isValid? - true
this.putByte((byte) 1); //ItemDescriptorType.DEFAULT
}

int runtimeId = item.getId();
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/CreativeItems/creative_items_685.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/main/resources/CreativeItems/creative_items_712.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/main/resources/CreativeItems/creative_items_729.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/main/resources/CreativeItems/creative_items_748.json

Large diffs are not rendered by default.

9 changes: 3 additions & 6 deletions src/main/resources/recipes649.json
Original file line number Diff line number Diff line change
Expand Up @@ -2715,8 +2715,7 @@
},
"output": [
{
"id": 33,
"damage": 1
"id": 33
}
],
"shape": [
Expand Down Expand Up @@ -21741,8 +21740,7 @@
"damage": -1
},
"B": {
"id": 4,
"damage": -1
"id": 4
},
"C": {
"id": 265,
Expand Down Expand Up @@ -21774,8 +21772,7 @@
"damage": -1
},
"B": {
"id": 4,
"damage": -1
"id": 4
},
"C": {
"id": 265,
Expand Down

0 comments on commit 17c4697

Please sign in to comment.