Java Code Examples for net.minecraft.item.ItemStack#hasDisplayName()
The following examples show how to use
net.minecraft.item.ItemStack#hasDisplayName() .
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: DispenserBehaviorMobEgg.java From Artifacts with MIT License | 6 votes |
/** * Dispense the specified stack, play the dispense sound and spawn particles. */ public ItemStack dispenseStack(IBlockSource par1IBlockSource, ItemStack par2ItemStack) { EnumFacing enumfacing = BlockDispenser.func_149937_b/*getFacing*/(par1IBlockSource.getBlockMetadata()); double d0 = par1IBlockSource.getX() + (double)enumfacing.getFrontOffsetX(); double d1 = (double)((float)par1IBlockSource.getYInt() + 0.2F) + enumfacing.getFrontOffsetY(); double d2 = par1IBlockSource.getZ() + (double)enumfacing.getFrontOffsetZ(); Entity entity = ItemMonsterPlacer.spawnCreature(par1IBlockSource.getWorld(), par2ItemStack.getItemDamage(), d0, d1, d2); if (entity instanceof EntityLiving && par2ItemStack.hasDisplayName()) { ((EntityLiving)entity).setCustomNameTag(par2ItemStack.getDisplayName()); } par2ItemStack.splitStack(1); return par2ItemStack; }
Example 2
Source File: ItemLocationBoundModular.java From enderutilities with GNU Lesser General Public License v3.0 | 6 votes |
@Override public String getTargetDisplayName(ItemStack stack) { ItemStack moduleStack = this.getSelectedModuleStack(stack, ModuleType.TYPE_LINKCRYSTAL); if (moduleStack.isEmpty() == false && moduleStack.getItem() instanceof ILocationBound) { if (moduleStack.hasDisplayName()) { // We need to get the name here directly, if we call ItemStack#getDisplayName(), it will recurse back to getItemStackDisplayName ;_; NBTTagCompound tag = moduleStack.getTagCompound().getCompoundTag("display"); return TextFormatting.ITALIC.toString() + tag.getString("Name") + TextFormatting.RESET.toString(); } return ((ILocationBound) moduleStack.getItem()).getTargetDisplayName(moduleStack); } return null; }
Example 3
Source File: BlockBloomeryFurnace.java From GardenCollection with MIT License | 6 votes |
@Override public void onBlockPlacedBy (World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack) { int dir = MathHelper.floor_double((double) (entity.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; switch (dir) { case 0: world.setBlockMetadataWithNotify(x, y, z, 2, 2); break; case 1: world.setBlockMetadataWithNotify(x, y, z, 5, 2); break; case 2: world.setBlockMetadataWithNotify(x, y, z, 3, 2); break; case 3: world.setBlockMetadataWithNotify(x, y, z, 4, 2); break; } if (stack.hasDisplayName()) { TileEntityBloomeryFurnace tile = (TileEntityBloomeryFurnace)world.getTileEntity(x, y, z); if (tile != null) tile.setCustomName(stack.getDisplayName()); } }
Example 4
Source File: BlockEngineeringTable.java From Cyberware with MIT License | 5 votes |
@Override public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) { if (stack.hasDisplayName()) { TileEntity tileentity = worldIn.getTileEntity(pos); if (tileentity instanceof TileEntityEngineeringTable) { ((TileEntityEngineeringTable) tileentity).setCustomInventoryName(stack.getDisplayName()); } } }
Example 5
Source File: BlockCarvableBeacon.java From Chisel-2 with GNU General Public License v2.0 | 5 votes |
@Override public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack) { super.onBlockPlacedBy(world, x, y, z, player, stack); if (stack.hasDisplayName()) { ((TileEntityCarvableBeacon) world.getTileEntity(x, y, z)).func_145999_a(stack.getDisplayName()); } }
Example 6
Source File: ItemLivingManipulator.java From enderutilities with GNU Lesser General Public License v3.0 | 5 votes |
@Override public String getItemStackDisplayName(ItemStack stack) { String str = super.getItemStackDisplayName(stack); String preGreen = TextFormatting.GREEN.toString(); String preGreenIta = preGreen + TextFormatting.ITALIC.toString(); String rst = TextFormatting.RESET.toString() + TextFormatting.WHITE.toString(); ItemStack moduleStack = this.getSelectedModuleStack(stack, ModuleType.TYPE_MEMORY_CARD_MISC); if (moduleStack.isEmpty() == false) { if (str.length() >= 14) { str = EUStringUtils.getInitialsWithDots(str); } // If the currently selected module has been renamed, show that name if (moduleStack.hasDisplayName()) { str = str + " " + preGreenIta + moduleStack.getDisplayName() + rst; } else { str = str + " MC: " + preGreen + (UtilItemModular.getClampedModuleSelection(stack, ModuleType.TYPE_MEMORY_CARD_MISC) + 1) + rst; } int index = this.getCurrentIndex(stack); int count = this.getStoredEntityCount(stack); str = str + " E: " + preGreen + (index + 1) + "/" + count + rst; String entityName = this.getEntityName(stack, index, true); if (entityName != null) { str = str + " -> " + entityName; } } return str; }
Example 7
Source File: ItemLocationBound.java From enderutilities with GNU Lesser General Public License v3.0 | 5 votes |
@Override public boolean shouldDisplayTargetName(ItemStack stack) { if (stack.hasDisplayName()) { return false; } String targetName = this.getTargetDisplayName(stack); return targetName != null && targetName.length() > 0; }
Example 8
Source File: ItemEntityEgg.java From Et-Futurum with The Unlicense | 5 votes |
@Override public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { if (world.isRemote) return stack; else { MovingObjectPosition movingobjectposition = getMovingObjectPositionFromPlayer(world, player, true); if (movingobjectposition == null) return stack; else { if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) { int i = movingobjectposition.blockX; int j = movingobjectposition.blockY; int k = movingobjectposition.blockZ; if (!world.canMineBlock(player, i, j, k)) return stack; if (!player.canPlayerEdit(i, j, k, movingobjectposition.sideHit, stack)) return stack; if (world.getBlock(i, j, k) instanceof BlockLiquid) { Entity entity = spawnEntity(world, stack.getItemDamage(), i, j, k); if (entity != null) { if (entity instanceof EntityLivingBase && stack.hasDisplayName()) ((EntityLiving) entity).setCustomNameTag(stack.getDisplayName()); if (!player.capabilities.isCreativeMode) stack.stackSize--; } } } return stack; } } }
Example 9
Source File: DispenserBehaviourSpawnEgg.java From Et-Futurum with The Unlicense | 5 votes |
@Override public ItemStack dispenseStack(IBlockSource block, ItemStack stack) { EnumFacing enumfacing = BlockDispenser.func_149937_b(block.getBlockMetadata()); double d0 = block.getX() + enumfacing.getFrontOffsetX(); double d1 = block.getYInt() + 0.2F; double d2 = block.getZ() + enumfacing.getFrontOffsetZ(); Entity entity = ItemEntityEgg.spawnEntity(block.getWorld(), stack.getItemDamage(), d0, d1, d2); if (entity instanceof EntityLivingBase && stack.hasDisplayName()) ((EntityLiving) entity).setCustomNameTag(stack.getDisplayName()); stack.splitStack(1); return stack; }
Example 10
Source File: ItemHandyBag.java From enderutilities with GNU Lesser General Public License v3.0 | 5 votes |
@Override public String getItemStackDisplayName(ItemStack stack) { ItemStack moduleStack = this.getSelectedModuleStack(stack, ModuleType.TYPE_MEMORY_CARD_ITEMS); if (moduleStack.isEmpty() == false && moduleStack.getTagCompound() != null) { String itemName = super.getItemStackDisplayName(stack); //I18n.format(this.getUnlocalizedName(stack) + ".name").trim(); String rst = TextFormatting.RESET.toString() + TextFormatting.WHITE.toString(); // If the currently selected module has been renamed, show that name if (moduleStack.hasDisplayName()) { String pre = TextFormatting.GREEN.toString() + TextFormatting.ITALIC.toString(); if (itemName.length() >= 14) { return EUStringUtils.getInitialsWithDots(itemName) + " " + pre + moduleStack.getDisplayName() + rst; } return itemName + " " + pre + moduleStack.getDisplayName() + rst; } return itemName; } return super.getItemStackDisplayName(stack); }
Example 11
Source File: BlockScanner.java From Cyberware with MIT License | 5 votes |
@Override public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) { if (stack.hasDisplayName()) { TileEntity tileentity = worldIn.getTileEntity(pos); if (tileentity instanceof TileEntityScanner) { ((TileEntityScanner) tileentity).setCustomInventoryName(stack.getDisplayName()); } } }
Example 12
Source File: BlockBlueprintArchive.java From Cyberware with MIT License | 5 votes |
@Override public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) { worldIn.setBlockState(pos, state.withProperty(FACING, placer.getHorizontalFacing().getOpposite()), 2); if (stack.hasDisplayName()) { TileEntity tileentity = worldIn.getTileEntity(pos); if (tileentity instanceof TileEntityBlueprintArchive) { ((TileEntityBlueprintArchive) tileentity).setCustomInventoryName(stack.getDisplayName()); } } }
Example 13
Source File: CooldownManager.java From SkyblockAddons with MIT License | 5 votes |
/** * Put an item on cooldown with provided cooldown, for items that do not show their cooldown * in their lore. * * @param item Item to put on cooldown * @param cooldown Cooldown in milliseconds */ public static void put(ItemStack item, long cooldown) { if(item == null || !item.hasDisplayName() || cooldown < 0) { return; } put(item.getDisplayName(), cooldown); }
Example 14
Source File: CooldownManager.java From SkyblockAddons with MIT License | 5 votes |
/** * Put an item on cooldown by reading the cooldown value from its lore. * * @param item ItemStack to put on cooldown */ public static void put(ItemStack item) { if(item == null || !item.hasDisplayName()) { return; } int cooldown = getLoreCooldown(item); if(cooldown > 0) { // cooldown is returned in seconds and required in milliseconds put(item.getDisplayName(), cooldown * 1000); } }
Example 15
Source File: ContainerBackpack.java From WearableBackpacks with MIT License | 5 votes |
public ContainerBackpack(EntityPlayer player, IBackpack backpack) { this.player = player; this.backpack = backpack; this.data = ((BackpackDataItems)backpack.getData()); size = data.getSize(); items = data.getItems(player.world, player); ItemStack stack = backpack.getStack(); title = (stack.hasDisplayName() ? stack.getDisplayName() : "container.wearablebackpacks.backpack"); titleLocalized = stack.hasDisplayName(); setupSlots(); }
Example 16
Source File: BaitManager.java From SkyblockAddons with MIT License | 4 votes |
/** * Re-count all baits in the inventory */ public void refreshBaits() { baitsInInventory.clear(); EntityPlayerSP player = Minecraft.getMinecraft().thePlayer; for (ItemStack itemStack : player.inventory.mainInventory) { if (itemStack == null || !itemStack.hasDisplayName()) continue; BaitType bait = BaitType.getByDisplayName(itemStack.getDisplayName()); if (bait == null) continue; baitsInInventory.put(bait, baitsInInventory.getOrDefault(bait, 0) + itemStack.stackSize); } }
Example 17
Source File: ItemEnderSword.java From enderutilities with GNU Lesser General Public License v3.0 | 4 votes |
@Override public void addTooltipLines(ItemStack stack, EntityPlayer player, List<String> list, boolean verbose) { ItemStack linkCrystalStack = this.getSelectedModuleStack(stack, ModuleType.TYPE_LINKCRYSTAL); ItemStack capacitorStack = this.getSelectedModuleStack(stack, ModuleType.TYPE_ENDERCAPACITOR); int coreTier = this.getSelectedModuleTier(stack, ModuleType.TYPE_ENDERCORE); String rst = TextFormatting.RESET.toString() + TextFormatting.GRAY.toString(); String preDGreen = TextFormatting.DARK_GREEN.toString(); String preBlue = TextFormatting.BLUE.toString(); // Drops mode SwordMode mode = SwordMode.fromStack(stack); String str = (mode == SwordMode.NORMAL ? "enderutilities.tooltip.item.normal" : mode == SwordMode.PLAYER ? "enderutilities.tooltip.item.endertool.playerinv" : mode == SwordMode.REMOTE ? "enderutilities.tooltip.item.endertool.remote" : "enderutilities.tooltip.item.endersword.summon"); str = I18n.format(str); list.add(I18n.format("enderutilities.tooltip.item.mode") + ": " + preDGreen + str + rst); // Installed Ender Core type str = I18n.format("enderutilities.tooltip.item.endercore") + ": "; if (coreTier >= ItemEnderPart.ENDER_CORE_TYPE_ACTIVE_BASIC && coreTier <= ItemEnderPart.ENDER_CORE_TYPE_ACTIVE_ADVANCED) { String coreType = (coreTier == ItemEnderPart.ENDER_CORE_TYPE_ACTIVE_BASIC ? "enderutilities.tooltip.item.basic" : (coreTier == ItemEnderPart.ENDER_CORE_TYPE_ACTIVE_ENHANCED ? "enderutilities.tooltip.item.enhanced" : "enderutilities.tooltip.item.advanced")); coreType = I18n.format(coreType); str += preDGreen + coreType + rst + " (" + preBlue + I18n.format("enderutilities.tooltip.item.tier") + " " + (coreTier + 1) + rst + ")"; } else { String preRed = TextFormatting.RED.toString(); str += preRed + I18n.format("enderutilities.tooltip.item.none") + rst; } list.add(str); // Link Crystals installed if (linkCrystalStack.isEmpty() == false && linkCrystalStack.getItem() instanceof ItemLinkCrystal) { String preWhiteIta = TextFormatting.WHITE.toString() + TextFormatting.ITALIC.toString(); // Valid target set in the currently selected Link Crystal if (TargetData.itemHasTargetTag(linkCrystalStack)) { ((ItemLinkCrystal) linkCrystalStack.getItem()).addTooltipLines(linkCrystalStack, player, list, verbose); } else { list.add(I18n.format("enderutilities.tooltip.item.notargetset")); } int num = UtilItemModular.getInstalledModuleCount(stack, ModuleType.TYPE_LINKCRYSTAL); int sel = UtilItemModular.getClampedModuleSelection(stack, ModuleType.TYPE_LINKCRYSTAL) + 1; String dName = (linkCrystalStack.hasDisplayName() ? preWhiteIta + linkCrystalStack.getDisplayName() + rst + " " : ""); list.add(I18n.format("enderutilities.tooltip.item.selectedlinkcrystal.short") + String.format(" %s(%s%d%s / %s%d%s)", dName, preBlue, sel, rst, preBlue, num, rst)); } else { list.add(I18n.format("enderutilities.tooltip.item.nolinkcrystals")); } // Capacitor installed if (capacitorStack.isEmpty() == false && capacitorStack.getItem() instanceof ItemEnderCapacitor) { ((ItemEnderCapacitor) capacitorStack.getItem()).addTooltipLines(capacitorStack, player, list, verbose); } }
Example 18
Source File: ItemInventorySwapper.java From enderutilities with GNU Lesser General Public License v3.0 | 4 votes |
@Override public void addTooltipLines(ItemStack containerStack, EntityPlayer player, List<String> list, boolean verbose) { if (containerStack.getTagCompound() == null) { return; } String preGreen = TextFormatting.GREEN.toString(); String preBlue = TextFormatting.BLUE.toString(); String preRed = TextFormatting.RED.toString(); String preWhite = TextFormatting.WHITE.toString(); String rst = TextFormatting.RESET.toString() + TextFormatting.GRAY.toString(); String strYes = preGreen + I18n.format("enderutilities.tooltip.item.yes") + rst; String strNo = preRed + I18n.format("enderutilities.tooltip.item.no") + rst; if (this.isEnabled(containerStack)) { list.add(I18n.format("enderutilities.tooltip.item.enabled") + ": " + strYes); } else { list.add(I18n.format("enderutilities.tooltip.item.enabled") + ": " + strNo); } if (NBTUtils.getBoolean(containerStack, TAG_NAME_CONTAINER, TAG_NAME_CYCLE_MODE)) { list.add(I18n.format("enderutilities.tooltip.item.cyclemode") + ": " + strYes); } else { list.add(I18n.format("enderutilities.tooltip.item.cyclemode") + ": " + strNo); } byte selected = NBTUtils.getByte(containerStack, TAG_NAME_CONTAINER, TAG_NAME_PRESET_SELECTION); list.add(I18n.format("enderutilities.tooltip.item.preset") + ": " + preBlue + (selected + 1) + rst); int installed = this.getInstalledModuleCount(containerStack, ModuleType.TYPE_MEMORY_CARD_ITEMS); if (installed > 0) { int slotNum = UtilItemModular.getStoredModuleSelection(containerStack, ModuleType.TYPE_MEMORY_CARD_ITEMS); String preWhiteIta = preWhite + TextFormatting.ITALIC.toString(); String strShort = I18n.format("enderutilities.tooltip.item.selectedmemorycard.short"); ItemStack moduleStack = UtilItemModular.getModuleStackBySlotNumber(containerStack, slotNum, ModuleType.TYPE_MEMORY_CARD_ITEMS); int max = this.getMaxModules(containerStack, ModuleType.TYPE_MEMORY_CARD_ITEMS); if (moduleStack.isEmpty() == false && moduleStack.getItem() == EnderUtilitiesItems.ENDER_PART) { String dName = (moduleStack.hasDisplayName() ? preWhiteIta + moduleStack.getDisplayName() + rst + " " : ""); list.add(String.format("%s %s (%s%d%s / %s%d%s)", strShort, dName, preBlue, slotNum + 1, rst, preBlue, max, rst)); ((ItemEnderPart) moduleStack.getItem()).addTooltipLines(moduleStack, player, list, false); return; } } else { list.add(I18n.format("enderutilities.tooltip.item.nomemorycards")); } }
Example 19
Source File: EntityPlayerSPHook.java From SkyblockAddons with MIT License | 4 votes |
public static EntityItem dropOneItemConfirmation(ReturnValue<?> returnValue) { SkyblockAddons main = SkyblockAddons.getInstance(); Minecraft mc = Minecraft.getMinecraft(); ItemStack heldItemStack = mc.thePlayer.getHeldItem(); if ((main.getUtils().isOnSkyblock() || main.getPlayerListener().aboutToJoinSkyblockServer())) { if (main.getConfigValues().isEnabled(Feature.LOCK_SLOTS) && !main.getUtils().isInDungeon()) { int slot = mc.thePlayer.inventory.currentItem + 36; if (main.getConfigValues().getLockedSlots().contains(slot) && (slot >= 9 || mc.thePlayer.openContainer instanceof ContainerPlayer && slot >= 5)) { main.getUtils().playLoudSound("note.bass", 0.5); SkyblockAddons.getInstance().getUtils().sendMessage(main.getConfigValues().getRestrictedColor(Feature.DROP_CONFIRMATION) + Message.MESSAGE_SLOT_LOCKED.getMessage()); returnValue.cancel(); return null; } if (System.currentTimeMillis() - MinecraftHook.getLastLockedSlotItemChange() < 200) { main.getUtils().playLoudSound("note.bass", 0.5); SkyblockAddons.getInstance().getUtils().sendMessage(main.getConfigValues().getRestrictedColor(Feature.DROP_CONFIRMATION) + Message.MESSAGE_SWITCHED_SLOTS.getMessage()); returnValue.cancel(); return null; } } if (heldItemStack != null && main.getConfigValues().isEnabled(Feature.STOP_DROPPING_SELLING_RARE_ITEMS) && !main.getUtils().isInDungeon()) { if (!main.getUtils().getItemDropChecker().canDropItem(heldItemStack, true)) { main.getUtils().sendMessage(main.getConfigValues().getRestrictedColor(Feature.STOP_DROPPING_SELLING_RARE_ITEMS) + Message.MESSAGE_CANCELLED_DROPPING.getMessage()); returnValue.cancel(); return null; } if (System.currentTimeMillis() - MinecraftHook.getLastLockedSlotItemChange() < 200) { main.getUtils().playLoudSound("note.bass", 0.5); SkyblockAddons.getInstance().getUtils().sendMessage(main.getConfigValues().getRestrictedColor(Feature.DROP_CONFIRMATION) + Message.MESSAGE_SWITCHED_SLOTS.getMessage()); returnValue.cancel(); return null; } } } if (heldItemStack != null && main.getConfigValues().isEnabled(Feature.DROP_CONFIRMATION) && !main.getUtils().isInDungeon() && (main.getUtils().isOnSkyblock() || main.getPlayerListener().aboutToJoinSkyblockServer() || main.getConfigValues().isEnabled(Feature.DOUBLE_DROP_IN_OTHER_GAMES))) { lastDrop = Minecraft.getSystemTime(); String heldItemName = heldItemStack.hasDisplayName() ? heldItemStack.getDisplayName() : heldItemStack.getUnlocalizedName(); if (lastItemName == null || !lastItemName.equals(heldItemName) || Minecraft.getSystemTime() - lastDrop >= 3000L) { SkyblockAddons.getInstance().getUtils().sendMessage(main.getConfigValues().getRestrictedColor(Feature.DROP_CONFIRMATION) + Message.MESSAGE_DROP_CONFIRMATION.getMessage()); lastItemName = heldItemName; returnValue.cancel(); } } return null; }
Example 20
Source File: GuiChestHook.java From SkyblockAddons with MIT License | 4 votes |
public static void handleMouseClick(Slot slotIn, Container slots, IInventory lowerChestInventory, ReturnValue<?> returnValue) { SkyblockAddons main = SkyblockAddons.getInstance(); if (main.getUtils().getEnchantmentMatches().size() > 0) { if (slotIn != null && !slotIn.inventory.equals(Minecraft.getMinecraft().thePlayer.inventory) && slotIn.getHasStack()) { if (slotIn.getSlotIndex() == 13 && EnumUtils.InventoryType.getCurrentInventoryType() == EnumUtils.InventoryType.ENCHANTMENT_TABLE) { ItemStack[] enchantBottles = {slots.getSlot(29).getStack(), slots.getSlot(31).getStack(), slots.getSlot(33).getStack()}; for (ItemStack bottle : enchantBottles) { if (bottle != null && bottle.hasDisplayName()) { if (bottle.getDisplayName().startsWith(ChatFormatting.GREEN + "Enchant Item")) { Minecraft mc = Minecraft.getMinecraft(); List<String> toolip = bottle.getTooltip(mc.thePlayer, false); if (toolip.size() > 2) { String[] lines = toolip.get(2).split(Pattern.quote("* ")); if (lines.length > 1) { String enchantLine = lines[1]; if (main.getUtils().enchantReforgeMatches(enchantLine)) { main.getUtils().playLoudSound("random.orb", 0.1); returnValue.cancel(); } } } } else if (bottle.getDisplayName().startsWith(ChatFormatting.RED + "Enchant Item")) { // Stop player from removing item before the enchants have even loaded. returnValue.cancel(); } } } } else if (slotIn.getSlotIndex() == 22 && EnumUtils.InventoryType.getCurrentInventoryType() == EnumUtils.InventoryType.REFORGE_ANVIL) { Slot itemSlot = slots.getSlot(13); if (itemSlot != null && itemSlot.getHasStack()) { ItemStack item = itemSlot.getStack(); if (item.hasDisplayName()) { String reforge = main.getUtils().getReforgeFromItem(item); if (reforge != null) { if (main.getUtils().enchantReforgeMatches(reforge)) { main.getUtils().playLoudSound("random.orb", 0.1); returnValue.cancel(); } } } } } } } if (main.getConfigValues().isEnabled(Feature.STOP_DROPPING_SELLING_RARE_ITEMS) && !main.getUtils().isInDungeon() && lowerChestInventory.hasCustomName() && NPCUtils.isFullMerchant(lowerChestInventory.getDisplayName().getUnformattedText()) && slotIn != null && slotIn.inventory instanceof InventoryPlayer) { if (!main.getUtils().getItemDropChecker().canDropItem(slotIn)) { returnValue.cancel(); } } }