本文整理匯總了Java中net.minecraft.nbt.NBTTagList.set方法的典型用法代碼示例。如果您正苦於以下問題:Java NBTTagList.set方法的具體用法?Java NBTTagList.set怎麽用?Java NBTTagList.set使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類net.minecraft.nbt.NBTTagList
的用法示例。
在下文中一共展示了NBTTagList.set方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: processInventory
import net.minecraft.nbt.NBTTagList; //導入方法依賴的package包/類
public static NBTTagCompound processInventory(IDataFixer fixer, NBTTagCompound compound, int version, String key)
{
if (compound.hasKey(key, 9))
{
NBTTagList nbttaglist = compound.getTagList(key, 10);
for (int i = 0; i < nbttaglist.tagCount(); ++i)
{
nbttaglist.set(i, fixer.process(FixTypes.ITEM_INSTANCE, nbttaglist.getCompoundTagAt(i), version));
}
}
return compound;
}
示例2: 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;
}
}
}
}
}
}
}