summaryrefslogtreecommitdiffstats
path: root/src/main/java/net/minecraft/server/ShapedRecipes.java
diff options
context:
space:
mode:
authorCeltic Minstrel <celtic.minstrel.ca@some.place>2011-07-14 20:54:07 -0400
committerEvilSeph <evilseph@gmail.com>2012-02-20 16:39:33 -0500
commit84ecdb5439ef5633c44b1ea0581174bf581b4969 (patch)
treeff5216b243f97bea871f9875edb8973296097200 /src/main/java/net/minecraft/server/ShapedRecipes.java
parent39048be4300b597a28ef153d705592cda638e691 (diff)
downloadcraftbukkit-84ecdb5439ef5633c44b1ea0581174bf581b4969.tar
craftbukkit-84ecdb5439ef5633c44b1ea0581174bf581b4969.tar.gz
craftbukkit-84ecdb5439ef5633c44b1ea0581174bf581b4969.tar.lz
craftbukkit-84ecdb5439ef5633c44b1ea0581174bf581b4969.tar.xz
craftbukkit-84ecdb5439ef5633c44b1ea0581174bf581b4969.zip
Imported from mc-dev:
- ShapedRecipes - ShapelessRecipes - CraftingRecipe - FurnaceRecipes
Diffstat (limited to 'src/main/java/net/minecraft/server/ShapedRecipes.java')
-rw-r--r--src/main/java/net/minecraft/server/ShapedRecipes.java82
1 files changed, 82 insertions, 0 deletions
diff --git a/src/main/java/net/minecraft/server/ShapedRecipes.java b/src/main/java/net/minecraft/server/ShapedRecipes.java
new file mode 100644
index 00000000..6fde0c73
--- /dev/null
+++ b/src/main/java/net/minecraft/server/ShapedRecipes.java
@@ -0,0 +1,82 @@
+package net.minecraft.server;
+
+public class ShapedRecipes implements CraftingRecipe {
+
+ private int b;
+ private int c;
+ private ItemStack[] d;
+ private ItemStack e;
+ public final int a;
+
+ public ShapedRecipes(int i, int j, ItemStack[] aitemstack, ItemStack itemstack) {
+ this.a = itemstack.id;
+ this.b = i;
+ this.c = j;
+ this.d = aitemstack;
+ this.e = itemstack;
+ }
+
+ public ItemStack b() {
+ return this.e;
+ }
+
+ public boolean a(InventoryCrafting inventorycrafting) {
+ for (int i = 0; i <= 3 - this.b; ++i) {
+ for (int j = 0; j <= 3 - this.c; ++j) {
+ if (this.a(inventorycrafting, i, j, true)) {
+ return true;
+ }
+
+ if (this.a(inventorycrafting, i, j, false)) {
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
+
+ private boolean a(InventoryCrafting inventorycrafting, int i, int j, boolean flag) {
+ for (int k = 0; k < 3; ++k) {
+ for (int l = 0; l < 3; ++l) {
+ int i1 = k - i;
+ int j1 = l - j;
+ ItemStack itemstack = null;
+
+ if (i1 >= 0 && j1 >= 0 && i1 < this.b && j1 < this.c) {
+ if (flag) {
+ itemstack = this.d[this.b - i1 - 1 + j1 * this.b];
+ } else {
+ itemstack = this.d[i1 + j1 * this.b];
+ }
+ }
+
+ ItemStack itemstack1 = inventorycrafting.b(k, l);
+
+ if (itemstack1 != null || itemstack != null) {
+ if (itemstack1 == null && itemstack != null || itemstack1 != null && itemstack == null) {
+ return false;
+ }
+
+ if (itemstack.id != itemstack1.id) {
+ return false;
+ }
+
+ if (itemstack.getData() != -1 && itemstack.getData() != itemstack1.getData()) {
+ return false;
+ }
+ }
+ }
+ }
+
+ return true;
+ }
+
+ public ItemStack b(InventoryCrafting inventorycrafting) {
+ return new ItemStack(this.e.id, this.e.count, this.e.getData());
+ }
+
+ public int a() {
+ return this.b * this.c;
+ }
+}