Java Code Examples for net.minecraft.nbt.NBTTagCompound#hasNoTags()
The following examples show how to use
net.minecraft.nbt.NBTTagCompound#hasNoTags() .
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: ItemBlockRemoteJar.java From Gadomancy with GNU Lesser General Public License v3.0 | 6 votes |
@Override public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { if(!world.isRemote) { if(player.isSneaking()) { NBTTagCompound compound = NBTHelper.getData(stack); if(compound.hasKey("networkId")) { compound.removeTag("networkId"); if(compound.hasNoTags()) { stack.setTagCompound(null); } player.addChatComponentMessage(new ChatComponentTranslation("gadomancy.info.RemoteJar.clear")); } } } return super.onItemRightClick(stack, world, player); }
Example 2
Source File: ContainerTFC.java From TFC2 with GNU General Public License v3.0 | 6 votes |
public static boolean areCompoundsEqual(ItemStack is1, ItemStack is2) { ItemStack is3 = is1.copy(); ItemStack is4 = is2.copy(); NBTTagCompound is3Tags = is3.getTagCompound(); NBTTagCompound is4Tags = is4.getTagCompound(); if (is3Tags == null) return is4Tags == null || is4Tags.hasNoTags(); if (is4Tags == null) return is3Tags.hasNoTags(); //Removed during porting this code to 1.8 due to there not being any heat infrastructure at the time. /*float temp3 = TFC_ItemHeat.getTemp(is1); float temp4 = TFC_ItemHeat.getTemp(is2); is3Tags.removeTag("temp"); is4Tags.removeTag("temp");*/ is3Tags.removeTag("Expiration"); is4Tags.removeTag("Expiration"); return is3Tags.equals(is4Tags) /*&& Math.abs(temp3 - temp4) < 5*/; }
Example 3
Source File: ItemLantern.java From GardenCollection with MIT License | 6 votes |
public ItemStack makeItemStack (int count, int meta, boolean hasGlass, String source, int sourceMeta) { ItemStack stack = new ItemStack(this, count, meta); NBTTagCompound tag = new NBTTagCompound(); if (hasGlass) tag.setBoolean("glass", true); if (source != null) tag.setString("src", source); if (sourceMeta != 0) tag.setShort("srcMeta", (short)sourceMeta); if (!tag.hasNoTags()) stack.setTagCompound(tag); return stack; }
Example 4
Source File: BlockMachine.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void getDrops(NonNullList<ItemStack> drops, IBlockAccess world, BlockPos pos, IBlockState state, int fortune) { MetaTileEntity metaTileEntity = tileEntities.get() == null ? getMetaTileEntity(world, pos) : tileEntities.get(); if (metaTileEntity == null) return; if (!metaTileEntity.shouldDropWhenDestroyed()) return; ItemStack itemStack = metaTileEntity.getStackForm(); NBTTagCompound tagCompound = new NBTTagCompound(); metaTileEntity.writeItemStackData(tagCompound); //only set item tag if it's not empty, so newly created items will stack with dismantled if (!tagCompound.hasNoTags()) itemStack.setTagCompound(tagCompound); drops.add(itemStack); metaTileEntity.getDrops(drops, harvesters.get()); }
Example 5
Source File: Tooltips.java From TinkersToolLeveling with MIT License | 5 votes |
public static void addTooltips(ItemStack itemStack, List<String> tooltips) { NBTTagCompound tag = TinkerUtil.getModifierTag(itemStack, TinkerToolLeveling.modToolLeveling.getModifierIdentifier()); if(!tag.hasNoTags()) { ToolLevelNBT data = new ToolLevelNBT(tag); if(Config.canLevelUp(data.level)) { tooltips.add(1, getXpToolTip(data.xp, TinkerToolLeveling.modToolLeveling.getXpForLevelup(data.level, itemStack))); } tooltips.add(1, getLevelTooltip(data.level)); } }
Example 6
Source File: NBTHelper.java From Levels with GNU General Public License v2.0 | 5 votes |
public static void saveStackNBT(ItemStack stack, NBTTagCompound nbt) { if (!stack.hasTagCompound() && !nbt.hasNoTags()) { stack.setTagCompound(nbt); } }
Example 7
Source File: NameRemover.java From NewHorizonsCoreMod with GNU General Public License v3.0 | 4 votes |
@Override public int checkRecipe() { if(getInputAt(0) == null) return 0; ItemStack output = getInputAt(0).copy(); NBTTagCompound nbt=output.getTagCompound(); boolean removeName = false, removeDisassembly = false; if(nbt!=null) { ItemStack circuit = getInputAt(1); int circuitSetting = 0; if (circuit != null && circuit.getItem() instanceof GT_IntegratedCircuit_Item) circuitSetting = circuit.getItemDamage(); switch (circuitSetting) { case 1: removeName = true; break; case 2: removeDisassembly = true; break; default: removeName = true; removeDisassembly = true; } if (removeName && nbt.hasKey("display")) { nbt.getCompoundTag("display").removeTag("Name"); if (nbt.getCompoundTag("display").hasNoTags()) { nbt.removeTag("display"); } } if (removeDisassembly && nbt.hasKey("GT.CraftingComponents")) { nbt.removeTag("GT.CraftingComponents"); } if (nbt.hasNoTags()) { output.setTagCompound(null); } } if(canOutput(output)) { getInputAt(0).stackSize = 0; mEUt=0; mMaxProgresstime=20; mOutputItems[0] = output; return 2; } return 0; }
Example 8
Source File: EventHandlerWorld.java From Gadomancy with GNU Lesser General Public License v3.0 | 4 votes |
@SubscribeEvent public void on(TickEvent.WorldTickEvent event) { if(event.phase == TickEvent.Phase.START && !event.world.isRemote && event.world.getTotalWorldTime() % 10 == 0) { Iterator<Map.Entry<EntityItem, Long>> iterator = trackedItems.entrySet().iterator(); while(iterator.hasNext()) { Map.Entry<EntityItem, Long> entry = iterator.next(); EntityItem entity = entry.getKey(); if(event.world == entity.worldObj) { if(entity.isDead || !isDisguised(entity.getEntityItem())) { iterator.remove(); continue; } int x = MathHelper.floor_double(entity.posX); int y = MathHelper.floor_double(entity.posY); int z = MathHelper.floor_double(entity.posZ); if(entity.delayBeforeCanPickup <= 0 && entity.worldObj.getTotalWorldTime() - entry.getValue() > 0) { if(ConfigBlocks.blockFluidPure == event.world.getBlock(x, y, z) && event.world.getBlockMetadata(x, y, z) == 0) { NBTTagCompound compound = NBTHelper.getPersistentData(entity.getEntityItem()); NBTBase base = compound.getTag("disguise"); if(base instanceof NBTTagCompound) { ItemStack stack = ItemStack.loadItemStackFromNBT((NBTTagCompound) base); EntityItem newEntity = new EntityItem(event.world, entity.posX, entity.posY, entity.posZ, stack); ItemUtils.applyRandomDropOffset(newEntity, event.world.rand); event.world.spawnEntityInWorld(newEntity); } compound.removeTag("disguise"); if(compound.hasNoTags()) { NBTHelper.removePersistentData(entity.getEntityItem()); if(entity.getEntityItem().getTagCompound().hasNoTags()) { entity.getEntityItem().setTagCompound(null); } } event.world.setBlockToAir(x, y, z); } } else { Gadomancy.proxy.spawnBubbles(event.world, (float)entity.posX, (float)entity.posY, (float)entity.posZ, 0.2f); } } } } }