Recipe work. No longer a registry. OreDictionary related code removed in favor of Tags. Started moving some OreDict items to tags.

Added code to RuntimeEnumExtender to return existing enum values with the same name if they exist instead of creating more.
This commit is contained in:
LexManos 2018-09-16 04:20:28 -07:00
parent e3a931bf96
commit c77d00efe4
49 changed files with 893 additions and 786 deletions

View file

@ -0,0 +1,40 @@
--- a/net/minecraft/item/EnumDyeColor.java
+++ b/net/minecraft/item/EnumDyeColor.java
@@ -44,6 +44,7 @@
private final int field_196066_w;
private final float[] colorComponentValues;
private final int field_196067_y;
+ private final net.minecraft.tags.Tag<Item> tag;
private EnumDyeColor(int p_i47810_3_, String p_i47810_4_, int p_i47810_5_, MapColor p_i47810_6_, int p_i47810_7_) {
this.field_196064_s = p_i47810_3_;
@@ -56,6 +57,7 @@
this.field_196066_w = k << 16 | j << 8 | i << 0;
this.colorComponentValues = new float[]{(float)i / 255.0F, (float)j / 255.0F, (float)k / 255.0F};
this.field_196067_y = p_i47810_7_;
+ this.tag = new net.minecraft.tags.ItemTags.Wrapper(new net.minecraft.util.ResourceLocation("minecraft", "dyes_" + p_i47810_4_));
}
public int func_196059_a() {
@@ -114,4 +116,21 @@
public String getName() {
return this.translationKey;
}
+
+ public net.minecraft.tags.Tag<Item> getTag() {
+ return tag;
+ }
+
+ @Nullable
+ public static EnumDyeColor getColor(ItemStack stack) {
+ if (stack.getItem() instanceof ItemDye)
+ return ((ItemDye)stack.getItem()).func_195962_g();
+
+ for (EnumDyeColor color : field_196062_q) {
+ if (stack.getItem().func_206844_a(color.getTag()))
+ return color;
+ }
+
+ return null;
+ }
}

View file

@ -0,0 +1,19 @@
--- a/net/minecraft/item/crafting/BannerAddPatternRecipe.java
+++ b/net/minecraft/item/crafting/BannerAddPatternRecipe.java
@@ -15,8 +15,6 @@
import net.minecraft.tileentity.TileEntityBanner;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
-import net.minecraftforge.api.distmarker.Dist;
-import net.minecraftforge.api.distmarker.OnlyIn;
public class BannerAddPatternRecipe extends IRecipeHidden {
public BannerAddPatternRecipe(ResourceLocation p_i48172_1_) {
@@ -167,7 +165,6 @@
return null;
}
- @OnlyIn(Dist.CLIENT)
public boolean canFit(int width, int height) {
return width >= 3 && height >= 3;
}

View file

@ -0,0 +1,19 @@
--- a/net/minecraft/item/crafting/BannerDuplicateRecipe.java
+++ b/net/minecraft/item/crafting/BannerDuplicateRecipe.java
@@ -10,8 +10,6 @@
import net.minecraft.util.NonNullList;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
-import net.minecraftforge.api.distmarker.Dist;
-import net.minecraftforge.api.distmarker.OnlyIn;
public class BannerDuplicateRecipe extends IRecipeHidden {
public BannerDuplicateRecipe(ResourceLocation p_i48171_1_) {
@@ -94,7 +92,6 @@
return RecipeSerializers.field_199586_l;
}
- @OnlyIn(Dist.CLIENT)
public boolean canFit(int width, int height) {
return width * height >= 2;
}

View file

@ -0,0 +1,19 @@
--- a/net/minecraft/item/crafting/FireworkRocketRecipe.java
+++ b/net/minecraft/item/crafting/FireworkRocketRecipe.java
@@ -9,8 +9,6 @@
import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
-import net.minecraftforge.api.distmarker.Dist;
-import net.minecraftforge.api.distmarker.OnlyIn;
public class FireworkRocketRecipe extends IRecipeHidden {
private static final Ingredient field_196209_a = Ingredient.func_199804_a(Items.PAPER);
@@ -80,7 +78,6 @@
return itemstack;
}
- @OnlyIn(Dist.CLIENT)
public boolean canFit(int width, int height) {
return width * height >= 2;
}

View file

@ -0,0 +1,19 @@
--- a/net/minecraft/item/crafting/FireworkStarFadeRecipe.java
+++ b/net/minecraft/item/crafting/FireworkStarFadeRecipe.java
@@ -10,8 +10,6 @@
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
-import net.minecraftforge.api.distmarker.Dist;
-import net.minecraftforge.api.distmarker.OnlyIn;
public class FireworkStarFadeRecipe extends IRecipeHidden {
private static final Ingredient field_196217_a = Ingredient.func_199804_a(Items.field_196153_dF);
@@ -73,7 +71,6 @@
}
}
- @OnlyIn(Dist.CLIENT)
public boolean canFit(int width, int height) {
return width * height >= 2;
}

View file

@ -0,0 +1,19 @@
--- a/net/minecraft/item/crafting/FireworkStarRecipe.java
+++ b/net/minecraft/item/crafting/FireworkStarRecipe.java
@@ -15,8 +15,6 @@
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.Util;
import net.minecraft.world.World;
-import net.minecraftforge.api.distmarker.Dist;
-import net.minecraftforge.api.distmarker.OnlyIn;
public class FireworkStarRecipe extends IRecipeHidden {
private static final Ingredient field_196212_a = Ingredient.func_199804_a(Items.FIRE_CHARGE, Items.FEATHER, Items.GOLD_NUGGET, Items.field_196182_dv, Items.field_196183_dw, Items.field_196185_dy, Items.field_196184_dx, Items.field_196151_dA, Items.field_196186_dz);
@@ -116,7 +114,6 @@
return itemstack;
}
- @OnlyIn(Dist.CLIENT)
public boolean canFit(int width, int height) {
return width * height >= 2;
}

View file

@ -0,0 +1,27 @@
--- a/net/minecraft/item/crafting/FurnaceRecipe.java
+++ b/net/minecraft/item/crafting/FurnaceRecipe.java
@@ -10,8 +10,6 @@
import net.minecraft.util.NonNullList;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
-import net.minecraftforge.api.distmarker.Dist;
-import net.minecraftforge.api.distmarker.OnlyIn;
public class FurnaceRecipe implements IRecipe {
private final ResourceLocation field_201832_a;
@@ -38,7 +36,6 @@
return this.field_201835_d.copy();
}
- @OnlyIn(Dist.CLIENT)
public boolean canFit(int width, int height) {
return true;
}
@@ -61,7 +58,6 @@
return this.field_201835_d;
}
- @OnlyIn(Dist.CLIENT)
public String getGroup() {
return this.field_201833_b;
}

View file

@ -1,21 +1,43 @@
--- a/net/minecraft/item/crafting/IRecipe.java
+++ b/net/minecraft/item/crafting/IRecipe.java
@@ -9,7 +9,7 @@
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@@ -1,20 +1,16 @@
package net.minecraft.item.crafting;
-public interface IRecipe {
+public interface IRecipe extends net.minecraftforge.registries.IForgeRegistryEntry<IRecipe> {
import net.minecraft.inventory.IInventory;
-import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
-import net.minecraftforge.api.distmarker.Dist;
-import net.minecraftforge.api.distmarker.OnlyIn;
public interface IRecipe {
boolean matches(IInventory inv, World worldIn);
ItemStack getCraftingResult(IInventory inv);
@@ -48,4 +48,9 @@
ResourceLocation func_199560_c();
IRecipeSerializer<?> func_199559_b();
+
+ @Override
+ default Class<IRecipe> getRegistryType() {
+ return IRecipe.class;
}
+}
- @OnlyIn(Dist.CLIENT)
boolean canFit(int width, int height);
ItemStack getRecipeOutput();
@@ -23,9 +19,9 @@
NonNullList<ItemStack> nonnulllist = NonNullList.<ItemStack>withSize(inv.getSizeInventory(), ItemStack.EMPTY);
for(int i = 0; i < nonnulllist.size(); ++i) {
- Item item = inv.getStackInSlot(i).getItem();
+ ItemStack item = inv.getStackInSlot(i);
if (item.hasContainerItem()) {
- nonnulllist.set(i, new ItemStack(item.getContainerItem()));
+ nonnulllist.set(i, item.getContainerItem());
}
}
@@ -40,7 +36,6 @@
return false;
}
- @OnlyIn(Dist.CLIENT)
default String getGroup() {
return "";
}

View file

@ -1,11 +0,0 @@
--- a/net/minecraft/item/crafting/IRecipeHidden.java
+++ b/net/minecraft/item/crafting/IRecipeHidden.java
@@ -3,7 +3,7 @@
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
-public abstract class IRecipeHidden implements IRecipe {
+public abstract class IRecipeHidden extends net.minecraftforge.registries.ForgeRegistryEntry<IRecipe> implements IRecipe {
private final ResourceLocation field_199563_a;
public IRecipeHidden(ResourceLocation p_i48169_1_) {

View file

@ -0,0 +1,61 @@
--- a/net/minecraft/item/crafting/Ingredient.java
+++ b/net/minecraft/item/crafting/Ingredient.java
@@ -25,10 +25,14 @@
import net.minecraft.util.IItemProvider;
import net.minecraft.util.JsonUtils;
import net.minecraft.util.ResourceLocation;
-import net.minecraftforge.api.distmarker.Dist;
-import net.minecraftforge.api.distmarker.OnlyIn;
public final class Ingredient implements Predicate<ItemStack> {
+ //Because Mojang caches things... we need to invalidate them.. so... here we go..
+ private static final java.util.Set<Ingredient> INSTANCES = java.util.Collections.newSetFromMap(new java.util.WeakHashMap<Ingredient, Boolean>());
+ public static void invalidateAll() {
+ INSTANCES.stream().filter(e -> e != null).forEach(i -> i.invalidate());
+ }
+
private static final Predicate<? super Ingredient.IItemList> field_209362_b = (p_209361_0_) -> {
return !p_209361_0_.func_199799_a().stream().allMatch(ItemStack::isEmpty);
};
@@ -36,14 +40,16 @@
private final Ingredient.IItemList[] field_199807_b;
private ItemStack[] matchingStacks;
private IntList matchingStacksPacked;
+ private final boolean isSimple;
private Ingredient(Stream<? extends Ingredient.IItemList> p_i49381_1_) {
this.field_199807_b = (Ingredient.IItemList[])p_i49381_1_.filter(field_209362_b).toArray((p_209360_0_) -> {
return new Ingredient.IItemList[p_209360_0_];
});
+ this.isSimple = !Arrays.stream(field_199807_b).anyMatch(list -> list.func_199799_a().stream().anyMatch(stack -> stack.getItem().isDamageable()));
+ Ingredient.INSTANCES.add(this);
}
- @OnlyIn(Dist.CLIENT)
public ItemStack[] getMatchingStacks() {
this.func_199806_d();
return this.matchingStacks;
@@ -121,6 +127,15 @@
return this.field_199807_b.length == 0 && (this.matchingStacks == null || this.matchingStacks.length == 0) && (this.matchingStacksPacked == null || this.matchingStacksPacked.isEmpty());
}
+ protected void invalidate() {
+ this.matchingStacks = null;
+ this.matchingStacksPacked = null;
+ }
+
+ public boolean isSimple() {
+ return isSimple || this == EMPTY;
+ }
+
private static Ingredient func_209357_a(Stream<? extends Ingredient.IItemList> p_209357_0_) {
Ingredient ingredient = new Ingredient(p_209357_0_);
return ingredient.field_199807_b.length == 0 ? EMPTY : ingredient;
@@ -132,7 +147,6 @@
}));
}
- @OnlyIn(Dist.CLIENT)
public static Ingredient fromStacks(ItemStack... stacks) {
return func_209357_a(Arrays.stream(stacks).map((p_209356_0_) -> {
return new Ingredient.SingleItemList(p_209356_0_);

View file

@ -0,0 +1,30 @@
--- a/net/minecraft/item/crafting/RecipeBookCloning.java
+++ b/net/minecraft/item/crafting/RecipeBookCloning.java
@@ -9,8 +9,6 @@
import net.minecraft.util.NonNullList;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
-import net.minecraftforge.api.distmarker.Dist;
-import net.minecraftforge.api.distmarker.OnlyIn;
public class RecipeBookCloning extends IRecipeHidden {
public RecipeBookCloning(ResourceLocation p_i48170_1_) {
@@ -86,8 +84,8 @@
for(int i = 0; i < nonnulllist.size(); ++i) {
ItemStack itemstack = inv.getStackInSlot(i);
- if (itemstack.getItem().hasContainerItem()) {
- nonnulllist.set(i, new ItemStack(itemstack.getItem().getContainerItem()));
+ if (itemstack.hasContainerItem()) {
+ nonnulllist.set(i, itemstack.getContainerItem());
} else if (itemstack.getItem() instanceof ItemWrittenBook) {
ItemStack itemstack1 = itemstack.copy();
itemstack1.setCount(1);
@@ -103,7 +101,6 @@
return RecipeSerializers.field_199578_d;
}
- @OnlyIn(Dist.CLIENT)
public boolean canFit(int width, int height) {
return width >= 3 && height >= 3;
}

View file

@ -0,0 +1,39 @@
--- a/net/minecraft/item/crafting/RecipeRepairItem.java
+++ b/net/minecraft/item/crafting/RecipeRepairItem.java
@@ -4,12 +4,9 @@
import java.util.List;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.InventoryCrafting;
-import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
-import net.minecraftforge.api.distmarker.Dist;
-import net.minecraftforge.api.distmarker.OnlyIn;
public class RecipeRepairItem extends IRecipeHidden {
public RecipeRepairItem(ResourceLocation p_i48163_1_) {
@@ -59,11 +56,10 @@
ItemStack itemstack3 = list.get(0);
ItemStack itemstack4 = list.get(1);
if (itemstack3.getItem() == itemstack4.getItem() && itemstack3.getCount() == 1 && itemstack4.getCount() == 1 && itemstack3.getItem().isDamageable()) {
- Item item = itemstack3.getItem();
- int j = item.getMaxDamage() - itemstack3.getItemDamage();
- int k = item.getMaxDamage() - itemstack4.getItemDamage();
- int l = j + k + item.getMaxDamage() * 5 / 100;
- int i1 = item.getMaxDamage() - l;
+ int j = itemstack3.getMaxDamage() - itemstack3.getItemDamage();
+ int k = itemstack3.getMaxDamage() - itemstack4.getItemDamage();
+ int l = j + k + itemstack3.getMaxDamage() * 5 / 100;
+ int i1 = itemstack3.getMaxDamage() - l;
if (i1 < 0) {
i1 = 0;
}
@@ -77,7 +73,6 @@
return ItemStack.EMPTY;
}
- @OnlyIn(Dist.CLIENT)
public boolean canFit(int width, int height) {
return width * height >= 2;
}

View file

@ -0,0 +1,19 @@
--- a/net/minecraft/item/crafting/RecipeTippedArrow.java
+++ b/net/minecraft/item/crafting/RecipeTippedArrow.java
@@ -7,8 +7,6 @@
import net.minecraft.potion.PotionUtils;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
-import net.minecraftforge.api.distmarker.Dist;
-import net.minecraftforge.api.distmarker.OnlyIn;
public class RecipeTippedArrow extends IRecipeHidden {
public RecipeTippedArrow(ResourceLocation p_i48184_1_) {
@@ -53,7 +51,6 @@
}
}
- @OnlyIn(Dist.CLIENT)
public boolean canFit(int width, int height) {
return width >= 2 && height >= 2;
}

View file

@ -0,0 +1,43 @@
--- a/net/minecraft/item/crafting/RecipesArmorDyes.java
+++ b/net/minecraft/item/crafting/RecipesArmorDyes.java
@@ -10,8 +10,6 @@
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
-import net.minecraftforge.api.distmarker.Dist;
-import net.minecraftforge.api.distmarker.OnlyIn;
public class RecipesArmorDyes extends IRecipeHidden {
public RecipesArmorDyes(ResourceLocation p_i48173_1_) {
@@ -35,7 +33,7 @@
itemstack = itemstack1;
} else {
- if (!(itemstack1.getItem() instanceof ItemDye)) {
+ if (!itemstack1.getItem().func_206844_a(net.minecraft.tags.ItemTags.DYES)) {
return false;
}
@@ -79,11 +77,12 @@
++j;
}
} else {
- if (!(item instanceof ItemDye)) {
+ net.minecraft.item.EnumDyeColor color = net.minecraft.item.EnumDyeColor.getColor(itemstack1);
+ if (color == null) {
return ItemStack.EMPTY;
}
- float[] afloat = ((ItemDye)item).func_195962_g().getColorComponentValues();
+ float[] afloat = color.getColorComponentValues();
int l1 = (int)(afloat[0] * 255.0F);
int i2 = (int)(afloat[1] * 255.0F);
int k2 = (int)(afloat[2] * 255.0F);
@@ -114,7 +113,6 @@
}
}
- @OnlyIn(Dist.CLIENT)
public boolean canFit(int width, int height) {
return width * height >= 2;
}

View file

@ -0,0 +1,19 @@
--- a/net/minecraft/item/crafting/RecipesMapCloning.java
+++ b/net/minecraft/item/crafting/RecipesMapCloning.java
@@ -6,8 +6,6 @@
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
-import net.minecraftforge.api.distmarker.Dist;
-import net.minecraftforge.api.distmarker.OnlyIn;
public class RecipesMapCloning extends IRecipeHidden {
public RecipesMapCloning(ResourceLocation p_i48165_1_) {
@@ -76,7 +74,6 @@
}
}
- @OnlyIn(Dist.CLIENT)
public boolean canFit(int width, int height) {
return width >= 3 && height >= 3;
}

View file

@ -0,0 +1,62 @@
--- a/net/minecraft/item/crafting/ShapedRecipe.java
+++ b/net/minecraft/item/crafting/ShapedRecipe.java
@@ -20,10 +20,21 @@
import net.minecraft.util.NonNullList;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
-import net.minecraftforge.api.distmarker.Dist;
-import net.minecraftforge.api.distmarker.OnlyIn;
public class ShapedRecipe implements IRecipe {
+ static int MAX_WIDTH = 3;
+ static int MAX_HEIGHT = 3;
+ /**
+ * Expand the max width and height allowed in the deserializer.
+ * This should be called by modders who add custom crafting tables that are larger than the vanilla 3x3.
+ * @param width your max recipe width
+ * @param height your max recipe height
+ */
+ public static void setCraftingSize(int width, int height) {
+ if (MAX_WIDTH < width) MAX_WIDTH = width;
+ if (MAX_HEIGHT < height) MAX_HEIGHT = height;
+ }
+
private final int recipeWidth;
private final int recipeHeight;
private final NonNullList<Ingredient> recipeItems;
@@ -48,7 +59,6 @@
return RecipeSerializers.field_199575_a;
}
- @OnlyIn(Dist.CLIENT)
public String getGroup() {
return this.group;
}
@@ -61,7 +71,6 @@
return this.recipeItems;
}
- @OnlyIn(Dist.CLIENT)
public boolean canFit(int width, int height) {
return width >= this.recipeWidth && height >= this.recipeHeight;
}
@@ -202,15 +211,15 @@
private static String[] patternFromJson(JsonArray jsonArr) {
String[] astring = new String[jsonArr.size()];
- if (astring.length > 3) {
- throw new JsonSyntaxException("Invalid pattern: too many rows, 3 is maximum");
+ if (astring.length > MAX_HEIGHT) {
+ throw new JsonSyntaxException("Invalid pattern: too many rows, " + MAX_HEIGHT + " is maximum");
} else if (astring.length == 0) {
throw new JsonSyntaxException("Invalid pattern: empty pattern not allowed");
} else {
for(int i = 0; i < astring.length; ++i) {
String s = JsonUtils.getString(jsonArr.get(i), "pattern[" + i + "]");
- if (s.length() > 3) {
- throw new JsonSyntaxException("Invalid pattern: too many columns, 3 is maximum");
+ if (s.length() > MAX_WIDTH) {
+ throw new JsonSyntaxException("Invalid pattern: too many columns, " + MAX_WIDTH + " is maximum");
}
if (i > 0 && astring[0].length() != s.length()) {

View file

@ -0,0 +1,77 @@
--- a/net/minecraft/item/crafting/ShapelessRecipe.java
+++ b/net/minecraft/item/crafting/ShapelessRecipe.java
@@ -12,20 +12,20 @@
import net.minecraft.util.NonNullList;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
-import net.minecraftforge.api.distmarker.Dist;
-import net.minecraftforge.api.distmarker.OnlyIn;
public class ShapelessRecipe implements IRecipe {
private final ResourceLocation field_199562_a;
private final String group;
private final ItemStack recipeOutput;
private final NonNullList<Ingredient> recipeItems;
+ private final boolean isSimple;
public ShapelessRecipe(ResourceLocation p_i48161_1_, String p_i48161_2_, ItemStack p_i48161_3_, NonNullList<Ingredient> p_i48161_4_) {
this.field_199562_a = p_i48161_1_;
this.group = p_i48161_2_;
this.recipeOutput = p_i48161_3_;
this.recipeItems = p_i48161_4_;
+ this.isSimple = p_i48161_4_.stream().allMatch(Ingredient::isSimple);
}
public ResourceLocation func_199560_c() {
@@ -36,7 +36,6 @@
return RecipeSerializers.field_199576_b;
}
- @OnlyIn(Dist.CLIENT)
public String getGroup() {
return this.group;
}
@@ -54,6 +53,7 @@
return false;
} else {
RecipeItemHelper recipeitemhelper = new RecipeItemHelper();
+ java.util.List<ItemStack> inputs = new java.util.ArrayList<>();
int i = 0;
for(int j = 0; j < inv.getHeight(); ++j) {
@@ -61,12 +61,15 @@
ItemStack itemstack = inv.getStackInSlot(k + j * inv.getWidth());
if (!itemstack.isEmpty()) {
++i;
+ if (isSimple)
recipeitemhelper.accountStack(new ItemStack(itemstack.getItem()));
+ else
+ inputs.add(itemstack);
}
}
}
- return i == this.recipeItems.size() && recipeitemhelper.canCraft(this, (IntList)null);
+ return i == this.recipeItems.size() && (isSimple ? recipeitemhelper.canCraft(this, (IntList)null) : net.minecraftforge.common.util.RecipeMatcher.findMatches(inputs, this.recipeItems) != null);
}
}
@@ -74,7 +77,6 @@
return this.recipeOutput.copy();
}
- @OnlyIn(Dist.CLIENT)
public boolean canFit(int width, int height) {
return width * height >= this.recipeItems.size();
}
@@ -85,8 +87,8 @@
NonNullList<Ingredient> nonnulllist = func_199568_a(JsonUtils.getJsonArray(p_199425_2_, "ingredients"));
if (nonnulllist.isEmpty()) {
throw new JsonParseException("No ingredients for shapeless recipe");
- } else if (nonnulllist.size() > 9) {
- throw new JsonParseException("Too many ingredients for shapeless recipe");
+ } else if (nonnulllist.size() > ShapedRecipe.MAX_WIDTH * ShapedRecipe.MAX_HEIGHT) {
+ throw new JsonParseException("Too many ingredients for shapeless recipe the max is " + (ShapedRecipe.MAX_WIDTH * ShapedRecipe.MAX_HEIGHT));
} else {
ItemStack itemstack = ShapedRecipe.func_199798_a(JsonUtils.getJsonObject(p_199425_2_, "result"));
return new ShapelessRecipe(p_199425_1_, s, itemstack, nonnulllist);

View file

@ -0,0 +1,19 @@
--- a/net/minecraft/item/crafting/ShieldRecipes.java
+++ b/net/minecraft/item/crafting/ShieldRecipes.java
@@ -8,8 +8,6 @@
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
-import net.minecraftforge.api.distmarker.Dist;
-import net.minecraftforge.api.distmarker.OnlyIn;
public class ShieldRecipes extends IRecipeHidden {
public ShieldRecipes(ResourceLocation p_i48160_1_) {
@@ -84,7 +82,6 @@
}
}
- @OnlyIn(Dist.CLIENT)
public boolean canFit(int width, int height) {
return width * height >= 2;
}

View file

@ -0,0 +1,55 @@
--- a/net/minecraft/item/crafting/ShulkerBoxColoringRecipe.java
+++ b/net/minecraft/item/crafting/ShulkerBoxColoringRecipe.java
@@ -10,8 +10,6 @@
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
-import net.minecraftforge.api.distmarker.Dist;
-import net.minecraftforge.api.distmarker.OnlyIn;
public class ShulkerBoxColoringRecipe extends IRecipeHidden {
public ShulkerBoxColoringRecipe(ResourceLocation p_i48159_1_) {
@@ -31,7 +29,7 @@
if (Block.getBlockFromItem(itemstack.getItem()) instanceof BlockShulkerBox) {
++i;
} else {
- if (!(itemstack.getItem() instanceof ItemDye)) {
+ if (!itemstack.getItem().func_206844_a(net.minecraft.tags.ItemTags.DYES)) {
return false;
}
@@ -50,7 +48,7 @@
public ItemStack getCraftingResult(IInventory inv) {
ItemStack itemstack = ItemStack.EMPTY;
- ItemDye itemdye = (ItemDye)Items.field_196106_bc;
+ net.minecraft.item.EnumDyeColor color = net.minecraft.item.EnumDyeColor.WHITE;
for(int i = 0; i < inv.getSizeInventory(); ++i) {
ItemStack itemstack1 = inv.getStackInSlot(i);
@@ -58,13 +56,14 @@
Item item = itemstack1.getItem();
if (Block.getBlockFromItem(item) instanceof BlockShulkerBox) {
itemstack = itemstack1;
- } else if (item instanceof ItemDye) {
- itemdye = (ItemDye)item;
+ } else {
+ net.minecraft.item.EnumDyeColor tmp = net.minecraft.item.EnumDyeColor.getColor(itemstack1);
+ if (tmp != null) color = tmp;
}
}
}
- ItemStack itemstack2 = BlockShulkerBox.getColoredItemStack(itemdye.func_195962_g());
+ ItemStack itemstack2 = BlockShulkerBox.getColoredItemStack(color);
if (itemstack.hasTagCompound()) {
itemstack2.setTagCompound(itemstack.getTagCompound().copy());
}
@@ -72,7 +71,6 @@
return itemstack2;
}
- @OnlyIn(Dist.CLIENT)
public boolean canFit(int width, int height) {
return width * height >= 2;
}

View file

@ -0,0 +1,27 @@
--- a/net/minecraft/tags/ItemTags.java
+++ b/net/minecraft/tags/ItemTags.java
@@ -41,6 +41,24 @@
public static final Tag<Item> field_212187_B = func_199901_a("trapdoors");
public static final Tag<Item> field_202902_o = func_199901_a("boats");
public static final Tag<Item> field_206964_G = func_199901_a("fishes");
+ public static final Tag<Item> DYES = func_199901_a("dyes");
+ public static final Tag<Item> DYES_BLACK = func_199901_a("dyes_black");
+ public static final Tag<Item> DYES_RED = func_199901_a("dyes_red");
+ public static final Tag<Item> DYES_GREEN = func_199901_a("dyes_green");
+ public static final Tag<Item> DYES_BROWN = func_199901_a("dyes_brown");
+ public static final Tag<Item> DYES_BLUE = func_199901_a("dyes_blue");
+ public static final Tag<Item> DYES_PURPLE = func_199901_a("dyes_purple");
+ public static final Tag<Item> DYES_CYAN = func_199901_a("dyes_cyan");
+ public static final Tag<Item> DYES_LIGHT_GRAY = func_199901_a("dyes_light_gray");
+ public static final Tag<Item> DYES_GRAY = func_199901_a("dyes_gray");
+ public static final Tag<Item> DYES_PINK = func_199901_a("dyes_pink");
+ public static final Tag<Item> DYES_LIME = func_199901_a("dyes_lime");
+ public static final Tag<Item> DYES_YELLOW = func_199901_a("dyes_yellow");
+ public static final Tag<Item> DYES_LIGHT_BLUE = func_199901_a("dyes_light_blue");
+ public static final Tag<Item> DYES_MAGENTA = func_199901_a("dyes_magenta");
+ public static final Tag<Item> DYES_ORANGE = func_199901_a("dyes_orange");
+ public static final Tag<Item> DYES_WHITE = func_199901_a("dyes_white");
+ public static final Tag<Item> MUSIC_DISCS = func_199901_a("music_discs");
public static void func_199902_a(TagCollection<Item> p_199902_0_) {
field_199906_c = p_199902_0_;

View file

@ -22,8 +22,7 @@ package net.minecraftforge.common;
import net.minecraft.block.state.IBlockState;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.common.util.EnumHelper;
import net.minecraft.world.IWorldReader;
public enum EnumPlantType
{
@ -38,22 +37,15 @@ public enum EnumPlantType
/**
* Getting a custom {@link EnumPlantType}, or an existing one if it has the same name as that one. Your plant should implement {@link IPlantable}
* and return this custom type in {@link IPlantable#getPlantType(IBlockAccess, BlockPos)}.
*
* <p>If your new plant grows on blocks like any one of them above, never create a new {@link EnumPlantType}.
* This enumeration is only functioning in
* {@link net.minecraft.block.Block#canSustainPlant(IBlockState, IBlockAccess, BlockPos, EnumFacing, IPlantable)},
*
* <p>If your new plant grows on blocks like any one of them above, never create a new {@link EnumPlantType}.
* This enumeration is only functioning in
* {@link net.minecraft.block.Block#canSustainPlant(IBlockState, IWorldReader, BlockPos, EnumFacing, IPlantable)},
* which you are supposed to override this function in your new block and create a new plant type to grow on that block.
*
*
* <p>You can create an instance of your plant type in your API and let your/others mods access it. It will be faster than calling this method.
* @param name the name of the type of plant, you had better follow the style above
* @return the acquired {@link EnumPlantType}, a new one if not found.
*/
public static EnumPlantType getPlantType(String name)
{
for (EnumPlantType t : values())
{
if (t.name().equalsIgnoreCase(name)) return t;
}
return EnumHelper.addEnum(EnumPlantType.class, name, new Class[0], new Object[0]);
}
public static EnumPlantType create(String name, int test, long bar, String foo){ return null; }
}

View file

@ -91,6 +91,8 @@ import net.minecraft.network.play.server.SPacketRecipeBook.State;
import net.minecraft.potion.PotionType;
import net.minecraft.potion.PotionUtils;
import net.minecraft.stats.StatList;
import net.minecraft.tags.ItemTags;
import net.minecraft.tags.Tag;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityNote;
import net.minecraft.util.DamageSource;
@ -870,9 +872,9 @@ public class ForgeHooks
public static EnumActionResult onPlaceItemIntoWorld(@Nonnull ItemUseContext context)
{
ItemStack itemstack = context.func_195996_i();
World world = context.func_195991_k();
ItemStack itemstack = context.func_195996_i();
World world = context.func_195991_k();
// handle all placement events here
int meta = itemstack.getItemDamage();
int size = itemstack.getCount();
@ -912,10 +914,10 @@ public class ForgeHooks
{
itemstack.setTagCompound(nbt);
}
EntityPlayer player = context.func_195999_j();
EnumFacing side = context.func_196000_l();
if (blockSnapshots.size() > 1)
{
placeEvent = ForgeEventFactory.onPlayerMultiBlockPlace(player, blockSnapshots, side, hand);
@ -997,23 +999,6 @@ public class ForgeHooks
return true;
}
/**
* Default implementation of IRecipe.func_179532_b {getRemainingItems} because
* this is just copy pasted over a lot of recipes.
*
* @param inv Crafting inventory
* @return Crafting inventory contents after the recipe.
*/
public static NonNullList<ItemStack> defaultRecipeGetRemainingItems(InventoryCrafting inv)
{
NonNullList<ItemStack> ret = NonNullList.withSize(inv.getSizeInventory(), ItemStack.EMPTY);
for (int i = 0; i < ret.size(); i++)
{
ret.set(i, getContainerItem(inv.getStackInSlot(i)));
}
return ret;
}
private static ThreadLocal<EntityPlayer> craftingPlayer = new ThreadLocal<EntityPlayer>();
public static void setCraftingPlayer(EntityPlayer player)
{
@ -1209,7 +1194,7 @@ public class ForgeHooks
{
this.name = name;
this.custom = custom;
this.vanilla = "minecraft".equals(this.name.getResourceDomain());
this.vanilla = "minecraft".equals(this.name.getNamespace());
}
private void resetPoolCtx()
@ -1422,7 +1407,7 @@ public class ForgeHooks
{
Item item = itemStack.getItem();
ResourceLocation registryName = item.getRegistryName();
String modId = registryName == null ? null : registryName.getResourceDomain();
String modId = registryName == null ? null : registryName.getNamespace();
if ("minecraft".equals(modId))
{
if (item instanceof ItemEnchantedBook)
@ -1437,7 +1422,7 @@ public class ForgeHooks
ResourceLocation resourceLocation = ForgeRegistries.ENCHANTMENTS.getKey(enchantment);
if (resourceLocation != null)
{
return resourceLocation.getResourceDomain();
return resourceLocation.getNamespace();
}
}
}
@ -1448,7 +1433,7 @@ public class ForgeHooks
ResourceLocation resourceLocation = ForgeRegistries.POTION_TYPES.getKey(potionType);
if (resourceLocation != null)
{
return resourceLocation.getResourceDomain();
return resourceLocation.getNamespace();
}
}
else if (item instanceof ItemMonsterPlacer)
@ -1456,7 +1441,7 @@ public class ForgeHooks
ResourceLocation resourceLocation = ItemMonsterPlacer.getNamedIdFrom(itemStack);
if (resourceLocation != null)
{
return resourceLocation.getResourceDomain();
return resourceLocation.getNamespace();
}
}
}
@ -1474,5 +1459,4 @@ public class ForgeHooks
}
return false;
}
}

View file

@ -23,6 +23,7 @@ import java.nio.file.Path;
import net.minecraftforge.fml.AdvancedLogMessageAdapter;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.objectweb.asm.Label;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.Type;
import org.objectweb.asm.commons.InstructionAdapter;
@ -40,10 +41,13 @@ public class RuntimeEnumExtender implements ILaunchPluginService {
private static final Logger LOGGER = LogManager.getLogger();
private final Type STRING = Type.getType(String.class);
private final Type ENUM = Type.getType(Enum.class);
private final Type ARRAY_UTILS = Type.getType("Lorg/apache/commons/lang3/ArrayUtils;"); //Don't directly reference this to prevent class loading.
private final String ADD_DESC = Type.getMethodDescriptor(Type.getType(Object[].class), Type.getType(Object[].class), Type.getType(Object.class));
private final Type ENUM_HELPER = Type.getType("Lnet/minecraftforge/common/util/EnumHelper;"); //Again, not direct reference to prevent class loading.
private final String CLEAN_DESC = Type.getMethodDescriptor(Type.VOID_TYPE, Type.getType(Class.class));
private final String NAME_DESC = Type.getMethodDescriptor(STRING);
private final String EQUALS_DESC = Type.getMethodDescriptor(Type.BOOLEAN_TYPE, STRING);
@Override
public String name() {
@ -110,30 +114,76 @@ public class RuntimeEnumExtender implements ILaunchPluginService {
mtd.instructions.clear();
InstructionAdapter ins = new InstructionAdapter(mtd);
//ret = new ThisType(name, VALUES.length + 1, args..)
ins.anew(classType);
ins.dup();
ins.load(0, STRING);
ins.getstatic(classType.getInternalName(), values.name, values.desc);
ins.arraylength();
ins.iconst(1);
ins.add(Type.INT_TYPE);
for (int x = 1; x < args.length; x++)
ins.load(x, args[x]);
ins.invokespecial(classType.getInternalName(), "<init>", desc, false);
ins.store(1, classType);
// VALUES = ArrayUtils.add(VALUES, ret)
ins.getstatic(classType.getInternalName(), values.name, values.desc);
ins.load(1, classType);
ins.invokestatic(ARRAY_UTILS.getInternalName(), "add", ADD_DESC, false);
ins.checkcast(Type.getType(values.desc));
ins.putstatic(classType.getInternalName(), values.name, values.desc);
//EnumHelper.cleanEnumCache(ThisType.class)
ins.visitLdcInsn(classType);
ins.invokestatic(ENUM_HELPER.getInternalName(), "cleanEnumCache", CLEAN_DESC, false);
//return ret
ins.load(1, classType);
ins.areturn(classType);
int vars = 0;
for (Type arg : args)
vars += arg.getSize();
{
vars += 1; //int x
Label for_start = new Label();
Label for_condition = new Label();
Label for_inc = new Label();
ins.iconst(0);
ins.store(vars, Type.INT_TYPE);
ins.goTo(for_condition);
//if (!VALUES[x].name().equalsIgnoreCase(name)) goto for_inc
ins.mark(for_start);
ins.getstatic(classType.getInternalName(), values.name, values.desc);
ins.load(vars, Type.INT_TYPE);
ins.aload(array);
ins.invokevirtual(ENUM.getInternalName(), "name", NAME_DESC, false);
ins.load(0, STRING);
ins.invokevirtual(STRING.getInternalName(), "equalsIgnoreCase", EQUALS_DESC, false);
ins.ifeq(for_inc);
//return VALUES[x];
ins.getstatic(classType.getInternalName(), values.name, values.desc);
ins.load(vars, Type.INT_TYPE);
ins.aload(array);
ins.areturn(classType);
//x++
ins.mark(for_inc);
ins.iinc(vars, 1);
//if (x < VALUES.length) goto for_start
ins.mark(for_condition);
ins.load(vars, Type.INT_TYPE);
ins.getstatic(classType.getInternalName(), values.name, values.desc);
ins.arraylength();
ins.ificmplt(for_start);
}
{
vars += 1; //enum ret;
//ret = new ThisType(name, VALUES.length + 1, args..)
ins.anew(classType);
ins.dup();
ins.load(0, STRING);
ins.getstatic(classType.getInternalName(), values.name, values.desc);
ins.arraylength();
ins.iconst(1);
ins.add(Type.INT_TYPE);
int idx = 1;
for (int x = 1; x < args.length; x++)
{
ins.load(idx, args[x]);
idx += args[x].getSize();
}
ins.invokespecial(classType.getInternalName(), "<init>", desc, false);
ins.store(vars, classType);
// VALUES = ArrayUtils.add(VALUES, ret)
ins.getstatic(classType.getInternalName(), values.name, values.desc);
ins.load(vars, classType);
ins.invokestatic(ARRAY_UTILS.getInternalName(), "add", ADD_DESC, false);
ins.checkcast(array);
ins.putstatic(classType.getInternalName(), values.name, values.desc);
//EnumHelper.cleanEnumCache(ThisType.class)
ins.visitLdcInsn(classType);
ins.invokestatic(ENUM_HELPER.getInternalName(), "cleanEnumCache", CLEAN_DESC, false);
//return ret
ins.load(vars, classType);
ins.areturn(classType);
}
});
return classNode;
}

View file

@ -23,8 +23,7 @@ import java.util.BitSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Queue;
import com.google.common.base.Predicate;
import java.util.function.Predicate;
public class RecipeMatcher
{
@ -61,7 +60,7 @@ public class RecipeMatcher
if (data.get(y))
continue;
if (test.apply(inputs.get(y)))
if (test.test(inputs.get(y)))
{
data.set(offset + y);
matched++;

View file

@ -1,126 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2018.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package net.minecraftforge.oredict;
import net.minecraft.item.EnumDyeColor;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import org.apache.commons.lang3.ArrayUtils;
import java.util.Arrays;
import java.util.Optional;
import java.util.OptionalInt;
/**
* Utility class for working with ore dictionary dyes.
*/
public class DyeUtils
{
/*
private static final String[] dyeOredicts = new String[]
{
"dyeWhite",
"dyeOrange",
"dyeMagenta",
"dyeLightBlue",
"dyeYellow",
"dyeLime",
"dyePink",
"dyeGray",
"dyeLightGray",
"dyeCyan",
"dyePurple",
"dyeBlue",
"dyeBrown",
"dyeGreen",
"dyeRed",
"dyeBlack"
};
/**
* Check if an item stack is a dye.
* @param stack the item stack
* @return whether the stack is a dye
* /
public static boolean isDye(ItemStack stack)
{
return metaFromStack(stack).isPresent();
}
/**
* Get the dye metadata from the stack, which can be passed into {@link EnumDyeColor#byMetadata(int)}.
* @param stack the item stack
* @return an {@link OptionalInt} holding the dye metadata for a dye, or an empty {@link OptionalInt} otherwise
* /
public static OptionalInt metaFromStack(ItemStack stack)
{
if (stack.isEmpty()) return OptionalInt.empty();
return Arrays.stream(OreDictionary.getOreIDs(stack))
.mapToObj(OreDictionary::getOreName)
.mapToInt(name -> ArrayUtils.indexOf(dyeOredicts, name))
.filter(id -> id >= 0)
.findFirst();
}
/**
* Similar to {@link #metaFromStack(ItemStack)}, except that it returns the raw integer (with a {@code -1} sentinel);
* this follows vanilla conventions.
* @param stack the item stack
* @return the dye metadata for a dye, or {@code -1} otherwise
* /
public static int rawMetaFromStack(ItemStack stack)
{
return metaFromStack(stack).orElse(-1);
}
/**
* Get the dye damage from the stack, which can be passed into {@link EnumDyeColor#byDyeDamage(int)}.
* @param stack the item stack
* @return an {@link OptionalInt} holding the dye damage for a dye, or an empty {@link OptionalInt} otherwise
* /
public static OptionalInt dyeDamageFromStack(ItemStack stack)
{
final OptionalInt meta = metaFromStack(stack);
return meta.isPresent() ? OptionalInt.of(0xF - meta.getAsInt()) : OptionalInt.empty();
}
/**
* Similar to {@link #dyeDamageFromStack(ItemStack)}, except that it returns the raw integer (with a {@code -1} sentinel);
* this follows vanilla conventions.
* @param stack the item stack
* @return the dye damage for a dye, or {@code -1} otherwise
* /
public static int rawDyeDamageFromStack(ItemStack stack)
{
return dyeDamageFromStack(stack).orElse(-1);
}
/**
* Get a dye's color.
* @param stack the item stack
* @return an {@link Optional} holding the dye color if present, or an empty {@link Optional} otherwise
* /
public static Optional<EnumDyeColor> colorFromStack(ItemStack stack)
{
final OptionalInt meta = metaFromStack(stack);
return meta.isPresent() ? Optional.of(EnumDyeColor.byMetadata(meta.getAsInt())) : Optional.empty();
}
*/
}

View file

@ -174,20 +174,6 @@ public class OreDictionary
registerOre("feather", Items.FEATHER);
registerOre("egg", Items.EGG);
// records
registerOre("record", Items.RECORD_13);
registerOre("record", Items.RECORD_CAT);
registerOre("record", Items.RECORD_BLOCKS);
registerOre("record", Items.RECORD_CHIRP);
registerOre("record", Items.RECORD_FAR);
registerOre("record", Items.RECORD_MALL);
registerOre("record", Items.RECORD_MELLOHI);
registerOre("record", Items.RECORD_STAL);
registerOre("record", Items.RECORD_STRAD);
registerOre("record", Items.RECORD_WARD);
registerOre("record", Items.RECORD_11);
registerOre("record", Items.RECORD_WAIT);
// blocks
registerOre("dirt", Blocks.DIRT);
registerOre("grass", Blocks.GRASS);

View file

@ -1,126 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2018.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package net.minecraftforge.oredict;
/*
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import it.unimi.dsi.fastutil.ints.IntArrayList;
import it.unimi.dsi.fastutil.ints.IntComparators;
import it.unimi.dsi.fastutil.ints.IntList;
import net.minecraft.client.util.RecipeItemHelper;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.util.NonNullList;
*/
public class OreIngredient //extends Ingredient
{
/*
private NonNullList<ItemStack> ores;
private IntList itemIds = null;
private ItemStack[] array = null;
private int lastSizeA = -1, lastSizeL = -1;
public OreIngredient(String ore)
{
super(0);
ores = OreDictionary.getOres(ore);
}
@Override
@Nonnull
public ItemStack[] getMatchingStacks()
{
if (array == null || this.lastSizeA != ores.size())
{
NonNullList<ItemStack> lst = NonNullList.create();
for (ItemStack itemstack : this.ores)
{
if (itemstack.getMetadata() == OreDictionary.WILDCARD_VALUE)
itemstack.getItem().getSubItems(CreativeTabs.SEARCH, lst);
else
lst.add(itemstack);
}
this.array = lst.toArray(new ItemStack[lst.size()]);
this.lastSizeA = ores.size();
}
return this.array;
}
@Override
@Nonnull
public IntList getValidItemStacksPacked()
{
if (this.itemIds == null || this.lastSizeL != ores.size())
{
this.itemIds = new IntArrayList(this.ores.size());
for (ItemStack itemstack : this.ores)
{
if (itemstack.getMetadata() == OreDictionary.WILDCARD_VALUE)
{
NonNullList<ItemStack> lst = NonNullList.create();
itemstack.getItem().getSubItems(CreativeTabs.SEARCH, lst);
for (ItemStack item : lst)
this.itemIds.add(RecipeItemHelper.pack(item));
}
else
{
this.itemIds.add(RecipeItemHelper.pack(itemstack));
}
}
this.itemIds.sort(IntComparators.NATURAL_COMPARATOR);
this.lastSizeL = ores.size();
}
return this.itemIds;
}
@Override
public boolean apply(@Nullable ItemStack input)
{
if (input == null)
return false;
for (ItemStack target : this.ores)
if (OreDictionary.itemMatches(target, input, false))
return true;
return false;
}
@Override
protected void invalidate()
{
this.itemIds = null;
this.array = null;
}
@Override
public boolean isSimple()
{
return true;
}
*/
}

View file

@ -1,259 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2018.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package net.minecraftforge.oredict;
import net.minecraft.block.Block;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.JsonUtils;
import net.minecraft.util.NonNullList;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeHooks;
import net.minecraftforge.common.crafting.CraftingHelper;
import net.minecraftforge.common.crafting.CraftingHelper.ShapedPrimer;
import net.minecraftforge.common.crafting.IShapedRecipe;
import net.minecraftforge.registries.IForgeRegistryEntry;
import net.minecraftforge.common.crafting.JsonContext;
import java.util.Map;
import java.util.Set;
import java.util.Map.Entry;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonSyntaxException;
public class ShapedOreRecipe //extends IForgeRegistryEntry.Impl<IRecipe> implements IShapedRecipe
{
/*
@Deprecated
public static final int MAX_CRAFT_GRID_WIDTH = 3;
@Deprecated
public static final int MAX_CRAFT_GRID_HEIGHT = 3;
@Nonnull
protected ItemStack output = ItemStack.EMPTY;
protected NonNullList<Ingredient> input = null;
protected int width = 0;
protected int height = 0;
protected boolean mirrored = true;
protected ResourceLocation group;
public ShapedOreRecipe(ResourceLocation group, Block result, Object... recipe){ this(group, new ItemStack(result), recipe); }
public ShapedOreRecipe(ResourceLocation group, Item result, Object... recipe){ this(group, new ItemStack(result), recipe); }
public ShapedOreRecipe(ResourceLocation group, @Nonnull ItemStack result, Object... recipe) { this(group, result, CraftingHelper.parseShaped(recipe)); }
public ShapedOreRecipe(ResourceLocation group, @Nonnull ItemStack result, ShapedPrimer primer)
{
this.group = group;
output = result.copy();
this.width = primer.width;
this.height = primer.height;
this.input = primer.input;
this.mirrored = primer.mirrored;
}
@Override
@Nonnull
public ItemStack getCraftingResult(@Nonnull InventoryCrafting var1){ return output.copy(); }
@Override
@Nonnull
public ItemStack getRecipeOutput(){ return output; }
@Override
public boolean matches(@Nonnull InventoryCrafting inv, @Nonnull World world)
{
for (int x = 0; x <= inv.getWidth() - width; x++)
{
for (int y = 0; y <= inv.getHeight() - height; ++y)
{
if (checkMatch(inv, x, y, false))
{
return true;
}
if (mirrored && checkMatch(inv, x, y, true))
{
return true;
}
}
}
return false;
}
/**
* Based on {@link net.minecraft.item.crafting.ShapedRecipes#checkMatch(InventoryCrafting, int, int, boolean)}
* /
protected boolean checkMatch(InventoryCrafting inv, int startX, int startY, boolean mirror)
{
for (int x = 0; x < inv.getWidth(); x++)
{
for (int y = 0; y < inv.getHeight(); y++)
{
int subX = x - startX;
int subY = y - startY;
Ingredient target = Ingredient.EMPTY;
if (subX >= 0 && subY >= 0 && subX < width && subY < height)
{
if (mirror)
{
target = input.get(width - subX - 1 + subY * width);
}
else
{
target = input.get(subX + subY * width);
}
}
if (!target.apply(inv.getStackInRowAndColumn(x, y)))
{
return false;
}
}
}
return true;
}
public ShapedOreRecipe setMirrored(boolean mirror)
{
mirrored = mirror;
return this;
}
@Override
@Nonnull
public NonNullList<Ingredient> getIngredients()
{
return this.input;
}
@Deprecated //Use IShapedRecipe.getRecipeWidth
public int getWidth()
{
return width;
}
@Override
public int getRecipeWidth()
{
return this.getWidth();
}
@Deprecated //Use IShapedRecipe.getRecipeHeight
public int getHeight()
{
return height;
}
@Override
public int getRecipeHeight()
{
return this.getHeight();
}
@Override
@Nonnull
public String getGroup()
{
return this.group == null ? "" : this.group.toString();
}
@Override
public boolean canFit(int p_194133_1_, int p_194133_2_)
{
return p_194133_1_ >= this.width && p_194133_2_ >= this.height;
}
public static ShapedOreRecipe factory(JsonContext context, JsonObject json)
{
String group = JsonUtils.getString(json, "group", "");
//if (!group.isEmpty() && group.indexOf(':') == -1)
// group = context.getModId() + ":" + group;
Map<Character, Ingredient> ingMap = Maps.newHashMap();
for (Entry<String, JsonElement> entry : JsonUtils.getJsonObject(json, "key").entrySet())
{
if (entry.getKey().length() != 1)
throw new JsonSyntaxException("Invalid key entry: '" + entry.getKey() + "' is an invalid symbol (must be 1 character only).");
if (" ".equals(entry.getKey()))
throw new JsonSyntaxException("Invalid key entry: ' ' is a reserved symbol.");
ingMap.put(entry.getKey().toCharArray()[0], CraftingHelper.getIngredient(entry.getValue(), context));
}
ingMap.put(' ', Ingredient.EMPTY);
JsonArray patternJ = JsonUtils.getJsonArray(json, "pattern");
if (patternJ.size() == 0)
throw new JsonSyntaxException("Invalid pattern: empty pattern not allowed");
String[] pattern = new String[patternJ.size()];
for (int x = 0; x < pattern.length; ++x)
{
String line = JsonUtils.getString(patternJ.get(x), "pattern[" + x + "]");
if (x > 0 && pattern[0].length() != line.length())
throw new JsonSyntaxException("Invalid pattern: each row must be the same width");
pattern[x] = line;
}
ShapedPrimer primer = new ShapedPrimer();
primer.width = pattern[0].length();
primer.height = pattern.length;
primer.mirrored = JsonUtils.getBoolean(json, "mirrored", true);
primer.input = NonNullList.withSize(primer.width * primer.height, Ingredient.EMPTY);
Set<Character> keys = Sets.newHashSet(ingMap.keySet());
keys.remove(' ');
int x = 0;
for (String line : pattern)
{
for (char chr : line.toCharArray())
{
Ingredient ing = ingMap.get(chr);
if (ing == null)
throw new JsonSyntaxException("Pattern references symbol '" + chr + "' but it's not defined in the key");
primer.input.set(x++, ing);
keys.remove(chr);
}
}
if (!keys.isEmpty())
throw new JsonSyntaxException("Key defines symbols that aren't used in pattern: " + keys);
ItemStack result = CraftingHelper.getItemStack(JsonUtils.getJsonObject(json, "result"), context);
return new ShapedOreRecipe(group.isEmpty() ? null : new ResourceLocation(group), result, primer);
}
*/
}

View file

@ -1,161 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2018.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package net.minecraftforge.oredict;
/*
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.client.util.RecipeItemHelper;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.JsonUtils;
import net.minecraft.util.NonNullList;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import net.minecraftforge.common.crafting.CraftingHelper;
import net.minecraftforge.common.crafting.JsonContext;
import net.minecraftforge.common.util.RecipeMatcher;
import net.minecraftforge.registries.IForgeRegistryEntry;
import javax.annotation.Nonnull;
import com.google.common.collect.Lists;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
*/
public class ShapelessOreRecipe {} /*extends IForgeRegistryEntry.Impl<IRecipe> implements IRecipe
{
@Nonnull
protected ItemStack output = ItemStack.EMPTY;
protected NonNullList<Ingredient> input = NonNullList.create();
protected ResourceLocation group;
protected boolean isSimple = true;
public ShapelessOreRecipe(ResourceLocation group, Block result, Object... recipe){ this(group, new ItemStack(result), recipe); }
public ShapelessOreRecipe(ResourceLocation group, Item result, Object... recipe){ this(group, new ItemStack(result), recipe); }
public ShapelessOreRecipe(ResourceLocation group, NonNullList<Ingredient> input, @Nonnull ItemStack result)
{
this.group = group;
output = result.copy();
this.input = input;
for (Ingredient i : input)
this.isSimple &= i.isSimple();
}
public ShapelessOreRecipe(ResourceLocation group, @Nonnull ItemStack result, Object... recipe)
{
this.group = group;
output = result.copy();
for (Object in : recipe)
{
Ingredient ing = CraftingHelper.getIngredient(in);
if (ing != null)
{
input.add(ing);
this.isSimple &= ing.isSimple();
}
else
{
String ret = "Invalid shapeless ore recipe: ";
for (Object tmp : recipe)
{
ret += tmp + ", ";
}
ret += output;
throw new RuntimeException(ret);
}
}
}
@Override
@Nonnull
public ItemStack getRecipeOutput(){ return output; }
@Override
@Nonnull
public ItemStack getCraftingResult(@Nonnull InventoryCrafting var1){ return output.copy(); }
@Override
public boolean matches(@Nonnull InventoryCrafting inv, @Nonnull World world)
{
int ingredientCount = 0;
RecipeItemHelper recipeItemHelper = new RecipeItemHelper();
List<ItemStack> items = Lists.newArrayList();
for (int i = 0; i < inv.getSizeInventory(); ++i)
{
ItemStack itemstack = inv.getStackInSlot(i);
if (!itemstack.isEmpty())
{
++ingredientCount;
if (this.isSimple)
recipeItemHelper.accountStack(itemstack, 1);
else
items.add(itemstack);
}
}
if (ingredientCount != this.input.size())
return false;
if (this.isSimple)
return recipeItemHelper.canCraft(this, null);
return RecipeMatcher.findMatches(items, this.input) != null;
}
@Override
@Nonnull
public NonNullList<Ingredient> getIngredients()
{
return this.input;
}
@Override
@Nonnull
public String getGroup()
{
return this.group == null ? "" : this.group.toString();
}
@Override
public boolean canFit(int p_194133_1_, int p_194133_2_)
{
return p_194133_1_ * p_194133_2_ >= this.input.size();
}
public static ShapelessOreRecipe factory(JsonContext context, JsonObject json)
{
String group = JsonUtils.getString(json, "group", "");
NonNullList<Ingredient> ings = NonNullList.create();
for (JsonElement ele : JsonUtils.getJsonArray(json, "ingredients"))
ings.add(CraftingHelper.getIngredient(ele, context));
if (ings.isEmpty())
throw new JsonParseException("No ingredients for shapeless recipe");
ItemStack itemstack = CraftingHelper.getItemStack(JsonUtils.getJsonObject(json, "result"), context);
return new ShapelessOreRecipe(group.isEmpty() ? null : new ResourceLocation(group), ings, itemstack);
}
}
*/

View file

@ -54,8 +54,6 @@ public class ForgeRegistries
public static final IForgeRegistry<VillagerProfession> VILLAGER_PROFESSIONS = RegistryManager.ACTIVE.getRegistry(VillagerProfession.class);
public static final IForgeRegistry<EntityType<?>> ENTITIES = RegistryManager.ACTIVE.getRegistry(EntityType.class);
public static final IForgeRegistry<TileEntityType<?>> TILE_ENTITIES = RegistryManager.ACTIVE.getRegistry(TileEntityType.class);
public static final IForgeRegistry<IRecipe> RECIPES = RegistryManager.ACTIVE.getRegistry(IRecipe.class);
/**
* This function is just to make sure static inializers in other classes have run and setup their registries before we query them.
*/

View file

@ -89,7 +89,6 @@ public class GameData
public static final ResourceLocation ENCHANTMENTS = new ResourceLocation("minecraft:enchantments");
public static final ResourceLocation ENTITIES = new ResourceLocation("minecraft:entities");
public static final ResourceLocation TILEENTITIES = new ResourceLocation("minecraft:tileentities");
public static final ResourceLocation RECIPES = new ResourceLocation("minecraft:recipes");
public static final ResourceLocation PROFESSIONS = new ResourceLocation("minecraft:villagerprofessions");
private static final int MAX_BLOCK_ID = 4095;
private static final int MIN_ITEM_ID = MAX_BLOCK_ID + 1;
@ -101,7 +100,6 @@ public class GameData
private static final int MAX_ENCHANTMENT_ID = Short.MAX_VALUE - 1; // Short - serialized as a short in ItemStack NBTs.
private static final int MAX_ENTITY_ID = Integer.MAX_VALUE >> 5; // Varint (SPacketSpawnMob)
private static final int MAX_TILE_ENTITY_ID = Integer.MAX_VALUE; //Doesnt seem to be serialized anywhere, so no max.
private static final int MAX_RECIPE_ID = Integer.MAX_VALUE >> 5; // Varint CPacketRecipeInfo/SPacketRecipeBook
private static final int MAX_PROFESSION_ID = 1024; //TODO: Is this serialized anywhere anymore?
private static final ResourceLocation BLOCK_TO_ITEM = new ResourceLocation("minecraft:blocktoitemmap");
@ -132,7 +130,6 @@ public class GameData
makeRegistry(SOUNDEVENTS, SoundEvent.class, MAX_SOUND_ID).create();
makeRegistry(POTIONTYPES, PotionType.class, MAX_POTIONTYPE_ID, new ResourceLocation("empty")).create();
makeRegistry(ENCHANTMENTS, Enchantment.class, MAX_ENCHANTMENT_ID).create();
// makeRegistry(RECIPES, IRecipe.class, MAX_RECIPE_ID).disableSaving().allowModification().addCallback(RecipeCallbacks.INSTANCE).create();
makeRegistry(PROFESSIONS, VillagerProfession.class, MAX_PROFESSION_ID).create();
// TODO do we need the callback and the static field anymore?
makeRegistry(ENTITIES, EntityType.class, MAX_ENTITY_ID).create();

View file

@ -0,0 +1,21 @@
{
"replace": false,
"values": [
"minecraft:ink_sack",
"minecraft:rose_red",
"minecraft:cactus_green",
"minecraft:cocoa_beans",
"minecraft:lapis_lazuli",
"minecraft:purple_dye",
"minecraft:cyan_dye",
"minecraft:light_gray_dye",
"minecraft:gray_dye",
"minecraft:pink_dye",
"minecraft:lime_dye",
"minecraft:dandelion_yellow",
"minecraft:light_blue_dye",
"minecraft:magenta_dye",
"minecraft:orange_dye",
"minecraft:bone_meal"
]
}

View file

@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"minecraft:ink_sack"
]
}

View file

@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"minecraft:lapis_lazuli"
]
}

View file

@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"minecraft:cocoa_beans"
]
}

View file

@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"minecraft:cyan_dye"
]
}

View file

@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"minecraft:gray_dye"
]
}

View file

@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"minecraft:cactus_green"
]
}

View file

@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"minecraft:light_blue_dye"
]
}

View file

@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"minecraft:light_gray_dye"
]
}

View file

@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"minecraft:lime_dye"
]
}

View file

@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"minecraft:magenta_dye"
]
}

View file

@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"minecraft:orange_dye"
]
}

View file

@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"minecraft:pink_dye"
]
}

View file

@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"minecraft:purple_dye"
]
}

View file

@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"minecraft:rose_red"
]
}

View file

@ -0,0 +1,21 @@
{
"replace": false,
"values": [
"minecraft:ink_sack",
"minecraft:rose_red",
"minecraft:cactus_green",
"minecraft:cocoa_beans",
"minecraft:lapis_lazuli",
"minecraft:purple_dye",
"minecraft:cyan_dye",
"minecraft:light_gray_dye",
"minecraft:gray_dye",
"minecraft:pink_dye",
"minecraft:lime_dye",
"minecraft:dandelion_yellow",
"minecraft:light_blue_dye",
"minecraft:magenta_dye",
"minecraft:orange_dye",
"minecraft:bone_meal"
]
}

View file

@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"minecraft:dandelion_yellow"
]
}

View file

@ -0,0 +1,17 @@
{
"replace": false,
"values": [
"minecraft:music_disc_13",
"minecraft:music_disc_cat",
"minecraft:music_disc_blocks",
"minecraft:music_disc_chirp",
"minecraft:music_disc_far",
"minecraft:music_disc_mall",
"minecraft:music_disc_mellohi",
"minecraft:music_disc_stal",
"minecraft:music_disc_strad",
"minecraft:music_disc_ward",
"minecraft:music_disc_11",
"minecraft:music_disc_wait"
]
}