use of net.minecraft.item.crafting.IRecipe in project BetterWithAddons by DaedalusGame.
the class BetterWithAddons method removeCraftingRecipe.
public static void removeCraftingRecipe(ItemStack withoutput) {
List<IRecipe> craftingList = CraftingManager.getInstance().getRecipeList();
for (Iterator<IRecipe> craftingIterator = craftingList.iterator(); craftingIterator.hasNext(); ) {
IRecipe recipe = craftingIterator.next();
if (withoutput.isEmpty() || !ItemStack.areItemStacksEqual(withoutput, recipe.getRecipeOutput()))
continue;
craftingIterator.remove();
}
}
use of net.minecraft.item.crafting.IRecipe in project BetterStorage by copygirl.
the class VanillaStationCrafting method findVanillaRecipe.
public static VanillaStationCrafting findVanillaRecipe(InventoryCraftingStation inv) {
World world = ((inv.entity != null) ? inv.entity.getWorldObj() : WorldUtils.getLocalWorld());
InventoryCrafting crafting = new InventoryCrafting(new FakeContainer(), 3, 3);
for (int i = 0; i < inv.crafting.length; i++) crafting.setInventorySlotContents(i, ItemStack.copyItemStack(inv.crafting[i]));
IRecipe recipe = findRecipe(crafting, world);
if (recipe == null)
return null;
return new VanillaStationCrafting(world, recipe, inv.crafting, recipe.getCraftingResult(crafting));
}
use of net.minecraft.item.crafting.IRecipe in project LogisticsPipes by RS485.
the class LogisticsCraftingTableTileEntity method cycleRecipe.
public void cycleRecipe(boolean down) {
cacheRecipe();
if (targetType == null) {
return;
}
cache = null;
AutoCraftingInventory craftInv = new AutoCraftingInventory(placedBy);
for (int i = 0; i < 9; i++) {
craftInv.setInventorySlotContents(i, matrix.getStackInSlot(i));
}
List<IRecipe> list = new ArrayList<>();
for (IRecipe r : CraftingUtil.getRecipeList()) {
if (r.matches(craftInv, getWorldObj())) {
list.add(r);
}
}
if (list.size() > 1) {
boolean found = false;
IRecipe prev = null;
for (IRecipe recipe : list) {
if (found) {
cache = recipe;
break;
}
craftInv = new AutoCraftingInventory(placedBy);
for (int i = 0; i < 9; i++) {
craftInv.setInventorySlotContents(i, matrix.getStackInSlot(i));
}
if (targetType != null && targetType.equals(ItemIdentifier.get(recipe.getCraftingResult(craftInv)))) {
if (down) {
found = true;
} else {
if (prev == null) {
cache = list.get(list.size() - 1);
} else {
cache = prev;
}
break;
}
}
prev = recipe;
}
if (cache == null) {
cache = list.get(0);
}
craftInv = new AutoCraftingInventory(placedBy);
for (int i = 0; i < 9; i++) {
craftInv.setInventorySlotContents(i, matrix.getStackInSlot(i));
}
targetType = ItemIdentifier.get(cache.getCraftingResult(craftInv));
}
if (!guiWatcher.isEmpty() && getWorldObj() != null && MainProxy.isServer(getWorldObj())) {
MainProxy.sendToPlayerList(PacketHandler.getPacket(CraftingSetType.class).setTargetType(targetType).setTilePos(this), guiWatcher);
}
cacheRecipe();
}
use of net.minecraft.item.crafting.IRecipe in project malmo by Microsoft.
the class CraftingHelper method getRecipesForRequestedOutput.
/** Attempt to find all recipes that result in an item of the requested output.
* @param output the desired item, eg from Types.xsd - "diamond_pickaxe" etc - or as a Minecraft name - eg "tile.woolCarpet.blue"
* @return a list of IRecipe objects that result in this item.
*/
public static List<IRecipe> getRecipesForRequestedOutput(String output) {
List<IRecipe> matchingRecipes = new ArrayList<IRecipe>();
ItemStack target = MinecraftTypeHelper.getItemStackFromParameterString(output);
List<?> recipes = CraftingManager.getInstance().getRecipeList();
for (Object obj : recipes) {
if (obj == null)
continue;
if (obj instanceof IRecipe) {
ItemStack is = ((IRecipe) obj).getRecipeOutput();
if (is == null)
continue;
if (ItemStack.areItemsEqual(is, target)) {
matchingRecipes.add((IRecipe) obj);
}
}
}
return matchingRecipes;
}
use of net.minecraft.item.crafting.IRecipe in project PneumaticCraft by MineMaarten.
the class CraftingRegistrator method addPressureChamberStorageBlockRecipes.
/**
* Adds recipes like 9 gold ingot --> 1 gold block, and 1 gold block --> 9 gold ingots.
*/
public static void addPressureChamberStorageBlockRecipes() {
List<IRecipe> recipes = CraftingManager.getInstance().getRecipeList();
for (IRecipe recipe : recipes) {
if (recipe instanceof ShapedRecipes) {
ShapedRecipes shaped = (ShapedRecipes) recipe;
ItemStack[] input = shaped.recipeItems;
ItemStack ref = input[0];
if (ref == null || input.length < 9)
continue;
boolean valid = true;
for (int i = 0; i < 9; i++) {
if (input[i] == null || !input[i].isItemEqual(ref)) {
valid = false;
break;
}
}
if (valid) {
ItemStack inputStack = ref.copy();
inputStack.stackSize = 9;
PressureChamberRecipe.chamberRecipes.add(new PressureChamberRecipe(new ItemStack[] { inputStack }, 1.0F, new ItemStack[] { shaped.getRecipeOutput() }, false));
ItemStack inputStack2 = shaped.getRecipeOutput().copy();
inputStack2.stackSize = 1;
PressureChamberRecipe.chamberRecipes.add(new PressureChamberRecipe(new ItemStack[] { inputStack2 }, -0.5F, new ItemStack[] { inputStack }, false));
}
}
}
}
Aggregations