本文整理汇总了Java中minetweaker.api.item.IItemStack类的典型用法代码示例。如果您正苦于以下问题:Java IItemStack类的具体用法?Java IItemStack怎么用?Java IItemStack使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IItemStack类属于minetweaker.api.item包,在下文中一共展示了IItemStack类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addMelting
import minetweaker.api.item.IItemStack; //导入依赖的package包/类
/**********************************************
* TConstruct Melting Recipes
**********************************************/
// Adding a Meltery Recipe
@ZenMethod
public static void addMelting(ILiquidStack output, IIngredient input, int temp) {
if (input == null || output == null) {
LogHelper.logError(String.format("Required parameters missing for %s Recipe.", nameMelting));
return;
}
List<MelteryRecipe> recipes = new LinkedList<>();
for (IItemStack in : input.getItems()) {
recipes.add(new MelteryRecipe(new RecipeMatch.ItemCombination(output.getAmount(), toStack(in)), toFluid(output), temp));
}
if (!recipes.isEmpty()) {
MineTweakerAPI.apply(new AddMelting(recipes));
} else {
LogHelper.logError(String.format("No %s recipes could be added for input %s.", nameMelting, input.toString()));
}
}
示例2: removeMelting
import minetweaker.api.item.IItemStack; //导入依赖的package包/类
@ZenMethod
public static void removeMelting(IItemStack input) {
List<MelteryRecipe> recipes = new LinkedList<>();
for (MelteryRecipe meta : MelteryHandler.meltingRecipes) {
NonNullList<ItemStack> items = NonNullList.create();
items.addAll(input.getItems().stream().map(InputHelper::toStack).collect(Collectors.toList()));
if (meta.input.matches(items) != null) {
recipes.add(meta);
}
}
if (!recipes.isEmpty()) {
MineTweakerAPI.apply(new RemoveMelting(recipes));
} else {
LogHelper.logWarning(String.format("No %s Recipe found for %s. Command ignored!", nameMelting, input.toString()));
}
}
示例3: addWeldRecipe
import minetweaker.api.item.IItemStack; //导入依赖的package包/类
@ZenMethod
public static void addWeldRecipe(IItemStack Output, IItemStack Input1, IItemStack Input2, int AnvilReq)
{
ItemStack result = MineTweakerMC.getItemStack(Output);
ItemStack input1 = MineTweakerMC.getItemStack(Input1);
ItemStack input2 = MineTweakerMC.getItemStack(Input2);
if(input1 == null || input1.getItem() == null)
MineTweakerAPI.logError("Missing first InputStack");
else if(input1 == null || input1.getItem() == null)
MineTweakerAPI.logError("Missing second InputStack");
else if(result == null || result.getItem() == null)
MineTweakerAPI.logError("Missing OutputStack");
else if(AnvilReq < 0 || AnvilReq > 7)
MineTweakerAPI.logError("Anvil type must be between 0 and 7, inclusive");
else
MineTweakerAPI.apply(new addWeldRecipeAction(result, input1, input2, AnvilReq));
}
示例4: removeWeldRecipe
import minetweaker.api.item.IItemStack; //导入依赖的package包/类
@ZenMethod
public static void removeWeldRecipe(IItemStack Output, IItemStack Input1, IItemStack Input2, int AnvilReq)
{
ItemStack result = MineTweakerMC.getItemStack(Output);
ItemStack input1 = MineTweakerMC.getItemStack(Input1);
ItemStack input2 = MineTweakerMC.getItemStack(Input2);
if(input1 == null || input1.getItem() == null)
MineTweakerAPI.logError("Missing first InputStack");
else if(input1 == null || input1.getItem() == null)
MineTweakerAPI.logError("Missing second InputStack");
else if(result == null || result.getItem() == null)
MineTweakerAPI.logError("Missing OutputStack");
else if(AnvilReq < 0 || AnvilReq > 6)
MineTweakerAPI.logError("Anvil type must be between 0 and 6, inclusive");
else
MineTweakerAPI.apply(new removeWeldRecipeAction(result, input1, input2, AnvilReq));
}
示例5: addRecipe
import minetweaker.api.item.IItemStack; //导入依赖的package包/类
@ZenMethod
public static void addRecipe(IItemStack output, IItemStack input, double heat, double specHeat)
{
ItemStack inputStack = MineTweakerMC.getItemStack(input);
ItemStack outputStack = MineTweakerMC.getItemStack(output);
if(inputStack == null || inputStack.getItem() == null)
MineTweakerAPI.logError("Missing InputStack");
else if(inputStack.getItem() instanceof ISmeltable &&
((ISmeltable)inputStack.getItem()).getMetalType(inputStack) == null)
MineTweakerAPI.logError(inputStack.getDisplayName() + " is invalid when melted.");
else if(outputStack == null || outputStack.getItem() == null)
MineTweakerAPI.logError("Missing OutputStack");
else if(heat < 0)
MineTweakerAPI.logError("Item melting point cannot be less than 0");
else if(specHeat < 0)
MineTweakerAPI.logError("Item specific heat cannot be less than 0");
else
MineTweakerAPI.apply(new addHeatingAction(outputStack, inputStack, heat, specHeat));
}
示例6: toStack
import minetweaker.api.item.IItemStack; //导入依赖的package包/类
public static ItemStack toStack(IItemStack iStack, boolean trim) {
if (iStack == null) return null;
else {
Object internal = iStack.getInternal();
if (internal == null || !(internal instanceof ItemStack)) {
MineTweakerAPI.getLogger().logError("Not a valid item stack: " + iStack);
} else if (trim) {
ItemStack t = (ItemStack) internal;
if (t.stackSize > 1) {
MineTweakerAPI.getLogger().logWarning("Stack size not supported, reduced to one item.");
t.stackSize = 1;
}
return t;
}
//noinspection ConstantConditions
return (ItemStack) internal;
}
}
示例7: set
import minetweaker.api.item.IItemStack; //导入依赖的package包/类
@ZenMethod
public static void set(IItemStack item, String tool, int level) {
if (item == null) {
MineTweakerAPI.getLogger().logError("Harvest level: Block/Item must not be null!");
return;
}
if (isABlock(toStack(item))) {
MineTweakerAPI.apply(new HarvestLevelChangeBlock(item, tool, level));
} else {
if (tool == null) {
MineTweakerAPI.getLogger().logError("Harvest level: For items tool must not be null!");
return;
}
MineTweakerAPI.apply(new HarvestLevelChangeItem(item, tool, level));
}
}
示例8: AddRecipeAction
import minetweaker.api.item.IItemStack; //导入依赖的package包/类
public AddRecipeAction(Object input, ItemStack output1, ItemStack output2)
{
if (input instanceof IItemStack)
input = MineTweakerMC.getItemStack((IItemStack) input);
//TODO
// if (input instanceof IOreDictEntry)
if (input instanceof ILiquidStack)
{
MineTweakerAPI.logError("A liquid was passed into a grinder recipe, grinder do not use liquids when crafting, aborting!");
input = output1 = output2 = null;
}
this.input = input;
this.output1 = output1;
this.output2 = output2;
}
示例9: set
import minetweaker.api.item.IItemStack; //导入依赖的package包/类
@ZenMethod
public static void set(final IItemStack stack, final int compostValue, final int scrapValue, final boolean ignoreRecipe, final boolean scrubFromOutput, final boolean blockFromScrapping) {
if(!MineTweakerUtil.checkNotNull(stack, "stack cannot be null"))
return;
if(!MineTweakerUtil.checkArgument(compostValue >=0 && compostValue < 3, "compostValue must be in range 0-2"))
return;
if(!MineTweakerUtil.checkArgument(scrapValue >= 0 && scrapValue < 4, "scrapValue must be in range 0-3"))
return;
final CompostIngredient cv = CompostIngredient.values()[compostValue];
final ScrapValue sv = ScrapValue.values()[scrapValue];
final ItemStack item = MineTweakerMC.getItemStack(stack);
final ItemData data = ItemRegistry.get(item);
data.value = sv;
data.compostValue = cv;
data.ignoreRecipe = ignoreRecipe;
data.scrubFromOutput = scrubFromOutput;
data.isBlockedFromScrapping = blockFromScrapping;
ItemRegistry.set(data);
}
示例10: add
import minetweaker.api.item.IItemStack; //导入依赖的package包/类
@ZenMethod
public static void add(IItemStack input, IItemStack output, int weight) {
if (!MineTweakerUtil.checkNotNull(input, "input cannot be null"))
return;
if (!MineTweakerUtil.checkArgument(weight > 0, "weight must be greater than 0"))
return;
final ItemStack theInput = MineTweakerMC.getItemStack(input);
final ItemStack theOutput = MineTweakerMC.getItemStack(output);
final ExtractionData data = ItemRegistry.getExtractionData(theInput);
if (data.isDefault()) {
final ItemStackWeightTable table = new ItemStackWeightTable();
table.add(new ItemStackItem(theOutput, weight));
ItemRegistry.setBlockedFromExtraction(theInput, false);
RecipeHelper.put(theInput, table);
} else {
data.getOutput().add(new ItemStackItem(theOutput, weight));
}
}
示例11: convertCatalysts
import minetweaker.api.item.IItemStack; //导入依赖的package包/类
private static OreRecipeElement[] convertCatalysts(IIngredient[] catalysts)
{
OreRecipeElement[] convertedCatalysts = new OreRecipeElement[catalysts.length];
for(int i = 0; i < catalysts.length; i++)
{
IIngredient ingredient = catalysts[i];
if(ingredient instanceof IOreDictEntry)
{
convertedCatalysts[i] = new OreRecipeElement(((IOreDictEntry) ingredient).getName(), ingredient.getAmount());
}
else if(ingredient instanceof IItemStack)
{
convertedCatalysts[i] = new OreRecipeElement(MineTweakerMC.getItemStack(ingredient));
}
else if (ingredient instanceof IngredientStack)
{
ItemStack[] validItems = MineTweakerMC.getItemStacks(ingredient.getItems());
for(ItemStack stack : validItems)
{
stack.stackSize = ingredient.getAmount();
}
convertedCatalysts[i] = new OreRecipeElement(validItems, ingredient.getAmount());
}
}
return convertedCatalysts;
}
示例12: convertShapedIngredients
import minetweaker.api.item.IItemStack; //导入依赖的package包/类
private static OreRecipeElement[][] convertShapedIngredients(IIngredient[][] inputs)
{
OreRecipeElement[][] convertedIngredients = new OreRecipeElement[3][3];
for(int row = 0; row < 3; row++)
{
for(int col = 0; col < 3; col++)
{
IIngredient ingredient = inputs[row][col];
if(ingredient instanceof IOreDictEntry)
{
convertedIngredients[row][col] = new OreRecipeElement(((IOreDictEntry) ingredient).getName(), 1);
}
else if(ingredient instanceof IItemStack)
{
convertedIngredients[row][col] = new OreRecipeElement(MineTweakerMC.getItemStack(ingredient));
}
}
}
return convertedIngredients;
}
示例13: addShaped
import minetweaker.api.item.IItemStack; //导入依赖的package包/类
@ZenMethod
public static void addShaped(IItemStack output, IIngredient[][] inputs) {
if (inputs == null) {
MineTweakerAPI.getLogger().logError("Large Furnace: Input set must not be null!");
return;
}
if (inputs.length == 0) {
MineTweakerAPI.getLogger().logError("Large Furnace: Input set must not empty!");
return;
}
if (output == null) {
MineTweakerAPI.getLogger().logError("Large Furnace: Output must not be null!");
return;
}
ShapedOreRecipe recipe = constructSafelyShaped(toStack(output), toShapedObjects(inputs, true));
if (recipe == null) {
MineTweakerAPI.getLogger().logError("Large Furnace: Illegal recipe.");
return;
}
MineTweakerAPI.apply(new FurnaceAdd(output, recipe));
}
示例14: addRecipe
import minetweaker.api.item.IItemStack; //导入依赖的package包/类
/**
* Adds an Arc Furnace recipe.
*
* @param outputs 1-4 recipe output
* @param input primary input
* @param fluidInput primary fluidInput
* @param outChances chances of 1-4 output
* @param durationTicks assembling duration, in ticks
* @param euPerTick eu consumption per tick
*/
@ZenMethod
public static void addRecipe(IItemStack[] outputs, IIngredient input, ILiquidStack fluidInput, int[] outChances, int durationTicks, int euPerTick) {
if (outputs.length < 1) {
MineTweakerAPI.logError("Arc Furnace must have at least 1 output");
} else if (outputs.length != outChances.length) {
MineTweakerAPI.logError("Number of Outputs does not equal number of Chances");
} else {
MineTweakerAPI.apply(new AddMultipleRecipeAction("Adding Arc Furnace recipe for " + input, input, fluidInput, outputs, outChances, durationTicks, euPerTick) {
@Override
protected void applySingleRecipe(ArgIterator i) {
RA.addSimpleArcFurnaceRecipe(i.nextItem(), i.nextFluid(), i.nextItemArr(), i.nextIntArr(), i.nextInt(), i.nextInt());
}
});
}
}
示例15: addRecipe
import minetweaker.api.item.IItemStack; //导入依赖的package包/类
/**
* Adds a Sifter recipe.
*
* @param outputs 1-9 outputs
* @param input primary input
* @param outChances chances of 1-9 output
* @param durationTicks reaction time, in ticks
* @param euPerTick eu consumption per tick
*/
@ZenMethod
public static void addRecipe(IItemStack[] outputs, IIngredient input, int[] outChances, int durationTicks, int euPerTick) {
if (outputs.length < 1) {
MineTweakerAPI.logError("Sifter must have at least 1 output");
} else if (outputs.length != outChances.length) {
MineTweakerAPI.logError("Number of Outputs does not equal number of Chances");
} else {
MineTweakerAPI.apply(new AddMultipleRecipeAction("Adding Sifter recipe for " + input, input, outputs, outChances, durationTicks, euPerTick) {
@Override
protected void applySingleRecipe(ArgIterator i) {
RA.addSifterRecipe(i.nextItem(), i.nextItemArr(), i.nextIntArr(), i.nextInt(), i.nextInt());
}
});
}
}