Java Code Examples for net.minecraft.item.ItemStack#setStackDisplayName()

The following examples show how to use net.minecraft.item.ItemStack#setStackDisplayName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ItemCoordinateCache.java    From ModdingTutorials with GNU General Public License v2.0 6 votes vote down vote up
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)
{
	if(!playerIn.isSneaking())
	{
		if(stack.getTagCompound() == null)
		{
			stack.setTagCompound(new NBTTagCompound());
		}
		NBTTagCompound nbt = new NBTTagCompound();
		nbt.setInteger("dim", playerIn.dimension);
		nbt.setInteger("posX", pos.getX());
		nbt.setInteger("posY", pos.getY());
		nbt.setInteger("posZ", pos.getZ());
		stack.getTagCompound().setTag("coords", nbt);
		stack.setStackDisplayName(EnumChatFormatting.DARK_PURPLE + "Coordinate Cache");
	}
	return false;
}
 
Example 2
Source File: ItemCoordinateCache.java    From ModdingTutorials with GNU General Public License v2.0 6 votes vote down vote up
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)
{
	if(!playerIn.isSneaking())
	{
		if(stack.getTagCompound() == null)
		{
			stack.setTagCompound(new NBTTagCompound());
		}
		NBTTagCompound nbt = new NBTTagCompound();
		nbt.setInteger("dim", playerIn.dimension);
		nbt.setInteger("posX", pos.getX());
		nbt.setInteger("posY", pos.getY());
		nbt.setInteger("posZ", pos.getZ());
		stack.getTagCompound().setTag("coords", nbt);
		stack.setStackDisplayName(EnumChatFormatting.DARK_PURPLE + "Coordinate Cache");
	}
	return false;
}
 
Example 3
Source File: AnvilUpdateEventHandler.java    From enderutilities with GNU Lesser General Public License v3.0 6 votes vote down vote up
private void updateItemName(AnvilUpdateEvent event, ItemStack outputStack)
{
    String name = event.getName();

    if (StringUtils.isBlank(name) == false)
    {
        outputStack.setStackDisplayName(name);
        event.setCost(event.getCost() + 1);
    }
    else if (outputStack.hasDisplayName())
    {
        // Remove the custom name
        outputStack.clearCustomName();
        event.setCost(event.getCost() + 1);
    }
}
 
Example 4
Source File: ShopkeeperTradesForMoon.java    From ToroQuest with GNU General Public License v3.0 5 votes vote down vote up
private static ItemStack level2Sword() {
	ItemStack stack = new ItemStack(Items.IRON_SWORD);
	stack.setStackDisplayName("Moon Sword II");
	stack.addEnchantment(Enchantment.REGISTRY.getObjectById(16), 1);
	stack.addEnchantment(Enchantment.REGISTRY.getObjectById(17), 2);
	stack.addEnchantment(Enchantment.REGISTRY.getObjectById(18), 2);
	return stack;
}
 
Example 5
Source File: ShopkeeperTradesForWater.java    From ToroQuest with GNU General Public License v3.0 5 votes vote down vote up
private static ItemStack level3Helmet() {
	ItemStack stack = new ItemStack(Items.DIAMOND_HELMET);
	stack.setStackDisplayName("Charybdis Helmet");
	stack.addEnchantment(Enchantment.REGISTRY.getObjectById(0), 1);
	stack.addEnchantment(Enchantment.REGISTRY.getObjectById(6), 2);
	stack.addEnchantment(Enchantment.REGISTRY.getObjectById(5), 2);
	return stack;
}
 
Example 6
Source File: ShopkeeperTradesForWater.java    From ToroQuest with GNU General Public License v3.0 5 votes vote down vote up
private static ItemStack loChangsRod() {
	ItemStack stack = new ItemStack(Items.FISHING_ROD);
	stack.setStackDisplayName("Lo Chang's Rod");
	stack.addEnchantment(Enchantment.REGISTRY.getObjectById(61), 4);
	stack.addEnchantment(Enchantment.REGISTRY.getObjectById(34), 4);
	stack.addEnchantment(Enchantment.REGISTRY.getObjectById(62), 4);
	return stack;
}
 
Example 7
Source File: ShopkeeperTradesForSun.java    From ToroQuest with GNU General Public License v3.0 5 votes vote down vote up
private static ItemStack level4Sword() {
	ItemStack stack = new ItemStack(Items.DIAMOND_SWORD);
	stack.setStackDisplayName("Amaterasu Sword");
	stack.addEnchantment(Enchantment.REGISTRY.getObjectById(17), 3);
	stack.addEnchantment(Enchantment.REGISTRY.getObjectById(16), 3);
	return stack;
}
 
Example 8
Source File: ShopkeeperTradesForEarth.java    From ToroQuest with GNU General Public License v3.0 5 votes vote down vote up
private static ItemStack level4Pick() {
	ItemStack stack = new ItemStack(Items.DIAMOND_PICKAXE);
	stack.setStackDisplayName("Gaea Pickaxe");
	stack.addEnchantment(Enchantment.REGISTRY.getObjectById(32), 3);
	stack.addEnchantment(Enchantment.REGISTRY.getObjectById(34), 2);
	stack.addEnchantment(Enchantment.REGISTRY.getObjectById(35), 1);
	return stack;
}
 
Example 9
Source File: ItemFamiliar_Old.java    From Gadomancy with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static ItemStack getPaybackPackage(ItemStack oldFamiliarStack) {
    if(oldFamiliarStack == null || !(oldFamiliarStack.getItem() instanceof ItemFamiliar_Old)) return null;
    ItemStack arcPackage = new ItemStack(RegisteredItems.itemPackage, 1, 2);
    List<ItemStack> contents = new ArrayList<ItemStack>();
    arcPackage.setStackDisplayName(EnumChatFormatting.GOLD + "Used Familiar Items");

    DeprecationItemPaybacks.addFamiliarCraftingPaybackStack(contents, oldFamiliarStack);

    if(RegisteredItems.itemFamiliar_old.hasUpgrade(oldFamiliarStack, FamiliarUpgrade.ATTACK_1)) {
        DeprecationItemPaybacks.addFamiliarAttack1Payback(contents, oldFamiliarStack);
    }
    if(RegisteredItems.itemFamiliar_old.hasUpgrade(oldFamiliarStack, FamiliarUpgrade.ATTACK_2)) {
        DeprecationItemPaybacks.addFamiliarAttack2Payback(contents, oldFamiliarStack);
    }
    if(RegisteredItems.itemFamiliar_old.hasUpgrade(oldFamiliarStack, FamiliarUpgrade.ATTACK_3)) {
        DeprecationItemPaybacks.addFamiliarAttack3Payback(contents, oldFamiliarStack);
    }
    if(RegisteredItems.itemFamiliar_old.hasUpgrade(oldFamiliarStack, FamiliarUpgrade.COOLDOWN_1)) {
        DeprecationItemPaybacks.addFamiliarCooldownPayback(contents, oldFamiliarStack);
    }
    if(RegisteredItems.itemFamiliar_old.hasUpgrade(oldFamiliarStack, FamiliarUpgrade.RANGE_1)) {
        DeprecationItemPaybacks.addFamiliarRangePayback(contents, oldFamiliarStack);
    }

    RegisteredItems.itemPackage.setContents(arcPackage, contents);

    return arcPackage;
}
 
Example 10
Source File: BlockComponentBox.java    From Cyberware with MIT License 5 votes vote down vote up
private ItemStack getStack(TileEntityComponentBox box)
{
	ItemStack stackToDrop = new ItemStack(ib);

	NBTTagCompound compound = new NBTTagCompound();
	compound.setTag("contents", box.slots.serializeNBT());
	stackToDrop.setTagCompound(compound);
	
	if (box.hasCustomName())
	{
		stackToDrop = stackToDrop.setStackDisplayName(box.getName());
	}
	return stackToDrop;
}
 
Example 11
Source File: ShopkeeperTradesForMoon.java    From ToroQuest with GNU General Public License v3.0 5 votes vote down vote up
private static ItemStack level4Sword() {
	ItemStack stack = new ItemStack(Items.DIAMOND_SWORD);
	stack.setStackDisplayName("Moon Sword IV");
	stack.addEnchantment(Enchantment.REGISTRY.getObjectById(16), 2);
	stack.addEnchantment(Enchantment.REGISTRY.getObjectById(17), 4);
	stack.addEnchantment(Enchantment.REGISTRY.getObjectById(18), 4);
	return stack;
}
 
Example 12
Source File: HandEntity.java    From pycode-minecraft with MIT License 5 votes vote down vote up
/**
 * Called when the entity is attacked.
 */
public boolean attackEntityFrom(DamageSource source, float amount) {
    if (!this.worldObj.isRemote && !this.isDead) {
        if (this.isEntityInvulnerable(source)) {
            return false;
        } else {
            this.setBeenAttacked();
            this.removePassengers();
            this.setDead();
            if (this.worldObj.getGameRules().getBoolean("doEntityDrops")) {
                ItemStack itemstack = new ItemStack(ModItems.python_hand, 1);
                itemstack.setStackDisplayName(this.getName());
                if (!itemstack.hasTagCompound()) {
                    itemstack.setTagCompound(new NBTTagCompound());
                }
                NBTTagCompound compound = itemstack.getTagCompound();
                if (compound == null) {
                    FMLLog.severe("Python Hand itemstack NBT missing??");
                } else {
                    this.writeToNBT(compound);
                }
                this.entityDropItem(itemstack, 0.0F);
            }

            return true;
        }
    } else {
        return true;
    }
}
 
Example 13
Source File: QuestCourier.java    From ToroQuest with GNU General Public License v3.0 5 votes vote down vote up
@Override
public List<ItemStack> accept(QuestData data, List<ItemStack> in) {
	Province deliverToProvince = getDeliverToProvince(data);
	ItemStack note = new ItemStack(Items.PAPER);
	note.setStackDisplayName("Deliver to the Lord of " + deliverToProvince.name);
	note.setTagInfo("toProvince", new NBTTagString(deliverToProvince.id.toString()));
	note.setTagInfo("questId", new NBTTagString(data.getQuestId().toString()));
	in.add(note);
	return in;
}
 
Example 14
Source File: EntityDrone.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onDeath(DamageSource par1DamageSource){
    for(int i = 0; i < inventory.getSizeInventory(); i++) {
        if(inventory.getStackInSlot(i) != null) {
            entityDropItem(inventory.getStackInSlot(i), 0);
            inventory.setInventorySlotContents(i, null);
        }
    }
    if(naturallySpawned) {

    } else {
        ItemStack drone = getDroppedStack();
        if(hasCustomNameTag()) drone.setStackDisplayName(getCustomNameTag());

        entityDropItem(drone, 0);

        if(!worldObj.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(hasCustomNameTag()) {
                    owner.addChatComponentMessage(new ChatComponentTranslation("death.drone.named", getCustomNameTag(), x, y, z));
                } else {
                    owner.addChatComponentMessage(new ChatComponentTranslation("death.drone", x, y, z));
                }
            }
        }
    }
    if(!worldObj.isRemote) ((FakePlayerItemInWorldManager)getFakePlayer().theItemInWorldManager).cancelDigging();
    super.onDeath(par1DamageSource);
}
 
Example 15
Source File: ShopkeeperTradesForFire.java    From ToroQuest with GNU General Public License v3.0 4 votes vote down vote up
private static ItemStack level1Sword() {
	ItemStack stack = new ItemStack(Items.IRON_SWORD);
	stack.setStackDisplayName("Logi Sword");
	stack.addEnchantment(Enchantment.REGISTRY.getObjectById(20), 1);
	return stack;
}
 
Example 16
Source File: ShopkeeperTradesForFire.java    From ToroQuest with GNU General Public License v3.0 4 votes vote down vote up
private static ItemStack level2FireProtection() {
	ItemStack stack = new ItemStack(Items.ENCHANTED_BOOK);
	stack.setStackDisplayName("Fire Protection II");
	ItemEnchantedBook.addEnchantment(stack, new EnchantmentData(Enchantment.REGISTRY.getObjectById(1), 2));
	return stack;
}
 
Example 17
Source File: ShopkeeperTradesForWater.java    From ToroQuest with GNU General Public License v3.0 4 votes vote down vote up
private static ItemStack level1Helmet() {
	ItemStack stack = new ItemStack(Items.LEATHER_HELMET);
	stack.setStackDisplayName("Delphin Helmet");
	stack.addEnchantment(Enchantment.REGISTRY.getObjectById(6), 1);
	return stack;
}
 
Example 18
Source File: ShopkeeperTradesForFire.java    From ToroQuest with GNU General Public License v3.0 4 votes vote down vote up
private static ItemStack level4FireProtection() {
	ItemStack stack = new ItemStack(Items.ENCHANTED_BOOK);
	stack.setStackDisplayName("Fire Protection IV");
	ItemEnchantedBook.addEnchantment(stack, new EnchantmentData(Enchantment.REGISTRY.getObjectById(1), 4));
	return stack;
}
 
Example 19
Source File: ShopkeeperTradesForFire.java    From ToroQuest with GNU General Public License v3.0 4 votes vote down vote up
private static ItemStack level1FireProtection() {
	ItemStack stack = new ItemStack(Items.ENCHANTED_BOOK);
	stack.setStackDisplayName("Fire Protection I");
	ItemEnchantedBook.addEnchantment(stack, new EnchantmentData(Enchantment.REGISTRY.getObjectById(1), 1));
	return stack;
}
 
Example 20
Source File: ShopkeeperTradesForFire.java    From ToroQuest with GNU General Public License v3.0 4 votes vote down vote up
private static ItemStack level3Sword() {
	ItemStack stack = new ItemStack(Items.DIAMOND_SWORD);
	stack.setStackDisplayName("Agni Sword");
	stack.addEnchantment(Enchantment.REGISTRY.getObjectById(20), 1);
	return stack;
}