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


Java NBTBase类代码示例

本文整理汇总了Java中net.minecraft.nbt.NBTBase的典型用法代码示例。如果您正苦于以下问题:Java NBTBase类的具体用法?Java NBTBase怎么用?Java NBTBase使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: deserializeNBT

import net.minecraft.nbt.NBTBase; //导入依赖的package包/类
@Override
public void deserializeNBT(NBTBase nbtIn) {
	if (nbtIn instanceof NBTTagCompound) {
		NBTTagCompound nbt = (NBTTagCompound) nbtIn;
		setSize(nbt.hasKey("Size", Constants.NBT.TAG_INT) ? nbt.getInteger("Size") : stacks.size());
		NBTTagList tagList = nbt.getTagList(getName(), Constants.NBT.TAG_COMPOUND);
		for (int i = 0; i < tagList.tagCount(); i++) {
			NBTTagCompound itemTags = tagList.getCompoundTagAt(i);
			int slot = itemTags.getInteger("Slot");

			if (slot >= 0 && slot < stacks.size()) {
				stacks.set(slot, new ItemStack(itemTags));
				stacks.get(slot).setCount(itemTags.getInteger("RealCount"));
			}
		}
		CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.readNBT(this, null, tagList);
		onLoad();
	}
}
 
开发者ID:p455w0rd,项目名称:DankNull,代码行数:20,代码来源:DankNullItemHandler.java

示例2: writeNBT

import net.minecraft.nbt.NBTBase; //导入依赖的package包/类
@Nullable
@Override
public NBTBase writeNBT(Capability<IHacking> capability, IHacking instance, EnumFacing side) {
    NBTTagCompound compound = new NBTTagCompound();
    if (!instance.getCurrentHacks().isEmpty()) {
        NBTTagList tagList = new NBTTagList();
        for (IHackableEntity hackableEntity : instance.getCurrentHacks()) {
            if (hackableEntity.getId() != null) {
                NBTTagCompound tag = new NBTTagCompound();
                tag.setString("id", hackableEntity.getId());
                tagList.appendTag(tag);
            }
        }
        compound.setTag("hackables", tagList);
    }
    return compound;
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:18,代码来源:HackingImpl.java

示例3: merge

import net.minecraft.nbt.NBTBase; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public void merge(NBTTagCompound nbt, NBTTagCompound other) {
	Iterator<String> iterator = other.func_150296_c().iterator();

	while (iterator.hasNext()) {
		String s = iterator.next();
		NBTBase nbtbase = other.getTag(s);

		if (nbtbase.getId() == 10) {
			if (nbt.hasKey(s, 10)) {
				NBTTagCompound nbttagcompound1 = nbt.getCompoundTag(s);
				merge(nbttagcompound1, (NBTTagCompound) nbtbase);
			} else
				nbt.setTag(s, nbtbase.copy());
		} else
			nbt.setTag(s, nbtbase.copy());
	}
}
 
开发者ID:jm-organization,项目名称:connor41-etfuturum2,代码行数:19,代码来源:ItemArmourStand.java

示例4: loadItems

import net.minecraft.nbt.NBTBase; //导入依赖的package包/类
private void loadItems(NBTTagCompound cmp) {
	NBTTagList nbttaglist = cmp.getTagList(TAG_INGREDIENTS, 10);
	if (nbttaglist.hasNoTags()) ingredients.clear();
	for (NBTBase nbt : nbttaglist) {
		if (nbt instanceof NBTTagCompound) {
			ingredients.add(new ItemStack((NBTTagCompound) nbt));
		}
	}

	if (cmp.hasKey(TAG_CONTAINER)) {
		NBTTagCompound tag = cmp.getCompoundTag(TAG_CONTAINER);
		container = new ItemStack(tag);
	} else {
		container = ItemStack.EMPTY;
	}
}
 
开发者ID:Um-Mitternacht,项目名称:Bewitchment,代码行数:17,代码来源:TileCauldron.java

示例5: parseStructureData

import net.minecraft.nbt.NBTBase; //导入依赖的package包/类
private static Set<Long> parseStructureData(MapGenStructureData data) {
    Set<Long> chunks = new HashSet<>();
    NBTTagCompound nbttagcompound = data.getTagCompound();

    for (String s : nbttagcompound.getKeySet()) {
        NBTBase nbtbase = nbttagcompound.getTag(s);

        if (nbtbase.getId() == 10) {
            NBTTagCompound nbttagcompound1 = (NBTTagCompound) nbtbase;

            if (nbttagcompound1.hasKey("ChunkX") && nbttagcompound1.hasKey("ChunkZ")) {
                int i = nbttagcompound1.getInteger("ChunkX");
                int j = nbttagcompound1.getInteger("ChunkZ");
                chunks.add(ChunkPos.asLong(i, j));
            }
        }
    }
    return chunks;
}
 
开发者ID:McJty,项目名称:InControl,代码行数:20,代码来源:StructureCache.java

示例6: getChildTag

import net.minecraft.nbt.NBTBase; //导入依赖的package包/类
private static NBTBase getChildTag(NBTBase p_getChildTag_0_, String p_getChildTag_1_)
{
    if (p_getChildTag_0_ instanceof NBTTagCompound)
    {
        NBTTagCompound nbttagcompound = (NBTTagCompound)p_getChildTag_0_;
        return nbttagcompound.getTag(p_getChildTag_1_);
    }
    else if (p_getChildTag_0_ instanceof NBTTagList)
    {
        NBTTagList nbttaglist = (NBTTagList)p_getChildTag_0_;

        if (p_getChildTag_1_.equals("count"))
        {
            return new NBTTagInt(nbttaglist.tagCount());
        }
        else
        {
            int i = Config.parseInt(p_getChildTag_1_, -1);
            return i < 0 ? null : nbttaglist.get(i);
        }
    }
    else
    {
        return null;
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:27,代码来源:NbtTagValue.java

示例7: getChildTag

import net.minecraft.nbt.NBTBase; //导入依赖的package包/类
private static NBTBase getChildTag(NBTBase p_getChildTag_0_, String p_getChildTag_1_)
{
    if (p_getChildTag_0_ instanceof NBTTagCompound)
    {
        NBTTagCompound nbttagcompound = (NBTTagCompound)p_getChildTag_0_;
        return nbttagcompound.getTag(p_getChildTag_1_);
    }
    else if (p_getChildTag_0_ instanceof NBTTagList)
    {
        NBTTagList nbttaglist = (NBTTagList)p_getChildTag_0_;
        int i = Config.parseInt(p_getChildTag_1_, -1);
        return i < 0 ? null : nbttaglist.get(i);
    }
    else
    {
        return null;
    }
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:19,代码来源:NbtTagValue.java

示例8: parse

import net.minecraft.nbt.NBTBase; //导入依赖的package包/类
/**
 * Parses the JSON string contained in this object.
 * @return an {@link NBTBase} which can be safely cast to the type represented by this class.
 */
@Override
public NBTBase parse() throws NBTException
{
	NBTTagCompound nbttagcompound = new NBTTagCompound();

	for (JsonToNBT.Any jsontonbt$any : this.tagList)
	{
		nbttagcompound.setTag(jsontonbt$any.json, jsontonbt$any.parse());
	}

	return nbttagcompound;
}
 
开发者ID:crazysnailboy,项目名称:VillagerTrades,代码行数:17,代码来源:JsonToNBT.java

示例9: readFromNBT

import net.minecraft.nbt.NBTBase; //导入依赖的package包/类
@Override
public void readFromNBT(NBTTagCompound compound) {
	super.readFromNBT(compound);
	NBTBase fluidTag = compound.getTag("fluid");
	if (fluidTag!=null) {
		try {
			CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY.getStorage().readNBT(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, storage, null, fluidTag);
		} catch (Throwable t) {}
	}
	
}
 
开发者ID:elytra,项目名称:Thermionics,代码行数:12,代码来源:TileEntityDrum.java

示例10: serializeNBT

import net.minecraft.nbt.NBTBase; //导入依赖的package包/类
@Override
public NBTTagCompound serializeNBT() {
    NBTTagCompound nbt = new NBTTagCompound();
    NBTBase base = FaerieInformationProvider.FAERIE_INFORMATION_CAPABILITY.getStorage().writeNBT(FaerieInformationProvider.FAERIE_INFORMATION_CAPABILITY, this, null);
    nbt.setTag("nbt_base", base);
    return nbt;
}
 
开发者ID:BenjaminSutter,项目名称:genera,代码行数:8,代码来源:FaerieInformation.java

示例11: writeNBT

import net.minecraft.nbt.NBTBase; //导入依赖的package包/类
@Nullable
@Override
public NBTBase writeNBT(Capability<IFaerieInformation> capability, IFaerieInformation instance, EnumFacing side) {
    NBTTagCompound comp = new NBTTagCompound();
    comp.setInteger("type", instance.getType());
    comp.setFloat("size", instance.getSize());
    comp.setDouble("max_health", instance.getMaxHealth());
    comp.setInteger("level", instance.getLevel());
    comp.setInteger("current_exp", instance.getCurrentExp());

    return comp;
}
 
开发者ID:BenjaminSutter,项目名称:genera,代码行数:13,代码来源:FaerieInformationStorage.java

示例12: initializeStructureData

import net.minecraft.nbt.NBTBase; //导入依赖的package包/类
protected void initializeStructureData(World worldIn)
{
    if (this.structureData == null)
    {
        this.structureData = (MapGenStructureData)worldIn.getPerWorldStorage().getOrLoadData(MapGenStructureData.class, this.getStructureName());

        if (this.structureData == null)
        {
            this.structureData = new MapGenStructureData(this.getStructureName());
            worldIn.getPerWorldStorage().setData(this.getStructureName(), this.structureData);
        }
        else
        {
            NBTTagCompound nbttagcompound = this.structureData.getTagCompound();

            for (String s : nbttagcompound.getKeySet())
            {
                NBTBase nbtbase = nbttagcompound.getTag(s);

                if (nbtbase.getId() == 10)
                {
                    NBTTagCompound nbttagcompound1 = (NBTTagCompound)nbtbase;

                    if (nbttagcompound1.hasKey("ChunkX") && nbttagcompound1.hasKey("ChunkZ"))
                    {
                        int i = nbttagcompound1.getInteger("ChunkX");
                        int j = nbttagcompound1.getInteger("ChunkZ");
                        StructureStart structurestart = MapGenStructureIO.getStructureStart(nbttagcompound1, worldIn);

                        if (structurestart != null)
                        {
                            this.structureMap.put(ChunkPos.asLong(i, j), structurestart);
                        }
                    }
                }
            }
        }
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:40,代码来源:MapGenStructure.java

示例13: writeNBT

import net.minecraft.nbt.NBTBase; //导入依赖的package包/类
@Override
public NBTBase writeNBT(Capability<CapabilityDivination> capability, CapabilityDivination instance, EnumFacing side) {
	NBTTagCompound tag = new NBTTagCompound();
	if (instance.getFortune() != null) {
		tag.setString("fortune", instance.getFortune().getRegistryName().toString());
		tag.setBoolean("active", instance.isActive());
		tag.setBoolean("removable", instance.isRemovable());
	}
	return tag;
}
 
开发者ID:Um-Mitternacht,项目名称:Bewitchment,代码行数:11,代码来源:DivinationStorage.java

示例14: readNBT

import net.minecraft.nbt.NBTBase; //导入依赖的package包/类
@Override
public void readNBT(Capability<CapabilityDivination> capability, CapabilityDivination instance, EnumFacing side, NBTBase nbt) {
	NBTTagCompound tag = (NBTTagCompound) nbt;
	if (tag.hasKey("fortune")) {
		instance.setFortune(Fortune.REGISTRY.getValue(new ResourceLocation(tag.getString("fortune"))));
		if (tag.getBoolean("active"))
			instance.setActive();
		if (tag.getBoolean("removable"))
			instance.setRemovable();
		;
	}
}
 
开发者ID:Um-Mitternacht,项目名称:Bewitchment,代码行数:13,代码来源:DivinationStorage.java

示例15: getSaveData

import net.minecraft.nbt.NBTBase; //导入依赖的package包/类
public NBTBase getSaveData() 
{
	NBTTagCompound animationData = new NBTTagCompound();		
	animationData.setFloat("XStart", Float.parseFloat(df.format(this.startPosition[0])));
	animationData.setFloat("YStart", Float.parseFloat(df.format(this.startPosition[1])));
	animationData.setFloat("ZStart", Float.parseFloat(df.format(this.startPosition[2])));
	animationData.setFloat("XEnd", Float.parseFloat(df.format(this.endPosition[0])));
	animationData.setFloat("YEnd", Float.parseFloat(df.format(this.endPosition[1])));
	animationData.setFloat("ZEnd", Float.parseFloat(df.format(this.endPosition[2])));
	animationData.setFloat("StartTime", this.startTime);
	animationData.setFloat("FinishTime", this.endTime);
	animationData.setString("Part", partName);
	return animationData;
}
 
开发者ID:ObsidianSuite,项目名称:ObsidianSuite,代码行数:15,代码来源:AnimationPart.java


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