本文整理了Java中net.minecraft.item.ItemStack.toString()
方法的一些代码示例,展示了ItemStack.toString()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ItemStack.toString()
方法的具体详情如下:
包路径:net.minecraft.item.ItemStack
类名称:ItemStack
方法名:toString
暂无
代码示例来源:origin: SlimeKnights/TinkersConstruct
/** Adds a new pattern to craft to the stenciltable. NBT sensitive. Has to be a Pattern. */
public static void registerStencilTableCrafting(ItemStack stencil) {
if(!(stencil.getItem() instanceof IPattern)) {
error(String.format(
"Stencil Table Crafting has to be a pattern (%s)", stencil.toString()));
return;
}
stencilTableCrafting.add(stencil);
}
代码示例来源:origin: SlimeKnights/TinkersConstruct
public void setRepresentativeItem(ItemStack representativeItem) {
if(representativeItem == null || representativeItem.isEmpty()) {
this.representativeItem = ItemStack.EMPTY;
}
else if(matches(representativeItem).isPresent()) {
this.representativeItem = representativeItem;
}
else {
TinkerRegistry.log.warn("Itemstack {} cannot represent material {} since it is not associated with the material!",
representativeItem.toString(),
identifier);
}
}
代码示例来源:origin: SlimeKnights/TinkersConstruct
public void setShard(@Nonnull ItemStack stack) {
if(stack.isEmpty()) {
this.shardItem = ItemStack.EMPTY;
}
else {
Optional<RecipeMatch.Match> matchOptional = matches(stack);
if(matchOptional.isPresent()) {
RecipeMatch.Match match = matchOptional.get();
if(match.amount == VALUE_Shard) {
this.shardItem = stack;
if(representativeItem.isEmpty()) {
this.setRepresentativeItem(shardItem.copy());
}
}
else {
TinkerRegistry.log.warn("Itemstack {} cannot be shard of material {} since it does not have the correct value! (is {}, has to be {})",
representativeItem.toString(),
identifier,
match.amount,
VALUE_Shard);
}
}
else {
TinkerRegistry.log.warn("Itemstack {} cannot be shard of material {} since it is not associated with the material!",
stack.toString(),
identifier);
}
}
}
代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2
private void warnAboutCraftingManager( boolean foundAlternative )
{
final String foundAlternativeRecipe = foundAlternative ? "Found alternative recipe." : "NOT FOUND, please report.";
final StringJoiner joinActualInputs = new StringJoiner( ", " );
for( int j = 0; j < this.testFrame.getSizeInventory(); j++ )
{
final ItemStack stack = this.testFrame.getStackInSlot( j );
if( !stack.isEmpty() )
{
joinActualInputs.add( stack.toString() );
}
}
AELog.warn( "Using CraftingManager fallback: Recipe <%s> for output <%s> rejected inputs [%s]. %s",
this.standardRecipe.getRegistryName(), this.standardRecipe.getRecipeOutput(), joinActualInputs, foundAlternativeRecipe );
}
代码示例来源:origin: SlimeKnights/TinkersConstruct
output.setCount(1);
TinkerRegistry.registerMelting(new MeltingRecipe(RecipeMatch.of(output, amount), fluid));
log.trace("Added automatic melting recipe for {} ({} {})", irecipe.getRecipeOutput().toString(), amount, fluid
.getName());
代码示例来源:origin: Chisel-Team/Chisel
@Override
public String toString() {
return stack.toString();
}
}
代码示例来源:origin: Vazkii/Patchouli
@Override
public String toString() {
return "Wrapper[" + stack.toString() + "]";
}
代码示例来源:origin: WayofTime/BloodMagic
public AlchemyArrayEffectCrafting(ItemStack outputStack, int tickLimit) {
this(outputStack.toString() + tickLimit, outputStack, tickLimit);
}
代码示例来源:origin: CoFH/CoFHCore
@Override
public ITextComponent processStack(ItemStack stack) {
return new TextComponentString(stack.toString());
}
}, Action("use") {
代码示例来源:origin: WayofTime/BloodMagic
public AlchemyArrayEffectCraftingNew(RecipeAlchemyArray recipe) {
this(recipe.getOutput().toString() + 200, recipe);
}
代码示例来源:origin: GregTechCE/GregTech
public static void addItem(ResourceLocation lootTable, ItemStack item, int minChance, int maxChance, int weight) {
LootEntryItem itemEntry = new LootEntryItem(item.getItem(), weight, 1, new LootFunction[] {
new LootFunction(NO_CONDITIONS) {
@Override
public ItemStack apply(ItemStack stack, Random rand, LootContext context) {
stack.setItemDamage(item.getItemDamage());
stack.setTagCompound(item.getTagCompound());
stack.setCount(minChance + rand.nextInt(maxChance));
return stack;
}
}
}, NO_CONDITIONS, "#gregtech:loot_" + item.toString());
if(lootEntryItems.containsKey(lootTable)) {
lootEntryItems.get(lootTable).add(itemEntry);
} else {
lootEntryItems.put(lootTable, Lists.newArrayList(itemEntry));
}
}
代码示例来源:origin: sinkillerj/ProjectE
protected void doWhitelistNBT(ItemStack s, String modName)
{
NBTWhitelist.register(s);
PECore.debugLog("Mod {} whitelisted {} for NBT duping", modName, s.toString());
}
}
代码示例来源:origin: SleepyTrousers/EnderIO
public EnchanterRecipe(@Nonnull Things input, int stackSizePerLevel, @Nonnull Enchantment enchantment, double costMultiplier) {
this.input = input;
this.stackSizePerLevel = stackSizePerLevel;
this.enchantment = enchantment;
this.costMultiplier = costMultiplier;
this.uuid = NullHelper.first(input.getItemStacksRaw().get(0).toString(), "invalid Recipe");
}
代码示例来源:origin: sinkillerj/ProjectE
private static void addItem(Item item, PageCategory category)
{
// Manually exclude alchBag from having 16 of the same entry
List<ItemStack> list = (item == ObjHandler.alchBag || !item.getHasSubtypes()) ? Collections.singletonList(new ItemStack(item)) : getSubItems(item);
for (ItemStack s : list)
{
AbstractPage page = AbstractPage.createItemPage(s, category);
categoryMap.get(category).add(page);
categoryMap.get(category).addAll(page.subPages);
PECore.debugLog("Added {} item pages for stack {}", page.subPages.size() + 1, s.toString());
}
}
代码示例来源:origin: CoFH/CoFHCore
public static void addInventoryContents(CrashReport report, String categoryName, final IItemHandler inv) {
CrashReportCategory category = report.makeCategory(categoryName);
if (inv == null) {
category.addCrashSection("Null?", "Null");
return;
}
category.addCrashSection("InventoryContents", (Callable<String>) () -> {
StringBuilder builder = new StringBuilder("\n\n");
builder.append(inv.toString()).append(" - ").append(inv.getSlots());
for (int i = 0; i < inv.getSlots(); i++) {
builder.append(i).append(" - ");
ItemStack stackInSlot;
try {
stackInSlot = inv.getStackInSlot(i);
} catch (Exception e) {
builder.append("Errored - ").append(e.toString()).append("\n");
continue;
}
builder.append(stackInSlot.isEmpty() ? "Empty" : stackInSlot.toString()).append("\n");
}
builder.append("\n\n");
return builder.toString();
});
}
代码示例来源:origin: ForestryMC/ForestryMC
public static String getInvalidIMCMessageText(FMLInterModComms.IMCMessage message) {
final Object messageValue;
if (message.isItemStackMessage()) {
messageValue = message.getItemStackValue().toString();
} else if (message.isNBTMessage()) {
messageValue = message.getNBTValue();
} else if (message.isStringMessage()) {
messageValue = message.getStringValue();
} else {
messageValue = "";
}
return String.format("Received an invalid '%s' request '%s' from mod '%s'. Please contact the author and report this issue.", message.key, messageValue, message.getSender());
}
代码示例来源:origin: sinkillerj/ProjectE
@Override
public void registerCustomEMC(@Nonnull ItemStack stack, long value)
{
Preconditions.checkNotNull(stack);
boolean flag = Loader.instance().isInState(LoaderState.PREINITIALIZATION) || Loader.instance().isInState(LoaderState.INITIALIZATION) || Loader.instance().isInState(LoaderState.POSTINITIALIZATION);
Preconditions.checkState(flag, String.format("Mod %s tried to register EMC at an invalid time!", Loader.instance().activeModContainer().getModId()));
APICustomEMCMapper.instance.registerCustomEMC(stack, value);
PECore.debugLog("Mod {} registered emc value {} for itemstack {}", Loader.instance().activeModContainer().getModId(), value, stack.toString());
}
代码示例来源:origin: ldtteam/minecolonies
/**
* Resolve the request in a building.
* @param manager the request manager.
* @param request the request.
* @param building the building.
*/
public void resolveForBuilding(@NotNull final IRequestManager manager, @NotNull final IRequest<? extends C> request, @NotNull final AbstractBuilding building)
{
final AbstractBuildingWorker buildingWorker = (AbstractBuildingWorker) building;
final IRecipeStorage storage = buildingWorker.getFirstFullFillableRecipe(request.getRequest().getStack());
if (storage == null)
{
Log.getLogger().error("Failed to craft a crafting recipe of: " + request.getRequest().getStack().toString() + ". Its ingredients are missing.");
return;
}
final int craftingCount = CraftingUtils.calculateMaxCraftingCount(request.getRequest().getCount(), storage);
for (int i = 0; i < craftingCount; i++)
{
buildingWorker.fullFillRecipe(storage);
}
manager.updateRequestState(request.getToken(), RequestState.COMPLETED);
}
}
代码示例来源:origin: ExtraCells/ExtraCells2
@Override
public IPart createPartFromItemStack(ItemStack itemStack) {
try {
return PartEnum.values()[MathHelper.clamp(
itemStack.getItemDamage(), 0, PartEnum.values().length - 1)]
.newInstance(itemStack);
} catch (Throwable ex) {
Log.error(
"ExtraCells2 severe error - could not create AE2 Part from ItemStack! This should not happen!\n"
+ "[ExtraCells2 SEVERE] Contact Leonelf/M3gaFr3ak with the following stack trace.\n"
+ "[ExtraCells2 SEVERE] Offending item: '%s'",
itemStack.toString(), ex);
return null;
}
}
代码示例来源:origin: TehNut/HWYLA
public static void renderStack(int x, int y, ItemStack stack) {
enable3DRender();
try {
renderItem.renderItemAndEffectIntoGUI(stack, x, y);
ItemStack overlayRender = stack.copy();
overlayRender.setCount(1);
renderItem.renderItemOverlayIntoGUI(fontRendererObj, overlayRender, x, y, null);
renderStackSize(fontRendererObj, stack, x, y);
} catch (Exception e) {
String stackStr = stack != null ? stack.toString() : "NullStack";
WailaExceptionHandler.handleErr(e, "renderStack | " + stackStr, null);
}
enable2DRender();
}
内容来源于网络,如有侵权,请联系作者删除!