Skip to content

Commit

Permalink
Move this logic to other method
Browse files Browse the repository at this point in the history
  • Loading branch information
Alemiz112 committed May 16, 2024
1 parent 0eeb31c commit 6dc8232
Showing 1 changed file with 21 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,12 @@ protected ShapelessRecipeData readShapelessRecipe(ByteBuf buffer, BedrockCodecHe
UUID uuid = helper.readUuid(buffer);
String craftingTag = helper.readString(buffer);
int priority = VarInts.readInt(buffer);
RecipeUnlockingRequirement requirement = this.readRequirement(buffer, helper, type);

RecipeUnlockingRequirement requirement = RecipeUnlockingRequirement.INVALID;
if (type == CraftingDataType.SHAPELESS) {
requirement = this.readRequirement(buffer, helper, type);
}

int networkId = VarInts.readUnsignedInt(buffer);
return ShapelessRecipeData.of(type, recipeId, inputs, outputs, uuid, craftingTag, priority, networkId, requirement);
}
Expand All @@ -44,7 +49,10 @@ protected void writeShapelessRecipe(ByteBuf buffer, BedrockCodecHelper helper, S
helper.writeUuid(buffer, data.getUuid());
helper.writeString(buffer, data.getTag());
VarInts.writeInt(buffer, data.getPriority());
this.writeRequirement(buffer, helper, data);

if (data.getType() == CraftingDataType.SHAPELESS) {
this.writeRequirement(buffer, helper, data);
}
VarInts.writeUnsignedInt(buffer, data.getNetId());
}

Expand All @@ -64,7 +72,12 @@ protected ShapedRecipeData readShapedRecipe(ByteBuf buffer, BedrockCodecHelper h
String craftingTag = helper.readString(buffer);
int priority = VarInts.readInt(buffer);
boolean assumeSymmetry = buffer.readBoolean();
RecipeUnlockingRequirement requirement = this.readRequirement(buffer, helper, type);

RecipeUnlockingRequirement requirement = RecipeUnlockingRequirement.INVALID;
if (type == CraftingDataType.SHAPED) {
requirement = this.readRequirement(buffer, helper, type);
}

int networkId = VarInts.readUnsignedInt(buffer);
return ShapedRecipeData.of(type, recipeId, width, height, inputs, outputs, uuid, craftingTag, priority, networkId, assumeSymmetry, requirement);
}
Expand All @@ -84,7 +97,11 @@ protected void writeShapedRecipe(ByteBuf buffer, BedrockCodecHelper helper, Shap
helper.writeString(buffer, data.getTag());
VarInts.writeInt(buffer, data.getPriority());
buffer.writeBoolean(data.isAssumeSymetry());
this.writeRequirement(buffer, helper, data);

if (data.getType() == CraftingDataType.SHAPED) {
this.writeRequirement(buffer, helper, data);
}

VarInts.writeUnsignedInt(buffer, data.getNetId());
}

Expand Down

0 comments on commit 6dc8232

Please sign in to comment.