本文整理汇总了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();
}
}
示例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;
}
示例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());
}
}
示例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;
}
}
示例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;
}
示例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;
}
}
示例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;
}
}
示例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;
}
示例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) {}
}
}
示例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;
}
示例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;
}
示例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);
}
}
}
}
}
}
}
示例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;
}
示例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();
;
}
}
示例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;
}