mirror of
https://github.com/smartcmd/MinecraftConsoles.git
synced 2026-08-20 09:57:09 +00:00
shaped recipes
This commit is contained in:
parent
12d11a8b1a
commit
4cacbee4aa
|
|
@ -1440,10 +1440,10 @@ inline ItemInstance* parseItemInstance(DataInputStream* dis) {
|
||||||
if (!displayTag->contains(L"Lore")) displayTag->put(L"Lore", new ListTag<StringTag>(L"Lore"));
|
if (!displayTag->contains(L"Lore")) displayTag->put(L"Lore", new ListTag<StringTag>(L"Lore"));
|
||||||
|
|
||||||
|
|
||||||
ListTag<StringTag>* list = static_cast<ListTag<StringTag> *>(item->tag->get(L"Lore"));
|
ListTag<StringTag>* list = static_cast<ListTag<StringTag> *>(displayTag->get(L"Lore"));
|
||||||
for (int i = 0; i < loreCount; i++) {
|
for (int i = 0; i < loreCount; i++) {
|
||||||
wstring loreLine = dis->readUTF();
|
wstring loreLine = dis->readUTF();
|
||||||
list->add(new StringTag(loreLine));
|
list->add(new StringTag(L"", loreLine));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1478,6 +1478,26 @@ void Recipes::rebuildRecipeArray(std::shared_ptr<CustomPayloadPacket> packet) {
|
||||||
ItemInstance* result = parseItemInstance(&input);
|
ItemInstance* result = parseItemInstance(&input);
|
||||||
ShapelessRecipy* recipe = new ShapelessRecipy(result, ingredients, static_cast<Recipy::_eGroupType>((recipeHeader >> 4) & 0x0F));
|
ShapelessRecipy* recipe = new ShapelessRecipy(result, ingredients, static_cast<Recipy::_eGroupType>((recipeHeader >> 4) & 0x0F));
|
||||||
recipies->push_back(recipe);
|
recipies->push_back(recipe);
|
||||||
|
} else if (recipeType == 1) { // Shaped recipe
|
||||||
|
unsigned char shapedRecipeHeader = input.readByte();
|
||||||
|
|
||||||
|
int width = (shapedRecipeHeader >> 4) & 0x0F;
|
||||||
|
int height = shapedRecipeHeader & 0x0F;
|
||||||
|
|
||||||
|
ItemInstance** ids = new ItemInstance * [width * height];
|
||||||
|
for (int j = 0; j < width * height; j++) {
|
||||||
|
byte isIngredientValid = input.readByte();
|
||||||
|
|
||||||
|
if (isIngredientValid) {
|
||||||
|
ids[j] = parseItemInstance(&input);
|
||||||
|
} else {
|
||||||
|
ids[j] = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ItemInstance* result = parseItemInstance(&input);
|
||||||
|
ShapedRecipy* recipe = new ShapedRecipy(width, height, ids, result, static_cast<Recipy::_eGroupType>((recipeHeader >> 4) & 0x0F));
|
||||||
|
recipies->push_back(recipe);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1508,17 +1528,18 @@ byteArray Recipes::buildSyncedRecipeArray() {
|
||||||
} else {
|
} else {
|
||||||
ShapedRecipy* shapedRecipe = static_cast<ShapedRecipy*>(recipe);
|
ShapedRecipy* shapedRecipe = static_cast<ShapedRecipy*>(recipe);
|
||||||
|
|
||||||
/*int width = shapedRecipe->getWidth();
|
int width = shapedRecipe->getWidth();
|
||||||
int height = shapedRecipe->getHeight();
|
int height = shapedRecipe->getHeight();
|
||||||
dos.writeByte((width << 4) | (height & 0x0F));
|
dos.writeByte((width << 4) | (height & 0x0F));
|
||||||
|
|
||||||
for (int h = 0; h < height; h++) {
|
ItemInstance** ingredients = shapedRecipe->getRecipeItems();
|
||||||
for (int w = 0; w < width; w++) {
|
for (int j = 0; j < width * height; j++) {
|
||||||
|
ItemInstance* ingredient = ingredients[j];
|
||||||
}
|
dos.writeByte((ingredient == nullptr ? 0 : 1));
|
||||||
|
if (ingredient == nullptr) continue;
|
||||||
|
|
||||||
|
serializeItemInstance(&dos, ingredient);
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
serializeItemInstance(&dos, const_cast<ItemInstance*>(recipe->getResultItem()));
|
serializeItemInstance(&dos, const_cast<ItemInstance*>(recipe->getResultItem()));
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,10 @@ public:
|
||||||
virtual const int getGroup();
|
virtual const int getGroup();
|
||||||
virtual bool matches(shared_ptr<CraftingContainer> craftSlots, Level *level);
|
virtual bool matches(shared_ptr<CraftingContainer> craftSlots, Level *level);
|
||||||
|
|
||||||
|
int getWidth() { return width; }
|
||||||
|
int getHeight() { return height; }
|
||||||
|
ItemInstance** getRecipeItems() { return recipeItems; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool matches(shared_ptr<CraftingContainer> craftSlots, int xOffs, int yOffs, bool xFlip);
|
bool matches(shared_ptr<CraftingContainer> craftSlots, int xOffs, int yOffs, bool xFlip);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue