├── .env.example ├── .eslintrc.json ├── .github └── workflows │ └── deploy.yml ├── .gitignore ├── LICENSE ├── README.md ├── conversion_scripts ├── .gitignore ├── all_items.json ├── change_puzzles.py ├── convert_recipes.py ├── items.json ├── old_merge_recipes.py ├── old_recipe.py └── recipes.json ├── loader ├── bigquery.sql ├── load.py ├── load_csv.sql ├── loadtest.sh ├── refresh_mv.sh ├── sqlite_loader.py └── through_sqlite_loader.sh ├── misc └── C418 - Aria Math (Minecraft Volume Beta).mp3 ├── next.config.js ├── package.json ├── pnpm-lock.yaml ├── postcss.config.js ├── prisma ├── MVs.sql ├── migrations │ ├── 20240118093728_init │ │ └── migration.sql │ └── migration_lock.toml └── schema.prisma ├── public ├── audio │ └── button_click.wav ├── data │ ├── given_ingredients.json │ ├── items.json │ ├── old_recipes.json │ └── recipes.json ├── favicon.ico ├── fonts │ ├── Minecraft-Regular.otf │ ├── Minecrafter-Cracked.ttf │ └── Minecrafter.ttf ├── icons │ ├── android-chrome-192x192.png │ ├── android-chrome-256x256.png │ ├── apple-touch-icon.png │ ├── browserconfig.xml │ ├── favicon-16x16.png │ ├── favicon-32x32.png │ ├── favicon.ico │ ├── mstile-150x150.png │ ├── safari-pinned-tab.svg │ └── site.webmanifest ├── images │ ├── button-background.png │ ├── dirt-background.webp │ ├── new.png │ └── original.png ├── next.svg └── vercel.svg ├── references.txt ├── src ├── components │ ├── CraftingTable.component.tsx │ ├── Cursor.component.tsx │ ├── Inventory.component.tsx │ ├── LoadingSpinner.component.tsx │ ├── MCButton.component.tsx │ ├── Popup.component.tsx │ ├── Slot.component.tsx │ └── StatRow.component.tsx ├── constants.ts ├── context │ └── Global │ │ ├── context.tsx │ │ └── index.tsx ├── pages │ ├── _app.tsx │ ├── _document.tsx │ ├── api │ │ └── trpc │ │ │ └── [trpc].ts │ ├── how-to-play.tsx │ ├── index.tsx │ ├── layout.tsx │ └── stats │ │ ├── [userId].tsx │ │ └── index.tsx ├── server │ ├── routers │ │ ├── _app.ts │ │ └── game.ts │ └── trpc.ts ├── styles │ └── globals.css ├── types.ts └── utils │ ├── prisma.ts │ ├── recipe.ts │ └── trpc.ts ├── tailwind.config.ts └── tsconfig.json /.env.example: -------------------------------------------------------------------------------- 1 | DATABASE_URL=postgresql://user:password@localhost:5432/minecraftle?schema=public 2 | 3 | # optional 4 | NEXT_PUBLIC_PUBLIC_DIR= -------------------------------------------------------------------------------- /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "next/core-web-vitals" 3 | } 4 | -------------------------------------------------------------------------------- /.github/workflows/deploy.yml: -------------------------------------------------------------------------------- 1 | name: deployment 2 | on: 3 | workflow_dispatch: 4 | push: 5 | branches: 6 | - main 7 | 8 | jobs: 9 | migrate: 10 | runs-on: ubuntu-latest 11 | environment: production 12 | steps: 13 | - uses: actions/checkout@v2 14 | - run: npm install 15 | - name: Run migrations on prod 16 | run: npm run migrate 17 | env: 18 | DATABASE_URL: ${{ secrets.DATABASE_URL }} 19 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | .yarn/install-state.gz 8 | 9 | # testing 10 | /coverage 11 | 12 | # next.js 13 | /.next/ 14 | /out/ 15 | 16 | # production 17 | /build 18 | 19 | # misc 20 | .DS_Store 21 | *.pem 22 | 23 | # debug 24 | npm-debug.log* 25 | yarn-debug.log* 26 | yarn-error.log* 27 | 28 | # local env files 29 | .env*.local 30 | .env 31 | 32 | # vercel 33 | .vercel 34 | 35 | # typescript 36 | *.tsbuildinfo 37 | next-env.d.ts 38 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU AFFERO GENERAL PUBLIC LICENSE 2 | Version 3, 19 November 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU Affero General Public License is a free, copyleft license for 11 | software and other kinds of works, specifically designed to ensure 12 | cooperation with the community in the case of network server software. 13 | 14 | The licenses for most software and other practical works are designed 15 | to take away your freedom to share and change the works. By contrast, 16 | our General Public Licenses are intended to guarantee your freedom to 17 | share and change all versions of a program--to make sure it remains free 18 | software for all its users. 19 | 20 | When we speak of free software, we are referring to freedom, not 21 | price. Our General Public Licenses are designed to make sure that you 22 | have the freedom to distribute copies of free software (and charge for 23 | them if you wish), that you receive source code or can get it if you 24 | want it, that you can change the software or use pieces of it in new 25 | free programs, and that you know you can do these things. 26 | 27 | Developers that use our General Public Licenses protect your rights 28 | with two steps: (1) assert copyright on the software, and (2) offer 29 | you this License which gives you legal permission to copy, distribute 30 | and/or modify the software. 31 | 32 | A secondary benefit of defending all users' freedom is that 33 | improvements made in alternate versions of the program, if they 34 | receive widespread use, become available for other developers to 35 | incorporate. Many developers of free software are heartened and 36 | encouraged by the resulting cooperation. However, in the case of 37 | software used on network servers, this result may fail to come about. 38 | The GNU General Public License permits making a modified version and 39 | letting the public access it on a server without ever releasing its 40 | source code to the public. 41 | 42 | The GNU Affero General Public License is designed specifically to 43 | ensure that, in such cases, the modified source code becomes available 44 | to the community. It requires the operator of a network server to 45 | provide the source code of the modified version running there to the 46 | users of that server. Therefore, public use of a modified version, on 47 | a publicly accessible server, gives the public access to the source 48 | code of the modified version. 49 | 50 | An older license, called the Affero General Public License and 51 | published by Affero, was designed to accomplish similar goals. This is 52 | a different license, not a version of the Affero GPL, but Affero has 53 | released a new version of the Affero GPL which permits relicensing under 54 | this license. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | TERMS AND CONDITIONS 60 | 61 | 0. Definitions. 62 | 63 | "This License" refers to version 3 of the GNU Affero General Public License. 64 | 65 | "Copyright" also means copyright-like laws that apply to other kinds of 66 | works, such as semiconductor masks. 67 | 68 | "The Program" refers to any copyrightable work licensed under this 69 | License. Each licensee is addressed as "you". "Licensees" and 70 | "recipients" may be individuals or organizations. 71 | 72 | To "modify" a work means to copy from or adapt all or part of the work 73 | in a fashion requiring copyright permission, other than the making of an 74 | exact copy. The resulting work is called a "modified version" of the 75 | earlier work or a work "based on" the earlier work. 76 | 77 | A "covered work" means either the unmodified Program or a work based 78 | on the Program. 79 | 80 | To "propagate" a work means to do anything with it that, without 81 | permission, would make you directly or secondarily liable for 82 | infringement under applicable copyright law, except executing it on a 83 | computer or modifying a private copy. Propagation includes copying, 84 | distribution (with or without modification), making available to the 85 | public, and in some countries other activities as well. 86 | 87 | To "convey" a work means any kind of propagation that enables other 88 | parties to make or receive copies. Mere interaction with a user through 89 | a computer network, with no transfer of a copy, is not conveying. 90 | 91 | An interactive user interface displays "Appropriate Legal Notices" 92 | to the extent that it includes a convenient and prominently visible 93 | feature that (1) displays an appropriate copyright notice, and (2) 94 | tells the user that there is no warranty for the work (except to the 95 | extent that warranties are provided), that licensees may convey the 96 | work under this License, and how to view a copy of this License. If 97 | the interface presents a list of user commands or options, such as a 98 | menu, a prominent item in the list meets this criterion. 99 | 100 | 1. Source Code. 101 | 102 | The "source code" for a work means the preferred form of the work 103 | for making modifications to it. "Object code" means any non-source 104 | form of a work. 105 | 106 | A "Standard Interface" means an interface that either is an official 107 | standard defined by a recognized standards body, or, in the case of 108 | interfaces specified for a particular programming language, one that 109 | is widely used among developers working in that language. 110 | 111 | The "System Libraries" of an executable work include anything, other 112 | than the work as a whole, that (a) is included in the normal form of 113 | packaging a Major Component, but which is not part of that Major 114 | Component, and (b) serves only to enable use of the work with that 115 | Major Component, or to implement a Standard Interface for which an 116 | implementation is available to the public in source code form. A 117 | "Major Component", in this context, means a major essential component 118 | (kernel, window system, and so on) of the specific operating system 119 | (if any) on which the executable work runs, or a compiler used to 120 | produce the work, or an object code interpreter used to run it. 121 | 122 | The "Corresponding Source" for a work in object code form means all 123 | the source code needed to generate, install, and (for an executable 124 | work) run the object code and to modify the work, including scripts to 125 | control those activities. However, it does not include the work's 126 | System Libraries, or general-purpose tools or generally available free 127 | programs which are used unmodified in performing those activities but 128 | which are not part of the work. For example, Corresponding Source 129 | includes interface definition files associated with source files for 130 | the work, and the source code for shared libraries and dynamically 131 | linked subprograms that the work is specifically designed to require, 132 | such as by intimate data communication or control flow between those 133 | subprograms and other parts of the work. 134 | 135 | The Corresponding Source need not include anything that users 136 | can regenerate automatically from other parts of the Corresponding 137 | Source. 138 | 139 | The Corresponding Source for a work in source code form is that 140 | same work. 141 | 142 | 2. Basic Permissions. 143 | 144 | All rights granted under this License are granted for the term of 145 | copyright on the Program, and are irrevocable provided the stated 146 | conditions are met. This License explicitly affirms your unlimited 147 | permission to run the unmodified Program. The output from running a 148 | covered work is covered by this License only if the output, given its 149 | content, constitutes a covered work. This License acknowledges your 150 | rights of fair use or other equivalent, as provided by copyright law. 151 | 152 | You may make, run and propagate covered works that you do not 153 | convey, without conditions so long as your license otherwise remains 154 | in force. You may convey covered works to others for the sole purpose 155 | of having them make modifications exclusively for you, or provide you 156 | with facilities for running those works, provided that you comply with 157 | the terms of this License in conveying all material for which you do 158 | not control copyright. Those thus making or running the covered works 159 | for you must do so exclusively on your behalf, under your direction 160 | and control, on terms that prohibit them from making any copies of 161 | your copyrighted material outside their relationship with you. 162 | 163 | Conveying under any other circumstances is permitted solely under 164 | the conditions stated below. Sublicensing is not allowed; section 10 165 | makes it unnecessary. 166 | 167 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 168 | 169 | No covered work shall be deemed part of an effective technological 170 | measure under any applicable law fulfilling obligations under article 171 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 172 | similar laws prohibiting or restricting circumvention of such 173 | measures. 174 | 175 | When you convey a covered work, you waive any legal power to forbid 176 | circumvention of technological measures to the extent such circumvention 177 | is effected by exercising rights under this License with respect to 178 | the covered work, and you disclaim any intention to limit operation or 179 | modification of the work as a means of enforcing, against the work's 180 | users, your or third parties' legal rights to forbid circumvention of 181 | technological measures. 182 | 183 | 4. Conveying Verbatim Copies. 184 | 185 | You may convey verbatim copies of the Program's source code as you 186 | receive it, in any medium, provided that you conspicuously and 187 | appropriately publish on each copy an appropriate copyright notice; 188 | keep intact all notices stating that this License and any 189 | non-permissive terms added in accord with section 7 apply to the code; 190 | keep intact all notices of the absence of any warranty; and give all 191 | recipients a copy of this License along with the Program. 192 | 193 | You may charge any price or no price for each copy that you convey, 194 | and you may offer support or warranty protection for a fee. 195 | 196 | 5. Conveying Modified Source Versions. 197 | 198 | You may convey a work based on the Program, or the modifications to 199 | produce it from the Program, in the form of source code under the 200 | terms of section 4, provided that you also meet all of these conditions: 201 | 202 | a) The work must carry prominent notices stating that you modified 203 | it, and giving a relevant date. 204 | 205 | b) The work must carry prominent notices stating that it is 206 | released under this License and any conditions added under section 207 | 7. This requirement modifies the requirement in section 4 to 208 | "keep intact all notices". 209 | 210 | c) You must license the entire work, as a whole, under this 211 | License to anyone who comes into possession of a copy. This 212 | License will therefore apply, along with any applicable section 7 213 | additional terms, to the whole of the work, and all its parts, 214 | regardless of how they are packaged. This License gives no 215 | permission to license the work in any other way, but it does not 216 | invalidate such permission if you have separately received it. 217 | 218 | d) If the work has interactive user interfaces, each must display 219 | Appropriate Legal Notices; however, if the Program has interactive 220 | interfaces that do not display Appropriate Legal Notices, your 221 | work need not make them do so. 222 | 223 | A compilation of a covered work with other separate and independent 224 | works, which are not by their nature extensions of the covered work, 225 | and which are not combined with it such as to form a larger program, 226 | in or on a volume of a storage or distribution medium, is called an 227 | "aggregate" if the compilation and its resulting copyright are not 228 | used to limit the access or legal rights of the compilation's users 229 | beyond what the individual works permit. Inclusion of a covered work 230 | in an aggregate does not cause this License to apply to the other 231 | parts of the aggregate. 232 | 233 | 6. Conveying Non-Source Forms. 234 | 235 | You may convey a covered work in object code form under the terms 236 | of sections 4 and 5, provided that you also convey the 237 | machine-readable Corresponding Source under the terms of this License, 238 | in one of these ways: 239 | 240 | a) Convey the object code in, or embodied in, a physical product 241 | (including a physical distribution medium), accompanied by the 242 | Corresponding Source fixed on a durable physical medium 243 | customarily used for software interchange. 244 | 245 | b) Convey the object code in, or embodied in, a physical product 246 | (including a physical distribution medium), accompanied by a 247 | written offer, valid for at least three years and valid for as 248 | long as you offer spare parts or customer support for that product 249 | model, to give anyone who possesses the object code either (1) a 250 | copy of the Corresponding Source for all the software in the 251 | product that is covered by this License, on a durable physical 252 | medium customarily used for software interchange, for a price no 253 | more than your reasonable cost of physically performing this 254 | conveying of source, or (2) access to copy the 255 | Corresponding Source from a network server at no charge. 256 | 257 | c) Convey individual copies of the object code with a copy of the 258 | written offer to provide the Corresponding Source. This 259 | alternative is allowed only occasionally and noncommercially, and 260 | only if you received the object code with such an offer, in accord 261 | with subsection 6b. 262 | 263 | d) Convey the object code by offering access from a designated 264 | place (gratis or for a charge), and offer equivalent access to the 265 | Corresponding Source in the same way through the same place at no 266 | further charge. You need not require recipients to copy the 267 | Corresponding Source along with the object code. If the place to 268 | copy the object code is a network server, the Corresponding Source 269 | may be on a different server (operated by you or a third party) 270 | that supports equivalent copying facilities, provided you maintain 271 | clear directions next to the object code saying where to find the 272 | Corresponding Source. Regardless of what server hosts the 273 | Corresponding Source, you remain obligated to ensure that it is 274 | available for as long as needed to satisfy these requirements. 275 | 276 | e) Convey the object code using peer-to-peer transmission, provided 277 | you inform other peers where the object code and Corresponding 278 | Source of the work are being offered to the general public at no 279 | charge under subsection 6d. 280 | 281 | A separable portion of the object code, whose source code is excluded 282 | from the Corresponding Source as a System Library, need not be 283 | included in conveying the object code work. 284 | 285 | A "User Product" is either (1) a "consumer product", which means any 286 | tangible personal property which is normally used for personal, family, 287 | or household purposes, or (2) anything designed or sold for incorporation 288 | into a dwelling. In determining whether a product is a consumer product, 289 | doubtful cases shall be resolved in favor of coverage. For a particular 290 | product received by a particular user, "normally used" refers to a 291 | typical or common use of that class of product, regardless of the status 292 | of the particular user or of the way in which the particular user 293 | actually uses, or expects or is expected to use, the product. A product 294 | is a consumer product regardless of whether the product has substantial 295 | commercial, industrial or non-consumer uses, unless such uses represent 296 | the only significant mode of use of the product. 297 | 298 | "Installation Information" for a User Product means any methods, 299 | procedures, authorization keys, or other information required to install 300 | and execute modified versions of a covered work in that User Product from 301 | a modified version of its Corresponding Source. The information must 302 | suffice to ensure that the continued functioning of the modified object 303 | code is in no case prevented or interfered with solely because 304 | modification has been made. 305 | 306 | If you convey an object code work under this section in, or with, or 307 | specifically for use in, a User Product, and the conveying occurs as 308 | part of a transaction in which the right of possession and use of the 309 | User Product is transferred to the recipient in perpetuity or for a 310 | fixed term (regardless of how the transaction is characterized), the 311 | Corresponding Source conveyed under this section must be accompanied 312 | by the Installation Information. But this requirement does not apply 313 | if neither you nor any third party retains the ability to install 314 | modified object code on the User Product (for example, the work has 315 | been installed in ROM). 316 | 317 | The requirement to provide Installation Information does not include a 318 | requirement to continue to provide support service, warranty, or updates 319 | for a work that has been modified or installed by the recipient, or for 320 | the User Product in which it has been modified or installed. Access to a 321 | network may be denied when the modification itself materially and 322 | adversely affects the operation of the network or violates the rules and 323 | protocols for communication across the network. 324 | 325 | Corresponding Source conveyed, and Installation Information provided, 326 | in accord with this section must be in a format that is publicly 327 | documented (and with an implementation available to the public in 328 | source code form), and must require no special password or key for 329 | unpacking, reading or copying. 330 | 331 | 7. Additional Terms. 332 | 333 | "Additional permissions" are terms that supplement the terms of this 334 | License by making exceptions from one or more of its conditions. 335 | Additional permissions that are applicable to the entire Program shall 336 | be treated as though they were included in this License, to the extent 337 | that they are valid under applicable law. If additional permissions 338 | apply only to part of the Program, that part may be used separately 339 | under those permissions, but the entire Program remains governed by 340 | this License without regard to the additional permissions. 341 | 342 | When you convey a copy of a covered work, you may at your option 343 | remove any additional permissions from that copy, or from any part of 344 | it. (Additional permissions may be written to require their own 345 | removal in certain cases when you modify the work.) You may place 346 | additional permissions on material, added by you to a covered work, 347 | for which you have or can give appropriate copyright permission. 348 | 349 | Notwithstanding any other provision of this License, for material you 350 | add to a covered work, you may (if authorized by the copyright holders of 351 | that material) supplement the terms of this License with terms: 352 | 353 | a) Disclaiming warranty or limiting liability differently from the 354 | terms of sections 15 and 16 of this License; or 355 | 356 | b) Requiring preservation of specified reasonable legal notices or 357 | author attributions in that material or in the Appropriate Legal 358 | Notices displayed by works containing it; or 359 | 360 | c) Prohibiting misrepresentation of the origin of that material, or 361 | requiring that modified versions of such material be marked in 362 | reasonable ways as different from the original version; or 363 | 364 | d) Limiting the use for publicity purposes of names of licensors or 365 | authors of the material; or 366 | 367 | e) Declining to grant rights under trademark law for use of some 368 | trade names, trademarks, or service marks; or 369 | 370 | f) Requiring indemnification of licensors and authors of that 371 | material by anyone who conveys the material (or modified versions of 372 | it) with contractual assumptions of liability to the recipient, for 373 | any liability that these contractual assumptions directly impose on 374 | those licensors and authors. 375 | 376 | All other non-permissive additional terms are considered "further 377 | restrictions" within the meaning of section 10. If the Program as you 378 | received it, or any part of it, contains a notice stating that it is 379 | governed by this License along with a term that is a further 380 | restriction, you may remove that term. If a license document contains 381 | a further restriction but permits relicensing or conveying under this 382 | License, you may add to a covered work material governed by the terms 383 | of that license document, provided that the further restriction does 384 | not survive such relicensing or conveying. 385 | 386 | If you add terms to a covered work in accord with this section, you 387 | must place, in the relevant source files, a statement of the 388 | additional terms that apply to those files, or a notice indicating 389 | where to find the applicable terms. 390 | 391 | Additional terms, permissive or non-permissive, may be stated in the 392 | form of a separately written license, or stated as exceptions; 393 | the above requirements apply either way. 394 | 395 | 8. Termination. 396 | 397 | You may not propagate or modify a covered work except as expressly 398 | provided under this License. Any attempt otherwise to propagate or 399 | modify it is void, and will automatically terminate your rights under 400 | this License (including any patent licenses granted under the third 401 | paragraph of section 11). 402 | 403 | However, if you cease all violation of this License, then your 404 | license from a particular copyright holder is reinstated (a) 405 | provisionally, unless and until the copyright holder explicitly and 406 | finally terminates your license, and (b) permanently, if the copyright 407 | holder fails to notify you of the violation by some reasonable means 408 | prior to 60 days after the cessation. 409 | 410 | Moreover, your license from a particular copyright holder is 411 | reinstated permanently if the copyright holder notifies you of the 412 | violation by some reasonable means, this is the first time you have 413 | received notice of violation of this License (for any work) from that 414 | copyright holder, and you cure the violation prior to 30 days after 415 | your receipt of the notice. 416 | 417 | Termination of your rights under this section does not terminate the 418 | licenses of parties who have received copies or rights from you under 419 | this License. If your rights have been terminated and not permanently 420 | reinstated, you do not qualify to receive new licenses for the same 421 | material under section 10. 422 | 423 | 9. Acceptance Not Required for Having Copies. 424 | 425 | You are not required to accept this License in order to receive or 426 | run a copy of the Program. Ancillary propagation of a covered work 427 | occurring solely as a consequence of using peer-to-peer transmission 428 | to receive a copy likewise does not require acceptance. However, 429 | nothing other than this License grants you permission to propagate or 430 | modify any covered work. These actions infringe copyright if you do 431 | not accept this License. Therefore, by modifying or propagating a 432 | covered work, you indicate your acceptance of this License to do so. 433 | 434 | 10. Automatic Licensing of Downstream Recipients. 435 | 436 | Each time you convey a covered work, the recipient automatically 437 | receives a license from the original licensors, to run, modify and 438 | propagate that work, subject to this License. You are not responsible 439 | for enforcing compliance by third parties with this License. 440 | 441 | An "entity transaction" is a transaction transferring control of an 442 | organization, or substantially all assets of one, or subdividing an 443 | organization, or merging organizations. If propagation of a covered 444 | work results from an entity transaction, each party to that 445 | transaction who receives a copy of the work also receives whatever 446 | licenses to the work the party's predecessor in interest had or could 447 | give under the previous paragraph, plus a right to possession of the 448 | Corresponding Source of the work from the predecessor in interest, if 449 | the predecessor has it or can get it with reasonable efforts. 450 | 451 | You may not impose any further restrictions on the exercise of the 452 | rights granted or affirmed under this License. For example, you may 453 | not impose a license fee, royalty, or other charge for exercise of 454 | rights granted under this License, and you may not initiate litigation 455 | (including a cross-claim or counterclaim in a lawsuit) alleging that 456 | any patent claim is infringed by making, using, selling, offering for 457 | sale, or importing the Program or any portion of it. 458 | 459 | 11. Patents. 460 | 461 | A "contributor" is a copyright holder who authorizes use under this 462 | License of the Program or a work on which the Program is based. The 463 | work thus licensed is called the contributor's "contributor version". 464 | 465 | A contributor's "essential patent claims" are all patent claims 466 | owned or controlled by the contributor, whether already acquired or 467 | hereafter acquired, that would be infringed by some manner, permitted 468 | by this License, of making, using, or selling its contributor version, 469 | but do not include claims that would be infringed only as a 470 | consequence of further modification of the contributor version. For 471 | purposes of this definition, "control" includes the right to grant 472 | patent sublicenses in a manner consistent with the requirements of 473 | this License. 474 | 475 | Each contributor grants you a non-exclusive, worldwide, royalty-free 476 | patent license under the contributor's essential patent claims, to 477 | make, use, sell, offer for sale, import and otherwise run, modify and 478 | propagate the contents of its contributor version. 479 | 480 | In the following three paragraphs, a "patent license" is any express 481 | agreement or commitment, however denominated, not to enforce a patent 482 | (such as an express permission to practice a patent or covenant not to 483 | sue for patent infringement). To "grant" such a patent license to a 484 | party means to make such an agreement or commitment not to enforce a 485 | patent against the party. 486 | 487 | If you convey a covered work, knowingly relying on a patent license, 488 | and the Corresponding Source of the work is not available for anyone 489 | to copy, free of charge and under the terms of this License, through a 490 | publicly available network server or other readily accessible means, 491 | then you must either (1) cause the Corresponding Source to be so 492 | available, or (2) arrange to deprive yourself of the benefit of the 493 | patent license for this particular work, or (3) arrange, in a manner 494 | consistent with the requirements of this License, to extend the patent 495 | license to downstream recipients. "Knowingly relying" means you have 496 | actual knowledge that, but for the patent license, your conveying the 497 | covered work in a country, or your recipient's use of the covered work 498 | in a country, would infringe one or more identifiable patents in that 499 | country that you have reason to believe are valid. 500 | 501 | If, pursuant to or in connection with a single transaction or 502 | arrangement, you convey, or propagate by procuring conveyance of, a 503 | covered work, and grant a patent license to some of the parties 504 | receiving the covered work authorizing them to use, propagate, modify 505 | or convey a specific copy of the covered work, then the patent license 506 | you grant is automatically extended to all recipients of the covered 507 | work and works based on it. 508 | 509 | A patent license is "discriminatory" if it does not include within 510 | the scope of its coverage, prohibits the exercise of, or is 511 | conditioned on the non-exercise of one or more of the rights that are 512 | specifically granted under this License. You may not convey a covered 513 | work if you are a party to an arrangement with a third party that is 514 | in the business of distributing software, under which you make payment 515 | to the third party based on the extent of your activity of conveying 516 | the work, and under which the third party grants, to any of the 517 | parties who would receive the covered work from you, a discriminatory 518 | patent license (a) in connection with copies of the covered work 519 | conveyed by you (or copies made from those copies), or (b) primarily 520 | for and in connection with specific products or compilations that 521 | contain the covered work, unless you entered into that arrangement, 522 | or that patent license was granted, prior to 28 March 2007. 523 | 524 | Nothing in this License shall be construed as excluding or limiting 525 | any implied license or other defenses to infringement that may 526 | otherwise be available to you under applicable patent law. 527 | 528 | 12. No Surrender of Others' Freedom. 529 | 530 | If conditions are imposed on you (whether by court order, agreement or 531 | otherwise) that contradict the conditions of this License, they do not 532 | excuse you from the conditions of this License. If you cannot convey a 533 | covered work so as to satisfy simultaneously your obligations under this 534 | License and any other pertinent obligations, then as a consequence you may 535 | not convey it at all. For example, if you agree to terms that obligate you 536 | to collect a royalty for further conveying from those to whom you convey 537 | the Program, the only way you could satisfy both those terms and this 538 | License would be to refrain entirely from conveying the Program. 539 | 540 | 13. Remote Network Interaction; Use with the GNU General Public License. 541 | 542 | Notwithstanding any other provision of this License, if you modify the 543 | Program, your modified version must prominently offer all users 544 | interacting with it remotely through a computer network (if your version 545 | supports such interaction) an opportunity to receive the Corresponding 546 | Source of your version by providing access to the Corresponding Source 547 | from a network server at no charge, through some standard or customary 548 | means of facilitating copying of software. This Corresponding Source 549 | shall include the Corresponding Source for any work covered by version 3 550 | of the GNU General Public License that is incorporated pursuant to the 551 | following paragraph. 552 | 553 | Notwithstanding any other provision of this License, you have 554 | permission to link or combine any covered work with a work licensed 555 | under version 3 of the GNU General Public License into a single 556 | combined work, and to convey the resulting work. The terms of this 557 | License will continue to apply to the part which is the covered work, 558 | but the work with which it is combined will remain governed by version 559 | 3 of the GNU General Public License. 560 | 561 | 14. Revised Versions of this License. 562 | 563 | The Free Software Foundation may publish revised and/or new versions of 564 | the GNU Affero General Public License from time to time. Such new versions 565 | will be similar in spirit to the present version, but may differ in detail to 566 | address new problems or concerns. 567 | 568 | Each version is given a distinguishing version number. If the 569 | Program specifies that a certain numbered version of the GNU Affero General 570 | Public License "or any later version" applies to it, you have the 571 | option of following the terms and conditions either of that numbered 572 | version or of any later version published by the Free Software 573 | Foundation. If the Program does not specify a version number of the 574 | GNU Affero General Public License, you may choose any version ever published 575 | by the Free Software Foundation. 576 | 577 | If the Program specifies that a proxy can decide which future 578 | versions of the GNU Affero General Public License can be used, that proxy's 579 | public statement of acceptance of a version permanently authorizes you 580 | to choose that version for the Program. 581 | 582 | Later license versions may give you additional or different 583 | permissions. However, no additional obligations are imposed on any 584 | author or copyright holder as a result of your choosing to follow a 585 | later version. 586 | 587 | 15. Disclaimer of Warranty. 588 | 589 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 590 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 591 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 592 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 593 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 594 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 595 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 596 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 597 | 598 | 16. Limitation of Liability. 599 | 600 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 601 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 602 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 603 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 604 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 605 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 606 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 607 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 608 | SUCH DAMAGES. 609 | 610 | 17. Interpretation of Sections 15 and 16. 611 | 612 | If the disclaimer of warranty and limitation of liability provided 613 | above cannot be given local legal effect according to their terms, 614 | reviewing courts shall apply local law that most closely approximates 615 | an absolute waiver of all civil liability in connection with the 616 | Program, unless a warranty or assumption of liability accompanies a 617 | copy of the Program in return for a fee. 618 | 619 | END OF TERMS AND CONDITIONS 620 | 621 | How to Apply These Terms to Your New Programs 622 | 623 | If you develop a new program, and you want it to be of the greatest 624 | possible use to the public, the best way to achieve this is to make it 625 | free software which everyone can redistribute and change under these terms. 626 | 627 | To do so, attach the following notices to the program. It is safest 628 | to attach them to the start of each source file to most effectively 629 | state the exclusion of warranty; and each file should have at least 630 | the "copyright" line and a pointer to where the full notice is found. 631 | 632 | 633 | Copyright (C) 634 | 635 | This program is free software: you can redistribute it and/or modify 636 | it under the terms of the GNU Affero General Public License as published 637 | by the Free Software Foundation, either version 3 of the License, or 638 | (at your option) any later version. 639 | 640 | This program is distributed in the hope that it will be useful, 641 | but WITHOUT ANY WARRANTY; without even the implied warranty of 642 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 643 | GNU Affero General Public License for more details. 644 | 645 | You should have received a copy of the GNU Affero General Public License 646 | along with this program. If not, see . 647 | 648 | Also add information on how to contact you by electronic and paper mail. 649 | 650 | If your software can interact with users remotely through a computer 651 | network, you should also make sure that it provides a way for users to 652 | get its source. For example, if your program is a web application, its 653 | interface could display a "Source" link that leads users to an archive 654 | of the code. There are many ways you could offer source, and different 655 | solutions will be better for different programs; see section 13 for the 656 | specific requirements. 657 | 658 | You should also get your employer (if you work as a programmer) or school, 659 | if any, to sign a "copyright disclaimer" for the program, if necessary. 660 | For more information on this, and how to apply and follow the GNU AGPL, see 661 | . 662 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Minecraftle 2 | 3 | A daily puzzle game fusing Wordle and Minecraft crafting recipes built with Next.js. 4 | 5 | [Play Minecraftle](https://minecraftle.zachmanson.com) 6 | 7 | ## Setting Up 8 | 9 | 1. Clone the repo 10 | 2. `npm install` 11 | 3. `npx prisma db generate` 12 | 4. Install postgres, create a database 13 | 5. `cp .env.example .env` 14 | 6. Update database login string 15 | 7. `npx db prisma` 16 | 8. `npm run dev` 17 | 18 | ## Original Creators 19 | 20 | | [Zach Manson](https://github.com/pavo-etc) | [Harrison Oates](https://github.com/Oatesha) | [Tamura Boog](https://github.com/Tamura77) | [Ivan Sossa](https://github.com/SossaG) | 21 | | -------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- | 22 | | Zach's beautiful face | Oates' beautiful face | Tamura's beautiful face | Ivan's beautiful face | 23 | 24 | CITS3403 Agile Web Development Project 2022 25 | 26 | Due date: May 23, 2022 12:00 (noon) 27 | 28 | Weighting: 30% 29 | 30 | Final mark: 100% 31 | -------------------------------------------------------------------------------- /conversion_scripts/.gitignore: -------------------------------------------------------------------------------- 1 | recipes/ -------------------------------------------------------------------------------- /conversion_scripts/change_puzzles.py: -------------------------------------------------------------------------------- 1 | import json 2 | from os import remove 3 | 4 | 5 | 6 | 7 | def main(): 8 | print("type exit or control + C to exit\n", "type ingredients to save the ingredients with the new list\n", "type add to add the inputted string to the ingredients list\n", 9 | "to remove ingredients type remove and then every ingredient name to remove them from the list\n", "for a list of recipe names type LOR\n", "to REPEAT these instructions type help") 10 | 11 | recipenames = [] 12 | with open("app\static\data\items.json") as f: 13 | jsonfile = json.load(f) 14 | for i in jsonfile: 15 | recipenames.append(i) 16 | ingredients = [] 17 | remove_ingredients = [] 18 | f = open("app/static/data/given_ingredients.json", "r+") 19 | for line in f: 20 | line = line.strip() 21 | 22 | if (line != "[" and line != "]"): 23 | newline = (line.replace("\"", "")) 24 | newline = newline.replace(",", "") 25 | ingredients.append(newline) 26 | 27 | while True: 28 | 29 | inp = input(); 30 | 31 | match inp: 32 | case "ingredients": 33 | print(ingredients) 34 | jsonfile = json.dumps(ingredients, indent=1) 35 | f.seek(0) 36 | f.truncate(0) 37 | f.write(jsonfile) 38 | f.close() 39 | 40 | 41 | case "exit": 42 | break 43 | 44 | case "add": 45 | while True: 46 | print(ingredients) 47 | inpu = input() 48 | if inpu == "exit": 49 | break 50 | else: 51 | if inpu in recipenames: 52 | ingredients.append(inpu) 53 | else: 54 | print("recipe not valid please refer to the list of recipe names") 55 | 56 | case "remove": 57 | while True: 58 | print(ingredients) 59 | inpute = input() 60 | if inpute == "exit": 61 | break 62 | else: 63 | if inpute in recipenames: 64 | remove_ingredients.append(inpute) 65 | ingredients = [x for x in ingredients if x not in remove_ingredients] 66 | else: 67 | print("recipe not valid please refer to the list of recipe names") 68 | case "LOR": 69 | print(recipenames) 70 | 71 | case "help": 72 | print("type exit or control + C to exit\n", "type ingredients to save the ingredients with the new list\n", "type add to add the inputted string to the ingredients list\n", 73 | "to remove ingredients type remove and then every ingredient name to remove them from the list\n", "for a list of recipe names type LOR\n", "to REPEAT these instructions type help") 74 | 75 | 76 | if __name__ == "__main__": 77 | main() 78 | -------------------------------------------------------------------------------- /conversion_scripts/convert_recipes.py: -------------------------------------------------------------------------------- 1 | """ 2 | Written by Zach Manson, based on the previous script by Harrison Oates 3 | 4 | To use, get the recipes folder from the Minecraft source files and copy it into 5 | this folder. Then run this script, which will output a single file, recipes.json. 6 | 7 | Copy recipes.json into the data folder in app/static/data. 8 | 9 | """ 10 | 11 | import json, os 12 | from pprint import pprint 13 | 14 | # Converts tags to acceptable equivalent blocks 15 | tag_map = { 16 | "planks": "minecraft:planks", 17 | "wooden_slabs": "minecraft:oak_slab", 18 | "logs": "minecraft:oak_log", 19 | "stone": "minecraft:cobblestone", 20 | "wool": "minecraft:white_wool", 21 | "coals": "minecraft:coal", 22 | } 23 | 24 | files_to_skip = ["stick_from_bamboo_item"] 25 | 26 | given_ingredients = json.load(open("../app/static/data/given_ingredients.json")) 27 | 28 | 29 | def process_recipes(path): 30 | # Reads all recipe filenames (in minecraft.jar they are all seperate) 31 | recipe_filenames = [ 32 | recipe for recipe in os.listdir(path) if recipe.endswith(".json") 33 | ] 34 | new_recipes = {} 35 | 36 | for recipe_filename in recipe_filenames: 37 | print(f"{recipe_filename=}") 38 | 39 | # Load all shaped files 40 | jsonfile = json.load(open(os.path.join(path, recipe_filename))) 41 | extless_filename = recipe_filename[: recipe_filename.find(".")] 42 | if extless_filename in files_to_skip: 43 | continue 44 | if jsonfile["type"] != "minecraft:crafting_shaped": 45 | continue 46 | 47 | new_recipe = {"type": "", "group": "", "output": "", "input": []} 48 | 49 | new_recipe["type"] = jsonfile["type"] 50 | new_recipe["group"] = jsonfile.get("group", "") 51 | 52 | new_recipe["output"] = jsonfile["result"]["item"] 53 | skip = False 54 | for row in jsonfile["pattern"]: 55 | new_row = [] 56 | for char in row: 57 | if char == " ": 58 | new_row.append(None) 59 | else: 60 | key_item = jsonfile["key"][char] 61 | if isinstance(key_item, list): 62 | key_item = key_item[0] 63 | itemname = key_item.get("item", None) 64 | 65 | # Convert tags to blocks 66 | if itemname is None: 67 | itemname = key_item.get("tag", None) 68 | for tag in tag_map.keys(): 69 | if tag in itemname: 70 | itemname = tag_map[tag] 71 | 72 | if itemname == "minecraft:oak_planks": 73 | itemname = "minecraft:planks" 74 | 75 | new_row.append(itemname) 76 | 77 | if itemname not in given_ingredients: 78 | skip = True 79 | 80 | new_recipe["input"].append(new_row) 81 | 82 | if skip: 83 | continue 84 | new_recipes[extless_filename] = new_recipe 85 | 86 | return new_recipes 87 | 88 | 89 | def create_recipes(): 90 | processed_recipes = process_recipes("./recipes/") 91 | outputfilename = "./recipes.json" 92 | with open(outputfilename, "w") as write_file: 93 | json.dump(processed_recipes, write_file, indent=4) 94 | 95 | print(f"Written {len(processed_recipes)} recipes to {outputfilename}") 96 | 97 | 98 | def create_all_items(): 99 | recipes = json.load(open("./recipes.json")) 100 | recipes_outputs = [value["output"] for value in recipes.values()] 101 | all_items = json.load(open("./all_items.json")) 102 | 103 | items = { 104 | key: value 105 | for key, value in all_items.items() 106 | if (key in recipes_outputs) or (key in given_ingredients) 107 | } 108 | 109 | outputfilename = "./items.json" 110 | with open(outputfilename, "w") as write_file: 111 | json.dump(items, write_file, indent=4) 112 | print(f"Written {len(items)} recipes to {outputfilename}") 113 | 114 | 115 | if __name__ == "__main__": 116 | create_recipes() 117 | create_all_items() 118 | -------------------------------------------------------------------------------- /conversion_scripts/old_merge_recipes.py: -------------------------------------------------------------------------------- 1 | import json 2 | import os 3 | 4 | all_recipes = {} 5 | dir = "app/static/data/sanitised recipes" 6 | 7 | for filename in os.listdir(dir): 8 | f = os.path.join(dir, filename) 9 | if os.path.isfile(f): 10 | with open(f,"r") as file: 11 | print(f) 12 | extless_filename = filename[:filename.find(".")] 13 | all_recipes[extless_filename] = json.load(file) 14 | 15 | print(all_recipes.keys()) 16 | with open("app/static/data/recipes.json", "w") as write_file: 17 | json.dump(all_recipes, write_file) 18 | -------------------------------------------------------------------------------- /conversion_scripts/old_recipe.py: -------------------------------------------------------------------------------- 1 | import json, os 2 | 3 | # this definitely could've been done better but was in a rush and this worked, very shoddy code but it runs fast enough thanks to modern beefy computers and it works 4 | # I would comment each function and explain but its a bit messy the gyst of it is we go through minecrafts standard recipe.json format and append the recipe "pattern" 5 | # to the new json format so the pattern is the name of the item rather than a key code like # or %. 6 | 7 | 8 | 9 | def writejson(dictionary, filename): 10 | jsonobject = json.dumps(dictionary, indent = 4) 11 | with open(("../sanitised recipes/" + filename), 'w') as jsonfile: 12 | jsonfile.write(jsonobject) 13 | 14 | 15 | 16 | def processrecipes(path): 17 | recipesprocessed = [] 18 | 19 | recipes = [recipe for recipe in os.listdir(path) if recipe.endswith('.json')] 20 | recipes = recipes 21 | for i in recipes: 22 | jsonfile = open(path + i) 23 | recipesprocessed.append(json.load(jsonfile)) 24 | 25 | for jsonfile, name in zip(recipesprocessed, recipes): 26 | standard_dict = { 27 | "type": "", 28 | "group": "", 29 | "output": "", 30 | "input": [ 31 | [None, None, None], 32 | [None, None, None], 33 | [None, None, None] 34 | ] 35 | } 36 | for key, value in jsonfile.items(): 37 | if key == "type": 38 | standard_dict["type"] = value 39 | 40 | if key == "group": 41 | standard_dict["group"] = value 42 | 43 | 44 | if key == "pattern": 45 | for listindex, desiredpattern in enumerate(value): 46 | for desiredindex, desiredpattern in enumerate(desiredpattern): 47 | if desiredpattern != ' ': 48 | standard_dict["input"][listindex][desiredindex] = desiredpattern 49 | 50 | if key == "key": 51 | for nestedkey, nestedvalue in value.items(): 52 | for i in standard_dict["input"]: 53 | for x in i: 54 | if x == nestedkey: 55 | if isinstance(nestedvalue, dict): 56 | for firstlist in range(len(standard_dict["input"])): 57 | for secondlist in range(len(standard_dict["input"][firstlist])): 58 | if standard_dict["input"][firstlist][secondlist] == nestedkey: 59 | standard_dict["input"][firstlist][secondlist] = 'None'.join(list(nestedvalue.values())) 60 | else: 61 | for firstlist in range(len(standard_dict["input"])): 62 | for secondlist in range(len(standard_dict["input"][firstlist])): 63 | if standard_dict["input"][firstlist][secondlist] == nestedkey: 64 | standard_dict["input"][firstlist][secondlist] = 'None'.join(list(nestedvalue[0].values())) 65 | if key == "ingredients": 66 | if isinstance(value, list): 67 | del standard_dict["input"] 68 | for i in value: 69 | if isinstance(i, dict): 70 | for ingredientkey in i.keys(): 71 | if "input" in standard_dict: 72 | standard_dict["input"].append(i[ingredientkey]) 73 | 74 | else: 75 | standard_dict["input"] = list(i[ingredientkey].split()) 76 | else: 77 | if "input" in standard_dict: 78 | standard_dict["input"].append(i) 79 | 80 | else: 81 | standard_dict["input"] = list(i) 82 | 83 | if key == "result": 84 | if isinstance(value, dict): 85 | standard_dict["output"] = value["item"] 86 | else: 87 | standard_dict["output"] = value 88 | 89 | if (standard_dict["type"] != "minecraft:crafting_shapeless"): 90 | removenull(standard_dict["input"]) 91 | 92 | standard_dict["input"] = list(map(list, zip(*standard_dict["input"]))) 93 | removenull(standard_dict["input"]) 94 | 95 | 96 | standard_dict["input"] = list(map(list, zip(*standard_dict["input"]))) 97 | writejson(standard_dict, name) 98 | 99 | 100 | def removenull(list): 101 | deletions = [] 102 | for index, element in enumerate(list): 103 | nullcount = 0; 104 | for j in element: 105 | if j == None: 106 | nullcount += 1 107 | if nullcount == 3: 108 | deletions.append(index) 109 | 110 | deletioncount = 0 111 | for i in deletions: 112 | if deletioncount == 1 and i == 1: 113 | i = 0 114 | elif (deletioncount == 1 and i == 2): 115 | i = 1 116 | elif (deletioncount == 2): 117 | i = 0 118 | del list[i] 119 | deletioncount += 1 120 | 121 | 122 | def main(): 123 | processrecipes("../recipes/") 124 | 125 | if __name__ == "__main__": 126 | main() -------------------------------------------------------------------------------- /loader/bigquery.sql: -------------------------------------------------------------------------------- 1 | WITH scores AS ( 2 | SELECT 3 | user_id, 4 | SUM(game_count) AS total_games, 5 | SUM(CASE WHEN attempts = 11 THEN game_count ELSE 0 END) as total_losses, 6 | 7 | SUM(CASE WHEN attempts = 1 THEN game_count ELSE 0 END) as total_1, 8 | SUM(CASE WHEN attempts = 2 THEN game_count ELSE 0 END) as total_2, 9 | SUM(CASE WHEN attempts = 3 THEN game_count ELSE 0 END) as total_3, 10 | SUM(CASE WHEN attempts = 4 THEN game_count ELSE 0 END) as total_4, 11 | SUM(CASE WHEN attempts = 5 THEN game_count ELSE 0 END) as total_5, 12 | SUM(CASE WHEN attempts = 6 THEN game_count ELSE 0 END) as total_6, 13 | SUM(CASE WHEN attempts = 7 THEN game_count ELSE 0 END) as total_7, 14 | SUM(CASE WHEN attempts = 8 THEN game_count ELSE 0 END) as total_8, 15 | SUM(CASE WHEN attempts = 9 THEN game_count ELSE 0 END) as total_9, 16 | SUM(CASE WHEN attempts = 10 THEN game_count ELSE 0 END) as total_10, 17 | 18 | SUM(CASE WHEN attempts != 11 THEN attempts ELSE 0 END) as total_win_attempts 19 | FROM public.game_count 20 | GROUP BY user_id 21 | ), 22 | scoreboard AS ( 23 | SELECT 24 | DENSE_RANK() OVER ( 25 | ORDER BY (total_games - total_losses) DESC 26 | ) dense_rank_number, 27 | * 28 | FROM scores 29 | ), 30 | user_rank AS ( 31 | SELECT dense_rank_number FROM scoreboard WHERE user_id = '17032533448130.3485657576066198' 32 | ) 33 | 34 | SELECT * 35 | FROM scoreboard 36 | WHERE user_id = '17032533448130.3485657576066198' 37 | OR user_id IN ( 38 | SELECT user_id 39 | FROM scoreboard 40 | WHERE dense_rank_number = (SELECT dense_rank_number FROM user_rank) - 1 41 | LIMIT 1 42 | ) 43 | OR user_id IN ( 44 | SELECT user_id 45 | FROM scoreboard 46 | WHERE dense_rank_number = (SELECT dense_rank_number FROM user_rank) + 1 47 | LIMIT 1 48 | ); -------------------------------------------------------------------------------- /loader/load.py: -------------------------------------------------------------------------------- 1 | import csv 2 | import sys, os 3 | 4 | # Reading from a CSV file 5 | with open("mctl.csv", "r") as file: 6 | with open("users.sql", "w") as user_query: 7 | user_query.write( 8 | """ 9 | INSERT INTO public.user (user_id, last_game_date) 10 | VALUES 11 | """ 12 | ) 13 | with open("games.sql", "w") as game_query: 14 | game_query.write( 15 | f""" 16 | INSERT INTO public.game_count (user_id, attempts, game_count) 17 | VALUES 18 | """ 19 | ) 20 | reader = csv.reader(file) 21 | for i, row in enumerate(reader): 22 | if i == 0: 23 | continue 24 | 25 | user_query.write( 26 | f""" 27 | ('{row[1]}', '{row[2]}'),""" 28 | ) 29 | if row[3] == "0": 30 | attempts = "11" 31 | else: 32 | attempts = row[4] 33 | 34 | game_query.write( 35 | f""" 36 | ('{row[1]}', {attempts}, 1),""" 37 | ) 38 | 39 | if len(sys.argv) > 1 and i > int(sys.argv[1]): 40 | break 41 | game_query.seek(game_query.tell() - 1, os.SEEK_SET) 42 | game_query.write("") 43 | game_query.write( 44 | """ 45 | ON CONFLICT (user_id, attempts) 46 | DO UPDATE SET 47 | game_count = public.game_count.game_count + 1; 48 | """ 49 | ) 50 | 51 | user_query.seek(user_query.tell() - 1, os.SEEK_SET) 52 | user_query.write("") 53 | user_query.write( 54 | """ 55 | ON CONFLICT (user_id) 56 | DO UPDATE SET 57 | last_game_date = excluded.last_game_date 58 | ; 59 | """ 60 | ) 61 | -------------------------------------------------------------------------------- /loader/load_csv.sql: -------------------------------------------------------------------------------- 1 | \copy public.user (user_id,last_game_date) FROM '/home/pg/user.csv' DELIMITER ','; 2 | 3 | \copy public.game_count (user_id,attempts,game_count) FROM '/home/pg/game_count.csv' DELIMITER ','; -------------------------------------------------------------------------------- /loader/loadtest.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | python3 load.py $1 4 | echo created sql bulk inserts 5 | # cat -n users.sql | sort -k2 -k1n | uniq -f1 | sort -nk1,1 | cut -f2- > clean_users.sql 6 | # cat -n games.sql | sort -k2 -k1n | uniq -f1 | sort -nk1,1 | cut -f2- > clean_games.sql 7 | echo removing duplicates 8 | psql -h localhost -d minecraftle -f users.sql > output1. 9 | echo inserted users 10 | psql -h localhost -d minecraftle -f games.sql > output2.txt 11 | echo inserted games 12 | time psql -h localhost -d minecraftle -f bigquery.sql -o output3.txt -------------------------------------------------------------------------------- /loader/refresh_mv.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | psql -h localhost -d minecraftle -c 'REFRESH MATERIALIZED VIEW scoreboard;' -------------------------------------------------------------------------------- /loader/sqlite_loader.py: -------------------------------------------------------------------------------- 1 | import sqlite3 2 | import sys, os 3 | import csv 4 | 5 | conn = sqlite3.connect("new_schema.db") 6 | cur = conn.cursor() 7 | cur.execute( 8 | """ 9 | -- CreateTable 10 | CREATE TABLE IF NOT EXISTS "user" ( 11 | "id" SERIAL NOT NULL, 12 | "user_id" TEXT NOT NULL, 13 | "last_game_date" TIMESTAMP(3), 14 | 15 | CONSTRAINT "user_pkey" PRIMARY KEY ("id") 16 | ); 17 | """ 18 | ) 19 | cur.execute( 20 | """ 21 | 22 | -- CreateTable 23 | CREATE TABLE IF NOT EXISTS "game_count" ( 24 | "id" SERIAL NOT NULL, 25 | "user_id" TEXT NOT NULL, 26 | "attempts" INTEGER NOT NULL, 27 | "game_count" INTEGER NOT NULL, 28 | 29 | CONSTRAINT "game_count_pkey" PRIMARY KEY ("id") 30 | ); 31 | """ 32 | ) 33 | 34 | cur.execute( 35 | """ 36 | -- CreateIndex 37 | CREATE UNIQUE INDEX IF NOT EXISTS "user_user_id_key" ON "user"("user_id"); 38 | """ 39 | ) 40 | cur.execute( 41 | """ 42 | -- CreateIndex 43 | CREATE UNIQUE INDEX IF NOT EXISTS "game_count_user_id_attempts_key" ON "game_count"("user_id", "attempts"); 44 | """ 45 | ) 46 | # Reading from a CSV file 47 | with open("mctl.csv", "r") as file: 48 | reader = csv.reader(file) 49 | for i, row in enumerate(reader): 50 | if i == 0: 51 | continue 52 | 53 | cur.execute( 54 | f""" 55 | INSERT INTO user (id, user_id, last_game_date) 56 | VALUES ({i},'{row[1]}', '{row[2]}') 57 | ON CONFLICT (user_id) 58 | DO UPDATE SET last_game_date = excluded.last_game_date;""" 59 | ) 60 | if row[3] == "0": 61 | attempts = "11" 62 | else: 63 | attempts = row[4] 64 | 65 | cur.execute( 66 | f""" 67 | INSERT INTO game_count (id, user_id, attempts, game_count) 68 | VALUES ({i}, '{row[1]}', {attempts}, 1) 69 | ON CONFLICT (user_id, attempts) 70 | DO UPDATE SET game_count = game_count.game_count + 1;""" 71 | ) 72 | 73 | if len(sys.argv) > 1 and i > int(sys.argv[1]): 74 | break 75 | 76 | conn.commit() 77 | -------------------------------------------------------------------------------- /loader/through_sqlite_loader.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | python3 sqlite_loader.py $1 4 | echo "created sqlite database finished" 5 | 6 | sqlite3 -csv new_schema.db "select user_id,last_game_date from user;" > user.csv 7 | echo user csv created 8 | sqlite3 -csv new_schema.db "select user_id,attempts,game_count from game_count;" > game_count.csv 9 | echo game_count csv created 10 | 11 | 12 | psql -h localhost -d minecraftle -f load_csv.sql > output.txt 13 | 14 | -------------------------------------------------------------------------------- /misc/C418 - Aria Math (Minecraft Volume Beta).mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zachpmanson/minecraftle/bdf2ce79d9019c48d9c4e94dfe4bd2f36dadda18/misc/C418 - Aria Math (Minecraft Volume Beta).mp3 -------------------------------------------------------------------------------- /next.config.js: -------------------------------------------------------------------------------- 1 | /** @type {import('next').NextConfig} */ 2 | const nextConfig = { 3 | reactStrictMode: true, 4 | async headers() { 5 | return [ 6 | { 7 | // matching all API routes 8 | source: "/api/:path*", 9 | headers: [ 10 | // { key: "Access-Control-Allow-Credentials", value: "true" }, 11 | { 12 | key: "Access-Control-Allow-Origin", 13 | value: "http://127.0.0.1:5000", 14 | }, // replace this your actual origin 15 | { 16 | key: "Access-Control-Allow-Methods", 17 | value: "GET,DELETE,PATCH,POST,PUT,OPTIONS", 18 | }, 19 | { 20 | key: "Access-Control-Allow-Headers", 21 | value: 22 | "X-CSRF-Token, X-Requested-With, Accept, Accept-Version, Content-Length, Content-MD5, Content-Type, Date, X-Api-Version", 23 | }, 24 | ], 25 | }, 26 | { 27 | source: "/:path*", 28 | headers: [ 29 | { 30 | key: "X-Frame-Options", 31 | value: "SAMEORIGIN", 32 | }, 33 | ], 34 | }, 35 | ]; 36 | }, 37 | }; 38 | 39 | module.exports = nextConfig; 40 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "minecraftle", 3 | "version": "0.1.0", 4 | "private": true, 5 | "scripts": { 6 | "dev": "next dev --turbo", 7 | "build": "next build", 8 | "start": "next start", 9 | "lint": "next lint", 10 | "generate": "prisma generate", 11 | "migrate": "prisma migrate deploy", 12 | "postinstall": "pnpm generate" 13 | }, 14 | "dependencies": { 15 | "@headlessui/react": "^1.7.19", 16 | "@prisma/client": "^5.22.0", 17 | "@tanstack/react-query": "^5.66.11", 18 | "@trpc/client": "11.0.0-rc.819", 19 | "@trpc/next": "11.0.0-rc.819", 20 | "@trpc/react-query": "11.0.0-rc.819", 21 | "@trpc/server": "11.0.0-rc.819", 22 | "next": "^15.2.0", 23 | "nuqs": "^1.20.0", 24 | "prisma": "^5.22.0", 25 | "react": "^18.3.1", 26 | "react-dom": "^18.3.1", 27 | "seedrandom": "^3.0.5", 28 | "zod": "^3.24.2" 29 | }, 30 | "devDependencies": { 31 | "@types/node": "^20.17.22", 32 | "@types/react": "^18.3.18", 33 | "@types/react-dom": "^18.3.5", 34 | "@types/seedrandom": "^3.0.8", 35 | "autoprefixer": "^10.4.20", 36 | "eslint": "^8.57.1", 37 | "eslint-config-next": "14.0.4", 38 | "postcss": "^8.5.3", 39 | "tailwindcss": "^3.4.17", 40 | "typescript": "^5.8.2" 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /postcss.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | plugins: { 3 | tailwindcss: {}, 4 | autoprefixer: {}, 5 | }, 6 | } 7 | -------------------------------------------------------------------------------- /prisma/MVs.sql: -------------------------------------------------------------------------------- 1 | 2 | CREATE MATERIALIZED VIEW scoreboard AS 3 | WITH scores AS ( 4 | SELECT 5 | gc.user_id, 6 | SUM(game_count) AS total_games, 7 | SUM(CASE WHEN attempts = 11 THEN game_count ELSE 0 END) as total_losses, 8 | 9 | SUM(CASE WHEN attempts = 1 THEN game_count ELSE 0 END) as total_1, 10 | SUM(CASE WHEN attempts = 2 THEN game_count ELSE 0 END) as total_2, 11 | SUM(CASE WHEN attempts = 3 THEN game_count ELSE 0 END) as total_3, 12 | SUM(CASE WHEN attempts = 4 THEN game_count ELSE 0 END) as total_4, 13 | SUM(CASE WHEN attempts = 5 THEN game_count ELSE 0 END) as total_5, 14 | SUM(CASE WHEN attempts = 6 THEN game_count ELSE 0 END) as total_6, 15 | SUM(CASE WHEN attempts = 7 THEN game_count ELSE 0 END) as total_7, 16 | SUM(CASE WHEN attempts = 8 THEN game_count ELSE 0 END) as total_8, 17 | SUM(CASE WHEN attempts = 9 THEN game_count ELSE 0 END) as total_9, 18 | SUM(CASE WHEN attempts = 10 THEN game_count ELSE 0 END) as total_10, 19 | 20 | SUM(CASE WHEN attempts != 11 THEN game_count*attempts ELSE 0 END) as total_win_attempts 21 | FROM public.game_count gc 22 | GROUP BY gc.user_idz 23 | ) 24 | 25 | SELECT 26 | DENSE_RANK() OVER ( 27 | ORDER BY (total_games - total_losses) DESC, total_win_attempts ASC 28 | ) dense_rank_number, 29 | * 30 | FROM scores; -------------------------------------------------------------------------------- /prisma/migrations/20240118093728_init/migration.sql: -------------------------------------------------------------------------------- 1 | -- CreateTable 2 | CREATE TABLE "user" ( 3 | "id" SERIAL NOT NULL, 4 | "user_id" TEXT NOT NULL, 5 | "last_game_date" TIMESTAMP(3), 6 | 7 | CONSTRAINT "user_pkey" PRIMARY KEY ("id") 8 | ); 9 | 10 | -- CreateTable 11 | CREATE TABLE "game_count" ( 12 | "id" SERIAL NOT NULL, 13 | "user_id" TEXT NOT NULL, 14 | "attempts" INTEGER NOT NULL, 15 | "game_count" INTEGER NOT NULL, 16 | 17 | CONSTRAINT "game_count_pkey" PRIMARY KEY ("id") 18 | ); 19 | 20 | -- CreateIndex 21 | CREATE UNIQUE INDEX "user_user_id_key" ON "user"("user_id"); 22 | 23 | -- CreateIndex 24 | CREATE UNIQUE INDEX "game_count_user_id_attempts_key" ON "game_count"("user_id", "attempts"); 25 | 26 | -- Custom modification MaterializedView 27 | CREATE MATERIALIZED VIEW scoreboard AS 28 | WITH scores AS ( 29 | SELECT 30 | gc.user_id, 31 | SUM(game_count) AS total_games, 32 | SUM(CASE WHEN attempts = 11 THEN game_count ELSE 0 END) as total_losses, 33 | 34 | SUM(CASE WHEN attempts = 1 THEN game_count ELSE 0 END) as total_1, 35 | SUM(CASE WHEN attempts = 2 THEN game_count ELSE 0 END) as total_2, 36 | SUM(CASE WHEN attempts = 3 THEN game_count ELSE 0 END) as total_3, 37 | SUM(CASE WHEN attempts = 4 THEN game_count ELSE 0 END) as total_4, 38 | SUM(CASE WHEN attempts = 5 THEN game_count ELSE 0 END) as total_5, 39 | SUM(CASE WHEN attempts = 6 THEN game_count ELSE 0 END) as total_6, 40 | SUM(CASE WHEN attempts = 7 THEN game_count ELSE 0 END) as total_7, 41 | SUM(CASE WHEN attempts = 8 THEN game_count ELSE 0 END) as total_8, 42 | SUM(CASE WHEN attempts = 9 THEN game_count ELSE 0 END) as total_9, 43 | SUM(CASE WHEN attempts = 10 THEN game_count ELSE 0 END) as total_10, 44 | 45 | SUM(CASE WHEN attempts != 11 THEN attempts ELSE 0 END) as total_win_attempts 46 | FROM public.game_count gc 47 | GROUP BY gc.user_id 48 | ) 49 | 50 | SELECT 51 | DENSE_RANK() OVER ( 52 | ORDER BY (total_games - total_losses) DESC, total_win_attempts ASC 53 | ) dense_rank_number, 54 | * 55 | FROM scores -------------------------------------------------------------------------------- /prisma/migrations/migration_lock.toml: -------------------------------------------------------------------------------- 1 | # Please do not edit this file manually 2 | # It should be added in your version-control system (i.e. Git) 3 | provider = "postgresql" -------------------------------------------------------------------------------- /prisma/schema.prisma: -------------------------------------------------------------------------------- 1 | // This is your Prisma schema file, 2 | // learn more about it in the docs: https://pris.ly/d/prisma-schema 3 | 4 | generator client { 5 | provider = "prisma-client-js" 6 | } 7 | 8 | datasource db { 9 | provider = "postgresql" 10 | url = env("DATABASE_URL") 11 | } 12 | 13 | model user { 14 | id Int @id @default(autoincrement()) 15 | user_id String @unique 16 | last_game_date DateTime? 17 | } 18 | 19 | model game_count { 20 | id Int @id @default(autoincrement()) 21 | user_id String 22 | attempts Int 23 | game_count Int 24 | 25 | @@unique([user_id, attempts]) 26 | } 27 | -------------------------------------------------------------------------------- /public/audio/button_click.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zachpmanson/minecraftle/bdf2ce79d9019c48d9c4e94dfe4bd2f36dadda18/public/audio/button_click.wav -------------------------------------------------------------------------------- /public/data/given_ingredients.json: -------------------------------------------------------------------------------- 1 | [ 2 | "minecraft:planks", 3 | "minecraft:cobblestone", 4 | "minecraft:stone", 5 | "minecraft:glass", 6 | "minecraft:white_wool", 7 | "minecraft:stick", 8 | "minecraft:coal", 9 | "minecraft:diamond", 10 | "minecraft:gold_ingot", 11 | "minecraft:iron_ingot", 12 | "minecraft:redstone", 13 | "minecraft:quartz", 14 | "minecraft:oak_slab", 15 | "minecraft:oak_log", 16 | "minecraft:iron_nugget", 17 | "minecraft:redstone_torch", 18 | "minecraft:string", 19 | "minecraft:leather" 20 | ] -------------------------------------------------------------------------------- /public/data/recipes.json: -------------------------------------------------------------------------------- 1 | { 2 | "activator_rail": { 3 | "type": "minecraft:crafting_shaped", 4 | "group": "", 5 | "output": "minecraft:activator_rail", 6 | "input": [ 7 | ["minecraft:iron_ingot", "minecraft:stick", "minecraft:iron_ingot"], 8 | ["minecraft:iron_ingot", "minecraft:redstone_torch", "minecraft:iron_ingot"], 9 | ["minecraft:iron_ingot", "minecraft:stick", "minecraft:iron_ingot"] 10 | ] 11 | }, 12 | "barrel": { 13 | "type": "minecraft:crafting_shaped", 14 | "group": "", 15 | "output": "minecraft:barrel", 16 | "input": [ 17 | ["minecraft:planks", "minecraft:oak_slab", "minecraft:planks"], 18 | ["minecraft:planks", null, "minecraft:planks"], 19 | ["minecraft:planks", "minecraft:oak_slab", "minecraft:planks"] 20 | ] 21 | }, 22 | "bow": { 23 | "type": "minecraft:crafting_shaped", 24 | "group": "", 25 | "output": "minecraft:bow", 26 | "input": [ 27 | [null, "minecraft:stick", "minecraft:string"], 28 | ["minecraft:stick", null, "minecraft:string"], 29 | [null, "minecraft:stick", "minecraft:string"] 30 | ] 31 | }, 32 | "bowl": { 33 | "type": "minecraft:crafting_shaped", 34 | "group": "", 35 | "output": "minecraft:bowl", 36 | "input": [ 37 | ["minecraft:planks", null, "minecraft:planks"], 38 | [null, "minecraft:planks", null] 39 | ] 40 | }, 41 | "bucket": { 42 | "type": "minecraft:crafting_shaped", 43 | "group": "", 44 | "output": "minecraft:bucket", 45 | "input": [ 46 | ["minecraft:iron_ingot", null, "minecraft:iron_ingot"], 47 | [null, "minecraft:iron_ingot", null] 48 | ] 49 | }, 50 | "campfire": { 51 | "type": "minecraft:crafting_shaped", 52 | "group": "", 53 | "output": "minecraft:campfire", 54 | "input": [ 55 | [null, "minecraft:stick", null], 56 | ["minecraft:stick", "minecraft:coal", "minecraft:stick"], 57 | ["minecraft:oak_log", "minecraft:oak_log", "minecraft:oak_log"] 58 | ] 59 | }, 60 | "cauldron": { 61 | "type": "minecraft:crafting_shaped", 62 | "group": "", 63 | "output": "minecraft:cauldron", 64 | "input": [ 65 | ["minecraft:iron_ingot", null, "minecraft:iron_ingot"], 66 | ["minecraft:iron_ingot", null, "minecraft:iron_ingot"], 67 | ["minecraft:iron_ingot", "minecraft:iron_ingot", "minecraft:iron_ingot"] 68 | ] 69 | }, 70 | "chain": { 71 | "type": "minecraft:crafting_shaped", 72 | "group": "", 73 | "output": "minecraft:chain", 74 | "input": [["minecraft:iron_nugget"], ["minecraft:iron_ingot"], ["minecraft:iron_nugget"]] 75 | }, 76 | "chest": { 77 | "type": "minecraft:crafting_shaped", 78 | "group": "", 79 | "output": "minecraft:chest", 80 | "input": [ 81 | ["minecraft:planks", "minecraft:planks", "minecraft:planks"], 82 | ["minecraft:planks", null, "minecraft:planks"], 83 | ["minecraft:planks", "minecraft:planks", "minecraft:planks"] 84 | ] 85 | }, 86 | "clock": { 87 | "type": "minecraft:crafting_shaped", 88 | "group": "", 89 | "output": "minecraft:clock", 90 | "input": [ 91 | [null, "minecraft:gold_ingot", null], 92 | ["minecraft:gold_ingot", "minecraft:redstone", "minecraft:gold_ingot"], 93 | [null, "minecraft:gold_ingot", null] 94 | ] 95 | }, 96 | "coal_block": { 97 | "type": "minecraft:crafting_shaped", 98 | "group": "", 99 | "output": "minecraft:coal_block", 100 | "input": [ 101 | ["minecraft:coal", "minecraft:coal", "minecraft:coal"], 102 | ["minecraft:coal", "minecraft:coal", "minecraft:coal"], 103 | ["minecraft:coal", "minecraft:coal", "minecraft:coal"] 104 | ] 105 | }, 106 | "cobblestone_slab": { 107 | "type": "minecraft:crafting_shaped", 108 | "group": "", 109 | "output": "minecraft:cobblestone_slab", 110 | "input": [["minecraft:cobblestone", "minecraft:cobblestone", "minecraft:cobblestone"]] 111 | }, 112 | "cobblestone_stairs": { 113 | "type": "minecraft:crafting_shaped", 114 | "group": "", 115 | "output": "minecraft:cobblestone_stairs", 116 | "input": [ 117 | ["minecraft:cobblestone", null, null], 118 | ["minecraft:cobblestone", "minecraft:cobblestone", null], 119 | ["minecraft:cobblestone", "minecraft:cobblestone", "minecraft:cobblestone"] 120 | ] 121 | }, 122 | "cobblestone_wall": { 123 | "type": "minecraft:crafting_shaped", 124 | "group": "", 125 | "output": "minecraft:cobblestone_wall", 126 | "input": [ 127 | ["minecraft:cobblestone", "minecraft:cobblestone", "minecraft:cobblestone"], 128 | ["minecraft:cobblestone", "minecraft:cobblestone", "minecraft:cobblestone"] 129 | ] 130 | }, 131 | "comparator": { 132 | "type": "minecraft:crafting_shaped", 133 | "group": "", 134 | "output": "minecraft:comparator", 135 | "input": [ 136 | [null, "minecraft:redstone_torch", null], 137 | ["minecraft:redstone_torch", "minecraft:quartz", "minecraft:redstone_torch"], 138 | ["minecraft:stone", "minecraft:stone", "minecraft:stone"] 139 | ] 140 | }, 141 | "compass": { 142 | "type": "minecraft:crafting_shaped", 143 | "group": "", 144 | "output": "minecraft:compass", 145 | "input": [ 146 | [null, "minecraft:iron_ingot", null], 147 | ["minecraft:iron_ingot", "minecraft:redstone", "minecraft:iron_ingot"], 148 | [null, "minecraft:iron_ingot", null] 149 | ] 150 | }, 151 | "composter": { 152 | "type": "minecraft:crafting_shaped", 153 | "group": "", 154 | "output": "minecraft:composter", 155 | "input": [ 156 | ["minecraft:oak_slab", null, "minecraft:oak_slab"], 157 | ["minecraft:oak_slab", null, "minecraft:oak_slab"], 158 | ["minecraft:oak_slab", "minecraft:oak_slab", "minecraft:oak_slab"] 159 | ] 160 | }, 161 | "crafting_table": { 162 | "type": "minecraft:crafting_shaped", 163 | "group": "", 164 | "output": "minecraft:crafting_table", 165 | "input": [ 166 | ["minecraft:planks", "minecraft:planks"], 167 | ["minecraft:planks", "minecraft:planks"] 168 | ] 169 | }, 170 | "daylight_detector": { 171 | "type": "minecraft:crafting_shaped", 172 | "group": "", 173 | "output": "minecraft:daylight_detector", 174 | "input": [ 175 | ["minecraft:glass", "minecraft:glass", "minecraft:glass"], 176 | ["minecraft:quartz", "minecraft:quartz", "minecraft:quartz"], 177 | ["minecraft:oak_slab", "minecraft:oak_slab", "minecraft:oak_slab"] 178 | ] 179 | }, 180 | "diamond_axe": { 181 | "type": "minecraft:crafting_shaped", 182 | "group": "", 183 | "output": "minecraft:diamond_axe", 184 | "input": [ 185 | ["minecraft:diamond", "minecraft:diamond"], 186 | ["minecraft:diamond", "minecraft:stick"], 187 | [null, "minecraft:stick"] 188 | ] 189 | }, 190 | "diamond_block": { 191 | "type": "minecraft:crafting_shaped", 192 | "group": "", 193 | "output": "minecraft:diamond_block", 194 | "input": [ 195 | ["minecraft:diamond", "minecraft:diamond", "minecraft:diamond"], 196 | ["minecraft:diamond", "minecraft:diamond", "minecraft:diamond"], 197 | ["minecraft:diamond", "minecraft:diamond", "minecraft:diamond"] 198 | ] 199 | }, 200 | "diamond_boots": { 201 | "type": "minecraft:crafting_shaped", 202 | "group": "", 203 | "output": "minecraft:diamond_boots", 204 | "input": [ 205 | ["minecraft:diamond", null, "minecraft:diamond"], 206 | ["minecraft:diamond", null, "minecraft:diamond"] 207 | ] 208 | }, 209 | "diamond_chestplate": { 210 | "type": "minecraft:crafting_shaped", 211 | "group": "", 212 | "output": "minecraft:diamond_chestplate", 213 | "input": [ 214 | ["minecraft:diamond", null, "minecraft:diamond"], 215 | ["minecraft:diamond", "minecraft:diamond", "minecraft:diamond"], 216 | ["minecraft:diamond", "minecraft:diamond", "minecraft:diamond"] 217 | ] 218 | }, 219 | "diamond_helmet": { 220 | "type": "minecraft:crafting_shaped", 221 | "group": "", 222 | "output": "minecraft:diamond_helmet", 223 | "input": [ 224 | ["minecraft:diamond", "minecraft:diamond", "minecraft:diamond"], 225 | ["minecraft:diamond", null, "minecraft:diamond"] 226 | ] 227 | }, 228 | "diamond_hoe": { 229 | "type": "minecraft:crafting_shaped", 230 | "group": "", 231 | "output": "minecraft:diamond_hoe", 232 | "input": [ 233 | ["minecraft:diamond", "minecraft:diamond"], 234 | [null, "minecraft:stick"], 235 | [null, "minecraft:stick"] 236 | ] 237 | }, 238 | "diamond_leggings": { 239 | "type": "minecraft:crafting_shaped", 240 | "group": "", 241 | "output": "minecraft:diamond_leggings", 242 | "input": [ 243 | ["minecraft:diamond", "minecraft:diamond", "minecraft:diamond"], 244 | ["minecraft:diamond", null, "minecraft:diamond"], 245 | ["minecraft:diamond", null, "minecraft:diamond"] 246 | ] 247 | }, 248 | "diamond_pickaxe": { 249 | "type": "minecraft:crafting_shaped", 250 | "group": "", 251 | "output": "minecraft:diamond_pickaxe", 252 | "input": [ 253 | ["minecraft:diamond", "minecraft:diamond", "minecraft:diamond"], 254 | [null, "minecraft:stick", null], 255 | [null, "minecraft:stick", null] 256 | ] 257 | }, 258 | "diamond_shovel": { 259 | "type": "minecraft:crafting_shaped", 260 | "group": "", 261 | "output": "minecraft:diamond_shovel", 262 | "input": [["minecraft:diamond"], ["minecraft:stick"], ["minecraft:stick"]] 263 | }, 264 | "diamond_sword": { 265 | "type": "minecraft:crafting_shaped", 266 | "group": "", 267 | "output": "minecraft:diamond_sword", 268 | "input": [["minecraft:diamond"], ["minecraft:diamond"], ["minecraft:stick"]] 269 | }, 270 | "diorite": { 271 | "type": "minecraft:crafting_shaped", 272 | "group": "", 273 | "output": "minecraft:diorite", 274 | "input": [ 275 | ["minecraft:cobblestone", "minecraft:quartz"], 276 | ["minecraft:quartz", "minecraft:cobblestone"] 277 | ] 278 | }, 279 | "dropper": { 280 | "type": "minecraft:crafting_shaped", 281 | "group": "", 282 | "output": "minecraft:dropper", 283 | "input": [ 284 | ["minecraft:cobblestone", "minecraft:cobblestone", "minecraft:cobblestone"], 285 | ["minecraft:cobblestone", null, "minecraft:cobblestone"], 286 | ["minecraft:cobblestone", "minecraft:redstone", "minecraft:cobblestone"] 287 | ] 288 | }, 289 | "fishing_rod": { 290 | "type": "minecraft:crafting_shaped", 291 | "group": "", 292 | "output": "minecraft:fishing_rod", 293 | "input": [ 294 | [null, null, "minecraft:stick"], 295 | [null, "minecraft:stick", "minecraft:string"], 296 | ["minecraft:stick", null, "minecraft:string"] 297 | ] 298 | }, 299 | "furnace": { 300 | "type": "minecraft:crafting_shaped", 301 | "group": "", 302 | "output": "minecraft:furnace", 303 | "input": [ 304 | ["minecraft:cobblestone", "minecraft:cobblestone", "minecraft:cobblestone"], 305 | ["minecraft:cobblestone", null, "minecraft:cobblestone"], 306 | ["minecraft:cobblestone", "minecraft:cobblestone", "minecraft:cobblestone"] 307 | ] 308 | }, 309 | "glass_bottle": { 310 | "type": "minecraft:crafting_shaped", 311 | "group": "", 312 | "output": "minecraft:glass_bottle", 313 | "input": [ 314 | ["minecraft:glass", null, "minecraft:glass"], 315 | [null, "minecraft:glass", null] 316 | ] 317 | }, 318 | "glass_pane": { 319 | "type": "minecraft:crafting_shaped", 320 | "group": "", 321 | "output": "minecraft:glass_pane", 322 | "input": [ 323 | ["minecraft:glass", "minecraft:glass", "minecraft:glass"], 324 | ["minecraft:glass", "minecraft:glass", "minecraft:glass"] 325 | ] 326 | }, 327 | "golden_axe": { 328 | "type": "minecraft:crafting_shaped", 329 | "group": "", 330 | "output": "minecraft:golden_axe", 331 | "input": [ 332 | ["minecraft:gold_ingot", "minecraft:gold_ingot"], 333 | ["minecraft:gold_ingot", "minecraft:stick"], 334 | [null, "minecraft:stick"] 335 | ] 336 | }, 337 | "golden_boots": { 338 | "type": "minecraft:crafting_shaped", 339 | "group": "", 340 | "output": "minecraft:golden_boots", 341 | "input": [ 342 | ["minecraft:gold_ingot", null, "minecraft:gold_ingot"], 343 | ["minecraft:gold_ingot", null, "minecraft:gold_ingot"] 344 | ] 345 | }, 346 | "golden_chestplate": { 347 | "type": "minecraft:crafting_shaped", 348 | "group": "", 349 | "output": "minecraft:golden_chestplate", 350 | "input": [ 351 | ["minecraft:gold_ingot", null, "minecraft:gold_ingot"], 352 | ["minecraft:gold_ingot", "minecraft:gold_ingot", "minecraft:gold_ingot"], 353 | ["minecraft:gold_ingot", "minecraft:gold_ingot", "minecraft:gold_ingot"] 354 | ] 355 | }, 356 | "golden_helmet": { 357 | "type": "minecraft:crafting_shaped", 358 | "group": "", 359 | "output": "minecraft:golden_helmet", 360 | "input": [ 361 | ["minecraft:gold_ingot", "minecraft:gold_ingot", "minecraft:gold_ingot"], 362 | ["minecraft:gold_ingot", null, "minecraft:gold_ingot"] 363 | ] 364 | }, 365 | "golden_hoe": { 366 | "type": "minecraft:crafting_shaped", 367 | "group": "", 368 | "output": "minecraft:golden_hoe", 369 | "input": [ 370 | ["minecraft:gold_ingot", "minecraft:gold_ingot"], 371 | [null, "minecraft:stick"], 372 | [null, "minecraft:stick"] 373 | ] 374 | }, 375 | "golden_leggings": { 376 | "type": "minecraft:crafting_shaped", 377 | "group": "", 378 | "output": "minecraft:golden_leggings", 379 | "input": [ 380 | ["minecraft:gold_ingot", "minecraft:gold_ingot", "minecraft:gold_ingot"], 381 | ["minecraft:gold_ingot", null, "minecraft:gold_ingot"], 382 | ["minecraft:gold_ingot", null, "minecraft:gold_ingot"] 383 | ] 384 | }, 385 | "golden_pickaxe": { 386 | "type": "minecraft:crafting_shaped", 387 | "group": "", 388 | "output": "minecraft:golden_pickaxe", 389 | "input": [ 390 | ["minecraft:gold_ingot", "minecraft:gold_ingot", "minecraft:gold_ingot"], 391 | [null, "minecraft:stick", null], 392 | [null, "minecraft:stick", null] 393 | ] 394 | }, 395 | "golden_shovel": { 396 | "type": "minecraft:crafting_shaped", 397 | "group": "", 398 | "output": "minecraft:golden_shovel", 399 | "input": [["minecraft:gold_ingot"], ["minecraft:stick"], ["minecraft:stick"]] 400 | }, 401 | "golden_sword": { 402 | "type": "minecraft:crafting_shaped", 403 | "group": "", 404 | "output": "minecraft:golden_sword", 405 | "input": [["minecraft:gold_ingot"], ["minecraft:gold_ingot"], ["minecraft:stick"]] 406 | }, 407 | "gold_block": { 408 | "type": "minecraft:crafting_shaped", 409 | "group": "", 410 | "output": "minecraft:gold_block", 411 | "input": [ 412 | ["minecraft:gold_ingot", "minecraft:gold_ingot", "minecraft:gold_ingot"], 413 | ["minecraft:gold_ingot", "minecraft:gold_ingot", "minecraft:gold_ingot"], 414 | ["minecraft:gold_ingot", "minecraft:gold_ingot", "minecraft:gold_ingot"] 415 | ] 416 | }, 417 | "heavy_weighted_pressure_plate": { 418 | "type": "minecraft:crafting_shaped", 419 | "group": "", 420 | "output": "minecraft:heavy_weighted_pressure_plate", 421 | "input": [["minecraft:iron_ingot", "minecraft:iron_ingot"]] 422 | }, 423 | "iron_axe": { 424 | "type": "minecraft:crafting_shaped", 425 | "group": "", 426 | "output": "minecraft:iron_axe", 427 | "input": [ 428 | ["minecraft:iron_ingot", "minecraft:iron_ingot"], 429 | ["minecraft:iron_ingot", "minecraft:stick"], 430 | [null, "minecraft:stick"] 431 | ] 432 | }, 433 | "iron_bars": { 434 | "type": "minecraft:crafting_shaped", 435 | "group": "", 436 | "output": "minecraft:iron_bars", 437 | "input": [ 438 | ["minecraft:iron_ingot", "minecraft:iron_ingot", "minecraft:iron_ingot"], 439 | ["minecraft:iron_ingot", "minecraft:iron_ingot", "minecraft:iron_ingot"] 440 | ] 441 | }, 442 | "iron_block": { 443 | "type": "minecraft:crafting_shaped", 444 | "group": "", 445 | "output": "minecraft:iron_block", 446 | "input": [ 447 | ["minecraft:iron_ingot", "minecraft:iron_ingot", "minecraft:iron_ingot"], 448 | ["minecraft:iron_ingot", "minecraft:iron_ingot", "minecraft:iron_ingot"], 449 | ["minecraft:iron_ingot", "minecraft:iron_ingot", "minecraft:iron_ingot"] 450 | ] 451 | }, 452 | "iron_boots": { 453 | "type": "minecraft:crafting_shaped", 454 | "group": "", 455 | "output": "minecraft:iron_boots", 456 | "input": [ 457 | ["minecraft:iron_ingot", null, "minecraft:iron_ingot"], 458 | ["minecraft:iron_ingot", null, "minecraft:iron_ingot"] 459 | ] 460 | }, 461 | "iron_chestplate": { 462 | "type": "minecraft:crafting_shaped", 463 | "group": "", 464 | "output": "minecraft:iron_chestplate", 465 | "input": [ 466 | ["minecraft:iron_ingot", null, "minecraft:iron_ingot"], 467 | ["minecraft:iron_ingot", "minecraft:iron_ingot", "minecraft:iron_ingot"], 468 | ["minecraft:iron_ingot", "minecraft:iron_ingot", "minecraft:iron_ingot"] 469 | ] 470 | }, 471 | "iron_door": { 472 | "type": "minecraft:crafting_shaped", 473 | "group": "", 474 | "output": "minecraft:iron_door", 475 | "input": [ 476 | ["minecraft:iron_ingot", "minecraft:iron_ingot"], 477 | ["minecraft:iron_ingot", "minecraft:iron_ingot"], 478 | ["minecraft:iron_ingot", "minecraft:iron_ingot"] 479 | ] 480 | }, 481 | "iron_helmet": { 482 | "type": "minecraft:crafting_shaped", 483 | "group": "", 484 | "output": "minecraft:iron_helmet", 485 | "input": [ 486 | ["minecraft:iron_ingot", "minecraft:iron_ingot", "minecraft:iron_ingot"], 487 | ["minecraft:iron_ingot", null, "minecraft:iron_ingot"] 488 | ] 489 | }, 490 | "iron_hoe": { 491 | "type": "minecraft:crafting_shaped", 492 | "group": "", 493 | "output": "minecraft:iron_hoe", 494 | "input": [ 495 | ["minecraft:iron_ingot", "minecraft:iron_ingot"], 496 | [null, "minecraft:stick"], 497 | [null, "minecraft:stick"] 498 | ] 499 | }, 500 | "iron_ingot_from_nuggets": { 501 | "type": "minecraft:crafting_shaped", 502 | "group": "iron_ingot", 503 | "output": "minecraft:iron_ingot", 504 | "input": [ 505 | ["minecraft:iron_nugget", "minecraft:iron_nugget", "minecraft:iron_nugget"], 506 | ["minecraft:iron_nugget", "minecraft:iron_nugget", "minecraft:iron_nugget"], 507 | ["minecraft:iron_nugget", "minecraft:iron_nugget", "minecraft:iron_nugget"] 508 | ] 509 | }, 510 | "iron_leggings": { 511 | "type": "minecraft:crafting_shaped", 512 | "group": "", 513 | "output": "minecraft:iron_leggings", 514 | "input": [ 515 | ["minecraft:iron_ingot", "minecraft:iron_ingot", "minecraft:iron_ingot"], 516 | ["minecraft:iron_ingot", null, "minecraft:iron_ingot"], 517 | ["minecraft:iron_ingot", null, "minecraft:iron_ingot"] 518 | ] 519 | }, 520 | "iron_pickaxe": { 521 | "type": "minecraft:crafting_shaped", 522 | "group": "", 523 | "output": "minecraft:iron_pickaxe", 524 | "input": [ 525 | ["minecraft:iron_ingot", "minecraft:iron_ingot", "minecraft:iron_ingot"], 526 | [null, "minecraft:stick", null], 527 | [null, "minecraft:stick", null] 528 | ] 529 | }, 530 | "iron_shovel": { 531 | "type": "minecraft:crafting_shaped", 532 | "group": "", 533 | "output": "minecraft:iron_shovel", 534 | "input": [["minecraft:iron_ingot"], ["minecraft:stick"], ["minecraft:stick"]] 535 | }, 536 | "iron_sword": { 537 | "type": "minecraft:crafting_shaped", 538 | "group": "", 539 | "output": "minecraft:iron_sword", 540 | "input": [["minecraft:iron_ingot"], ["minecraft:iron_ingot"], ["minecraft:stick"]] 541 | }, 542 | "iron_trapdoor": { 543 | "type": "minecraft:crafting_shaped", 544 | "group": "", 545 | "output": "minecraft:iron_trapdoor", 546 | "input": [ 547 | ["minecraft:iron_ingot", "minecraft:iron_ingot"], 548 | ["minecraft:iron_ingot", "minecraft:iron_ingot"] 549 | ] 550 | }, 551 | "item_frame": { 552 | "type": "minecraft:crafting_shaped", 553 | "group": "", 554 | "output": "minecraft:item_frame", 555 | "input": [ 556 | ["minecraft:stick", "minecraft:stick", "minecraft:stick"], 557 | ["minecraft:stick", "minecraft:leather", "minecraft:stick"], 558 | ["minecraft:stick", "minecraft:stick", "minecraft:stick"] 559 | ] 560 | }, 561 | "jukebox": { 562 | "type": "minecraft:crafting_shaped", 563 | "group": "", 564 | "output": "minecraft:jukebox", 565 | "input": [ 566 | ["minecraft:planks", "minecraft:planks", "minecraft:planks"], 567 | ["minecraft:planks", "minecraft:diamond", "minecraft:planks"], 568 | ["minecraft:planks", "minecraft:planks", "minecraft:planks"] 569 | ] 570 | }, 571 | "ladder": { 572 | "type": "minecraft:crafting_shaped", 573 | "group": "", 574 | "output": "minecraft:ladder", 575 | "input": [ 576 | ["minecraft:stick", null, "minecraft:stick"], 577 | ["minecraft:stick", "minecraft:stick", "minecraft:stick"], 578 | ["minecraft:stick", null, "minecraft:stick"] 579 | ] 580 | }, 581 | "leather_boots": { 582 | "type": "minecraft:crafting_shaped", 583 | "group": "", 584 | "output": "minecraft:leather_boots", 585 | "input": [ 586 | ["minecraft:leather", null, "minecraft:leather"], 587 | ["minecraft:leather", null, "minecraft:leather"] 588 | ] 589 | }, 590 | "leather_chestplate": { 591 | "type": "minecraft:crafting_shaped", 592 | "group": "", 593 | "output": "minecraft:leather_chestplate", 594 | "input": [ 595 | ["minecraft:leather", null, "minecraft:leather"], 596 | ["minecraft:leather", "minecraft:leather", "minecraft:leather"], 597 | ["minecraft:leather", "minecraft:leather", "minecraft:leather"] 598 | ] 599 | }, 600 | "leather_helmet": { 601 | "type": "minecraft:crafting_shaped", 602 | "group": "", 603 | "output": "minecraft:leather_helmet", 604 | "input": [ 605 | ["minecraft:leather", "minecraft:leather", "minecraft:leather"], 606 | ["minecraft:leather", null, "minecraft:leather"] 607 | ] 608 | }, 609 | "leather_horse_armor": { 610 | "type": "minecraft:crafting_shaped", 611 | "group": "", 612 | "output": "minecraft:leather_horse_armor", 613 | "input": [ 614 | ["minecraft:leather", null, "minecraft:leather"], 615 | ["minecraft:leather", "minecraft:leather", "minecraft:leather"], 616 | ["minecraft:leather", null, "minecraft:leather"] 617 | ] 618 | }, 619 | "leather_leggings": { 620 | "type": "minecraft:crafting_shaped", 621 | "group": "", 622 | "output": "minecraft:leather_leggings", 623 | "input": [ 624 | ["minecraft:leather", "minecraft:leather", "minecraft:leather"], 625 | ["minecraft:leather", null, "minecraft:leather"], 626 | ["minecraft:leather", null, "minecraft:leather"] 627 | ] 628 | }, 629 | "lever": { 630 | "type": "minecraft:crafting_shaped", 631 | "group": "", 632 | "output": "minecraft:lever", 633 | "input": [["minecraft:stick"], ["minecraft:cobblestone"]] 634 | }, 635 | "light_weighted_pressure_plate": { 636 | "type": "minecraft:crafting_shaped", 637 | "group": "", 638 | "output": "minecraft:light_weighted_pressure_plate", 639 | "input": [["minecraft:gold_ingot", "minecraft:gold_ingot"]] 640 | }, 641 | "loom": { 642 | "type": "minecraft:crafting_shaped", 643 | "group": "", 644 | "output": "minecraft:loom", 645 | "input": [ 646 | ["minecraft:string", "minecraft:string"], 647 | ["minecraft:planks", "minecraft:planks"] 648 | ] 649 | }, 650 | "minecart": { 651 | "type": "minecraft:crafting_shaped", 652 | "group": "", 653 | "output": "minecraft:minecart", 654 | "input": [ 655 | ["minecraft:iron_ingot", null, "minecraft:iron_ingot"], 656 | ["minecraft:iron_ingot", "minecraft:iron_ingot", "minecraft:iron_ingot"] 657 | ] 658 | }, 659 | "note_block": { 660 | "type": "minecraft:crafting_shaped", 661 | "group": "", 662 | "output": "minecraft:note_block", 663 | "input": [ 664 | ["minecraft:planks", "minecraft:planks", "minecraft:planks"], 665 | ["minecraft:planks", "minecraft:redstone", "minecraft:planks"], 666 | ["minecraft:planks", "minecraft:planks", "minecraft:planks"] 667 | ] 668 | }, 669 | "oak_boat": { 670 | "type": "minecraft:crafting_shaped", 671 | "group": "boat", 672 | "output": "minecraft:oak_boat", 673 | "input": [ 674 | ["minecraft:planks", null, "minecraft:planks"], 675 | ["minecraft:planks", "minecraft:planks", "minecraft:planks"] 676 | ] 677 | }, 678 | "oak_door": { 679 | "type": "minecraft:crafting_shaped", 680 | "group": "wooden_door", 681 | "output": "minecraft:oak_door", 682 | "input": [ 683 | ["minecraft:planks", "minecraft:planks"], 684 | ["minecraft:planks", "minecraft:planks"], 685 | ["minecraft:planks", "minecraft:planks"] 686 | ] 687 | }, 688 | "oak_fence": { 689 | "type": "minecraft:crafting_shaped", 690 | "group": "wooden_fence", 691 | "output": "minecraft:oak_fence", 692 | "input": [ 693 | ["minecraft:planks", "minecraft:stick", "minecraft:planks"], 694 | ["minecraft:planks", "minecraft:stick", "minecraft:planks"] 695 | ] 696 | }, 697 | "oak_fence_gate": { 698 | "type": "minecraft:crafting_shaped", 699 | "group": "wooden_fence_gate", 700 | "output": "minecraft:oak_fence_gate", 701 | "input": [ 702 | ["minecraft:stick", "minecraft:planks", "minecraft:stick"], 703 | ["minecraft:stick", "minecraft:planks", "minecraft:stick"] 704 | ] 705 | }, 706 | "oak_pressure_plate": { 707 | "type": "minecraft:crafting_shaped", 708 | "group": "wooden_pressure_plate", 709 | "output": "minecraft:oak_pressure_plate", 710 | "input": [["minecraft:planks", "minecraft:planks"]] 711 | }, 712 | "oak_sign": { 713 | "type": "minecraft:crafting_shaped", 714 | "group": "wooden_sign", 715 | "output": "minecraft:oak_sign", 716 | "input": [ 717 | ["minecraft:planks", "minecraft:planks", "minecraft:planks"], 718 | ["minecraft:planks", "minecraft:planks", "minecraft:planks"], 719 | [null, "minecraft:stick", null] 720 | ] 721 | }, 722 | "oak_slab": { 723 | "type": "minecraft:crafting_shaped", 724 | "group": "wooden_slab", 725 | "output": "minecraft:oak_slab", 726 | "input": [["minecraft:planks", "minecraft:planks", "minecraft:planks"]] 727 | }, 728 | "oak_stairs": { 729 | "type": "minecraft:crafting_shaped", 730 | "group": "wooden_stairs", 731 | "output": "minecraft:oak_stairs", 732 | "input": [ 733 | ["minecraft:planks", null, null], 734 | ["minecraft:planks", "minecraft:planks", null], 735 | ["minecraft:planks", "minecraft:planks", "minecraft:planks"] 736 | ] 737 | }, 738 | "oak_trapdoor": { 739 | "type": "minecraft:crafting_shaped", 740 | "group": "wooden_trapdoor", 741 | "output": "minecraft:oak_trapdoor", 742 | "input": [ 743 | ["minecraft:planks", "minecraft:planks", "minecraft:planks"], 744 | ["minecraft:planks", "minecraft:planks", "minecraft:planks"] 745 | ] 746 | }, 747 | "oak_wood": { 748 | "type": "minecraft:crafting_shaped", 749 | "group": "bark", 750 | "output": "minecraft:oak_wood", 751 | "input": [ 752 | ["minecraft:oak_log", "minecraft:oak_log"], 753 | ["minecraft:oak_log", "minecraft:oak_log"] 754 | ] 755 | }, 756 | "observer": { 757 | "type": "minecraft:crafting_shaped", 758 | "group": "", 759 | "output": "minecraft:observer", 760 | "input": [ 761 | ["minecraft:cobblestone", "minecraft:cobblestone", "minecraft:cobblestone"], 762 | ["minecraft:redstone", "minecraft:redstone", "minecraft:quartz"], 763 | ["minecraft:cobblestone", "minecraft:cobblestone", "minecraft:cobblestone"] 764 | ] 765 | }, 766 | "painting": { 767 | "type": "minecraft:crafting_shaped", 768 | "group": "", 769 | "output": "minecraft:painting", 770 | "input": [ 771 | ["minecraft:stick", "minecraft:stick", "minecraft:stick"], 772 | ["minecraft:stick", "minecraft:white_wool", "minecraft:stick"], 773 | ["minecraft:stick", "minecraft:stick", "minecraft:stick"] 774 | ] 775 | }, 776 | "piston": { 777 | "type": "minecraft:crafting_shaped", 778 | "group": "", 779 | "output": "minecraft:piston", 780 | "input": [ 781 | ["minecraft:planks", "minecraft:planks", "minecraft:planks"], 782 | ["minecraft:cobblestone", "minecraft:iron_ingot", "minecraft:cobblestone"], 783 | ["minecraft:cobblestone", "minecraft:redstone", "minecraft:cobblestone"] 784 | ] 785 | }, 786 | "powered_rail": { 787 | "type": "minecraft:crafting_shaped", 788 | "group": "", 789 | "output": "minecraft:powered_rail", 790 | "input": [ 791 | ["minecraft:gold_ingot", null, "minecraft:gold_ingot"], 792 | ["minecraft:gold_ingot", "minecraft:stick", "minecraft:gold_ingot"], 793 | ["minecraft:gold_ingot", "minecraft:redstone", "minecraft:gold_ingot"] 794 | ] 795 | }, 796 | "quartz_block": { 797 | "type": "minecraft:crafting_shaped", 798 | "group": "", 799 | "output": "minecraft:quartz_block", 800 | "input": [ 801 | ["minecraft:quartz", "minecraft:quartz"], 802 | ["minecraft:quartz", "minecraft:quartz"] 803 | ] 804 | }, 805 | "rail": { 806 | "type": "minecraft:crafting_shaped", 807 | "group": "", 808 | "output": "minecraft:rail", 809 | "input": [ 810 | ["minecraft:iron_ingot", null, "minecraft:iron_ingot"], 811 | ["minecraft:iron_ingot", "minecraft:stick", "minecraft:iron_ingot"], 812 | ["minecraft:iron_ingot", null, "minecraft:iron_ingot"] 813 | ] 814 | }, 815 | "redstone_block": { 816 | "type": "minecraft:crafting_shaped", 817 | "group": "", 818 | "output": "minecraft:redstone_block", 819 | "input": [ 820 | ["minecraft:redstone", "minecraft:redstone", "minecraft:redstone"], 821 | ["minecraft:redstone", "minecraft:redstone", "minecraft:redstone"], 822 | ["minecraft:redstone", "minecraft:redstone", "minecraft:redstone"] 823 | ] 824 | }, 825 | "redstone_torch": { 826 | "type": "minecraft:crafting_shaped", 827 | "group": "", 828 | "output": "minecraft:redstone_torch", 829 | "input": [["minecraft:redstone"], ["minecraft:stick"]] 830 | }, 831 | "repeater": { 832 | "type": "minecraft:crafting_shaped", 833 | "group": "", 834 | "output": "minecraft:repeater", 835 | "input": [ 836 | ["minecraft:redstone_torch", "minecraft:redstone", "minecraft:redstone_torch"], 837 | ["minecraft:stone", "minecraft:stone", "minecraft:stone"] 838 | ] 839 | }, 840 | "shears": { 841 | "type": "minecraft:crafting_shaped", 842 | "group": "", 843 | "output": "minecraft:shears", 844 | "input": [ 845 | [null, "minecraft:iron_ingot"], 846 | ["minecraft:iron_ingot", null] 847 | ] 848 | }, 849 | "shield": { 850 | "type": "minecraft:crafting_shaped", 851 | "group": "", 852 | "output": "minecraft:shield", 853 | "input": [ 854 | ["minecraft:planks", "minecraft:iron_ingot", "minecraft:planks"], 855 | ["minecraft:planks", "minecraft:planks", "minecraft:planks"], 856 | [null, "minecraft:planks", null] 857 | ] 858 | }, 859 | "smithing_table": { 860 | "type": "minecraft:crafting_shaped", 861 | "group": "", 862 | "output": "minecraft:smithing_table", 863 | "input": [ 864 | ["minecraft:iron_ingot", "minecraft:iron_ingot"], 865 | ["minecraft:planks", "minecraft:planks"], 866 | ["minecraft:planks", "minecraft:planks"] 867 | ] 868 | }, 869 | "stick": { 870 | "type": "minecraft:crafting_shaped", 871 | "group": "sticks", 872 | "output": "minecraft:stick", 873 | "input": [["minecraft:planks"], ["minecraft:planks"]] 874 | }, 875 | "stonecutter": { 876 | "type": "minecraft:crafting_shaped", 877 | "group": "", 878 | "output": "minecraft:stonecutter", 879 | "input": [ 880 | [null, "minecraft:iron_ingot", null], 881 | ["minecraft:stone", "minecraft:stone", "minecraft:stone"] 882 | ] 883 | }, 884 | "stone_axe": { 885 | "type": "minecraft:crafting_shaped", 886 | "group": "", 887 | "output": "minecraft:stone_axe", 888 | "input": [ 889 | ["minecraft:cobblestone", "minecraft:cobblestone"], 890 | ["minecraft:cobblestone", "minecraft:stick"], 891 | [null, "minecraft:stick"] 892 | ] 893 | }, 894 | "stone_bricks": { 895 | "type": "minecraft:crafting_shaped", 896 | "group": "", 897 | "output": "minecraft:stone_bricks", 898 | "input": [ 899 | ["minecraft:stone", "minecraft:stone"], 900 | ["minecraft:stone", "minecraft:stone"] 901 | ] 902 | }, 903 | "stone_hoe": { 904 | "type": "minecraft:crafting_shaped", 905 | "group": "", 906 | "output": "minecraft:stone_hoe", 907 | "input": [ 908 | ["minecraft:cobblestone", "minecraft:cobblestone"], 909 | [null, "minecraft:stick"], 910 | [null, "minecraft:stick"] 911 | ] 912 | }, 913 | "stone_pickaxe": { 914 | "type": "minecraft:crafting_shaped", 915 | "group": "", 916 | "output": "minecraft:stone_pickaxe", 917 | "input": [ 918 | ["minecraft:cobblestone", "minecraft:cobblestone", "minecraft:cobblestone"], 919 | [null, "minecraft:stick", null], 920 | [null, "minecraft:stick", null] 921 | ] 922 | }, 923 | "stone_pressure_plate": { 924 | "type": "minecraft:crafting_shaped", 925 | "group": "", 926 | "output": "minecraft:stone_pressure_plate", 927 | "input": [["minecraft:stone", "minecraft:stone"]] 928 | }, 929 | "stone_shovel": { 930 | "type": "minecraft:crafting_shaped", 931 | "group": "", 932 | "output": "minecraft:stone_shovel", 933 | "input": [["minecraft:cobblestone"], ["minecraft:stick"], ["minecraft:stick"]] 934 | }, 935 | "stone_slab": { 936 | "type": "minecraft:crafting_shaped", 937 | "group": "", 938 | "output": "minecraft:stone_slab", 939 | "input": [["minecraft:stone", "minecraft:stone", "minecraft:stone"]] 940 | }, 941 | "stone_stairs": { 942 | "type": "minecraft:crafting_shaped", 943 | "group": "", 944 | "output": "minecraft:stone_stairs", 945 | "input": [ 946 | ["minecraft:stone", null, null], 947 | ["minecraft:stone", "minecraft:stone", null], 948 | ["minecraft:stone", "minecraft:stone", "minecraft:stone"] 949 | ] 950 | }, 951 | "stone_sword": { 952 | "type": "minecraft:crafting_shaped", 953 | "group": "", 954 | "output": "minecraft:stone_sword", 955 | "input": [["minecraft:cobblestone"], ["minecraft:cobblestone"], ["minecraft:stick"]] 956 | }, 957 | "torch": { 958 | "type": "minecraft:crafting_shaped", 959 | "group": "", 960 | "output": "minecraft:torch", 961 | "input": [["minecraft:coal"], ["minecraft:stick"]] 962 | }, 963 | "tripwire_hook": { 964 | "type": "minecraft:crafting_shaped", 965 | "group": "", 966 | "output": "minecraft:tripwire_hook", 967 | "input": [["minecraft:iron_ingot"], ["minecraft:stick"], ["minecraft:planks"]] 968 | }, 969 | "white_banner": { 970 | "type": "minecraft:crafting_shaped", 971 | "group": "banner", 972 | "output": "minecraft:white_banner", 973 | "input": [ 974 | ["minecraft:white_wool", "minecraft:white_wool", "minecraft:white_wool"], 975 | ["minecraft:white_wool", "minecraft:white_wool", "minecraft:white_wool"], 976 | [null, "minecraft:stick", null] 977 | ] 978 | }, 979 | "white_bed": { 980 | "type": "minecraft:crafting_shaped", 981 | "group": "bed", 982 | "output": "minecraft:white_bed", 983 | "input": [ 984 | ["minecraft:white_wool", "minecraft:white_wool", "minecraft:white_wool"], 985 | ["minecraft:planks", "minecraft:planks", "minecraft:planks"] 986 | ] 987 | }, 988 | "white_carpet": { 989 | "type": "minecraft:crafting_shaped", 990 | "group": "carpet", 991 | "output": "minecraft:white_carpet", 992 | "input": [["minecraft:white_wool", "minecraft:white_wool"]] 993 | }, 994 | "white_wool_from_string": { 995 | "type": "minecraft:crafting_shaped", 996 | "group": "", 997 | "output": "minecraft:white_wool", 998 | "input": [ 999 | ["minecraft:string", "minecraft:string"], 1000 | ["minecraft:string", "minecraft:string"] 1001 | ] 1002 | }, 1003 | "wooden_axe": { 1004 | "type": "minecraft:crafting_shaped", 1005 | "group": "", 1006 | "output": "minecraft:wooden_axe", 1007 | "input": [ 1008 | ["minecraft:planks", "minecraft:planks"], 1009 | ["minecraft:planks", "minecraft:stick"], 1010 | [null, "minecraft:stick"] 1011 | ] 1012 | }, 1013 | "wooden_hoe": { 1014 | "type": "minecraft:crafting_shaped", 1015 | "group": "", 1016 | "output": "minecraft:wooden_hoe", 1017 | "input": [ 1018 | ["minecraft:planks", "minecraft:planks"], 1019 | [null, "minecraft:stick"], 1020 | [null, "minecraft:stick"] 1021 | ] 1022 | }, 1023 | "wooden_pickaxe": { 1024 | "type": "minecraft:crafting_shaped", 1025 | "group": "", 1026 | "output": "minecraft:wooden_pickaxe", 1027 | "input": [ 1028 | ["minecraft:planks", "minecraft:planks", "minecraft:planks"], 1029 | [null, "minecraft:stick", null], 1030 | [null, "minecraft:stick", null] 1031 | ] 1032 | }, 1033 | "wooden_shovel": { 1034 | "type": "minecraft:crafting_shaped", 1035 | "group": "", 1036 | "output": "minecraft:wooden_shovel", 1037 | "input": [["minecraft:planks"], ["minecraft:stick"], ["minecraft:stick"]] 1038 | }, 1039 | "wooden_sword": { 1040 | "type": "minecraft:crafting_shaped", 1041 | "group": "", 1042 | "output": "minecraft:wooden_sword", 1043 | "input": [["minecraft:planks"], ["minecraft:planks"], ["minecraft:stick"]] 1044 | }, 1045 | "lead": { 1046 | "type": "minecraft:crafting_shaped", 1047 | "group": "", 1048 | "output": "minecraft:lead", 1049 | "input": [ 1050 | ["minecraft:string", "minecraft:string", null], 1051 | ["minecraft:string", "minecraft:string", null], 1052 | [null, null, "minecraft:string"] 1053 | ] 1054 | }, 1055 | "chiseled_bookshelf": { 1056 | "type": "minecraft:crafting_shaped", 1057 | "group": "", 1058 | "output": "minecraft:chiseled_bookshelf", 1059 | "input": [ 1060 | ["minecraft:planks", "minecraft:planks", "minecraft:planks"], 1061 | ["minecraft:oak_slab", "minecraft:oak_slab", "minecraft:oak_slab"], 1062 | ["minecraft:planks", "minecraft:planks", "minecraft:planks"] 1063 | ] 1064 | }, 1065 | "white_harness": { 1066 | "type": "minecraft:crafting_shaped", 1067 | "group": "harness", 1068 | "output": "minecraft:white_harness", 1069 | "input": [ 1070 | ["minecraft:leather", "minecraft:leather", "minecraft:leather"], 1071 | ["minecraft:glass", "minecraft:white_wool", "minecraft:glass"] 1072 | ] 1073 | } 1074 | } 1075 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zachpmanson/minecraftle/bdf2ce79d9019c48d9c4e94dfe4bd2f36dadda18/public/favicon.ico -------------------------------------------------------------------------------- /public/fonts/Minecraft-Regular.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zachpmanson/minecraftle/bdf2ce79d9019c48d9c4e94dfe4bd2f36dadda18/public/fonts/Minecraft-Regular.otf -------------------------------------------------------------------------------- /public/fonts/Minecrafter-Cracked.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zachpmanson/minecraftle/bdf2ce79d9019c48d9c4e94dfe4bd2f36dadda18/public/fonts/Minecrafter-Cracked.ttf -------------------------------------------------------------------------------- /public/fonts/Minecrafter.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zachpmanson/minecraftle/bdf2ce79d9019c48d9c4e94dfe4bd2f36dadda18/public/fonts/Minecrafter.ttf -------------------------------------------------------------------------------- /public/icons/android-chrome-192x192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zachpmanson/minecraftle/bdf2ce79d9019c48d9c4e94dfe4bd2f36dadda18/public/icons/android-chrome-192x192.png -------------------------------------------------------------------------------- /public/icons/android-chrome-256x256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zachpmanson/minecraftle/bdf2ce79d9019c48d9c4e94dfe4bd2f36dadda18/public/icons/android-chrome-256x256.png -------------------------------------------------------------------------------- /public/icons/apple-touch-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zachpmanson/minecraftle/bdf2ce79d9019c48d9c4e94dfe4bd2f36dadda18/public/icons/apple-touch-icon.png -------------------------------------------------------------------------------- /public/icons/browserconfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | #da532c 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /public/icons/favicon-16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zachpmanson/minecraftle/bdf2ce79d9019c48d9c4e94dfe4bd2f36dadda18/public/icons/favicon-16x16.png -------------------------------------------------------------------------------- /public/icons/favicon-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zachpmanson/minecraftle/bdf2ce79d9019c48d9c4e94dfe4bd2f36dadda18/public/icons/favicon-32x32.png -------------------------------------------------------------------------------- /public/icons/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zachpmanson/minecraftle/bdf2ce79d9019c48d9c4e94dfe4bd2f36dadda18/public/icons/favicon.ico -------------------------------------------------------------------------------- /public/icons/mstile-150x150.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zachpmanson/minecraftle/bdf2ce79d9019c48d9c4e94dfe4bd2f36dadda18/public/icons/mstile-150x150.png -------------------------------------------------------------------------------- /public/icons/safari-pinned-tab.svg: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 8 | Created by potrace 1.14, written by Peter Selinger 2001-2017 9 | 10 | 12 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /public/icons/site.webmanifest: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Minecraftle", 3 | "short_name": "Minecraftle", 4 | "icons": [ 5 | { 6 | "src": "/static/icons/android-chrome-192x192.png", 7 | "sizes": "192x192", 8 | "type": "image/png" 9 | }, 10 | { 11 | "src": "/static/icons/android-chrome-256x256.png", 12 | "sizes": "256x256", 13 | "type": "image/png" 14 | } 15 | ], 16 | "theme_color": "#ffffff", 17 | "background_color": "#ffffff", 18 | "display": "standalone" 19 | } 20 | -------------------------------------------------------------------------------- /public/images/button-background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zachpmanson/minecraftle/bdf2ce79d9019c48d9c4e94dfe4bd2f36dadda18/public/images/button-background.png -------------------------------------------------------------------------------- /public/images/dirt-background.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zachpmanson/minecraftle/bdf2ce79d9019c48d9c4e94dfe4bd2f36dadda18/public/images/dirt-background.webp -------------------------------------------------------------------------------- /public/images/new.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zachpmanson/minecraftle/bdf2ce79d9019c48d9c4e94dfe4bd2f36dadda18/public/images/new.png -------------------------------------------------------------------------------- /public/images/original.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zachpmanson/minecraftle/bdf2ce79d9019c48d9c4e94dfe4bd2f36dadda18/public/images/original.png -------------------------------------------------------------------------------- /public/next.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /public/vercel.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /references.txt: -------------------------------------------------------------------------------- 1 | Minecraft-Regular font: 2 | https://fonts2u.com/minecraft-regular.font 3 | 4 | Minecrafter font: 5 | https://www.dafont.com/minecrafter.font 6 | 7 | Dirt background: 8 | https://minecraft.fandom.com/wiki/Background?file=Dirt_background_JE2.png 9 | 10 | Button background: 11 | https://i.ibb.co/rb2TWXL/bgbtn.png 12 | 13 | Minecraft Button Style adapted from: 14 | https://codepen.io/joexmdq/pen/EOMLzg 15 | 16 | Minecraft 1.18 crafting recipes and item data: 17 | Adapted from Minecraft games files (.minecraft/versions/1.18.1.jar/data/minecraft/recipes) 18 | 19 | Window popups for social links: 20 | https://pastebin.com/g84Ms4Lv 21 | 22 | -------------------------------------------------------------------------------- /src/components/CraftingTable.component.tsx: -------------------------------------------------------------------------------- 1 | import { COLORS, HICONTRAST_COLORS } from "@/constants"; 2 | import { useGlobal } from "@/context/Global/context"; 3 | import { ColorTable } from "@/types"; 4 | import { useEffect, useState } from "react"; 5 | import Slot from "./Slot.component"; 6 | 7 | export default function CraftingTable({ 8 | solved = false, 9 | active = true, 10 | noBackground = false, 11 | tableNum = 0, 12 | }: { 13 | solved?: boolean; 14 | active?: boolean; 15 | noBackground?: boolean; 16 | tableNum?: number; 17 | }) { 18 | const { 19 | cursorItem, 20 | setCursorItem, 21 | setCraftingTables, 22 | craftingTables, 23 | checkAllVariants, 24 | solution, 25 | trimVariants, 26 | colorTables, 27 | setColorTables, 28 | setGameState, 29 | recipes, 30 | remainingSolutionVariants, 31 | options: { highContrast }, 32 | } = useGlobal(); 33 | 34 | const [currentRecipe, setCurrentRecipe] = useState(); 35 | 36 | const colorTable = solved 37 | ? [ 38 | [undefined, undefined, undefined], 39 | [undefined, undefined, undefined], 40 | [undefined, undefined, undefined], 41 | ] 42 | : colorTables[tableNum]; 43 | const currentTable = solved 44 | ? remainingSolutionVariants[0] 45 | : craftingTables[tableNum]; 46 | 47 | const [isDown, setIsDown] = useState(false); // TODO: remove this 48 | const [isDragging, setIsDragging] = useState(false); 49 | 50 | const { SUCCESS_COLOR, NEAR_SUCCESS_COLOR } = highContrast 51 | ? HICONTRAST_COLORS 52 | : COLORS; 53 | 54 | const COLOR_MAP: { [key: number]: string | undefined } = { 55 | 0: undefined, 56 | 2: SUCCESS_COLOR, 57 | 3: NEAR_SUCCESS_COLOR, 58 | }; 59 | 60 | useEffect(() => { 61 | if (currentTable) { 62 | for (let row of currentTable) { 63 | for (let item of row) { 64 | if (item) { 65 | return; 66 | } 67 | } 68 | } 69 | } 70 | setCurrentRecipe(undefined); 71 | }, [craftingTables]); 72 | 73 | const onReleaseMouseDown = () => { 74 | setIsDown(false); 75 | const result = checkAllVariants(currentTable); 76 | setCurrentRecipe(result); 77 | document.removeEventListener("mouseup", onReleaseMouseDown); 78 | }; 79 | 80 | const onMouseDown = (row: number, col: number) => { 81 | if (!!cursorItem) { 82 | setIsDown(true); 83 | document.addEventListener("mouseup", onReleaseMouseDown); 84 | } 85 | }; 86 | 87 | const onMouseUp = (row: number, col: number) => { 88 | let oldCursorItem = cursorItem; 89 | let oldCraftingTableItem = currentTable[row][col]; 90 | 91 | setIsDown(false); 92 | if (isDragging) { 93 | setCursorItem(undefined); 94 | setIsDragging(false); 95 | } else { 96 | setCraftingTables((old) => { 97 | const newCraftingTables = [...old]; 98 | newCraftingTables[tableNum][row][col] = oldCursorItem; 99 | return newCraftingTables; 100 | }); 101 | // setTimeout hack to prevent cursor item changing before mouse movement is registered 102 | setTimeout(() => setCursorItem(oldCraftingTableItem), 0); 103 | } 104 | const result = checkAllVariants(currentTable); 105 | setCurrentRecipe(result); 106 | }; 107 | 108 | const onMouseMove = (row: number, col: number) => { 109 | if (isDown && !currentTable[row][col]) { 110 | setIsDragging(true); 111 | setCraftingTables((old) => { 112 | const newCraftingTables = [...old]; 113 | newCraftingTables[tableNum][row][col] = cursorItem; 114 | return newCraftingTables; 115 | }); 116 | } 117 | }; 118 | 119 | const setColorTable = (t: ColorTable) => { 120 | setColorTables((o) => { 121 | let n = [...o]; 122 | n[tableNum] = t; 123 | return n; 124 | }); 125 | }; 126 | 127 | const processGuess = () => { 128 | if (solved) return; 129 | 130 | if ( 131 | currentRecipe?.replace("minecraft:", "") === 132 | recipes[solution].output.replace("minecraft:", "") 133 | ) { 134 | setColorTable([ 135 | [2, 2, 2], 136 | [2, 2, 2], 137 | [2, 2, 2], 138 | ]); 139 | setTimeout(() => { 140 | setGameState("won"); 141 | }, 1000); 142 | return; 143 | } 144 | 145 | // is wrong, trim the remaining solution variants 146 | const correctSlots = trimVariants(currentTable); 147 | 148 | // update colors based on matchmap 149 | setColorTable(correctSlots); 150 | 151 | if (craftingTables.length < 10) { 152 | setCraftingTables((old) => { 153 | const newCraftingTables = [...old]; 154 | newCraftingTables.push([ 155 | [undefined, undefined, undefined], 156 | [undefined, undefined, undefined], 157 | [undefined, undefined, undefined], 158 | ]); 159 | return newCraftingTables; 160 | }); 161 | setColorTables((old) => { 162 | const newColorTables = [...old]; 163 | newColorTables.push([ 164 | [undefined, undefined, undefined], 165 | [undefined, undefined, undefined], 166 | [undefined, undefined, undefined], 167 | ]); 168 | return newColorTables; 169 | }); 170 | } else { 171 | setTimeout(() => { 172 | setGameState("lost"); 173 | }, 1000); 174 | } 175 | }; 176 | 177 | return ( 178 | <> 179 |
e.stopPropagation()} 185 | > 186 |
187 | {currentTable.map((row, rowIndex) => ( 188 |
189 | {row.map((item, columnIndex) => ( 190 | onMouseDown(rowIndex, columnIndex)} 198 | onMouseUp={() => onMouseUp(rowIndex, columnIndex)} 199 | onMouseMove={() => onMouseMove(rowIndex, columnIndex)} 200 | /> 201 | ))} 202 |
203 | ))} 204 |
205 | 206 |

207 |
208 | 214 |
215 |
216 | 217 | ); 218 | } 219 | -------------------------------------------------------------------------------- /src/components/Cursor.component.tsx: -------------------------------------------------------------------------------- 1 | import { useGlobal } from "@/context/Global/context"; 2 | import { useEffect, useState } from "react"; 3 | 4 | export default function Cursor() { 5 | const { items, cursorItem, setCursorItem } = useGlobal(); 6 | const [cursorPosition, setCursorPosition] = useState({ left: 0, top: 0 }); 7 | 8 | useEffect(() => { 9 | if (document) { 10 | document.addEventListener("mousemove", (e) => { 11 | setCursorPosition({ left: e.pageX - 5, top: e.pageY - 5 }); 12 | }); 13 | } 14 | return document.removeEventListener("mousemove", (e) => {}); 15 | }, []); 16 | 17 | const backgroundItem = cursorItem ? `url(${cursorItem && items[cursorItem].icon})` : undefined; 18 | 19 | return ( 20 |
27 | ); 28 | } 29 | -------------------------------------------------------------------------------- /src/components/Inventory.component.tsx: -------------------------------------------------------------------------------- 1 | import { CACHE_VERSION, COLORS, HICONTRAST_COLORS, PUBLIC_DIR } from "@/constants"; 2 | import { useGlobal } from "@/context/Global/context"; 3 | import { Color } from "@/types"; 4 | import { useEffect, useMemo, useState } from "react"; 5 | import MCButton from "./MCButton.component"; 6 | import Slot from "./Slot.component"; 7 | 8 | export default function Inventory({ guessCount }: { guessCount: number }) { 9 | const { 10 | setCursorItem, 11 | craftingTables, 12 | setCraftingTables, 13 | gameState, 14 | colorTables, 15 | items, 16 | options: { highContrast }, 17 | } = useGlobal(); 18 | const [givenIngredients, setGivenIngredients] = useState([]); 19 | 20 | const isTableEmpty = useMemo( 21 | () => 22 | craftingTables.length > 0 && 23 | craftingTables[craftingTables.length - 1].every((row) => 24 | row.every((slot) => slot === undefined || slot === null) 25 | ), 26 | [craftingTables] 27 | ); 28 | 29 | const invBackgrounds = 30 | useMemo(() => { 31 | if (givenIngredients.length > 0 && craftingTables.length > 0) { 32 | const newInvBackgrounds: { [key: string]: Color } = {}; 33 | for (let ingredient of givenIngredients) { 34 | newInvBackgrounds[ingredient] = -1; 35 | } 36 | for (let [tableNum, table] of colorTables.entries()) { 37 | for (let [r, row] of table.entries()) { 38 | for (let [c, slot] of row.entries()) { 39 | if (craftingTables[tableNum][r][c] !== undefined && craftingTables[tableNum][r][c] !== null) { 40 | const newColor = colorTables[tableNum][r][c]; 41 | const existingColor = newInvBackgrounds[craftingTables[tableNum][r][c]!]; 42 | 43 | if (existingColor === 2 || newColor === 2) { 44 | newInvBackgrounds[craftingTables[tableNum][r][c]!] = 2; 45 | } else if (existingColor === 3 || newColor === 3) { 46 | newInvBackgrounds[craftingTables[tableNum][r][c]!] = 3; 47 | } else if (existingColor === 0 || newColor === 0) { 48 | newInvBackgrounds[craftingTables[tableNum][r][c]!] = 0; 49 | } 50 | } 51 | } 52 | } 53 | } 54 | return newInvBackgrounds; 55 | } 56 | }, [givenIngredients, craftingTables, colorTables]) ?? {}; 57 | 58 | const { SUCCESS_COLOR, NEAR_SUCCESS_COLOR, WRONG_COLOR } = highContrast ? HICONTRAST_COLORS : COLORS; 59 | 60 | const COLOR_MAP: { [key: number]: string | undefined } = { 61 | 0: WRONG_COLOR, 62 | 2: SUCCESS_COLOR, 63 | 3: NEAR_SUCCESS_COLOR, 64 | }; 65 | 66 | useEffect(() => { 67 | let storedgivenIngredients = JSON.parse(localStorage.getItem(`givenIngredients_${CACHE_VERSION}`) ?? "[]"); 68 | if (storedgivenIngredients.length === 0) { 69 | fetch(PUBLIC_DIR + "/data/given_ingredients.json", { 70 | headers: { 71 | "Cache-Control": "no-cache", 72 | }, 73 | }) 74 | .then((response) => response.json()) 75 | .then((obj) => { 76 | setGivenIngredients(obj); 77 | localStorage.setItem(`givenIngredients_${CACHE_VERSION}`, JSON.stringify(obj)); 78 | }); 79 | } else { 80 | setGivenIngredients(storedgivenIngredients); 81 | } 82 | }, []); 83 | 84 | const clearLastTable = () => { 85 | setCraftingTables((old) => { 86 | const newCraftingTables = [...old]; 87 | newCraftingTables.pop(); 88 | newCraftingTables.push([ 89 | [undefined, undefined, undefined], 90 | [undefined, undefined, undefined], 91 | [undefined, undefined, undefined], 92 | ]); 93 | return newCraftingTables; 94 | }); 95 | setCursor(undefined); 96 | }; 97 | 98 | const setCursor = (ingredient?: string) => { 99 | // setTimeout hack to prevent cursor item changing before mouse movement is registered 100 | setTimeout(() => setCursorItem(ingredient), 0); 101 | }; 102 | 103 | return ( 104 |
e.stopPropagation()} 107 | > 108 |

Crafting Ingredients

109 |
110 | {Object.keys(items).length > 0 && 111 | givenIngredients.map((ingredient, i) => ( 112 | setCursor(ingredient)} 116 | backgroundColor={COLOR_MAP[invBackgrounds[ingredient] ?? 0]} 117 | clickable 118 | /> 119 | ))} 120 |
121 |
122 |
123 | {gameState === "inprogress" && !isTableEmpty && Clear} 124 |
125 |

Guess {guessCount}/10

126 |
127 |
128 | ); 129 | } 130 | -------------------------------------------------------------------------------- /src/components/LoadingSpinner.component.tsx: -------------------------------------------------------------------------------- 1 | export default function LoadingSpinner() { 2 | return ( 3 |
4 | 20 | Loading... 21 |
22 | ); 23 | } 24 | -------------------------------------------------------------------------------- /src/components/MCButton.component.tsx: -------------------------------------------------------------------------------- 1 | export default function MCButton(props: { 2 | children: React.ReactNode; 3 | className?: string; 4 | onClick?: () => void; 5 | }) { 6 | const onClickWithSound = () => { 7 | const audioToPlay = new Audio("/audio/button_click.wav"); 8 | audioToPlay.play(); 9 | if (props.onClick) props.onClick(); 10 | }; 11 | return ( 12 |
onClickWithSound()} 15 | > 16 |
{props.children}
17 |
18 | ); 19 | } 20 | -------------------------------------------------------------------------------- /src/components/Popup.component.tsx: -------------------------------------------------------------------------------- 1 | import { useGlobal } from "@/context/Global/context"; 2 | import { Dialog, Transition } from "@headlessui/react"; 3 | import Link from "next/link"; 4 | import { Fragment, useState } from "react"; 5 | import MCButton from "./MCButton.component"; 6 | import CraftingTable from "@/components/CraftingTable.component"; 7 | 8 | export default function Popup({ 9 | isOpen, 10 | closeModal, 11 | isRandom, 12 | }: { 13 | isOpen: boolean; 14 | closeModal: () => void; 15 | isRandom: boolean; 16 | }) { 17 | const { 18 | gameState, 19 | solution, 20 | craftingTables, 21 | colorTables, 22 | userId, 23 | recipes, 24 | items, 25 | options: { highContrast }, 26 | resetGame, 27 | gameDate, 28 | } = useGlobal(); 29 | const [copyButtonText, setCopyButtonText] = useState("Copy"); 30 | console.log("highContrast", highContrast); 31 | const generateSummary = () => { 32 | let summaryString = `Minecraftle ${new Date(gameDate.getTime() - gameDate.getTimezoneOffset() * 1000 * 60).toISOString().slice(0, 10)} ${ 33 | craftingTables.length 34 | }/10\n`; 35 | 36 | for (let table of colorTables) { 37 | for (let row of table) { 38 | for (let slot of row) { 39 | if (slot === 2) { 40 | summaryString += highContrast ? "🟧" : "🟩"; 41 | } else if (slot === 3) { 42 | summaryString += highContrast ? "🟦" : "🟨"; 43 | } else { 44 | summaryString += "⬜"; 45 | } 46 | } 47 | summaryString += "\n"; 48 | } 49 | summaryString += "\n"; 50 | } 51 | return summaryString.trim(); 52 | }; 53 | 54 | const copyToClipboard = (str: string) => { 55 | if (navigator && navigator.clipboard && navigator.clipboard.writeText) 56 | return navigator.clipboard.writeText(str); 57 | return Promise.reject("The Clipboard API is not available."); 58 | }; 59 | 60 | const handleCopy = () => { 61 | copyToClipboard(generateSummary()).then(() => { 62 | setCopyButtonText("Copied!"); 63 | setTimeout(() => { 64 | setCopyButtonText("Copy"); 65 | }, 1000); 66 | }); 67 | }; 68 | 69 | // get name of solution item for label 70 | const solutionName = items[recipes[solution].output].name; 71 | 72 | return ( 73 | <> 74 | 75 | 76 | 85 |
86 | 87 | 88 |
89 |
90 | 99 | 100 |
101 | 102 | 103 | {`Solution: ` + solutionName} 104 | 105 | 109 | You {gameState}! Took {craftingTables.length} guesses. 110 | 111 | {!isRandom && ( 112 |

113 | {generateSummary()} 114 |

115 | )} 116 |
117 |
118 | {!isRandom && ( 119 | <> 120 | handleCopy()}> 121 | {copyButtonText} 122 | 123 | 124 | Stats 125 | 126 | 127 | )} 128 | Close 129 | {isRandom && ( 130 | { 132 | closeModal(); 133 | resetGame(true); 134 | }} 135 | > 136 | New Random 137 | 138 | )} 139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 | 149 | ); 150 | } 151 | -------------------------------------------------------------------------------- /src/components/Slot.component.tsx: -------------------------------------------------------------------------------- 1 | import { useGlobal } from "@/context/Global/context"; 2 | import { TableItem } from "@/types"; 3 | 4 | export default function Slot({ 5 | item, 6 | backgroundColor, 7 | clickable, 8 | onClick, 9 | onMouseDown, 10 | onMouseUp, 11 | onMouseMove, 12 | }: { 13 | item?: TableItem; 14 | backgroundColor?: string; 15 | clickable?: boolean; 16 | onClick?: () => void; 17 | onMouseDown?: () => void; 18 | onMouseUp?: () => void; 19 | onMouseMove?: () => void; 20 | }) { 21 | const { items } = useGlobal(); 22 | const itemImage = item ? items[item]?.icon : undefined; 23 | 24 | const click = (event: any) => { 25 | event.stopPropagation(); 26 | if (clickable && onClick) { 27 | onClick(); 28 | } 29 | }; 30 | 31 | const mousedown = (event: any) => { 32 | event.stopPropagation(); 33 | if (clickable && onMouseDown) { 34 | onMouseDown(); 35 | } 36 | }; 37 | 38 | const mouseup = (event: any) => { 39 | event.stopPropagation(); 40 | if (clickable && onMouseUp) { 41 | onMouseUp(); 42 | } 43 | }; 44 | 45 | const mousemove = (event: any) => { 46 | if (clickable && onMouseMove) { 47 | onMouseMove(); 48 | } 49 | }; 50 | 51 | const backgroundImage = itemImage 52 | ? { backgroundImage: `url(${itemImage})` } 53 | : {}; 54 | return ( 55 |
63 |
64 |
65 | ); 66 | } 67 | -------------------------------------------------------------------------------- /src/components/StatRow.component.tsx: -------------------------------------------------------------------------------- 1 | const Row = ({ left, right }: { left: string; right?: string }) => ( 2 | 3 | {left} 4 | {right && {right}} 5 | 6 | ); 7 | 8 | export default Row; 9 | -------------------------------------------------------------------------------- /src/constants.ts: -------------------------------------------------------------------------------- 1 | export const COLORS = { 2 | SUCCESS_COLOR: "hsla(92, 100%, 37%, 0.859)", 3 | NEAR_SUCCESS_COLOR: "#caa905", 4 | WRONG_COLOR: "rgb(83, 83, 83)", 5 | }; 6 | 7 | export const HICONTRAST_COLORS = { 8 | ...COLORS, 9 | SUCCESS_COLOR: "#f5793a", 10 | NEAR_SUCCESS_COLOR: "#85c0f9", 11 | }; 12 | export const CACHE_VERSION = "20250531_3"; 13 | 14 | export const DEFAULT_OPTIONS = { 15 | highContrast: false, 16 | }; 17 | 18 | export const PUBLIC_DIR = process.env.NEXT_PUBLIC_PUBLIC_DIR || ""; 19 | -------------------------------------------------------------------------------- /src/context/Global/context.tsx: -------------------------------------------------------------------------------- 1 | import { DEFAULT_OPTIONS } from "@/constants"; 2 | import { 3 | ColorTable, 4 | GameState, 5 | ItemMap, 6 | MatchMap, 7 | Options, 8 | RecipeMap, 9 | Table, 10 | TableItem, 11 | } from "@/types"; 12 | import { Dispatch, SetStateAction, createContext, useContext } from "react"; 13 | 14 | export type GlobalContextProps = { 15 | userId: string; 16 | solution: string; 17 | items: ItemMap; 18 | cursorItem: TableItem; 19 | setCursorItem: Dispatch>; 20 | craftingTables: Table[]; 21 | setCraftingTables: Dispatch>; 22 | colorTables: ColorTable[]; 23 | setColorTables: Dispatch>; 24 | recipes: RecipeMap; 25 | trimVariants: (guess: Table) => MatchMap; 26 | checkAllVariants: (guess: Table) => string | undefined; 27 | gameState: GameState; 28 | setGameState: Dispatch>; 29 | options: Options; 30 | setOptions: Dispatch>; 31 | resetGame: (isRandom: boolean) => void; 32 | gameDate: Date; 33 | remainingSolutionVariants: Table[]; 34 | }; 35 | 36 | const GlobalContext = createContext({ 37 | userId: "", 38 | solution: "stick", 39 | items: {}, 40 | cursorItem: undefined, 41 | setCursorItem: () => {}, 42 | craftingTables: [], 43 | setCraftingTables: () => {}, 44 | colorTables: [], 45 | setColorTables: () => {}, 46 | recipes: {}, 47 | trimVariants: () => [ 48 | [-1, -1, -1], 49 | [-1, -1, -1], 50 | [-1, -1, -1], 51 | ], 52 | checkAllVariants: () => undefined, 53 | gameState: "inprogress", 54 | setGameState: () => {}, 55 | options: DEFAULT_OPTIONS, 56 | setOptions: () => {}, 57 | resetGame: () => {}, 58 | gameDate: new Date(), 59 | remainingSolutionVariants: [], 60 | }); 61 | 62 | export const GlobalContextProvider = GlobalContext.Provider; 63 | 64 | export const useGlobal = () => useContext(GlobalContext); 65 | -------------------------------------------------------------------------------- /src/context/Global/index.tsx: -------------------------------------------------------------------------------- 1 | import { CACHE_VERSION, DEFAULT_OPTIONS, PUBLIC_DIR } from "@/constants"; 2 | import { ColorTable, GameState, ItemMap, MatchMap, Options, RecipeMap, Table, TableItem } from "@/types"; 3 | import { compareTables, getVariantsWithReflections } from "@/utils/recipe"; 4 | import { ReactNode, useEffect, useMemo, useState } from "react"; 5 | import seedrandom from "seedrandom"; 6 | import { GlobalContextProps, GlobalContextProvider } from "./context"; 7 | 8 | const GlobalProvider = ({ children }: { children: ReactNode }) => { 9 | const [userId, setUserId] = useState(""); 10 | const [options, setOptions] = useState(DEFAULT_OPTIONS); // ["stick", "planks", "wood" 11 | 12 | const [gameDate, setGameDate] = useState(new Date()); 13 | const [gameState, setGameState] = useState("inprogress"); 14 | const [solution, setSolution] = useState("stick"); 15 | const [items, setItems] = useState({}); 16 | const [cursorItem, setCursorItem] = useState(undefined); 17 | const [craftingTables, setCraftingTables] = useState([ 18 | [ 19 | [undefined, undefined, undefined], 20 | [undefined, undefined, undefined], 21 | [undefined, undefined, undefined], 22 | ], 23 | ]); 24 | const [colorTables, setColorTables] = useState([ 25 | [ 26 | [undefined, undefined, undefined], 27 | [undefined, undefined, undefined], 28 | [undefined, undefined, undefined], 29 | ], 30 | ]); 31 | 32 | const [recipes, setRecipes] = useState({}); 33 | const [solutionRecipe, setSolutionRecipe] = useState<(string | null)[][]>([]); 34 | const [allRecipesAllVariants, setAllRecipesAllVariants] = useState<{ 35 | [key: string]: Table[]; 36 | }>({}); 37 | const [allSolutionVariants, setAllSolutionVariants] = useState([]); 38 | const [remainingSolutionVariants, setRemainingSolutionVariants] = useState([]); 39 | const [solution_n_items, setSolution_n_items] = useState<{ 40 | [key: string]: number; 41 | }>({}); 42 | 43 | useEffect(() => { 44 | getUserId(); 45 | getOptions(); 46 | getItems(); 47 | getRecipes(); 48 | }, []); 49 | 50 | const resetGame = (isRandom: boolean) => { 51 | setGameState("inprogress"); 52 | if (isRandom) { 53 | const randomSolution = Object.keys(recipes)[Math.floor(Math.random() * Object.keys(recipes).length)]; 54 | setSolution(randomSolution); 55 | } else { 56 | const newDate = new Date(); 57 | setGameDate(newDate); 58 | generateSetPuzzle(newDate); 59 | } 60 | 61 | setCursorItem(undefined); 62 | setCraftingTables([]); 63 | setTimeout( 64 | () => 65 | setCraftingTables([ 66 | [ 67 | [undefined, undefined, undefined], 68 | [undefined, undefined, undefined], 69 | [undefined, undefined, undefined], 70 | ], 71 | ]), 72 | 250 73 | ); 74 | setColorTables([ 75 | [ 76 | [undefined, undefined, undefined], 77 | [undefined, undefined, undefined], 78 | [undefined, undefined, undefined], 79 | ], 80 | ]); 81 | }; 82 | 83 | useEffect(() => { 84 | if (Object.keys(recipes).length > 0) { 85 | // load all item recipes with all variants 86 | let newAllRecipesAllVariants = { ...allRecipesAllVariants }; 87 | for (let [key, value] of Object.entries(recipes)) { 88 | newAllRecipesAllVariants[value.output] = getVariantsWithReflections(value.input); 89 | } 90 | setAllRecipesAllVariants(newAllRecipesAllVariants); 91 | if (solution) { 92 | setSolutionRecipe(recipes[solution].input); 93 | } 94 | } 95 | }, [recipes, solution]); 96 | 97 | useEffect(() => { 98 | if (solutionRecipe.length > 0) { 99 | // generate all solution variants based on initial soln recipe 100 | let newSolution_n_items: { [key: string]: number } = {}; 101 | for (let i = 0; i < solutionRecipe.length; i++) { 102 | for (let j = 0; j < solutionRecipe[0].length; j++) { 103 | if (solutionRecipe[i][j] === null) { 104 | continue; 105 | } 106 | if (newSolution_n_items[solutionRecipe[i][j]!] === undefined) { 107 | newSolution_n_items[solutionRecipe[i][j]!] = 1; 108 | } else { 109 | newSolution_n_items[solutionRecipe[i][j]!]++; 110 | } 111 | } 112 | } 113 | setSolution_n_items(newSolution_n_items); 114 | 115 | // include reflections 116 | let solutionVariants = getVariantsWithReflections(solutionRecipe); 117 | setAllSolutionVariants(solutionVariants); 118 | setRemainingSolutionVariants(solutionVariants); 119 | } 120 | }, [solutionRecipe]); 121 | 122 | useEffect(() => { 123 | generateSetPuzzle(gameDate); 124 | }, [recipes]); 125 | 126 | const generateSetPuzzle = (date: Date) => { 127 | const random = seedrandom(date.toDateString()); 128 | 129 | const randomSolution = Object.keys(recipes)[Math.floor(random() * Object.keys(recipes).length)]; 130 | setSolution(randomSolution); 131 | }; 132 | 133 | const getUserId = () => { 134 | let user_id = localStorage.getItem("user_id"); 135 | 136 | if (user_id === null) { 137 | user_id = Date.now().toString() + Math.random().toString(); //self.crypto.randomUUID();// crypto only works with SSL 138 | localStorage.setItem("user_id", user_id); 139 | } 140 | 141 | setUserId(user_id); 142 | }; 143 | 144 | useEffect(() => { 145 | localStorage.setItem(`options`, JSON.stringify(options)); 146 | }, [options]); 147 | 148 | const getOptions = () => { 149 | const options = JSON.parse(localStorage.getItem(`options`) ?? "{}") as Options; 150 | if (Object.keys(options).length === 0) { 151 | setOptions(DEFAULT_OPTIONS); 152 | } else { 153 | setOptions(options); 154 | } 155 | }; 156 | 157 | const getItems = () => { 158 | const itemMap = JSON.parse(localStorage.getItem(`items_${CACHE_VERSION}`) ?? "{}") as ItemMap; 159 | 160 | if (Object.keys(itemMap).length === 0) { 161 | fetch(PUBLIC_DIR + "/data/items.json", { 162 | headers: { 163 | "Content-Type": "application/json", 164 | "Cache-Control": "no-cache", 165 | }, 166 | }) 167 | .then((res) => res.json()) 168 | .then((res) => { 169 | setItems(res); 170 | localStorage.setItem(`items_${CACHE_VERSION}`, JSON.stringify(res)); 171 | }); 172 | } else { 173 | setItems(itemMap); 174 | } 175 | }; 176 | 177 | const getRecipes = () => { 178 | const recipeMap = JSON.parse(localStorage.getItem(`recipes_${CACHE_VERSION}`) ?? "{}") as RecipeMap; 179 | 180 | if (Object.keys(recipeMap).length === 0) { 181 | fetch(PUBLIC_DIR + "/data/recipes.json", { 182 | headers: { 183 | "Content-Type": "application/json", 184 | "Cache-Control": "no-cache", 185 | }, 186 | }) 187 | .then((res) => res.json()) 188 | .then((res) => { 189 | setRecipes(res); 190 | localStorage.setItem(`recipes_${CACHE_VERSION}`, JSON.stringify(res)); 191 | }); 192 | } else { 193 | setRecipes(recipeMap); 194 | } 195 | }; 196 | 197 | /** 198 | * Compares a guess to all recipes and returns the first match 199 | * @param guess Table 200 | * @returns first match name or undefined 201 | */ 202 | const checkAllVariants = (guess: Table): string | undefined => { 203 | for (let [key, recipe] of Object.entries(allRecipesAllVariants)) { 204 | for (let variant of recipe) { 205 | let [mm, matchcount, isFullMatch] = compareTables(variant, guess); 206 | // matchData[2] is boolean isFullMatch 207 | if (isFullMatch) { 208 | return key; 209 | } 210 | } 211 | } 212 | return undefined; 213 | }; 214 | 215 | const getFirstSolutionVariant = (): Table => { 216 | return remainingSolutionVariants[0]; 217 | }; 218 | 219 | const trimVariants = (guess: Table) => { 220 | let [matchmaps, matchcounts] = checkRemainingSolutionVariants(guess); 221 | // find remaining variants, correctSlots only has green slots 222 | let [remainingVariantsIndices, correctSlots] = findRemainingVariantsIndices(matchmaps, matchcounts); 223 | 224 | setRemainingSolutionVariants((old) => [...old].filter((_, i) => remainingVariantsIndices.includes(i))); 225 | 226 | // add orange slots to correctSlots 227 | addOrangeSlots(guess, correctSlots); 228 | 229 | return correctSlots; 230 | }; 231 | 232 | const checkRemainingSolutionVariants = (guess: Table): [MatchMap[], number[]] => { 233 | let matchmaps: MatchMap[] = []; 234 | let matchcounts: number[] = []; 235 | 236 | for (let variant of remainingSolutionVariants) { 237 | let matchData = compareTables(variant, guess); 238 | 239 | matchmaps.push(matchData[0]); 240 | matchcounts.push(matchData[1]); 241 | } 242 | 243 | return [matchmaps, matchcounts]; 244 | }; 245 | 246 | /** 247 | * Determines which variants in remainingVariants will stay. Chooses variant 248 | * with highest number of matches. If multiple of these, picks one and only 249 | * keeps variants with matching correct slots as the chosen one. 250 | * @param {Array} matchmaps 251 | * @param {Array} matchcounts 252 | * @returns 253 | */ 254 | function findRemainingVariantsIndices(matchmaps: MatchMap[], matchcounts: number[]): [number[], MatchMap] { 255 | // Get index of max value in matchcounts 256 | let maxMatchesIndex = matchcounts.indexOf(Math.max(...matchcounts)); 257 | // generate mask matchmap at this index for 2's 258 | let [correctSlots, _, __] = compareTables(matchmaps[maxMatchesIndex], matchmaps[maxMatchesIndex], 2); 259 | 260 | let remainingVariantsIndices: number[] = []; 261 | 262 | for (let [i, matchmap] of matchmaps.entries()) { 263 | // mask to only include 2's in matchmaps 264 | let matchDataToCompare = compareTables(matchmap, matchmap, 2); 265 | // compare masked 266 | let correctSlotOverlapData = compareTables(correctSlots, matchDataToCompare[0]); 267 | 268 | // if correctSlotOverlapData is full match 269 | if (correctSlotOverlapData[2]) { 270 | remainingVariantsIndices.push(i); 271 | } 272 | } 273 | 274 | return [remainingVariantsIndices, correctSlots]; 275 | } 276 | 277 | /** 278 | * Adds orange slots to a given table. Requires all correctSlots to already be 279 | * filled in. 280 | * @param {Array} guess 281 | * @param {Array} correctSlots 282 | */ 283 | function addOrangeSlots(guess: Table, correctSlots: MatchMap) { 284 | let n_items: { [key: string]: number } = {}; 285 | // first pass initiliases all item dict entries to 0 286 | for (let i = 0; i < 3; i++) { 287 | for (let j = 0; j < 3; j++) { 288 | if (guess[i][j] === null || guess[i][j] === undefined) { 289 | continue; 290 | } 291 | 292 | if (n_items[guess[i][j]!] === undefined) { 293 | n_items[guess[i][j]!] = 0; 294 | } 295 | } 296 | } 297 | 298 | // Second pass counts how many of each item are correct 299 | for (let i = 0; i < 3; i++) { 300 | for (let j = 0; j < 3; j++) { 301 | if (guess[i][j] === null || guess[i][j] === undefined) { 302 | continue; 303 | } 304 | 305 | if (correctSlots[i][j] === 2) { 306 | n_items[guess[i][j]!]++; 307 | } 308 | } 309 | } 310 | 311 | // finds how many of each item are left to be identified 312 | let n_unidentified_items = { ...solution_n_items }; 313 | for (let name of Object.keys(n_unidentified_items)) { 314 | n_unidentified_items[name] -= n_items[name]; 315 | } 316 | 317 | // final pass marks (at most n) orange slots for each item in n_unidentified_items 318 | for (let i = 0; i < 3; i++) { 319 | for (let j = 0; j < 3; j++) { 320 | if (guess[i][j] === null || guess[i][j] === undefined) { 321 | continue; 322 | } 323 | 324 | if (correctSlots[i][j] !== 2 && n_unidentified_items[guess[i][j]!] > 0) { 325 | correctSlots[i][j] = 3; 326 | n_unidentified_items[guess[i][j]!]--; 327 | } 328 | } 329 | } 330 | } 331 | 332 | const value: GlobalContextProps = useMemo( 333 | () => ({ 334 | userId, 335 | solution, 336 | items, 337 | cursorItem, 338 | setCursorItem, 339 | craftingTables, 340 | setCraftingTables, 341 | colorTables, 342 | setColorTables, 343 | recipes, 344 | checkAllVariants, 345 | getFirstSolutionVariant, 346 | trimVariants, 347 | gameState, 348 | setGameState, 349 | options, 350 | setOptions, 351 | resetGame, 352 | gameDate, 353 | remainingSolutionVariants, 354 | }), 355 | [ 356 | userId, 357 | solution, 358 | items, 359 | cursorItem, 360 | setCursorItem, 361 | craftingTables, 362 | setCraftingTables, 363 | recipes, 364 | checkAllVariants, 365 | getFirstSolutionVariant, 366 | trimVariants, 367 | colorTables, 368 | setColorTables, 369 | gameState, 370 | setGameState, 371 | options, 372 | setOptions, 373 | resetGame, 374 | gameDate, 375 | remainingSolutionVariants, 376 | ] 377 | ); 378 | 379 | return {children}; 380 | }; 381 | 382 | export default GlobalProvider; 383 | -------------------------------------------------------------------------------- /src/pages/_app.tsx: -------------------------------------------------------------------------------- 1 | import GlobalProvider from "@/context/Global"; 2 | import "@/styles/globals.css"; 3 | import type { AppProps } from "next/app"; 4 | import Head from "next/head"; 5 | import Layout from "./layout"; 6 | 7 | import { trpc } from "../utils/trpc"; 8 | 9 | function App({ Component, pageProps }: AppProps) { 10 | const layout = ( 11 | 12 | 13 | Minecraftle 14 | 15 | 19 | 24 | 30 | 36 | 37 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | ); 50 | return {layout}; 51 | } 52 | 53 | export default trpc.withTRPC(App); 54 | -------------------------------------------------------------------------------- /src/pages/_document.tsx: -------------------------------------------------------------------------------- 1 | import { Html, Head, Main, NextScript } from 'next/document' 2 | 3 | export default function Document() { 4 | return ( 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | ) 13 | } 14 | -------------------------------------------------------------------------------- /src/pages/api/trpc/[trpc].ts: -------------------------------------------------------------------------------- 1 | import * as trpcNext from "@trpc/server/adapters/next"; 2 | import { appRouter } from "../../../server/routers/_app"; 3 | 4 | // export API handler 5 | // @link https://trpc.io/docs/v11/server/adapters 6 | export default trpcNext.createNextApiHandler({ 7 | router: appRouter, 8 | createContext: () => ({}), 9 | }); 10 | -------------------------------------------------------------------------------- /src/pages/how-to-play.tsx: -------------------------------------------------------------------------------- 1 | import Link from "next/link"; 2 | 3 | export default function HowToPlay() { 4 | return ( 5 |
6 |
7 |

How To Play

8 |

9 | Your goal is to try to craft the secret item from the ingredients in 10 | your inventory: 11 |

12 |
    13 |
  1. 14 | You have 10 guesses 15 |
  2. 16 |
  3. 17 | If your guess is incorrect, some of the grid may be coloured to give 18 | you feedback 19 |
  4. 20 |
  5. 21 | If the square remains grey, the ingredient you placed here is not in 22 | the recipe, hmmm... 23 |
  6. 24 |
  7. 25 | An orange square means that this ingredient is needed somewhere else 26 | on the grid, but not at the spot... 27 |
  8. 28 |
  9. 29 | A green square means the ingredient placed on that square is correct 30 | and in the right spot! 31 |
  10. 32 |
33 |

34 | Click below to start the game and test your true knowledge of 35 | Minecraft...Your reputation is on the line! 36 |

37 |

38 | 39 | Play game! 40 | 41 |

42 |
43 |
44 |

About

45 |

46 | Originally created by Tamura Boog, Zach Manson, Harrison Oates, Ivan 47 | Sossa Gongora in 2022. Other contributors can be seen on the GitHub 48 | repo. 49 |

50 |

51 | Built originally Flask, recently rebuilt with Next.js and React. 52 |
53 | Source code:{" "} 54 | 58 | GitHub 59 | 60 |

61 |

62 | Hosted by{" "} 63 | 64 | Zach Manson 65 | 66 | . If you are reading this please{" "} 67 | 68 | email me 69 | {" "} 70 | and tell me how you found the site since I haven't a clue. 71 |

72 |
73 |
74 | ); 75 | } 76 | -------------------------------------------------------------------------------- /src/pages/index.tsx: -------------------------------------------------------------------------------- 1 | import CraftingTable from "@/components/CraftingTable.component"; 2 | import Cursor from "@/components/Cursor.component"; 3 | import Inventory from "@/components/Inventory.component"; 4 | import LoadingSpinner from "@/components/LoadingSpinner.component"; 5 | import MCButton from "@/components/MCButton.component"; 6 | import Popup from "@/components/Popup.component"; 7 | import { useGlobal } from "@/context/Global/context"; 8 | import { trpc } from "@/utils/trpc"; 9 | import { Inter } from "next/font/google"; 10 | import { useRouter } from "next/router"; 11 | import { useEffect, useRef, useState } from "react"; 12 | const inter = Inter({ subsets: ["latin"] }); 13 | 14 | export default function Home() { 15 | const router = useRouter(); 16 | const { random } = router.query; 17 | const { 18 | craftingTables, 19 | gameState, 20 | userId, 21 | resetGame, 22 | recipes, 23 | gameDate, 24 | items, 25 | } = useGlobal(); 26 | const [popupVisible, setPopupVisible] = useState(false); 27 | 28 | const submitGame = trpc.game.submitGame.useMutation(); 29 | 30 | const divRef = useRef(null); 31 | 32 | useEffect(() => { 33 | divRef?.current?.scrollIntoView({ behavior: "smooth" }); 34 | }, [craftingTables.length]); 35 | 36 | useEffect(() => { 37 | if (random) { 38 | resetGame(true); 39 | setPopupVisible(false); 40 | } 41 | }, [random]); 42 | 43 | useEffect(() => { 44 | if (gameState === "inprogress") return; 45 | 46 | setPopupVisible(true); 47 | 48 | if ( 49 | localStorage.getItem("lastGameDate") !== gameDate.toDateString() && 50 | !random 51 | ) { 52 | submitGame 53 | .mutateAsync({ 54 | user_id: userId, 55 | attempts: gameState === "won" ? craftingTables.length : 11, 56 | date: gameDate.toISOString(), // TODO make this based on the start time 57 | }) 58 | .then((res) => { 59 | localStorage.setItem("lastGameDate", gameDate.toDateString()); 60 | }); 61 | } 62 | }, [gameState]); 63 | 64 | return ( 65 |
68 | 69 | 70 | {Object.keys(recipes).length > 0 && Object.keys(items).length > 0 ? ( 71 |
72 | {craftingTables.map((table, index) => ( 73 | 81 | ))} 82 |
83 | ) : ( 84 |
85 | 86 |
87 | )} 88 | 89 | 90 |
91 | {popupVisible && ( 92 | { 96 | setPopupVisible(false); 97 | }} 98 | /> 99 | )} 100 | {gameState !== "inprogress" && ( 101 | setPopupVisible(true)}>Show Summary 102 | )} 103 |
104 | ); 105 | } 106 | -------------------------------------------------------------------------------- /src/pages/layout.tsx: -------------------------------------------------------------------------------- 1 | import MCButton from "@/components/MCButton.component"; 2 | import { useGlobal } from "@/context/Global/context"; 3 | import Link from "next/link"; 4 | 5 | export default function Layout({ children }: any) { 6 | const { setCursorItem, userId, setOptions, resetGame } = useGlobal(); 7 | // const [isPlaying, setIsPlaying] = useState(false); 8 | // const audioToPlay = useRef(); 9 | // const playMusic = () => { 10 | // if (isPlaying) { 11 | // audioToPlay.current?.pause(); 12 | // } else { 13 | // audioToPlay.current = new Audio( 14 | // "/audio/C418 - Aria Math (Minecraft Volume Beta).mp3" 15 | // ); 16 | // audioToPlay.current.play(); 17 | // } 18 | // setIsPlaying((o) => !o); 19 | // }; 20 | return ( 21 |
{ 23 | setCursorItem(undefined); 24 | }} 25 | > 26 |
27 |
28 |

MINECRAFTLE

29 | 70 |
71 |
{children}
72 |
73 |
74 | ); 75 | } 76 | -------------------------------------------------------------------------------- /src/pages/stats/[userId].tsx: -------------------------------------------------------------------------------- 1 | import Row from "@/components/StatRow.component"; 2 | import { ScoreboardRow } from "@/types"; 3 | import prisma from "@/utils/prisma"; 4 | import { trpc } from "@/utils/trpc"; 5 | import { GetServerSideProps } from "next"; 6 | import { useRouter } from "next/router"; 7 | 8 | export default function Stats({ 9 | liveUserScores, // actual user scores 10 | totalPlayerCount, 11 | }: { 12 | liveUserScores: ScoreboardRow; 13 | totalPlayerCount: number; 14 | }) { 15 | const router = useRouter(); 16 | const userId = router.query.userId as string; 17 | 18 | const { data, isLoading } = trpc.game.scoreboard.useQuery( 19 | { 20 | userId: userId ?? "", 21 | }, 22 | { 23 | enabled: !!userId, 24 | } 25 | ); 26 | const localLeaderboard = data?.localLeaderboard; 27 | 28 | const allAttempts = Object.keys(liveUserScores) 29 | .filter((key) => key.match(/^total_\d+$/)) 30 | .map((key) => ({ 31 | attempts: parseInt(key.replace("total_", "")), 32 | count: liveUserScores[key as keyof ScoreboardRow] as number, 33 | })); 34 | 35 | const ranking = () => { 36 | if (!localLeaderboard || isLoading) { 37 | return ; 38 | } 39 | if (localLeaderboard.length === 0) { 40 | if (liveUserScores.total_games > 0) { 41 | return ; 42 | } else { 43 | return ; 44 | } 45 | } 46 | 47 | const userRow = localLeaderboard?.find((r) => r.user_id)!; 48 | const upRow = localLeaderboard?.find((r) => r.dense_rank_number === userRow.dense_rank_number - 1); 49 | const downRow = localLeaderboard?.find((r) => r.dense_rank_number === userRow.dense_rank_number + 1); 50 | console.log(upRow, "upRow"); 51 | 52 | let catchupMessage; 53 | if (upRow) { 54 | if (upRow?.total_games - upRow?.total_losses - (userRow?.total_games - userRow?.total_losses) === 0) { 55 | catchupMessage = ( 56 | <> 57 | 58 | 59 | 60 | ); 61 | } else { 62 | catchupMessage = ( 63 | 71 | ); 72 | } 73 | } 74 | 75 | let leadMessage; 76 | if (downRow) { 77 | if (userRow?.total_games - userRow?.total_losses - (downRow?.total_games - downRow?.total_losses) === 0) { 78 | leadMessage = ( 79 | <> 80 | 81 | 82 | 83 | ); 84 | } else { 85 | leadMessage = ( 86 | 94 | ); 95 | } 96 | } 97 | 98 | return ( 99 | <> 100 | 104 | 105 | {upRow && catchupMessage} 106 | {downRow && leadMessage} 107 | 108 | ); 109 | }; 110 | 111 | return ( 112 |
113 |

Statistics

114 |
115 | 116 | 117 | {ranking()} 118 | 119 | 120 | 121 | 122 | 134 | 135 | 136 | {Object.values(allAttempts).map((a, i) => ( 137 | 138 | ))} 139 | 140 |
141 |
142 |
143 | ); 144 | } 145 | 146 | const DEFAULT_SCOREBOARD_ROW: ScoreboardRow = { 147 | user_id: "", 148 | dense_rank_number: 0, 149 | total_games: 0, 150 | total_win_attempts: 0, 151 | total_losses: 0, 152 | total_1: 0, 153 | total_2: 0, 154 | total_3: 0, 155 | total_4: 0, 156 | total_5: 0, 157 | total_6: 0, 158 | total_7: 0, 159 | total_8: 0, 160 | total_9: 0, 161 | total_10: 0, 162 | }; 163 | 164 | export const getServerSideProps: GetServerSideProps = async (context) => { 165 | const { userId } = context.params as { userId: string }; 166 | 167 | let liveUserScores: ScoreboardRow[] = []; 168 | let results: ScoreboardRow[] = []; 169 | let totalPlayerCount: number; 170 | 171 | try { 172 | [liveUserScores, /* results,*/ totalPlayerCount] = await prisma.$transaction([ 173 | prisma.$queryRaw` 174 | SELECT 175 | -1, 176 | user_id, 177 | SUM(game_count) AS total_games, 178 | SUM(CASE WHEN attempts = 11 THEN game_count ELSE 0 END) as total_losses, 179 | 180 | SUM(CASE WHEN attempts = 1 THEN game_count ELSE 0 END) as total_1, 181 | SUM(CASE WHEN attempts = 2 THEN game_count ELSE 0 END) as total_2, 182 | SUM(CASE WHEN attempts = 3 THEN game_count ELSE 0 END) as total_3, 183 | SUM(CASE WHEN attempts = 4 THEN game_count ELSE 0 END) as total_4, 184 | SUM(CASE WHEN attempts = 5 THEN game_count ELSE 0 END) as total_5, 185 | SUM(CASE WHEN attempts = 6 THEN game_count ELSE 0 END) as total_6, 186 | SUM(CASE WHEN attempts = 7 THEN game_count ELSE 0 END) as total_7, 187 | SUM(CASE WHEN attempts = 8 THEN game_count ELSE 0 END) as total_8, 188 | SUM(CASE WHEN attempts = 9 THEN game_count ELSE 0 END) as total_9, 189 | SUM(CASE WHEN attempts = 10 THEN game_count ELSE 0 END) as total_10, 190 | 191 | SUM(CASE WHEN attempts != 11 THEN game_count*attempts ELSE 0 END) as total_win_attempts 192 | FROM public.game_count 193 | WHERE user_id = ${userId} GROUP BY user_id; 194 | `, 195 | // prisma.$queryRaw` 196 | // WITH user_rank AS ( 197 | // SELECT dense_rank_number FROM scoreboard WHERE user_id = ${userId} 198 | // ) 199 | 200 | // SELECT * 201 | // FROM scoreboard 202 | // WHERE user_id = ${userId} 203 | // OR user_id IN ( 204 | // SELECT user_id 205 | // FROM scoreboard 206 | // WHERE dense_rank_number = (SELECT dense_rank_number FROM user_rank) - 1 207 | // LIMIT 1 208 | // ) 209 | // OR user_id IN ( 210 | // SELECT user_id 211 | // FROM scoreboard 212 | // WHERE dense_rank_number = (SELECT dense_rank_number FROM user_rank) + 1 213 | // LIMIT 1 214 | // ); 215 | // `, 216 | prisma.user.count(), 217 | ]); 218 | console.log(userId, "results", results); 219 | } catch (e) { 220 | console.error(e); 221 | return { 222 | redirect: { 223 | destination: "/", 224 | permanent: false, 225 | }, 226 | }; 227 | } 228 | 229 | // hack to make bigint work with JSON.stringify 230 | liveUserScores = JSON.parse( 231 | JSON.stringify(liveUserScores, (_key, value) => (typeof value === "bigint" ? Number(value) : value)) 232 | ); 233 | results = JSON.parse(JSON.stringify(results, (_key, value) => (typeof value === "bigint" ? Number(value) : value))); 234 | 235 | return { 236 | props: { 237 | liveUserScores: liveUserScores.at(0) ?? DEFAULT_SCOREBOARD_ROW, 238 | localLeaderboard: results.map((r) => ({ 239 | ...r, 240 | user_id: r.user_id === userId ? userId : null, 241 | })), 242 | totalPlayerCount: totalPlayerCount, 243 | }, 244 | }; 245 | }; 246 | -------------------------------------------------------------------------------- /src/pages/stats/index.tsx: -------------------------------------------------------------------------------- 1 | import Row from "@/components/StatRow.component"; 2 | import prisma from "@/utils/prisma"; 3 | import { GetServerSideProps } from "next"; 4 | 5 | export default function Stats({ 6 | count_1, 7 | count_7, 8 | count_30, 9 | count_90, 10 | count_365, 11 | count_all_time, 12 | }: { 13 | count_1: number; 14 | count_7: number; 15 | count_30: number; 16 | count_90: number; 17 | count_365: number; 18 | count_all_time: number; 19 | }) { 20 | return ( 21 |
22 |

Statistics

23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 |
35 |
36 |
37 | ); 38 | } 39 | 40 | export const getServerSideProps: GetServerSideProps = async (context) => { 41 | let count_1: number; 42 | let count_7: number; 43 | let count_30: number; 44 | let count_90: number; 45 | let count_365: number; 46 | let count_all_time: number; 47 | 48 | const MS_PER_DAY = 24 * 60 * 60 * 1000; 49 | 50 | try { 51 | [count_1, count_7, count_30, count_90, count_365, count_all_time] = await prisma.$transaction([ 52 | prisma.user.count({ 53 | where: { 54 | last_game_date: { 55 | gte: new Date(Date.now() - 1 * MS_PER_DAY), 56 | }, 57 | }, 58 | }), 59 | prisma.user.count({ 60 | where: { 61 | last_game_date: { 62 | gte: new Date(Date.now() - 7 * MS_PER_DAY), 63 | }, 64 | }, 65 | }), 66 | prisma.user.count({ 67 | where: { 68 | last_game_date: { 69 | gte: new Date(Date.now() - 30 * MS_PER_DAY), 70 | }, 71 | }, 72 | }), 73 | prisma.user.count({ 74 | where: { 75 | last_game_date: { 76 | gte: new Date(Date.now() - 90 * MS_PER_DAY), 77 | }, 78 | }, 79 | }), 80 | prisma.user.count({ 81 | where: { 82 | last_game_date: { 83 | gte: new Date(Date.now() - 365 * MS_PER_DAY), 84 | }, 85 | }, 86 | }), 87 | prisma.user.count(), 88 | ]); 89 | } catch (e) { 90 | console.error(e); 91 | return { 92 | redirect: { 93 | destination: "/", 94 | permanent: false, 95 | }, 96 | }; 97 | } 98 | 99 | return { 100 | props: { 101 | count_1, 102 | count_7, 103 | count_30, 104 | count_90, 105 | count_365, 106 | count_all_time, 107 | }, 108 | }; 109 | }; 110 | -------------------------------------------------------------------------------- /src/server/routers/_app.ts: -------------------------------------------------------------------------------- 1 | import { z } from "zod"; 2 | import { publicProcedure, createRouter } from "../trpc"; 3 | import { gameRouter } from "./game"; 4 | 5 | export const appRouter = createRouter({ 6 | hello: publicProcedure 7 | .input( 8 | z.object({ 9 | text: z.string(), 10 | }) 11 | ) 12 | .query((opts) => { 13 | return { 14 | greeting: `hello ${opts.input.text}`, 15 | }; 16 | }), 17 | game: gameRouter, 18 | }); 19 | 20 | // export type definition of API 21 | export type AppRouter = typeof appRouter; 22 | -------------------------------------------------------------------------------- /src/server/routers/game.ts: -------------------------------------------------------------------------------- 1 | import { ScoreboardRow } from "@/types"; 2 | import prisma from "@/utils/prisma"; 3 | import { TRPCError } from "@trpc/server"; 4 | import { z } from "zod"; 5 | import { createRouter, publicProcedure } from "../trpc"; 6 | 7 | export const gameRouter = createRouter({ 8 | scoreboard: publicProcedure 9 | .input(z.object({ userId: z.string() })) 10 | .query(async ({ ctx, input }) => { 11 | const userId = input.userId; 12 | let localLeaderboard: ScoreboardRow[] = []; 13 | try { 14 | localLeaderboard = await prisma.$queryRaw` 15 | WITH user_rank AS ( 16 | SELECT dense_rank_number FROM scoreboard WHERE user_id = ${userId} 17 | ) 18 | 19 | SELECT * 20 | FROM scoreboard 21 | WHERE user_id = ${userId} 22 | OR user_id IN ( 23 | SELECT user_id 24 | FROM scoreboard 25 | WHERE dense_rank_number = (SELECT dense_rank_number FROM user_rank) - 1 26 | LIMIT 1 27 | ) 28 | OR user_id IN ( 29 | SELECT user_id 30 | FROM scoreboard 31 | WHERE dense_rank_number = (SELECT dense_rank_number FROM user_rank) + 1 32 | LIMIT 1 33 | ); 34 | `; 35 | } catch (error) { 36 | console.error(error); 37 | throw new TRPCError({ 38 | code: "INTERNAL_SERVER_ERROR", 39 | message: "error", 40 | }); 41 | } 42 | 43 | localLeaderboard = JSON.parse( 44 | JSON.stringify(localLeaderboard, (_key, value) => 45 | typeof value === "bigint" ? Number(value) : value 46 | ) 47 | ); 48 | 49 | localLeaderboard = localLeaderboard.map((r) => ({ 50 | ...r, 51 | user_id: r.user_id === userId ? userId : null, 52 | })); 53 | console.log({ localLeaderboard: localLeaderboard }); 54 | return { localLeaderboard: localLeaderboard }; 55 | }), 56 | submitGame: publicProcedure 57 | .input( 58 | z.object({ 59 | user_id: z.string().refine((s) => !Number.isNaN(parseFloat(s))), 60 | attempts: z.number().min(1).max(11), 61 | date: z 62 | .string() 63 | .datetime() 64 | .refine( 65 | (date) => { 66 | const threeDaysAgo = new Date(); 67 | const twoDayFromNow = new Date(); 68 | threeDaysAgo.setDate(threeDaysAgo.getDate() - 3); 69 | twoDayFromNow.setDate(twoDayFromNow.getDate() + 2); 70 | return ( 71 | new Date(date) >= threeDaysAgo && 72 | new Date(date) <= twoDayFromNow 73 | ); 74 | }, 75 | { 76 | message: "Date must be within the last 3 days", 77 | } 78 | ), 79 | }) 80 | ) 81 | .mutation(async ({ ctx, input }) => { 82 | const { user_id, attempts, date } = input; 83 | const flatDate = new Date(date.slice(0, 10) + "T00:00:00.000Z"); 84 | 85 | try { 86 | const user = await prisma.user.findUnique({ 87 | where: { 88 | user_id: user_id, 89 | }, 90 | select: { 91 | last_game_date: true, 92 | }, 93 | }); 94 | console.log( 95 | user?.last_game_date, 96 | flatDate, 97 | user?.last_game_date?.getTime() === flatDate.getTime() 98 | ); 99 | if (user?.last_game_date?.getTime() === flatDate.getTime()) { 100 | return new TRPCError({ 101 | code: "CONFLICT", 102 | message: "Already submitted a game today!", 103 | }); 104 | } else { 105 | await prisma.$transaction([ 106 | prisma.user.upsert({ 107 | where: { 108 | user_id: user_id.toString(), 109 | }, 110 | update: { 111 | last_game_date: flatDate, 112 | }, 113 | create: { 114 | user_id: user_id.toString(), 115 | last_game_date: flatDate, 116 | }, 117 | }), 118 | 119 | prisma.game_count.upsert({ 120 | where: { 121 | user_id_attempts: { 122 | user_id: user_id.toString(), 123 | attempts: attempts, 124 | }, 125 | }, 126 | update: { 127 | game_count: { 128 | increment: 1, 129 | }, 130 | }, 131 | create: { 132 | user_id: user_id.toString(), 133 | attempts: attempts, 134 | game_count: 1, 135 | }, 136 | }), 137 | ]); 138 | } 139 | } catch (error: any) { 140 | console.error(error); 141 | 142 | throw new TRPCError({ 143 | code: "INTERNAL_SERVER_ERROR", 144 | message: "Game record insertion failed" + error.toString(), 145 | }); 146 | } 147 | return { success: true }; 148 | }), 149 | }); 150 | 151 | export type GameRouter = typeof gameRouter; 152 | -------------------------------------------------------------------------------- /src/server/trpc.ts: -------------------------------------------------------------------------------- 1 | import { initTRPC } from "@trpc/server"; 2 | 3 | // Avoid exporting the entire t-object 4 | // since it's not very descriptive. 5 | // For instance, the use of a t variable 6 | // is common in i18n libraries. 7 | const t = initTRPC.create(); 8 | 9 | // Base router and procedure helpers 10 | export const createRouter = t.router; 11 | export const publicProcedure = t.procedure; 12 | -------------------------------------------------------------------------------- /src/styles/globals.css: -------------------------------------------------------------------------------- 1 | @tailwind base; 2 | @tailwind components; 3 | @tailwind utilities; 4 | 5 | @font-face { 6 | font-family: Minecraft-Regular; 7 | src: url("/fonts/Minecraft-Regular.otf") format("opentype"); 8 | } 9 | 10 | @font-face { 11 | font-family: Minecrafter; 12 | src: url("/fonts/Minecrafter.ttf") format("truetype"); 13 | } 14 | 15 | @font-face { 16 | font-family: Minecrafter-Cracked; 17 | src: url("/fonts/Minecrafter-Cracked.ttf") format("truetype"); 18 | } 19 | 20 | :root { 21 | --inv-background: #c6c6c6; 22 | --slot-background: #8b8b8b; 23 | --slot-background-hover: #9f9f9f; 24 | --slot-shadow: rgba(55, 55, 55, 0.7); 25 | --slot-inset: #fefefe; 26 | 27 | --button-text: #ddd; 28 | --button-text-shadow: #000a; 29 | --button-text-hover: #ffffa0; 30 | --button-text-hover-shadow: #202013cc; 31 | --button-background: #999; 32 | --button-background-hover: rgba(100, 100, 255, 0.45); 33 | --button-active-inset-dark: #0004; 34 | --button-active-inset-light: #fff7; 35 | --button-text-inset-dark: #0006; 36 | --button-active-text-inset-light: #fff5; 37 | } 38 | 39 | 40 | body { 41 | background-image: url("/images/dirt-background.webp"); 42 | margin: 1rem; 43 | font-family: Minecraft-Regular; 44 | } 45 | 46 | 47 | /* Minecraft Style Button */ 48 | .mc-button { 49 | overflow: hidden; 50 | white-space: nowrap; 51 | user-select: none; 52 | 53 | color: var(--inv-background); 54 | text-decoration: none; 55 | 56 | background: var(--button-background) url("/images/button-background.png") 57 | center / cover; 58 | image-rendering: pixelated; 59 | border: 2px solid black; 60 | 61 | text-align: center; 62 | } 63 | 64 | .mc-button .title { 65 | font-family: Minecraft-Regular; 66 | } 67 | 68 | /* Mouseover */ 69 | .mc-button:hover .title { 70 | background-color: var(--button-background-hover); 71 | text-shadow: 2px 2px var(--button-text-hover-shadow); 72 | color: var(--button-text-hover); 73 | } 74 | 75 | .mc-button:active .title { 76 | box-shadow: inset -2px -4px var(--button-active-inset-dark), 77 | inset 2px 2px var(--button-active-text-inset-light); 78 | } 79 | 80 | /* Button title */ 81 | .mc-button .title { 82 | width: 100%; 83 | height: 100%; 84 | padding: 0.25rem 0.5rem; 85 | 86 | color: var(--button-text); 87 | text-shadow: 2px 2px var(--button-text-shadow); 88 | box-shadow: inset -2px -4px var(--button-text-inset-dark), 89 | inset 2px 2px var(--button-active-inset-light); 90 | } 91 | 92 | h1 { 93 | /* font-size: 3em; */ 94 | font-size: min(3em, 10vw); 95 | font-family: Minecrafter-Cracked; 96 | } 97 | 98 | h2 { 99 | font-size: min(1.5em, 10vw); 100 | font-family: Minecraft-Regular; 101 | font-weight: bold; 102 | } 103 | 104 | p { 105 | font-family: Minecraft-Regular; 106 | } 107 | 108 | header { 109 | color: var(--inv-background); 110 | } 111 | 112 | .box { 113 | padding: 1.5rem; 114 | } 115 | 116 | .inv-background { 117 | background: var(--inv-background); 118 | color: var(--slot-shadow); 119 | border-radius: 3px; 120 | box-shadow: 5px 5px 0px var(--slot-shadow), 121 | inset 4px 4px 0px var(--slot-inset); 122 | margin-bottom: 10px; 123 | } 124 | 125 | .slot { 126 | width: 3rem; 127 | height: 3rem; 128 | display: flex; 129 | justify-content: center; 130 | background-color: var(--slot-background); 131 | box-shadow: inset 2px 2px 0px var(--slot-shadow), 132 | inset -2px -2px 0px var(--slot-inset); 133 | } 134 | 135 | .slot:hover, 136 | .slot.dragging { 137 | background-color: var(--slot-background-hover); 138 | } 139 | 140 | .slot-image { 141 | margin: auto; 142 | width: 2.5rem; 143 | height: 2.5rem; 144 | image-rendering: pixelated; 145 | /* image-rendering: auto; */ 146 | background-size: contain; 147 | background-position: bottom; 148 | background-repeat: no-repeat; 149 | } 150 | 151 | #cursor { 152 | position: absolute; 153 | transform: translate(-50%, -50%); 154 | pointer-events: none; 155 | height: 3rem; 156 | width: 3rem; 157 | margin: auto; 158 | background-size: cover; 159 | image-rendering: pixelated; 160 | z-index: 100000; 161 | } 162 | -------------------------------------------------------------------------------- /src/types.ts: -------------------------------------------------------------------------------- 1 | import { z } from "zod"; 2 | 3 | export type GenericApiError = { 4 | error: string | z.ZodError; 5 | details?: any; 6 | }; 7 | 8 | export type TableItem = string | undefined | null | number; 9 | export type Row = [TableItem, TableItem, TableItem]; 10 | export type Table = [Row, Row, Row]; 11 | 12 | export type Color = number | undefined; 13 | export type ColorRow = [Color, Color, Color]; 14 | export type ColorTable = [ColorRow, ColorRow, ColorRow]; 15 | 16 | export type Item = { 17 | name: string; 18 | icon: string; 19 | stack: number; 20 | }; 21 | export type ItemMap = { [key: string]: Item }; 22 | 23 | export type RawRecipe = (string | null)[][]; 24 | 25 | export type Recipe = { 26 | type: string; 27 | group: string; 28 | output: string; 29 | input: RawRecipe; 30 | }; 31 | 32 | export type RecipeMap = { 33 | [key: string]: Recipe; 34 | }; 35 | 36 | export type MatchMapRow = [number, number, number]; 37 | export type MatchMap = [MatchMapRow, MatchMapRow, MatchMapRow]; 38 | 39 | export type GameState = "inprogress" | "won" | "lost"; 40 | 41 | export type Options = { 42 | highContrast: boolean; 43 | }; 44 | 45 | export type ScoreboardRow = { 46 | user_id: string | null; 47 | dense_rank_number: number; 48 | total_games: number; 49 | total_win_attempts: number; 50 | total_losses: number; 51 | total_1: number; 52 | total_2: number; 53 | total_3: number; 54 | total_4: number; 55 | total_5: number; 56 | total_6: number; 57 | total_7: number; 58 | total_8: number; 59 | total_9: number; 60 | total_10: number; 61 | }; 62 | -------------------------------------------------------------------------------- /src/utils/prisma.ts: -------------------------------------------------------------------------------- 1 | import { PrismaClient } from "@prisma/client"; 2 | 3 | let prisma: PrismaClient; 4 | if (process.env.NODE_ENV === "production") { 5 | console.debug("New prisma client created (prod)"); 6 | prisma = new PrismaClient(); 7 | } else { 8 | let globalWithPrisma = global as typeof globalThis & { 9 | prisma: PrismaClient; 10 | }; 11 | if (!globalWithPrisma.prisma) { 12 | console.debug("New prisma client created (dev)"); 13 | globalWithPrisma.prisma = new PrismaClient(); 14 | } 15 | prisma = globalWithPrisma.prisma; 16 | } 17 | 18 | export default prisma; 19 | -------------------------------------------------------------------------------- /src/utils/recipe.ts: -------------------------------------------------------------------------------- 1 | import { MatchMap, RawRecipe, Table } from "@/types"; 2 | 3 | export function getVariantsWithReflections(solution: RawRecipe): Table[] { 4 | let variants = generateVariants(solution); 5 | for (let i = 0; i < solution.length; i++) { 6 | solution[i].reverse(); 7 | } 8 | variants = variants.concat(generateVariants(solution)); 9 | return variants; 10 | } 11 | 12 | function generateVariants(recipe: RawRecipe): Table[] { 13 | let height = recipe.length; 14 | let width = recipe[0].length; 15 | let verticalVariants = 4 - recipe.length; 16 | let horizontalVariants = 4 - recipe[0].length; 17 | 18 | let variants = []; 19 | 20 | for (let i = 0; i < verticalVariants; i++) { 21 | for (let j = 0; j < horizontalVariants; j++) { 22 | let currentVariant: Table = [ 23 | [null, null, null], 24 | [null, null, null], 25 | [null, null, null], 26 | ]; 27 | 28 | for (let k = 0; k < height; k++) { 29 | for (let l = 0; l < width; l++) { 30 | currentVariant[i + k][j + l] = recipe[k][l]; 31 | } 32 | } 33 | variants.push(currentVariant); 34 | } 35 | } 36 | return variants; 37 | } 38 | 39 | export function compareTables( 40 | table1: Table, 41 | table2: Table, 42 | matchOnly?: string | number 43 | ): [MatchMap, number, boolean] { 44 | // console.log("compareTables", table1, table2); 45 | // 0 is wrong, 1 is null match, 2 is item match 46 | let matchmap: MatchMap = [ 47 | [0, 0, 0], 48 | [0, 0, 0], 49 | [0, 0, 0], 50 | ]; 51 | let matchcount = 0; 52 | let isFullMatch = true; 53 | for (let i = 0; i < table1.length; i++) { 54 | for (let j = 0; j < table1[0].length; j++) { 55 | // coerce to null 56 | table1[i][j] = table1[i][j] === undefined ? null : table1[i][j]; 57 | table2[i][j] = table2[i][j] === undefined ? null : table2[i][j]; 58 | // if matchOnly arg given 59 | if (matchOnly !== undefined) { 60 | // if either do not match matchOnly 61 | if (table1[i][j] !== matchOnly || table2[i][j] !== matchOnly) { 62 | // leave matchmap entry as incorrect 63 | continue; 64 | } 65 | } 66 | 67 | if (table1[i][j] === table2[i][j]) { 68 | if (table1[i][j] === null) { 69 | // if match is air 70 | matchmap[i][j] = 1; 71 | } else { 72 | // if match is item 73 | matchmap[i][j] = 2; 74 | matchcount++; 75 | } 76 | } else { 77 | isFullMatch = false; 78 | } 79 | } 80 | } 81 | 82 | // console.log([matchmap, matchcount, isFullMatch]); 83 | return [matchmap, matchcount, isFullMatch]; 84 | } 85 | -------------------------------------------------------------------------------- /src/utils/trpc.ts: -------------------------------------------------------------------------------- 1 | import { httpBatchLink } from "@trpc/client"; 2 | import { createTRPCNext } from "@trpc/next"; 3 | import type { AppRouter } from "../server/routers/_app"; 4 | 5 | function getBaseUrl() { 6 | if (typeof window !== "undefined") 7 | // browser should use relative path 8 | return ""; 9 | 10 | if (process.env.VERCEL_URL) 11 | // reference for vercel.com 12 | return `https://${process.env.VERCEL_URL}`; 13 | 14 | if (process.env.RENDER_INTERNAL_HOSTNAME) 15 | // reference for render.com 16 | return `http://${process.env.RENDER_INTERNAL_HOSTNAME}:${process.env.PORT}`; 17 | 18 | // assume localhost 19 | return `http://localhost:${process.env.PORT ?? 3000}`; 20 | } 21 | 22 | export const trpc = createTRPCNext({ 23 | config(opts) { 24 | return { 25 | links: [ 26 | httpBatchLink({ 27 | /** 28 | * If you want to use SSR, you need to use the server's full URL 29 | * @link https://trpc.io/docs/v11/ssr 30 | **/ 31 | url: `${getBaseUrl()}/api/trpc`, 32 | 33 | // You can pass any HTTP headers you wish here 34 | async headers() { 35 | return { 36 | // authorization: getAuthCookie(), 37 | }; 38 | }, 39 | }), 40 | ], 41 | }; 42 | }, 43 | /** 44 | * @link https://trpc.io/docs/v11/ssr 45 | **/ 46 | ssr: false, 47 | }); 48 | -------------------------------------------------------------------------------- /tailwind.config.ts: -------------------------------------------------------------------------------- 1 | import type { Config } from "tailwindcss"; 2 | 3 | const config: Config = { 4 | content: [ 5 | "./src/pages/**/*.{js,ts,jsx,tsx,mdx}", 6 | "./src/components/**/*.{js,ts,jsx,tsx,mdx}", 7 | "./src/app/**/*.{js,ts,jsx,tsx,mdx}", 8 | ], 9 | theme: { 10 | extend: { 11 | backgroundImage: { 12 | "gradient-radial": "radial-gradient(var(--tw-gradient-stops))", 13 | "gradient-conic": 14 | "conic-gradient(from 180deg at 50% 50%, var(--tw-gradient-stops))", 15 | }, 16 | colors: { 17 | "transparent-black": "rgba(0, 0, 0, 0.5)", 18 | "inv-background": "#c6c6c6", 19 | "slot-background": "#8b8b8b", 20 | "slot-background-hover": "#9f9f9f", 21 | "slot-shadow": "rgba(55, 55, 55, 0.7)", 22 | "slot-inset": "#fefefe", 23 | }, 24 | }, 25 | }, 26 | plugins: [], 27 | }; 28 | export default config; 29 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "lib": ["dom", "dom.iterable", "esnext"], 5 | "allowJs": true, 6 | "skipLibCheck": true, 7 | "downlevelIteration": true, 8 | "strict": true, 9 | "noEmit": true, 10 | "esModuleInterop": true, 11 | "module": "esnext", 12 | "moduleResolution": "bundler", 13 | "resolveJsonModule": true, 14 | "isolatedModules": true, 15 | "jsx": "preserve", 16 | "incremental": true, 17 | "paths": { 18 | "@/*": ["./src/*"] 19 | } 20 | }, 21 | "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", "src/utils/crafting.js"], 22 | "exclude": ["node_modules"] 23 | } 24 | --------------------------------------------------------------------------------