本文整理匯總了Java中net.minecraft.nbt.NBTTagList類的典型用法代碼示例。如果您正苦於以下問題:Java NBTTagList類的具體用法?Java NBTTagList怎麽用?Java NBTTagList使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
NBTTagList類屬於net.minecraft.nbt包,在下文中一共展示了NBTTagList類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: readFromNBT
import net.minecraft.nbt.NBTTagList; //導入依賴的package包/類
public void readFromNBT(NBTTagCompound compound)
{
super.readFromNBT(compound);
if (!this.checkLootAndRead(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");
}
}
示例2: readFromNBT
import net.minecraft.nbt.NBTTagList; //導入依賴的package包/類
@Override
public void readFromNBT(NBTTagCompound compound) {
super.readFromNBT(compound);
timeout = compound.getInteger("timeout");
portalSide = EnumFacing.VALUES[compound.getByte("portalSide")];
BlockPos pos = BlockPos.fromLong(compound.getLong("pos"));
int dim = compound.getInteger("dim");
EnumFacing side = EnumFacing.VALUES[compound.getByte("side")];
other = new TeleportDestination("", dim, pos, side);
NBTTagList list = compound.getTagList("bl", Constants.NBT.TAG_COMPOUND);
blackListed.clear();
for (int i = 0 ; i < list.tagCount() ; i++) {
NBTTagCompound tc = list.getCompoundTagAt(i);
UUID uuid = new UUID(tc.getLong("m"), tc.getLong("l"));
blackListed.add(uuid);
}
}
示例3: removeBannerData
import net.minecraft.nbt.NBTTagList; //導入依賴的package包/類
/**
* Removes all the banner related data from a provided instance of ItemStack.
*/
public static void removeBannerData(ItemStack stack)
{
NBTTagCompound nbttagcompound = stack.getSubCompound("BlockEntityTag", false);
if (nbttagcompound != null && nbttagcompound.hasKey("Patterns", 9))
{
NBTTagList nbttaglist = nbttagcompound.getTagList("Patterns", 10);
if (nbttaglist.tagCount() > 0)
{
nbttaglist.removeTag(nbttaglist.tagCount() - 1);
if (nbttaglist.hasNoTags())
{
stack.getTagCompound().removeTag("BlockEntityTag");
if (stack.getTagCompound().hasNoTags())
{
stack.setTagCompound((NBTTagCompound)null);
}
}
}
}
}
示例4: addCustomPotionEffectToList
import net.minecraft.nbt.NBTTagList; //導入依賴的package包/類
public static void addCustomPotionEffectToList(@Nullable NBTTagCompound tag, List<PotionEffect> effectList)
{
if (tag != null && tag.hasKey("CustomPotionEffects", 9))
{
NBTTagList nbttaglist = tag.getTagList("CustomPotionEffects", 10);
for (int i = 0; i < nbttaglist.tagCount(); ++i)
{
NBTTagCompound nbttagcompound = nbttaglist.getCompoundTagAt(i);
PotionEffect potioneffect = PotionEffect.readCustomPotionEffectFromNBT(nbttagcompound);
if (potioneffect != null)
{
effectList.add(potioneffect);
}
}
}
}
示例5: readEntityFromNBT
import net.minecraft.nbt.NBTTagList; //導入依賴的package包/類
/**
* (abstract) Protected helper method to read subclass entity data from NBT.
*/
protected void readEntityFromNBT(NBTTagCompound tagCompund)
{
super.readEntityFromNBT(tagCompund);
NBTTagList nbttaglist = tagCompund.getTagList("Items", 10);
this.minecartContainerItems = 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.minecartContainerItems.length)
{
this.minecartContainerItems[j] = ItemStack.loadItemStackFromNBT(nbttagcompound);
}
}
}
示例6: spawnFirework
import net.minecraft.nbt.NBTTagList; //導入依賴的package包/類
public static void spawnFirework(World world, double x, double y, double z) {
ItemStack rocket = new ItemStack(Items.FIREWORKS);
ItemStack itemstack1 = getFireworkCharge();
NBTTagCompound nbttagcompound = new NBTTagCompound();
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
NBTTagList nbttaglist = new NBTTagList();
if (itemstack1 != null && itemstack1.getItem() == Items.FIREWORK_CHARGE && itemstack1.hasTagCompound() && itemstack1.getTagCompound().hasKey("Explosion")) {
nbttaglist.appendTag(itemstack1.getTagCompound().getCompoundTag("Explosion"));
}
nbttagcompound1.setTag("Explosions", nbttaglist);
nbttagcompound1.setByte("Flight", (byte) 2);
nbttagcompound.setTag("Fireworks", nbttagcompound1);
rocket.setTagCompound(nbttagcompound);
EntityFireworkRocket entity = new EntityFireworkRocket(world, x, y, z, rocket);
world.spawnEntity(entity);
}
示例7: writeToNBT
import net.minecraft.nbt.NBTTagList; //導入依賴的package包/類
/**
* Writes a NBT Node with inventory.
*/
public void writeToNBT() {
NBTTagList itemList = new NBTTagList();
for (int i = 0; i < getSizeInventory(); i++) {
if (!getStackInSlot(i).isEmpty()) {
NBTTagCompound slotEntry = new NBTTagCompound();
slotEntry.setByte("Slot", (byte) i);
getStackInSlot(i).writeToNBT(slotEntry);
itemList.appendTag(slotEntry);
}
}
// save content in Inventory->Items
NBTTagCompound inventory = new NBTTagCompound();
inventory.setTag("Items", itemList);
NBTUtil.setCompoundTag(armorStack, "UpgradeInventory", inventory);
NBTUtil.removeTag(armorStack, "Inventory");
}
示例8: getRelevantVariableNames
import net.minecraft.nbt.NBTTagList; //導入依賴的package包/類
private static Set<String> getRelevantVariableNames(@Nonnull ItemStack remote) {
Set<String> variables = new HashSet<>();
NBTTagCompound tag = remote.getTagCompound();
if (tag != null) {
NBTTagList tagList = tag.getTagList("actionWidgets", 10);
for (int i = 0; i < tagList.tagCount(); i++) {
NBTTagCompound widgetTag = tagList.getCompoundTagAt(i);
variables.add(widgetTag.getString("variableName"));
variables.add(widgetTag.getString("enableVariable"));
TextVariableParser parser = new TextVariableParser(widgetTag.getString("text"));
parser.parse();
variables.addAll(parser.getRelevantVariables());
}
}
return variables;
}
示例9: readFromNBT
import net.minecraft.nbt.NBTTagList; //導入依賴的package包/類
/**
* A custom method to read our inventory from an ItemStack's NBT compound
*/
public void readFromNBT(NBTTagCompound compound) {
if ("".equals(uniqueID)) {
// try to read unique ID from NBT
uniqueID = compound.getString("uniqueID");
// if it's still "", assign a new one:
if ("".equals(uniqueID)) {
uniqueID = UUID.randomUUID().toString();
}
}
NBTTagList items = compound.getTagList("ItemInventory", Constants.NBT.TAG_COMPOUND);
for (int i = 0; i < items.tagCount(); ++i) {
NBTTagCompound item = items.getCompoundTagAt(i);
int slot = item.getInteger("Slot");
if (slot >= 0 && slot < getSizeInventory()) {
inventory.set(slot, new ItemStack(item));
}
}
}
示例10: 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");
}
}
示例11: writeToNBT
import net.minecraft.nbt.NBTTagList; //導入依賴的package包/類
public void writeToNBT(NBTTagCompound compound)
{
super.writeToNBT(compound);
NBTTagList nbttaglist = new NBTTagList();
for (int i = 0; i < this.inventory.length; ++i)
{
if (this.inventory[i] != null)
{
NBTTagCompound nbttagcompound = new NBTTagCompound();
nbttagcompound.setByte("Slot", (byte)i);
this.inventory[i].writeToNBT(nbttagcompound);
nbttaglist.appendTag(nbttagcompound);
}
}
compound.setTag("Items", nbttaglist);
compound.setInteger("TransferCooldown", this.transferCooldown);
if (this.hasCustomName())
{
compound.setString("CustomName", this.customName);
}
}
示例12: RemoteLayout
import net.minecraft.nbt.NBTTagList; //導入依賴的package包/類
public RemoteLayout(ItemStack remote, int guiLeft, int guiTop) {
NBTTagCompound tag = remote.getTagCompound();
if (tag != null) {
NBTTagList tagList = tag.getTagList("actionWidgets", 10);
for (int i = 0; i < tagList.tagCount(); i++) {
NBTTagCompound widgetTag = tagList.getCompoundTagAt(i);
String id = widgetTag.getString("id");
Class<? extends ActionWidget> clazz = registeredWidgets.get(id);
try {
ActionWidget widget = clazz.newInstance();
widget.readFromNBT(widgetTag, guiLeft, guiTop);
actionWidgets.add(widget);
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
示例13: saveInventoryToNBT
import net.minecraft.nbt.NBTTagList; //導入依賴的package包/類
public NBTTagList saveInventoryToNBT()
{
NBTTagList nbttaglist = new NBTTagList();
for (int i = 0; i < this.getSizeInventory(); ++i)
{
ItemStack itemstack = this.getStackInSlot(i);
if (itemstack != null)
{
NBTTagCompound nbttagcompound = new NBTTagCompound();
nbttagcompound.setByte("Slot", (byte)i);
itemstack.writeToNBT(nbttagcompound);
nbttaglist.appendTag(nbttagcompound);
}
}
return nbttaglist;
}
示例14: writeStructureComponentsToNBT
import net.minecraft.nbt.NBTTagList; //導入依賴的package包/類
public NBTTagCompound writeStructureComponentsToNBT(int chunkX, int chunkZ)
{
NBTTagCompound nbttagcompound = new NBTTagCompound();
nbttagcompound.setString("id", MapGenStructureIO.getStructureStartName(this));
nbttagcompound.setInteger("ChunkX", chunkX);
nbttagcompound.setInteger("ChunkZ", chunkZ);
nbttagcompound.setTag("BB", this.boundingBox.toNBTTagIntArray());
NBTTagList nbttaglist = new NBTTagList();
for (StructureComponent structurecomponent : this.components)
{
nbttaglist.appendTag(structurecomponent.createStructureBaseNBT());
}
nbttagcompound.setTag("Children", nbttaglist);
this.writeToNBT(nbttagcompound);
return nbttagcompound;
}
示例15: readScores
import net.minecraft.nbt.NBTTagList; //導入依賴的package包/類
protected void readScores(NBTTagList nbt)
{
for (int i = 0; i < nbt.tagCount(); ++i)
{
NBTTagCompound nbttagcompound = nbt.getCompoundTagAt(i);
ScoreObjective scoreobjective = this.theScoreboard.getObjective(nbttagcompound.getString("Objective"));
String s = nbttagcompound.getString("Name");
if (s.length() > 40)
{
s = s.substring(0, 40);
}
Score score = this.theScoreboard.getOrCreateScore(s, scoreobjective);
score.setScorePoints(nbttagcompound.getInteger("Score"));
if (nbttagcompound.hasKey("Locked"))
{
score.setLocked(nbttagcompound.getBoolean("Locked"));
}
}
}