Integrated recipes
This commit is contained in:
parent
f4239f1838
commit
a55a7ac473
3 changed files with 289 additions and 264 deletions
|
@ -771,7 +771,7 @@ public class WarpDrive {
|
|||
final static public ArrayList<Potion> potions = new ArrayList<>(10);
|
||||
final static public ArrayList<PotionType> potionTypes = new ArrayList<>(10);
|
||||
final static public ArrayList<SoundEvent> soundEvents = new ArrayList<>(100);
|
||||
final static public ArrayList<IRecipe> recipes = new ArrayList<>(100);
|
||||
final static public HashMap<ResourceLocation, IRecipe> recipes = new HashMap<>(100);
|
||||
final static public ArrayList<VillagerProfession> villagerProfessions = new ArrayList<>(10);
|
||||
|
||||
// Register a Biome.
|
||||
|
@ -793,7 +793,8 @@ public class WarpDrive {
|
|||
public static <BLOCK extends Block> BLOCK register(final BLOCK block, @Nullable final ItemBlock itemBlock) {
|
||||
final ResourceLocation resourceLocation = block.getRegistryName();
|
||||
if (resourceLocation == null) {
|
||||
WarpDrive.logger.error(String.format("Missing registry name for block %s, ignoring registration...", block));
|
||||
WarpDrive.logger.error(String.format("Missing registry name for block %s, ignoring registration...",
|
||||
block));
|
||||
return block;
|
||||
}
|
||||
|
||||
|
@ -833,6 +834,9 @@ public class WarpDrive {
|
|||
|
||||
// Register a recipe.
|
||||
public static <RECIPE extends IRecipe> RECIPE register(final RECIPE recipe) {
|
||||
return register(recipe, "");
|
||||
}
|
||||
public static <RECIPE extends IRecipe> RECIPE register(final RECIPE recipe, final String suffix) {
|
||||
ResourceLocation registryName = recipe.getRegistryName();
|
||||
if (registryName == null) {
|
||||
final String path;
|
||||
|
@ -840,20 +844,33 @@ public class WarpDrive {
|
|||
if (itemStackOutput.isEmpty()) {
|
||||
path = recipe.toString();
|
||||
} else if (itemStackOutput.getCount() == 1) {
|
||||
path = String.format("%s@%d",
|
||||
itemStackOutput.getItem().getUnlocalizedName(),
|
||||
itemStackOutput.getItemDamage() );
|
||||
} else {
|
||||
path = String.format("%s@%dx%d",
|
||||
itemStackOutput.getItem().getUnlocalizedName(),
|
||||
path = String.format("%s@%d%s",
|
||||
itemStackOutput.getItem().getRegistryName(),
|
||||
itemStackOutput.getItemDamage(),
|
||||
itemStackOutput.getCount() );
|
||||
suffix );
|
||||
} else {
|
||||
path = String.format("%s@%dx%d%s",
|
||||
itemStackOutput.getItem().getRegistryName(),
|
||||
itemStackOutput.getItemDamage(),
|
||||
itemStackOutput.getCount(),
|
||||
suffix );
|
||||
}
|
||||
registryName = new ResourceLocation(MODID, path);
|
||||
if (recipes.containsKey(registryName)) {
|
||||
logger.error(String.format("Overlapping recipe detected, please report this to the mod author %s",
|
||||
registryName));
|
||||
registryName = new ResourceLocation(MODID, path + "!" + System.nanoTime());
|
||||
try {
|
||||
Thread.sleep(10000);
|
||||
} catch (final Exception exception) {
|
||||
// ignored
|
||||
}
|
||||
assert false;
|
||||
}
|
||||
recipe.setRegistryName(registryName);
|
||||
}
|
||||
|
||||
recipes.add(recipe);
|
||||
recipes.put(registryName, recipe);
|
||||
return recipe;
|
||||
}
|
||||
|
||||
|
@ -998,7 +1015,7 @@ public class WarpDrive {
|
|||
|
||||
Recipes.initDynamic();
|
||||
|
||||
for (final IRecipe recipe : recipes) {
|
||||
for (final IRecipe recipe : recipes.values()) {
|
||||
event.getRegistry().register(recipe);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ import java.util.List;
|
|||
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.EnumDyeColor;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
@ -29,7 +30,7 @@ public class RecipeTuningDriver implements IRecipe {
|
|||
private final int size;
|
||||
private ResourceLocation group;
|
||||
|
||||
public RecipeTuningDriver(@Nonnull final ResourceLocation group, final ItemStack itemStackTool, final ItemStack itemStackConsumable, final int countDyes) {
|
||||
public RecipeTuningDriver(@Nonnull final ResourceLocation group, final ItemStack itemStackTool, final ItemStack itemStackConsumable, final int countDyes, final String suffix) {
|
||||
this.group = group;
|
||||
this.itemStackTool = itemStackTool.copy();
|
||||
this.itemStackConsumable = itemStackConsumable.copy();
|
||||
|
@ -43,7 +44,7 @@ public class RecipeTuningDriver implements IRecipe {
|
|||
for (int index = 0; index < countDyes; index++) {
|
||||
recipe[2 + index] = "dye";
|
||||
}
|
||||
WarpDrive.register(new ShapelessOreRecipe(group, itemStackTool, recipe));
|
||||
WarpDrive.register(new ShapelessOreRecipe(group, itemStackTool, recipe), suffix);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -117,14 +118,14 @@ public class RecipeTuningDriver implements IRecipe {
|
|||
} else {
|
||||
// find a matching dye from ore dictionary
|
||||
boolean matched = false;
|
||||
for (int indexDye = 0; indexDye < Recipes.oreDyes.length; indexDye++) {
|
||||
final List<ItemStack> itemStackDyes = OreDictionary.getOres(Recipes.oreDyes[indexDye]);
|
||||
for (final EnumDyeColor enumDyeColor : EnumDyeColor.values()) {
|
||||
final List<ItemStack> itemStackDyes = OreDictionary.getOres("dye" + enumDyeColor.getUnlocalizedName());
|
||||
for (final ItemStack itemStackDye : itemStackDyes) {
|
||||
if (OreDictionary.itemMatches(itemStackSlot, itemStackDye, true)) {
|
||||
// match found, update dye combination
|
||||
matched = true;
|
||||
countDyesFound++;
|
||||
dye = dye * 16 + indexDye;
|
||||
dye = dye * 16 + enumDyeColor.getDyeDamage();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue