本文整理匯總了Java中net.minecraft.nbt.NBTTagCompound.getTag方法的典型用法代碼示例。如果您正苦於以下問題:Java NBTTagCompound.getTag方法的具體用法?Java NBTTagCompound.getTag怎麽用?Java NBTTagCompound.getTag使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類net.minecraft.nbt.NBTTagCompound
的用法示例。
在下文中一共展示了NBTTagCompound.getTag方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: deSerialize
import net.minecraft.nbt.NBTTagCompound; //導入方法依賴的package包/類
public static Tuple<List<BrewEffect>, List<PotionEffect>> deSerialize(NBTTagCompound compound) {
List<PotionEffect> potionEffects = PotionUtils.getEffectsFromTag(compound);
List<BrewEffect> brewEffects = new ArrayList<>();
Tuple<List<BrewEffect>, List<PotionEffect>> tuple = new Tuple<>(brewEffects, potionEffects);
NBTTagList list = (NBTTagList) compound.getTag(BREW_DATA);
for (int i = 0, size = list.tagCount(); i < size; i++) {
NBTTagCompound tag = list.getCompoundTagAt(i);
IBrew brew = BrewRegistry.getRegisteredBrew(tag.getString(BREW_ID));
int duration = tag.getInteger(BREW_DURATION);
int amplifier = tag.getInteger(BREW_AMPLIFIER);
brewEffects.add(new BrewEffect(brew, duration, amplifier));
}
return tuple;
}
示例2: getChildTag
import net.minecraft.nbt.NBTTagCompound; //導入方法依賴的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;
}
}
示例3: readFromNBT
import net.minecraft.nbt.NBTTagCompound; //導入方法依賴的package包/類
@Override
public void readFromNBT(NBTTagCompound compound) {
super.readFromNBT(compound);
if (compound.hasKey("Attributes")) {
NBTTagCompound attrs = compound.getCompoundTag("Attributes");
NBTTagList attrList = (NBTTagList) compound.getTag("AttributesList");
for (String key : attrs.getKeySet())
this.attributes.put(TF2Attribute.attributes[Integer.parseInt(key)], attrs.getInteger(key));
for (int i = 0; i < attrList.tagCount(); i++)
this.attributeList[i] = TF2Attribute.attributes[attrList.getIntAt(i)];
}
}
示例4: getExplosionTag
import net.minecraft.nbt.NBTTagCompound; //導入方法依賴的package包/類
public static NBTBase getExplosionTag(ItemStack stack, String key)
{
if (stack.hasTagCompound())
{
NBTTagCompound nbttagcompound = stack.getTagCompound().getCompoundTag("Explosion");
if (nbttagcompound != null)
{
return nbttagcompound.getTag(key);
}
}
return null;
}
示例5: initializeStructureData
import net.minecraft.nbt.NBTTagCompound; //導入方法依賴的package包/類
protected void initializeStructureData(World worldIn)
{
if (this.structureData == null)
{
this.structureData = (MapGenStructureData)worldIn.loadItemData(MapGenStructureData.class, this.getStructureName());
if (this.structureData == null)
{
this.structureData = new MapGenStructureData(this.getStructureName());
worldIn.setItemData(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);
}
}
}
}
}
}
}
示例6: readFromNBT
import net.minecraft.nbt.NBTTagCompound; //導入方法依賴的package包/類
@Override
public void readFromNBT(NBTTagCompound nbt)
{
NBTTagList list = (NBTTagList)nbt.getTag("tiles");
tiles = new TreeMap<TilePos,Tile>();
for(int i=0; i<list.tagCount(); i++)
{
NBTTagCompound entry = list.getCompoundTagAt(i);
Tile tile = Tile.readFromNBT(entry, world);
}
}
示例7: addValue
import net.minecraft.nbt.NBTTagCompound; //導入方法依賴的package包/類
public static float addValue(float value, NBTTagCompound attributelist, String effect) {
for(String name : attributelist.getKeySet()) {
NBTBase tag = attributelist.getTag(name);
if (tag instanceof NBTTagFloat) {
TF2Attribute attribute = attributes[Integer.parseInt(name)];
if (attribute != null && attribute.effect.equals(effect))
if (attribute.typeOfValue == Type.ADDITIVE)
value += ((NBTTagFloat) tag).getFloat();
else
value *= ((NBTTagFloat) tag).getFloat();
}
}
return value;
}
示例8: loadIdCounts
import net.minecraft.nbt.NBTTagCompound; //導入方法依賴的package包/類
/**
* Loads the idCounts Map from the 'idcounts' file.
*/
private void loadIdCounts()
{
try
{
this.idCounts.clear();
if (this.saveHandler == null)
{
return;
}
File file1 = this.saveHandler.getMapFileFromName("idcounts");
if (file1 != null && file1.exists())
{
DataInputStream datainputstream = new DataInputStream(new FileInputStream(file1));
NBTTagCompound nbttagcompound = CompressedStreamTools.read(datainputstream);
datainputstream.close();
for (String s : nbttagcompound.getKeySet())
{
NBTBase nbtbase = nbttagcompound.getTag(s);
if (nbtbase instanceof NBTTagShort)
{
NBTTagShort nbttagshort = (NBTTagShort)nbtbase;
short short1 = nbttagshort.getShort();
this.idCounts.put(s, Short.valueOf(short1));
}
}
}
}
catch (Exception exception)
{
exception.printStackTrace();
}
}
示例9: initializeStructureData
import net.minecraft.nbt.NBTTagCompound; //導入方法依賴的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);
}
}
}
}
}
}
}
示例10: readItemsFromNBT
import net.minecraft.nbt.NBTTagCompound; //導入方法依賴的package包/類
public static NonNullList<Pair<Integer, ItemStack>> readItemsFromNBT(NBTTagCompound tagCompound)
{
NonNullList<Pair<Integer, ItemStack>> items = NonNullList.create();
NBTTagList nbtList = tagCompound.getTagList("Items", 10);
for (int i = 0; i < nbtList.tagCount(); ++i)
{
NBTTagCompound nbtTagCompound = nbtList.getCompoundTagAt(i);
NBTBase nbt = nbtTagCompound.getTag("Slot");
int j;
if (nbt instanceof NBTTagByte)
{
j = nbtTagCompound.getByte("Slot") & 255;
} else
{
j = nbtTagCompound.getShort("Slot");
}
if (j >= 0)
{
ItemStack itemstack = new ItemStack(nbtTagCompound);
items.add(Pair.of(j, itemstack));
}
}
return items;
}
示例11: isValidInput
import net.minecraft.nbt.NBTTagCompound; //導入方法依賴的package包/類
public static boolean isValidInput(ItemStack input, ItemStack modifier)
{
if (input == null || modifier == null || modifier.getItem() != Items.DIAMOND)
return false;
for (SocketRecipe recipe : recipes)
{
if (recipe.input.isAssignableFrom(input.getItem().getClass()))
{
NBTTagCompound tag = input.getTagCompound();
if (tag == null || !tag.hasKey("sockets"))
return false;
NBTTagCompound socketTag = (NBTTagCompound) tag.getTag("sockets");
int availableSockets = 0;
for (int i = 0 ; i < socketTag.getInteger("number"); i++)
{
if (socketTag.getString("socket-"+i) == "none")
availableSockets++;
}
if (availableSockets > 0)
return true;
}
}
return false;
}
示例12: readFromNBT
import net.minecraft.nbt.NBTTagCompound; //導入方法依賴的package包/類
@Override
public void readFromNBT(NBTTagCompound compound) {
super.readFromNBT(compound);
NBTBase energyTag = compound.getTag("energy");
if (energyTag!=null) {
try {
CapabilityEnergy.ENERGY.getStorage().readNBT(CapabilityEnergy.ENERGY, energyStorage, null, energyTag);
} catch (Throwable t) {}
}
}
示例13: readFromNBT
import net.minecraft.nbt.NBTTagCompound; //導入方法依賴的package包/類
@Override
public void readFromNBT(NBTTagCompound compound) {
NBTTagList list = (NBTTagList) compound.getTag(QuantumHandler.NBT_TAG);
list.forEach(stackList -> {
NBTTagList stacks = (NBTTagList) ((NBTTagCompound) stackList).getTag("list");
UUID key = ((NBTTagCompound) stackList).getUniqueId("key");
if(key != null) {
getEntanglement(key).clear();
stacks.forEach(tag -> getEntanglement(key).add(new ItemStack((NBTTagCompound) tag)));
}
});
}
示例14: getEnchantments
import net.minecraft.nbt.NBTTagCompound; //導入方法依賴的package包/類
public NBTTagList getEnchantments(ItemStack stack)
{
NBTTagCompound nbttagcompound = stack.getTagCompound();
return nbttagcompound != null && nbttagcompound.hasKey("StoredEnchantments", 9) ? (NBTTagList)nbttagcompound.getTag("StoredEnchantments") : new NBTTagList();
}
示例15: spawnNewEntity
import net.minecraft.nbt.NBTTagCompound; //導入方法依賴的package包/類
private Entity spawnNewEntity(Entity entityIn, boolean spawn)
{
if (this.getRandomEntity() != null)
{
NBTTagCompound nbttagcompound = new NBTTagCompound();
entityIn.writeToNBTOptional(nbttagcompound);
for (String s : this.getRandomEntity().nbtData.getKeySet())
{
NBTBase nbtbase = this.getRandomEntity().nbtData.getTag(s);
nbttagcompound.setTag(s, nbtbase.copy());
}
entityIn.readFromNBT(nbttagcompound);
if (entityIn.worldObj != null && spawn)
{
entityIn.worldObj.spawnEntityInWorld(entityIn);
}
NBTTagCompound nbttagcompound2;
for (Entity entity = entityIn; nbttagcompound.hasKey("Riding", 10); nbttagcompound = nbttagcompound2)
{
nbttagcompound2 = nbttagcompound.getCompoundTag("Riding");
Entity entity1 = EntityList.createEntityByName(nbttagcompound2.getString("id"), entityIn.worldObj);
if (entity1 != null)
{
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
entity1.writeToNBTOptional(nbttagcompound1);
for (String s1 : nbttagcompound2.getKeySet())
{
NBTBase nbtbase1 = nbttagcompound2.getTag(s1);
nbttagcompound1.setTag(s1, nbtbase1.copy());
}
entity1.readFromNBT(nbttagcompound1);
entity1.setLocationAndAngles(entity.posX, entity.posY, entity.posZ, entity.rotationYaw, entity.rotationPitch);
if (entityIn.worldObj != null && spawn)
{
entityIn.worldObj.spawnEntityInWorld(entity1);
}
entity.mountEntity(entity1);
}
entity = entity1;
}
}
else if (entityIn instanceof EntityLivingBase && entityIn.worldObj != null && spawn)
{
if (entityIn instanceof EntityLiving)
{
((EntityLiving)entityIn).onInitialSpawn(entityIn.worldObj.getDifficultyForLocation(new BlockPos(entityIn)), (IEntityLivingData)null);
}
entityIn.worldObj.spawnEntityInWorld(entityIn);
}
return entityIn;
}