Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-18 20:40:08 +01:00
Imported from mc-dev:
- ShapedRecipes - ShapelessRecipes - CraftingRecipe - FurnaceRecipes
Dieser Commit ist enthalten in:
Ursprung
39048be430
Commit
84ecdb5439
12
src/main/java/net/minecraft/server/CraftingRecipe.java
Normale Datei
12
src/main/java/net/minecraft/server/CraftingRecipe.java
Normale Datei
@ -0,0 +1,12 @@
|
||||
package net.minecraft.server;
|
||||
|
||||
public interface CraftingRecipe {
|
||||
|
||||
boolean a(InventoryCrafting inventorycrafting);
|
||||
|
||||
ItemStack b(InventoryCrafting inventorycrafting);
|
||||
|
||||
int a();
|
||||
|
||||
ItemStack b();
|
||||
}
|
44
src/main/java/net/minecraft/server/FurnaceRecipes.java
Normale Datei
44
src/main/java/net/minecraft/server/FurnaceRecipes.java
Normale Datei
@ -0,0 +1,44 @@
|
||||
package net.minecraft.server;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class FurnaceRecipes {
|
||||
|
||||
private static final FurnaceRecipes a = new FurnaceRecipes();
|
||||
private Map b = new HashMap();
|
||||
|
||||
public static final FurnaceRecipes getInstance() {
|
||||
return a;
|
||||
}
|
||||
|
||||
private FurnaceRecipes() {
|
||||
this.registerRecipe(Block.IRON_ORE.id, new ItemStack(Item.IRON_INGOT));
|
||||
this.registerRecipe(Block.GOLD_ORE.id, new ItemStack(Item.GOLD_INGOT));
|
||||
this.registerRecipe(Block.DIAMOND_ORE.id, new ItemStack(Item.DIAMOND));
|
||||
this.registerRecipe(Block.SAND.id, new ItemStack(Block.GLASS));
|
||||
this.registerRecipe(Item.PORK.id, new ItemStack(Item.GRILLED_PORK));
|
||||
this.registerRecipe(Item.RAW_BEEF.id, new ItemStack(Item.COOKED_BEEF));
|
||||
this.registerRecipe(Item.RAW_CHICKEN.id, new ItemStack(Item.COOKED_CHICKEN));
|
||||
this.registerRecipe(Item.RAW_FISH.id, new ItemStack(Item.COOKED_FISH));
|
||||
this.registerRecipe(Block.COBBLESTONE.id, new ItemStack(Block.STONE));
|
||||
this.registerRecipe(Item.CLAY_BALL.id, new ItemStack(Item.CLAY_BRICK));
|
||||
this.registerRecipe(Block.CACTUS.id, new ItemStack(Item.INK_SACK, 1, 2));
|
||||
this.registerRecipe(Block.LOG.id, new ItemStack(Item.COAL, 1, 1));
|
||||
this.registerRecipe(Block.COAL_ORE.id, new ItemStack(Item.COAL));
|
||||
this.registerRecipe(Block.REDSTONE_ORE.id, new ItemStack(Item.REDSTONE));
|
||||
this.registerRecipe(Block.LAPIS_ORE.id, new ItemStack(Item.INK_SACK, 1, 4));
|
||||
}
|
||||
|
||||
public void registerRecipe(int i, ItemStack itemstack) {
|
||||
this.b.put(Integer.valueOf(i), itemstack);
|
||||
}
|
||||
|
||||
public ItemStack a(int i) {
|
||||
return (ItemStack) this.b.get(Integer.valueOf(i));
|
||||
}
|
||||
|
||||
public Map b() {
|
||||
return this.b;
|
||||
}
|
||||
}
|
82
src/main/java/net/minecraft/server/ShapedRecipes.java
Normale Datei
82
src/main/java/net/minecraft/server/ShapedRecipes.java
Normale Datei
@ -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;
|
||||
}
|
||||
}
|
59
src/main/java/net/minecraft/server/ShapelessRecipes.java
Normale Datei
59
src/main/java/net/minecraft/server/ShapelessRecipes.java
Normale Datei
@ -0,0 +1,59 @@
|
||||
package net.minecraft.server;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
public class ShapelessRecipes implements CraftingRecipe {
|
||||
|
||||
private final ItemStack a;
|
||||
private final List b;
|
||||
|
||||
public ShapelessRecipes(ItemStack itemstack, List list) {
|
||||
this.a = itemstack;
|
||||
this.b = list;
|
||||
}
|
||||
|
||||
public ItemStack b() {
|
||||
return this.a;
|
||||
}
|
||||
|
||||
public boolean a(InventoryCrafting inventorycrafting) {
|
||||
ArrayList arraylist = new ArrayList(this.b);
|
||||
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
for (int j = 0; j < 3; ++j) {
|
||||
ItemStack itemstack = inventorycrafting.b(j, i);
|
||||
|
||||
if (itemstack != null) {
|
||||
boolean flag = false;
|
||||
Iterator iterator = arraylist.iterator();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
ItemStack itemstack1 = (ItemStack) iterator.next();
|
||||
|
||||
if (itemstack.id == itemstack1.id && (itemstack1.getData() == -1 || itemstack.getData() == itemstack1.getData())) {
|
||||
flag = true;
|
||||
arraylist.remove(itemstack1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!flag) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return arraylist.isEmpty();
|
||||
}
|
||||
|
||||
public ItemStack b(InventoryCrafting inventorycrafting) {
|
||||
return this.a.cloneItemStack();
|
||||
}
|
||||
|
||||
public int a() {
|
||||
return this.b.size();
|
||||
}
|
||||
}
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren