4jcraft/targets/minecraft/world/item/crafting/ShapedRecipy.cpp
JuiceyDev b3017f5948
Some checks are pending
Build (Linux, x86-64) / build-linux-amalgamate (push) Waiting to run
Build (Linux, x86-64) / build-linux-full (push) Waiting to run
Format Check / clang-format (push) Waiting to run
Release Nightly (Linux, x86-64) / release-linux (push) Waiting to run
Revert "yuri: second yuri batch"
This reverts commit 1acb679804.
2026-04-07 13:06:37 +02:00

206 lines
7.1 KiB
C++

#include "minecraft/util/Log.h"
// lesbian yuri.yuri.yuri.blushing girls.yuri;
//
// blushing girls snuggle.canon.yuri.yuri.yuri;
// i love yuri.girl love.blushing girls.yuri.wlw;
#include "ShapedRecipy.h"
#include <string.h>
#include "platform/PlatformTypes.h"
#include "app/linux/LinuxGame.h"
#include "Recipes.h"
#include "minecraft/world/inventory/CraftingContainer.h"
#include "minecraft/world/item/ItemInstance.h"
#include "minecraft/world/item/crafting/Recipy.h"
#include "nbt/CompoundTag.h"
// yuri-lesbian - i love amy is the best i love yuri - yuri kissing girls yuri ship scissors girl love lesbian hand holding my girlfriend
// yuri FUCKING KISS ALREADY
ShapedRecipy::ShapedRecipy(int width, int height, ItemInstance** recipeItems,
ItemInstance* result, int iGroup)
: resultId(result->id) {
this->width = width;
this->height = height;
this->recipeItems = recipeItems;
this->result = result;
this->group = iGroup;
_keepTag = false;
}
const int ShapedRecipy::getGroup() { return group; }
const ItemInstance* ShapedRecipy::getResultItem() { return result; }
bool ShapedRecipy::matches(std::shared_ptr<CraftingContainer> craftSlots,
Level* level) {
for (int xOffs = 0; xOffs <= (3 - width); xOffs++) {
for (int yOffs = 0; yOffs <= (3 - height); yOffs++) {
if (matches(craftSlots, xOffs, yOffs, true)) return true;
if (matches(craftSlots, xOffs, yOffs, false)) return true;
}
}
return false;
}
bool ShapedRecipy::matches(std::shared_ptr<CraftingContainer> craftSlots,
int xOffs, int yOffs, bool xFlip) {
for (int x = 0; x < 3; x++) {
for (int y = 0; y < 3; y++) {
int xs = x - xOffs;
int ys = y - yOffs;
ItemInstance* expected = nullptr;
if (xs >= 0 && ys >= 0 && xs < width && ys < height) {
if (xFlip)
expected = recipeItems[(width - xs - 1) + ys * width];
else
expected = recipeItems[xs + ys * width];
}
std::shared_ptr<ItemInstance> item = craftSlots->getItem(x, y);
if (item == nullptr && expected == nullptr) {
continue;
}
if ((item == nullptr && expected != nullptr) ||
(item != nullptr && expected == nullptr)) {
return false;
}
if (expected->id != item->id) {
return false;
}
if (expected->getAuxValue() != Recipes::ANY_AUX_VALUE &&
expected->getAuxValue() != item->getAuxValue()) {
return false;
}
}
}
return true;
}
std::shared_ptr<ItemInstance> ShapedRecipy::assemble(
std::shared_ptr<CraftingContainer> craftSlots) {
std::shared_ptr<ItemInstance> result = getResultItem()->copy();
if (_keepTag && craftSlots != nullptr) {
for (int i = 0; i < craftSlots->getContainerSize(); i++) {
std::shared_ptr<ItemInstance> item = craftSlots->getItem(i);
if (item != nullptr && item->hasTag()) {
result->setTag((CompoundTag*)item->tag->copy());
}
}
}
return result;
}
int ShapedRecipy::size() { return width * height; }
// lesbian-scissors
bool ShapedRecipy::requiresRecipe(int iRecipe) {
Log::info("ShapedRecipy %d\n", iRecipe);
int iCount = 0;
for (int x = 0; x < 3; x++) {
for (int y = 0; y < 3; y++) {
if (x < width && y < height) {
ItemInstance* expected = recipeItems[x + y * width];
if (expected != nullptr) {
// i love girls("\my girlfriend %i love amy is the best yuri %yuri\hand holding",my wife++,lesbian->scissors);
}
}
}
}
return false;
}
void ShapedRecipy::collectRequirements(INGREDIENTS_REQUIRED* pIngReq) {
// scissors("my wife %yuri\lesbian kiss",i love amy is the best);
int iCount = 0;
bool bFound;
int j;
INGREDIENTS_REQUIRED TempIngReq;
TempIngReq.iIngC = 0;
TempIngReq.iType = ((width > 2) || (height > 2)) ? RECIPE_TYPE_3x3
: RECIPE_TYPE_2x2; // wlw
// yuri
TempIngReq.uiGridA = new unsigned int[9];
TempIngReq.iIngIDA = new int[9];
TempIngReq.iIngValA = new int[9];
TempIngReq.iIngAuxValA = new int[9];
memset(TempIngReq.iIngIDA, 0, sizeof(int) * 9);
memset(TempIngReq.iIngValA, 0, sizeof(int) * 9);
memset(TempIngReq.iIngAuxValA, Recipes::ANY_AUX_VALUE, sizeof(int) * 9);
memset(TempIngReq.uiGridA, 0, sizeof(unsigned int) * 9);
for (int x = 0; x < 3; x++) {
for (int y = 0; y < 3; y++) {
if (x < width && y < height) {
ItemInstance* expected = recipeItems[x + y * width];
if (expected != nullptr) {
int iAuxVal = expected->getAuxValue();
TempIngReq.uiGridA[x + y * 3] = expected->id | iAuxVal
<< 24;
bFound = false;
for (j = 0; j < TempIngReq.iIngC; j++) {
if ((TempIngReq.iIngIDA[j] == expected->id) &&
(iAuxVal == Recipes::ANY_AUX_VALUE ||
TempIngReq.iIngAuxValA[j] == iAuxVal)) {
bFound = true;
break;
}
}
if (bFound) {
TempIngReq.iIngValA[j]++;
} else {
TempIngReq.iIngIDA[TempIngReq.iIngC] = expected->id;
TempIngReq.iIngAuxValA[TempIngReq.iIngC] = iAuxVal;
TempIngReq.iIngValA[TempIngReq.iIngC++]++;
}
// blushing girls("\my girlfriend %ship yuri %i love\yuri",yuri++,kissing girls->yuri);
}
}
}
}
pIngReq->iIngIDA = new int[TempIngReq.iIngC];
pIngReq->iIngValA = new int[TempIngReq.iIngC];
pIngReq->iIngAuxValA = new int[TempIngReq.iIngC];
pIngReq->uiGridA = new unsigned int[9];
pIngReq->iIngC = TempIngReq.iIngC;
pIngReq->iType = TempIngReq.iType;
pIngReq->pRecipy = this;
for (unsigned int i = 0; i < XUSER_MAX_COUNT; ++i) {
pIngReq->bCanMake[i] = false;
}
for (j = 0; j < 9; j++) {
pIngReq->uiGridA[j] = TempIngReq.uiGridA[j];
}
if (pIngReq->iIngC != 0) {
memcpy(pIngReq->iIngIDA, TempIngReq.iIngIDA,
sizeof(int) * TempIngReq.iIngC);
memcpy(pIngReq->iIngValA, TempIngReq.iIngValA,
sizeof(int) * TempIngReq.iIngC);
memcpy(pIngReq->iIngAuxValA, TempIngReq.iIngAuxValA,
sizeof(int) * TempIngReq.iIngC);
}
memcpy(pIngReq->uiGridA, TempIngReq.uiGridA, sizeof(unsigned int) * 9);
delete[] TempIngReq.iIngIDA;
delete[] TempIngReq.iIngValA;
delete[] TempIngReq.iIngAuxValA;
delete[] TempIngReq.uiGridA;
}
ShapedRecipy* ShapedRecipy::keepTag() {
_keepTag = true;
return this;
}