当前位置: 首页>>代码示例>>Java>>正文


Java ItemStack.setStackDisplayName方法代码示例

本文整理汇总了Java中net.minecraft.item.ItemStack.setStackDisplayName方法的典型用法代码示例。如果您正苦于以下问题:Java ItemStack.setStackDisplayName方法的具体用法?Java ItemStack.setStackDisplayName怎么用?Java ItemStack.setStackDisplayName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.minecraft.item.ItemStack的用法示例。


在下文中一共展示了ItemStack.setStackDisplayName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: copyName

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
private void copyName(IInventory craftMatrix, ItemStack newItem)	// Does the weapon have a custom name? If so then we're transfering that to the new item
{
	// Step 1, find the actual item (It's possible that this is not a reloading action, meaning there is no weapon to copy the name from)

	int slot = 0;

	while (slot < 9)
	{
		ItemStack stack = craftMatrix.getStackInSlot(slot);

		if (stack != null && stack.getItem() instanceof _WeaponBase)	// Found it. Does it have a name tag?
		{
			if (stack.hasDisplayName() && !newItem.hasDisplayName()) { newItem.setStackDisplayName(stack.getDisplayName()); }
			// else, has no custom display name or the new item already has one. Fine with me either way.

			return;	// Either way, we're done here
		}
		// else, either doesn't exist or not what I'm looking for

		slot += 1;
	}
}
 
开发者ID:Domochevsky,项目名称:minecraft-quiverbow,代码行数:23,代码来源:Listener.java

示例2: updateItemName

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
 * used by the Anvil GUI to update the Item Name being typed by the player
 */
public void updateItemName(String newName)
{
    this.repairedItemName = newName;

    if (this.getSlot(2).getHasStack())
    {
        ItemStack itemstack = this.getSlot(2).getStack();

        if (StringUtils.isBlank(newName))
        {
            itemstack.clearCustomName();
        }
        else
        {
            itemstack.setStackDisplayName(this.repairedItemName);
        }
    }

    this.updateRepairOutput();
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:24,代码来源:ContainerRepair.java

示例3: breakBlock

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Override
public void breakBlock(World worldIn, BlockPos pos, IBlockState state) {
	TileEntityBloodVessel te = (TileEntityBloodVessel) worldIn.getTileEntity(pos);
	int amount = te.getPossibleRemove();
	int max = te.getMax();
	worldIn.removeTileEntity(pos);
	ItemStack stack = new ItemStack(this);
	if(amount != 0)
	{
		NBTTagCompound nbttagcompound = new NBTTagCompound();
        nbttagcompound.setInteger("BloodLevel", amount);
        stack.setTagCompound(nbttagcompound);
        stack.setStackDisplayName("�r" + getLocalizedName() + " [" + amount + "/" + max + "]");
	}
	if(!creativeBreakMap.containsKey(pos) || !creativeBreakMap.get(pos))
		worldIn.spawnEntity(new EntityItem(worldIn, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, stack));
	creativeBreakMap.remove(pos);
}
 
开发者ID:kenijey,项目名称:harshencastle,代码行数:19,代码来源:BloodVessel.java

示例4: killMinecart

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public void killMinecart(DamageSource source)
{
    this.setDead();

    if (this.worldObj.getGameRules().getBoolean("doEntityDrops"))
    {
        ItemStack itemstack = new ItemStack(Items.MINECART, 1);

        if (this.getName() != null)
        {
            itemstack.setStackDisplayName(this.getName());
        }

        this.entityDropItem(itemstack, 0.0F);
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:17,代码来源:EntityMinecart.java

示例5: killMinecart

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public void killMinecart(DamageSource p_94095_1_)
{
    this.setDead();

    if (this.worldObj.getGameRules().getBoolean("doEntityDrops"))
    {
        ItemStack itemstack = new ItemStack(Items.minecart, 1);

        if (this.entityName != null)
        {
            itemstack.setStackDisplayName(this.entityName);
        }

        this.entityDropItem(itemstack, 0.0F);
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:17,代码来源:EntityMinecart.java

示例6: onDeath

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Override
public void onDeath(DamageSource par1DamageSource) {
    for (int i = 0; i < inventory.getSlots(); i++) {
        if (!inventory.getStackInSlot(i).isEmpty()) {
            entityDropItem(inventory.getStackInSlot(i), 0);
            inventory.setStackInSlot(i, ItemStack.EMPTY);
        }
    }
    if (naturallySpawned) {

    } else {
        ItemStack drone = getDroppedStack();
        if (hasCustomName()) drone.setStackDisplayName(getCustomNameTag());
        entityDropItem(drone, 0);

        if (!world.isRemote) {
            EntityPlayer owner = getOwner();
            if (owner != null) {
                int x = (int) Math.floor(posX);
                int y = (int) Math.floor(posY);
                int z = (int) Math.floor(posZ);
                if (hasCustomName()) {
                    owner.sendStatusMessage(new TextComponentTranslation("death.drone.named", getCustomNameTag(), x, y, z), false);
                } else {
                    owner.sendStatusMessage(new TextComponentTranslation("death.drone", x, y, z), false);
                }
            }
        }
    }
    if (!world.isRemote) getFakePlayer().interactionManager.cancelDestroyingBlock();
    super.onDeath(par1DamageSource);
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:33,代码来源:EntityDrone.java

示例7: setName

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Override
public void setName(String string) {
    droneName = string;
    if (drone != null) {
        drone.setCustomNameTag(droneName);
    }
    ItemStack stack = inventory.getStackInSlot(0).copy();
    if (!stack.isEmpty()) {
        stack.setStackDisplayName(string);
        inventory.setStackInSlot(0, stack);
    }
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:13,代码来源:TileEntityProgrammableController.java

示例8: onEnable

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Override
public void onEnable()
{
	// check gamemode
	if(!WMinecraft.getPlayer().capabilities.isCreativeMode)
	{
		ChatUtils.error("Creative mode only.");
		setEnabled(false);
		return;
	}
	
	// check held item
	ItemStack heldStack = WMinecraft.getPlayer().inventory.getCurrentItem();
	if(heldStack == null || !(heldStack.getItem() instanceof ItemNameTag))
	{
		ChatUtils.error("You need a nametag in your hand.");
		setEnabled(false);
		return;
	}
	
	// modify held item
	StringBuilder stackName = new StringBuilder();
	for(int i = 0; i < 18000; i++)
		stackName.append('#');
	heldStack.setStackDisplayName(stackName.toString());
	
	// open & close the inventory
	// for some reason that's needed for the item to update
	mc.displayGuiScreen(new GuiInventory(WMinecraft.getPlayer()));
	WMinecraft.getPlayer().closeScreen();
	
	ChatUtils.message("Nametag modified.");
	setEnabled(false);
}
 
开发者ID:Wurst-Imperium,项目名称:Wurst-MC-1.12,代码行数:35,代码来源:CrashTagMod.java

示例9: createUnreadBook

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public static ItemStack createUnreadBook() {
	ItemStack book = new ItemStack(Items.WRITTEN_BOOK, 1);
	NBTTagCompound bookNbt = new NBTTagCompound();
	bookNbt.setTag(NBT_UNREAD_DISCOVERY, new NBTTagInt(nextBookID++));
	book.setTagCompound(bookNbt);
	book.setStackDisplayName("Unread Nemesis Book");
	return book;
}
 
开发者ID:ToroCraft,项目名称:NemesisSystem,代码行数:9,代码来源:DiscoveryUtil.java

示例10: copyProps

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public static void copyProps(IInventory craftMatrix, ItemStack newItem)
{
	// Step 1, find the actual item (It's possible that this is not a reloading action, meaning there is no weapon to copy the name from)
	
	int slot = 0;
	
	while (slot < 9)
	{
		ItemStack stack = craftMatrix.getStackInSlot(slot);
		
		if (stack != null && stack.getItem() instanceof _WeaponBase)	// Found it. Does it have a name tag?
		{
			if (stack.hasDisplayName() && !newItem.hasDisplayName()) { newItem.setStackDisplayName(stack.getDisplayName()); }
			// else, has no custom display name or the new item already has one. Fine with me either way.
			
			// Upgrades
			if (stack.hasTagCompound() && stack.getTagCompound().getBoolean("hasEmeraldMuzzle"))
			{
				if (!newItem.hasTagCompound()) { newItem.setTagCompound(new NBTTagCompound()); }	// Init
				newItem.getTagCompound().setBoolean("hasEmeraldMuzzle", true);						// Keeping the upgrade
			}
			
			return;	// Either way, we're done here
		}
		// else, either doesn't exist or not what I'm looking for
		
		slot += 1;
	}
}
 
开发者ID:Domochevsky,项目名称:minecraft-quiverbow,代码行数:30,代码来源:Helper.java

示例11: onEnable

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Override
public void onEnable()
{
	// check gamemode
	if(!WMinecraft.getPlayer().capabilities.isCreativeMode)
	{
		ChatUtils.error("Creative mode only.");
		setEnabled(false);
		return;
	}
	
	// generate potion
	ItemStack stack = InventoryUtils.createSplashPotion();
	NBTTagList effects = new NBTTagList();
	for(int i = 1; i <= 23; i++)
	{
		NBTTagCompound effect = new NBTTagCompound();
		effect.setInteger("Amplifier", Integer.MAX_VALUE);
		effect.setInteger("Duration", Integer.MAX_VALUE);
		effect.setInteger("Id", i);
		effects.appendTag(effect);
	}
	stack.setTagInfo("CustomPotionEffects", effects);
	stack.setStackDisplayName("�rSplash Potion of Trolling");
	
	// give potion
	if(InventoryUtils.placeStackInHotbar(stack))
		ChatUtils.message("Potion created.");
	else
		ChatUtils.error("Please clear a slot in your hotbar.");
	
	setEnabled(false);
}
 
开发者ID:Wurst-Imperium,项目名称:Wurst-MC-1.12,代码行数:34,代码来源:TrollPotionMod.java

示例12: getCraftingResult

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
 * Returns an Item that is the result of this recipe
 */
public ItemStack getCraftingResult(InventoryCrafting inv)
{
    int i = 0;
    ItemStack itemstack = null;

    for (int j = 0; j < inv.getSizeInventory(); ++j)
    {
        ItemStack itemstack1 = inv.getStackInSlot(j);

        if (itemstack1 != null)
        {
            if (itemstack1.getItem() == Items.filled_map)
            {
                if (itemstack != null)
                {
                    return null;
                }

                itemstack = itemstack1;
            }
            else
            {
                if (itemstack1.getItem() != Items.map)
                {
                    return null;
                }

                ++i;
            }
        }
    }

    if (itemstack != null && i >= 1)
    {
        ItemStack itemstack2 = new ItemStack(Items.filled_map, i + 1, itemstack.getMetadata());

        if (itemstack.hasDisplayName())
        {
            itemstack2.setStackDisplayName(itemstack.getDisplayName());
        }

        return itemstack2;
    }
    else
    {
        return null;
    }
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:52,代码来源:RecipesMapCloning.java

示例13: getUnlocalizedName

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Override
public String getUnlocalizedName(ItemStack stack) {
	stack.setStackDisplayName(getName(stack));
	return super.getUnlocalizedName(stack);
}
 
开发者ID:kenijey,项目名称:harshencastle,代码行数:6,代码来源:ItemLiquid.java

示例14: getCraftingResult

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
 * Returns an Item that is the result of this recipe
 */
public ItemStack getCraftingResult(InventoryCrafting inv)
{
    int i = 0;
    ItemStack itemstack = null;

    for (int j = 0; j < inv.getSizeInventory(); ++j)
    {
        ItemStack itemstack1 = inv.getStackInSlot(j);

        if (itemstack1 != null)
        {
            if (itemstack1.getItem() == Items.written_book)
            {
                if (itemstack != null)
                {
                    return null;
                }

                itemstack = itemstack1;
            }
            else
            {
                if (itemstack1.getItem() != Items.writable_book)
                {
                    return null;
                }

                ++i;
            }
        }
    }

    if (itemstack != null && i >= 1 && ItemEditableBook.getGeneration(itemstack) < 2)
    {
        ItemStack itemstack2 = new ItemStack(Items.written_book, i);
        itemstack2.setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy());
        itemstack2.getTagCompound().setInteger("generation", ItemEditableBook.getGeneration(itemstack) + 1);

        if (itemstack.hasDisplayName())
        {
            itemstack2.setStackDisplayName(itemstack.getDisplayName());
        }

        return itemstack2;
    }
    else
    {
        return null;
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:54,代码来源:RecipeBookCloning.java

示例15: getCraftingResult

import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
 * Returns an Item that is the result of this recipe
 */
public ItemStack getCraftingResult(InventoryCrafting inv)
{
    int i = 0;
    ItemStack itemstack = ItemStack.field_190927_a;

    for (int j = 0; j < inv.getSizeInventory(); ++j)
    {
        ItemStack itemstack1 = inv.getStackInSlot(j);

        if (!itemstack1.func_190926_b())
        {
            if (itemstack1.getItem() == Items.WRITTEN_BOOK)
            {
                if (!itemstack.func_190926_b())
                {
                    return ItemStack.field_190927_a;
                }

                itemstack = itemstack1;
            }
            else
            {
                if (itemstack1.getItem() != Items.WRITABLE_BOOK)
                {
                    return ItemStack.field_190927_a;
                }

                ++i;
            }
        }
    }

    if (!itemstack.func_190926_b() && itemstack.hasTagCompound() && i >= 1 && ItemWrittenBook.getGeneration(itemstack) < 2)
    {
        ItemStack itemstack2 = new ItemStack(Items.WRITTEN_BOOK, i);
        itemstack2.setTagCompound(itemstack.getTagCompound().copy());
        itemstack2.getTagCompound().setInteger("generation", ItemWrittenBook.getGeneration(itemstack) + 1);

        if (itemstack.hasDisplayName())
        {
            itemstack2.setStackDisplayName(itemstack.getDisplayName());
        }

        return itemstack2;
    }
    else
    {
        return ItemStack.field_190927_a;
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:54,代码来源:RecipeBookCloning.java


注:本文中的net.minecraft.item.ItemStack.setStackDisplayName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。