本文整理汇总了Java中net.minecraft.item.crafting.CraftingManager类的典型用法代码示例。如果您正苦于以下问题:Java CraftingManager类的具体用法?Java CraftingManager怎么用?Java CraftingManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CraftingManager类属于net.minecraft.item.crafting包,在下文中一共展示了CraftingManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: removeRecipe
import net.minecraft.item.crafting.CraftingManager; //导入依赖的package包/类
/**
* Removes all recipes that produce a given item.
* @param itemToRemove The item whose recipes are to be removed.
*/
private static void removeRecipe(Item itemToRemove) {
Iterator<IRecipe> iter = CraftingManager.getInstance().getRecipeList().iterator();
while (iter.hasNext()) {
IRecipe recipe = iter.next();
ItemStack out = recipe.getRecipeOutput();
if (out != ItemStack.EMPTY && out.getItem() == itemToRemove) {
FMLLog.info("Removing recipe for " + out);
iter.remove();
}
}
}
示例2: getDyeColorMixFromParents
import net.minecraft.item.crafting.CraftingManager; //导入依赖的package包/类
/**
* Attempts to mix both parent sheep to come up with a mixed dye color.
*/
private EnumDyeColor getDyeColorMixFromParents(EntityAnimal father, EntityAnimal mother)
{
int i = ((EntitySheep)father).getFleeceColor().getDyeDamage();
int j = ((EntitySheep)mother).getFleeceColor().getDyeDamage();
this.inventoryCrafting.getStackInSlot(0).setItemDamage(i);
this.inventoryCrafting.getStackInSlot(1).setItemDamage(j);
ItemStack itemstack = CraftingManager.getInstance().findMatchingRecipe(this.inventoryCrafting, ((EntitySheep)father).worldObj);
int k;
if (itemstack != null && itemstack.getItem() == Items.dye)
{
k = itemstack.getMetadata();
}
else
{
k = this.worldObj.rand.nextBoolean() ? i : j;
}
return EnumDyeColor.byDyeDamage(k);
}
示例3: loadElements
import net.minecraft.item.crafting.CraftingManager; //导入依赖的package包/类
@Override
public IGuideElement[] loadElements() {
String[] txt = new String[]{"Heyo", "This is just a test of a new algorithm for my little guide :D", "", "Nice to meet ya", "Ya boi", "", "", "Hehehehe", ""};
return new IGuideElement[]{
/*new TextElement(Arrays.asList(txt)),
new TextElement(Arrays.asList(txt)),
new TextElement(Arrays.asList(txt)),*/
new CraftingElement(CraftingManager.getInstance().getRecipeList().get((int)(Math.random() * CraftingManager.getInstance().getRecipeList().size()))),
new CraftingElement(CraftingManager.getInstance().getRecipeList().get((int)(Math.random() * CraftingManager.getInstance().getRecipeList().size()))),
new CraftingElement(CraftingManager.getInstance().getRecipeList().get((int)(Math.random() * CraftingManager.getInstance().getRecipeList().size()))),
new CraftingElement(CraftingManager.getInstance().getRecipeList().get((int)(Math.random() * CraftingManager.getInstance().getRecipeList().size()))),
new CraftingElement(CraftingManager.getInstance().getRecipeList().get((int)(Math.random() * CraftingManager.getInstance().getRecipeList().size()))),
new CraftingElement(CraftingManager.getInstance().getRecipeList().get((int)(Math.random() * CraftingManager.getInstance().getRecipeList().size()))),
new CraftingElement(CraftingManager.getInstance().getRecipeList().get((int)(Math.random() * CraftingManager.getInstance().getRecipeList().size()))),
new CraftingElement(CraftingManager.getInstance().getRecipeList().get((int)(Math.random() * CraftingManager.getInstance().getRecipeList().size()))),
new CraftingElement(CraftingManager.getInstance().getRecipeList().get((int)(Math.random() * CraftingManager.getInstance().getRecipeList().size()))),
};
}
示例4: getRecipesForRequestedOutput
import net.minecraft.item.crafting.CraftingManager; //导入依赖的package包/类
/** 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;
}
示例5: onCraftingMatrixChanged
import net.minecraft.item.crafting.CraftingManager; //导入依赖的package包/类
@Override
public void onCraftingMatrixChanged() {
if (currentRecipe == null || !currentRecipe.matches(matrix, DimensionManager.getWorld(controllerDimension))) {
currentRecipe = CraftingManager.findMatchingRecipe(matrix, DimensionManager.getWorld(controllerDimension));
}
if (currentRecipe == null) {
result.setInventorySlotContents(0, ItemStack.EMPTY);
} else {
result.setInventorySlotContents(0, currentRecipe.getCraftingResult(matrix));
}
if (!getStack().hasTagCompound()) {
getStack().setTagCompound(new NBTTagCompound());
}
StackUtils.writeItems(matrix, 1, getStack().getTagCompound());
}
示例6: getDyeColorMixFromParents
import net.minecraft.item.crafting.CraftingManager; //导入依赖的package包/类
/**
* Attempts to mix both parent sheep to come up with a mixed dye color.
*/
private EnumDyeColor getDyeColorMixFromParents(EntityAnimal father, EntityAnimal mother)
{
int i = ((EntitySheep)father).getFleeceColor().getDyeDamage();
int j = ((EntitySheep)mother).getFleeceColor().getDyeDamage();
this.inventoryCrafting.getStackInSlot(0).setItemDamage(i);
this.inventoryCrafting.getStackInSlot(1).setItemDamage(j);
ItemStack itemstack = CraftingManager.getInstance().findMatchingRecipe(this.inventoryCrafting, ((EntitySheep)father).world);
int k;
if (itemstack.getItem() == Items.DYE)
{
k = itemstack.getMetadata();
}
else
{
k = this.world.rand.nextBoolean() ? i : j;
}
return EnumDyeColor.byDyeDamage(k);
}
示例7: getSmeltingResult
import net.minecraft.item.crafting.CraftingManager; //导入依赖的package包/类
public ItemStack[] getSmeltingResult(InventoryCrafting inv, World world, Tier tier) {
return new ItemStack[] { CraftingManager.getInstance().findMatchingRecipe(inv, world) };
/*
@SuppressWarnings("unchecked")
List<IRecipe> recipeList = CraftingManager.getInstance().getRecipeList();
Iterator<IRecipe> iterator = recipeList.iterator();
while(iterator.hasNext()) {
IRecipe recipe = iterator.next();
if(recipe != null && inv != null) {
if(recipe.getCraftingResult(inv) != null)
FMLLog.log(Level.INFO, "result: " + recipe.getCraftingResult(inv));
else
FMLLog.log(Level.INFO, "result: null");
if(recipe.matches(inv, world)) {
return new ItemStack[] { recipe.getCraftingResult(inv) };
}
} else {
FMLLog.log(Level.INFO, "_null");
}
}
return null;
*/
}
示例8: sortCraftManager
import net.minecraft.item.crafting.CraftingManager; //导入依赖的package包/类
public static void sortCraftManager()
{
bake();
FMLLog.fine("Sorting recipes");
warned.clear();
Collections.sort(CraftingManager.getInstance().getRecipeList(), INSTANCE);
}
示例9: getDyeColorMixFromParents
import net.minecraft.item.crafting.CraftingManager; //导入依赖的package包/类
/**
* Attempts to mix both parent sheep to come up with a mixed dye color.
*/
private EnumDyeColor getDyeColorMixFromParents(EntityAnimal father, EntityAnimal mother)
{
int i = ((EntitySheep)father).getFleeceColor().getDyeDamage();
int j = ((EntitySheep)mother).getFleeceColor().getDyeDamage();
this.inventoryCrafting.getStackInSlot(0).setItemDamage(i);
this.inventoryCrafting.getStackInSlot(1).setItemDamage(j);
ItemStack itemstack = CraftingManager.getInstance().findMatchingRecipe(this.inventoryCrafting, ((EntitySheep)father).worldObj);
int k;
if (itemstack != null && itemstack.getItem() == Items.DYE)
{
k = itemstack.getMetadata();
}
else
{
k = this.worldObj.rand.nextBoolean() ? i : j;
}
return EnumDyeColor.byDyeDamage(k);
}
示例10: loadUsageRecipes
import net.minecraft.item.crafting.CraftingManager; //导入依赖的package包/类
@Override
public void loadUsageRecipes(ItemStack ingredient) {
for (IRecipe irecipe : CraftingManager.getInstance().getRecipeList()) {
CachedShapedRecipe recipe = null;
if (irecipe instanceof ShapedRecipes) {
recipe = new CachedShapedRecipe((ShapedRecipes) irecipe);
} else if (irecipe instanceof ShapedOreRecipe) {
recipe = forgeShapedRecipe((ShapedOreRecipe) irecipe);
}
if (recipe == null || !recipe.contains(recipe.ingredients, ingredient.getItem())) {
continue;
}
recipe.computeVisuals();
if (recipe.contains(recipe.ingredients, ingredient)) {
recipe.setIngredientPermutation(recipe.ingredients, ingredient);
arecipes.add(recipe);
}
}
}
示例11: SC2RecipeTweaks
import net.minecraft.item.crafting.CraftingManager; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public static void SC2RecipeTweaks()
{
if(Loader.isModLoaded("steamcraft2"))
{
if(!ConfigSettings.FleshBlockRecipe)
{
List<IRecipe> recipes = CraftingManager.getInstance().getRecipeList();
for (int i = 0; i < recipes.size(); i++)
{
if (recipes.get(i) != null)
{
ItemStack recipeResult = recipes.get(i).getRecipeOutput();
if (recipeResult != null && recipeResult.getItem() == Item.getItemFromBlock(InitBlocks.blockFlesh))
{
recipes.remove(i--);
}
}
}
}
//OreDictionary.registerOre("itemAxe", new ItemStack(InitItems.axeSteam, 1, OreDictionary.WILDCARD_VALUE));
}
}
示例12: loadCraftingRecipes
import net.minecraft.item.crafting.CraftingManager; //导入依赖的package包/类
@Override
public void loadCraftingRecipes(String outputId, Object... results) {
if (outputId.equals("crafting") && getClass() == ShapelessRecipeHandler.class) {
List<IRecipe> allrecipes = CraftingManager.getInstance().getRecipeList();
for (IRecipe irecipe : allrecipes) {
CachedShapelessRecipe recipe = null;
if (irecipe instanceof ShapelessRecipes)
recipe = shapelessRecipe((ShapelessRecipes) irecipe);
else if (irecipe instanceof ShapelessOreRecipe)
recipe = forgeShapelessRecipe((ShapelessOreRecipe) irecipe);
if (recipe == null)
continue;
arecipes.add(recipe);
}
} else {
super.loadCraftingRecipes(outputId, results);
}
}
示例13: loadCraftingRecipes
import net.minecraft.item.crafting.CraftingManager; //导入依赖的package包/类
@Override
public void loadCraftingRecipes(String outputId, Object... results) {
if (outputId.equals("crafting") && getClass() == ShapedRecipeHandler.class) {
for (IRecipe irecipe : CraftingManager.getInstance().getRecipeList()) {
CachedShapedRecipe recipe = null;
if (irecipe instanceof ShapedRecipes) {
recipe = new CachedShapedRecipe((ShapedRecipes) irecipe);
} else if (irecipe instanceof ShapedOreRecipe) {
recipe = forgeShapedRecipe((ShapedOreRecipe) irecipe);
}
if (recipe == null) {
continue;
}
recipe.computeVisuals();
arecipes.add(recipe);
}
} else {
super.loadCraftingRecipes(outputId, results);
}
}
示例14: loadUsageRecipes
import net.minecraft.item.crafting.CraftingManager; //导入依赖的package包/类
@Override
public void loadUsageRecipes(ItemStack ingredient) {
List<IRecipe> allrecipes = CraftingManager.getInstance().getRecipeList();
for (IRecipe irecipe : allrecipes) {
CachedShapelessRecipe recipe = null;
if (irecipe instanceof ShapelessRecipes)
recipe = shapelessRecipe((ShapelessRecipes) irecipe);
else if (irecipe instanceof ShapelessOreRecipe)
recipe = forgeShapelessRecipe((ShapelessOreRecipe) irecipe);
if (recipe == null)
continue;
if (recipe.contains(recipe.ingredients, ingredient)) {
recipe.setIngredientPermutation(recipe.ingredients, ingredient);
arecipes.add(recipe);
}
}
}
示例15: loadCraftingRecipes
import net.minecraft.item.crafting.CraftingManager; //导入依赖的package包/类
@Override
public void loadCraftingRecipes(String outputId, Object... results) {
if (outputId.equals("crafting") && getClass() == ShapedRecipeHandler.class) {
for (IRecipe irecipe : (List<IRecipe>) CraftingManager.getInstance().getRecipeList()) {
CachedShapedRecipe recipe = null;
if (irecipe instanceof ShapedRecipes)
recipe = new CachedShapedRecipe((ShapedRecipes) irecipe);
else if (irecipe instanceof ShapedOreRecipe)
recipe = forgeShapedRecipe((ShapedOreRecipe) irecipe);
if (recipe == null)
continue;
recipe.computeVisuals();
arecipes.add(recipe);
}
} else {
super.loadCraftingRecipes(outputId, results);
}
}