本文整理匯總了Java中net.minecraft.nbt.NBTTagList.getStringTagAt方法的典型用法代碼示例。如果您正苦於以下問題:Java NBTTagList.getStringTagAt方法的具體用法?Java NBTTagList.getStringTagAt怎麽用?Java NBTTagList.getStringTagAt使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類net.minecraft.nbt.NBTTagList
的用法示例。
在下文中一共展示了NBTTagList.getStringTagAt方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createToolString
import net.minecraft.nbt.NBTTagList; //導入方法依賴的package包/類
private String createToolString(ItemStack tool) {
String toolString = "";
if (tool == null || tool.getItem() == null) {
return toolString;
}
toolString += tool.getItem().getUnlocalizedName();
toolString += ";;";
if (tool.getEnchantmentTagList() != null) {
toolString += tool.getEnchantmentTagList().toString();
}
if (tool.hasTagCompound() && tool.getTagCompound().hasKey("display")) {
NBTTagCompound displayTag = tool.getTagCompound().getCompoundTag("display");
if (displayTag.getTagId("Lore") == 9) {
NBTTagList nbttaglist3 = displayTag.getTagList("Lore", 8);
if (!nbttaglist3.hasNoTags()) {
for (int l1 = 0; l1 < nbttaglist3.tagCount(); ++l1) {
toolString += ";;";
toolString += nbttaglist3.getStringTagAt(l1);
}
}
}
}
return toolString;
}
示例2: loadActions
import net.minecraft.nbt.NBTTagList; //導入方法依賴的package包/類
private void loadActions(NBTTagList actionsList)
{
for (int i = 0; i < actionsList.tagCount(); i++)
{
NBTTagCompound timeCompound = actionsList.getCompoundTagAt(i);
int time = timeCompound.getInteger("Time");
NBTTagList nameList = timeCompound.getTagList("Names", Constants.NBT.TAG_STRING);
for (int j = 0; j < nameList.tagCount(); j++)
{
String name = nameList.getStringTagAt(j);
addActionPoint(time, name);
}
}
}
示例3: 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;
}
}
示例4: buildFilter
import net.minecraft.nbt.NBTTagList; //導入方法依賴的package包/類
public ChemicalFilter buildFilter()
{
//get book content
ItemStack stack = this.getStackInSlot(0);
if(stack != null && stack.stackSize >= 0){
NBTTagCompound tag = stack.getTagCompound();
if(tag != null && tag.hasKey("pages")){
NBTTagList pages = tag.getTagList("pages", 8);
ChemicalFilter filter = new ChemicalFilter();
// one atom per line
for(int i = 0; i < pages.tagCount(); i++){
String content = pages.getStringTagAt(i);
if(content != null){
for(String line : content.split("\n")){
if(line.length() > 0 && line.charAt(0) == '-'){ //check if blacklist policy
filter.policy = false;
line = line.substring(1);
}
Molecule m = Molecule.fromNotation(line);
if(m != null)
filter.molecules.add(m);
}
}
}
return filter;
}
}
return null;
}
示例5: buildFilter
import net.minecraft.nbt.NBTTagList; //導入方法依賴的package包/類
public ChemicalFilter buildFilter()
{
//get book content
ItemStack stack = this.getStackInSlot(0);
if(stack != null && stack.stackSize >= 0){
NBTTagCompound tag = stack.getTagCompound();
if(tag != null && tag.hasKey("pages")){
NBTTagList pages = tag.getTagList("pages", 8);
ChemicalFilter filter = new ChemicalFilter();
// one atom per line
for(int i = 0; i < pages.tagCount(); i++){
String content = pages.getStringTagAt(i);
if(content != null){
for(String line : content.split("\n")){
if(line.length() > 0 && line.charAt(0) == '-'){ //check if blacklist policy
filter.policy = false;
line = line.substring(1);
}
Integer an = FundamentalChemistry.elements.get(line.replaceAll("[^a-zA-Z]", ""));
if(an != null)
filter.atoms.add(an);
}
}
}
return filter;
}
}
return null;
}
示例6: 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.length() > 32767)
{
return false;
}
}
return true;
}
}
示例7: updateTick
import net.minecraft.nbt.NBTTagList; //導入方法依賴的package包/類
@Override
public void updateTick(World world, BlockPos pos, IBlockState state, Random rand) {
if (this.getAge(state) >= getMaxAge() || world.isRemote)
return;
Iterable<BlockPos> getBox = BlockPos.getAllInBox(pos.add(-4, -2, -4), pos.add(4, 2, 4));
Iterator it = getBox.iterator();
while (it.hasNext()) {
BlockPos fromIt = (BlockPos)it.next();
IBlockState loopstate = world.getBlockState(fromIt);
if (loopstate.getBlock() == Blocks.BOOKSHELF) {
TileEntity te = world.getTileEntity(fromIt.add(0, 1, 0));
if (te != null && te.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.DOWN)) {
IItemHandler cap = te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.DOWN);
boolean found = false;
for (int i = 0; i < cap.getSlots(); i++) {
if (found)
return;
ItemStack book = cap.getStackInSlot(i);
if (book != null && book.getItem() == Items.WRITTEN_BOOK) {
NBTTagCompound tag = book.getTagCompound();
if (ItemWrittenBook.validBookTagContents(tag) && !NBTUtils.getBoolean(book, "UC_tagRead", false) && ItemWrittenBook.getGeneration(book) == 0)
{
NBTTagList taglist = tag.getTagList("pages", 8);
for (int j = 0; j < taglist.tagCount(); ++j)
{
String str = taglist.getStringTagAt(j);
ITextComponent text = ITextComponent.Serializer.fromJsonLenient(str);
try
{
if (str.length() >= 100 && str.length() <= 512)
found = true;
}
catch (Exception e)
{
System.out.println("whoopsy doopsy");
}
if (found) {
ITextComponent newStr = eatSomeLetters(text);
taglist.set(j, new NBTTagString(newStr.getUnformattedText()));
break;
}
}
tag.setTag("pages", taglist);
tag.setBoolean("UC_tagRead", true);
if (found) {
int addAge = taglist.tagCount();
if (getAge(state) + addAge >= ((BlockCrops)state.getBlock()).getMaxAge())
world.setBlockState(pos, ((BlockCrops)state.getBlock()).withAge(((BlockCrops)state.getBlock()).getMaxAge()), 2);
else
world.setBlockState(pos, ((BlockCrops)state.getBlock()).withAge(getAge(state) + addAge), 2);
}
return;
}
}
}
}
}
}
}
示例8: isNameOnWhitelist
import net.minecraft.nbt.NBTTagList; //導入方法依賴的package包/類
public static boolean isNameOnWhitelist(Entity_AA turret, String nameOrCmd)
{
if (turret.storage == null) { return false; } // Has no space to store anything in
int counter = 0;
// Step 1, find a book in our inventory
while (counter < turret.storage.length)
{
if (turret.storage[counter] != null)
{
if (turret.storage[counter].getItem() == Items.writable_book || turret.storage[counter].getItem() == Items.written_book)
{
//System.out.println("[TURRET] Checking writable book for whitelist against " + playerName);
if (turret.storage[counter].hasTagCompound())
{
NBTTagList pageList = turret.storage[counter].getTagCompound().getTagList("pages", 8);
int pageCount = 0;
String currentPage = pageList.getStringTagAt(pageCount);
while (currentPage != null && !currentPage.isEmpty())
{
String[] lines = currentPage.split("\n");
int lineCount = 0;
while (lineCount < lines.length)
{
//System.out.println("[TURRET] Book page " + pageCount + " - line " + lineCount + ": " + lines[lineCount]);
if (lines[lineCount].equals(nameOrCmd)) { return true; } // Found it!
// else, not on this line
lineCount += 1;
}
pageCount += 1;
currentPage = pageList.getStringTagAt(pageCount); // Next!
}
// Done with all known pages (will stop when there's empty pages inbetween)
}
// else, no tag, so can't have anything in it
}
// else, not a book
}
// else, nothing in that slot
counter += 1;
}
return false; // Fallback. Didn't find a book with this name
}