本文整理匯總了Java中net.minecraft.nbt.NBTTagList.tagCount方法的典型用法代碼示例。如果您正苦於以下問題:Java NBTTagList.tagCount方法的具體用法?Java NBTTagList.tagCount怎麽用?Java NBTTagList.tagCount使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類net.minecraft.nbt.NBTTagList
的用法示例。
在下文中一共展示了NBTTagList.tagCount方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: readFromNBT
import net.minecraft.nbt.NBTTagList; //導入方法依賴的package包/類
@Override
public void readFromNBT(NBTTagCompound compound) {
if (compound.hasKey("RootUser")) {
this.rootUser = compound.getString("RootUser");
}
if (compound.hasKey("Rules")) {
NBTTagList rulesList = compound.getTagList("Rules", NBT.TAG_COMPOUND);
this.rules = new ArrayList<Rule>();
for (int i = 0, max = rulesList.tagCount(); i < max; ++i) {
NBTTagCompound ruleNBT = (NBTTagCompound)rulesList.get(i);
this.rules.add(new Rule(ruleNBT.getString("ID"), ruleNBT.getString("Name"), ruleNBT.getInteger("Mode")));
}
}
if (this.rules == null || this.rules.size() == 0) {
// Reset rules.
this.rules = new ArrayList<Rule>();
this.rules.add(new Rule("<machines>", Rule.MODE_OPEN));
this.rules.add(new Rule("<players>", Rule.MODE_RESTRICTED));
}
super.readFromNBT(compound);
}
示例2: applyEnchantmentModifier
import net.minecraft.nbt.NBTTagList; //導入方法依賴的package包/類
/**
* Executes the enchantment modifier on the ItemStack passed.
*/
private static void applyEnchantmentModifier(EnchantmentHelper.IModifier modifier, ItemStack stack)
{
if (stack != null)
{
NBTTagList nbttaglist = stack.getEnchantmentTagList();
if (nbttaglist != null)
{
for (int i = 0; i < nbttaglist.tagCount(); ++i)
{
int j = nbttaglist.getCompoundTagAt(i).getShort("id");
int k = nbttaglist.getCompoundTagAt(i).getShort("lvl");
if (Enchantment.getEnchantmentById(j) != null)
{
modifier.calculateModifier(Enchantment.getEnchantmentById(j), k);
}
}
}
}
}
示例3: addInformation
import net.minecraft.nbt.NBTTagList; //導入方法依賴的package包/類
/**
* allows items to add custom lines of information to the mouseover description
*/
public void addInformation(ItemStack stack, EntityPlayer playerIn, List<String> tooltip, boolean advanced)
{
NBTTagCompound nbttagcompound = stack.getSubCompound("BlockEntityTag", false);
if (nbttagcompound != null && nbttagcompound.hasKey("Patterns"))
{
NBTTagList nbttaglist = nbttagcompound.getTagList("Patterns", 10);
for (int i = 0; i < nbttaglist.tagCount() && i < 6; ++i)
{
NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i);
EnumDyeColor enumdyecolor = EnumDyeColor.byDyeDamage(nbttagcompound1.getInteger("Color"));
TileEntityBanner.EnumBannerPattern tileentitybanner$enumbannerpattern = TileEntityBanner.EnumBannerPattern.getPatternByID(nbttagcompound1.getString("Pattern"));
if (tileentitybanner$enumbannerpattern != null)
{
tooltip.add(StatCollector.translateToLocal("item.banner." + tileentitybanner$enumbannerpattern.getPatternName() + "." + enumdyecolor.getUnlocalizedName()));
}
}
}
}
示例4: readFromNBT
import net.minecraft.nbt.NBTTagList; //導入方法依賴的package包/類
public void readFromNBT(NBTTagCompound compound)
{
super.readFromNBT(compound);
NBTTagList nbttaglist = compound.getTagList("Items", 10);
this.chestContents = new ItemStack[this.getSizeInventory()];
if (compound.hasKey("CustomName", 8))
{
this.customName = compound.getString("CustomName");
}
for (int i = 0; i < nbttaglist.tagCount(); ++i)
{
NBTTagCompound nbttagcompound = nbttaglist.getCompoundTagAt(i);
int j = nbttagcompound.getByte("Slot") & 255;
if (j >= 0 && j < this.chestContents.length)
{
this.chestContents[j] = ItemStack.loadItemStackFromNBT(nbttagcompound);
}
}
}
示例5: readFromNBT
import net.minecraft.nbt.NBTTagList; //導入方法依賴的package包/類
public void readFromNBT(NBTTagCompound tagCompound)
{
super.readFromNBT(tagCompound);
NBTTagList tagList = tagCompound.getTagList("Items", 10);
this.inventory = new ItemStack[this.getSizeInventory()];
for(int i = 0; i < tagList.tagCount(); ++i)
{
NBTTagCompound tempTagCompound = tagList.getCompoundTagAt(i);
byte slot = tempTagCompound.getByte("Slot");
if(slot >= 0 && slot < this.inventory.length)
{
this.setInventorySlotContents(slot, ItemStack.loadItemStackFromNBT(tempTagCompound));
}
}
if(tagCompound.hasKey("CustomName", 8))
{
this.customName = tagCompound.getString("CustomName");
}
}
示例6: readFromNBT
import net.minecraft.nbt.NBTTagList; //導入方法依賴的package包/類
public void readFromNBT(NBTTagCompound compound)
{
super.readFromNBT(compound);
NBTTagList nbttaglist = compound.getTagList("Items", 10);
this.stacks = new ItemStack[this.getSizeInventory()];
for (int i = 0; i < nbttaglist.tagCount(); ++i)
{
NBTTagCompound nbttagcompound = nbttaglist.getCompoundTagAt(i);
int j = nbttagcompound.getByte("Slot") & 255;
if (j >= 0 && j < this.stacks.length)
{
this.stacks[j] = ItemStack.loadItemStackFromNBT(nbttagcompound);
}
}
if (compound.hasKey("CustomName", 8))
{
this.customName = compound.getString("CustomName");
}
}
示例7: readFromNBT
import net.minecraft.nbt.NBTTagList; //導入方法依賴的package包/類
@Override
public void readFromNBT(NBTTagCompound compound) {
super.readFromNBT(compound);
NBTTagList list = compound.getTagList("playerList", 10);
isGameLive = compound.getBoolean("isGameLive");
players.clear();
UUID uuid;
for (int i = 0; i < list.tagCount(); i++) {
uuid = getUUIDFromTag(list.getCompoundTagAt(i));
if (worldObj != null && worldObj.playerEntities != null) {
for (EntityPlayer player : (List<EntityPlayer>) worldObj.playerEntities) {
if (player.getGameProfile().getId() == uuid) {
players.add(uuid);
break;
}
}
}
}
}
示例8: deSerialize
import net.minecraft.nbt.NBTTagList; //導入方法依賴的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;
}
示例9: addInformation
import net.minecraft.nbt.NBTTagList; //導入方法依賴的package包/類
/**
* allows items to add custom lines of information to the mouseover description
*/
public void addInformation(ItemStack stack, EntityPlayer playerIn, List<String> tooltip, boolean advanced)
{
super.addInformation(stack, playerIn, tooltip, advanced);
NBTTagList nbttaglist = this.getEnchantments(stack);
if (nbttaglist != null)
{
for (int i = 0; i < nbttaglist.tagCount(); ++i)
{
int j = nbttaglist.getCompoundTagAt(i).getShort("id");
int k = nbttaglist.getCompoundTagAt(i).getShort("lvl");
if (Enchantment.getEnchantmentByID(j) != null)
{
tooltip.add(Enchantment.getEnchantmentByID(j).getTranslatedName(k));
}
}
}
}
示例10: isNBTValid
import net.minecraft.nbt.NBTTagList; //導入方法依賴的package包/類
/**
* this method returns true if the book's NBT Tag List "pages" is valid
*/
public static boolean isNBTValid(NBTTagCompound nbt)
{
if (nbt == null)
{
return false;
}
else if (!nbt.hasKey("pages", 9))
{
return false;
}
else
{
NBTTagList nbttaglist = nbt.getTagList("pages", 8);
for (int i = 0; i < nbttaglist.tagCount(); ++i)
{
String s = nbttaglist.getStringTagAt(i);
if (s == null)
{
return false;
}
if (s.length() > 32767)
{
return false;
}
}
return true;
}
}
示例11: readFromNBT
import net.minecraft.nbt.NBTTagList; //導入方法依賴的package包/類
/**
* reads in data from the NBTTagCompound into this MapDataBase
*/
public void readFromNBT(NBTTagCompound nbt)
{
this.tickCounter = nbt.getInteger("Tick");
NBTTagList nbttaglist = nbt.getTagList("Villages", 10);
for (int i = 0; i < nbttaglist.tagCount(); ++i)
{
NBTTagCompound nbttagcompound = nbttaglist.getCompoundTagAt(i);
Village village = new Village();
village.readVillageDataFromNBT(nbttagcompound);
this.villageList.add(village);
}
}
示例12: readFromNBT
import net.minecraft.nbt.NBTTagList; //導入方法依賴的package包/類
@Override
public void readFromNBT(NBTTagCompound compound)
{
if(compound.hasKey("links"))
{
NBTTagList linktags = compound.getTagList("links", 10);
for(int i = 0; i < linktags.tagCount(); i++)
{
NBTTagCompound com = linktags.getCompoundTagAt(i);
links.add(NodeLink.fromNBT(com));
}
}
items.deserializeNBT(compound.getCompoundTag("items"));
super.readFromNBT(compound);
}
示例13: readFromNBT
import net.minecraft.nbt.NBTTagList; //導入方法依賴的package包/類
public void readFromNBT(NBTTagList listOfPlayers) {
int howManyTimesToLoop = listOfPlayers.tagCount();
for (int i = 0; i < howManyTimesToLoop; i++) {
NBTTagCompound nbt = listOfPlayers.getCompoundTagAt(i);
LocalDateTime enterTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(nbt.getLong("enterTime")), ZoneId.systemDefault());
UUID player = nbt.getUniqueId("PlayerUUID");
if (nbt.getBoolean("HasLeft")) {
LocalDateTime leaveTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(nbt.getLong("LeaveTime")), ZoneId.systemDefault());
Duration stayTime = Duration.ofMillis(nbt.getLong("StayTime"));
playersInChunk.add(new PlayerInChunk(enterTime, leaveTime, stayTime, player));
} else {
playersInChunk.add(new PlayerInChunk(enterTime, player));
}
}
}
示例14: getEnchantmentLevel
import net.minecraft.nbt.NBTTagList; //導入方法依賴的package包/類
/**
* Returns the level of enchantment on the ItemStack passed.
*/
public static int getEnchantmentLevel(int enchID, ItemStack stack)
{
if (stack == null)
{
return 0;
}
else
{
NBTTagList nbttaglist = stack.getEnchantmentTagList();
if (nbttaglist == null)
{
return 0;
}
else
{
for (int i = 0; i < nbttaglist.tagCount(); ++i)
{
int j = nbttaglist.getCompoundTagAt(i).getShort("id");
int k = nbttaglist.getCompoundTagAt(i).getShort("lvl");
if (j == enchID)
{
return k;
}
}
return 0;
}
}
}
示例15: readFromNBT
import net.minecraft.nbt.NBTTagList; //導入方法依賴的package包/類
@Override
public void readFromNBT(NBTTagCompound nbt) {
NBTTagList list = nbt.getTagList("actions", Constants.NBT.TAG_COMPOUND);
options = new ArrayList<>();
optionMap = new HashMap<>();
for (int i = 0; i < list.tagCount(); i++) {
ActionOptions opt = new ActionOptions(list.getCompoundTagAt(i));
options.add(opt);
optionMap.put(opt.getActionId(), opt);
}
lastId = nbt.getInteger("lastId");
}