本文整理汇总了Java中net.minecraft.nbt.NBTTagCompound.getCompoundTag方法的典型用法代码示例。如果您正苦于以下问题:Java NBTTagCompound.getCompoundTag方法的具体用法?Java NBTTagCompound.getCompoundTag怎么用?Java NBTTagCompound.getCompoundTag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.nbt.NBTTagCompound
的用法示例。
在下文中一共展示了NBTTagCompound.getCompoundTag方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: readEntityFromNBT
import net.minecraft.nbt.NBTTagCompound; //导入方法依赖的package包/类
/**
* (abstract) Protected helper method to read subclass entity data from NBT.
*/
public void readEntityFromNBT(NBTTagCompound compound)
{
this.fireworkAge = compound.getInteger("Life");
this.lifetime = compound.getInteger("LifeTime");
NBTTagCompound nbttagcompound = compound.getCompoundTag("FireworksItem");
if (nbttagcompound != null)
{
ItemStack itemstack = ItemStack.loadItemStackFromNBT(nbttagcompound);
if (itemstack != null)
{
this.dataManager.set(FIREWORK_ITEM, Optional.of(itemstack));
}
}
}
示例2: fixTagCompound
import net.minecraft.nbt.NBTTagCompound; //导入方法依赖的package包/类
public NBTTagCompound fixTagCompound(NBTTagCompound compound)
{
String s = compound.getString("id");
if ("minecraft:potion".equals(s) || "minecraft:splash_potion".equals(s) || "minecraft:lingering_potion".equals(s) || "minecraft:tipped_arrow".equals(s))
{
NBTTagCompound nbttagcompound = compound.getCompoundTag("tag");
if (!nbttagcompound.hasKey("Potion", 8))
{
nbttagcompound.setString("Potion", "minecraft:water");
}
if (!compound.hasKey("tag", 10))
{
compound.setTag("tag", nbttagcompound);
}
}
return compound;
}
示例3: readEntityFromNBT
import net.minecraft.nbt.NBTTagCompound; //导入方法依赖的package包/类
/**
* (abstract) Protected helper method to read subclass entity data from NBT.
*/
public void readEntityFromNBT(NBTTagCompound compound)
{
super.readEntityFromNBT(compound);
this.setHorseVariant(compound.getInteger("Variant"));
if (compound.hasKey("ArmorItem", 10))
{
ItemStack itemstack = new ItemStack(compound.getCompoundTag("ArmorItem"));
if (!itemstack.func_190926_b() && HorseArmorType.isHorseArmor(itemstack.getItem()))
{
this.horseChest.setInventorySlotContents(1, itemstack);
}
}
this.updateHorseSlots();
}
示例4: ItemStack
import net.minecraft.nbt.NBTTagCompound; //导入方法依赖的package包/类
public ItemStack(NBTTagCompound p_i47263_1_)
{
this.item = Item.getByNameOrId(p_i47263_1_.getString("id"));
this.stackSize = p_i47263_1_.getByte("Count");
this.itemDamage = Math.max(0, p_i47263_1_.getShort("Damage"));
if (p_i47263_1_.hasKey("tag", 10))
{
this.stackTagCompound = p_i47263_1_.getCompoundTag("tag");
if (this.item != null)
{
this.item.updateItemStackNBT(p_i47263_1_);
}
}
this.func_190923_F();
}
示例5: readFromNBT
import net.minecraft.nbt.NBTTagCompound; //导入方法依赖的package包/类
@Override
public void readFromNBT(NBTTagCompound compound) {
super.readFromNBT(compound);
inventory.deserializeNBT(compound.getCompoundTag("inv"));
isCooking = compound.getBoolean("cooking");
fuelTimer = compound.getInteger("fuel");
maxFuelTimer = compound.getInteger("max");
NBTTagCompound connections = compound.getCompoundTag("connections");
System.out.println("read "+connections);
for (int i = 0; i < 4; i++)
if(connections.hasKey(String.valueOf(i)))
{
BlockPos pos = BlockPos.fromLong(connections.getLong(String.valueOf(i)));
connected.add(pos);
}
}
示例6: readCapabilitiesFromNBT
import net.minecraft.nbt.NBTTagCompound; //导入方法依赖的package包/类
public void readCapabilitiesFromNBT(NBTTagCompound tagCompound)
{
if (tagCompound.hasKey("abilities", 10))
{
NBTTagCompound nbttagcompound = tagCompound.getCompoundTag("abilities");
this.disableDamage = nbttagcompound.getBoolean("invulnerable");
this.isFlying = nbttagcompound.getBoolean("flying");
this.allowFlying = nbttagcompound.getBoolean("mayfly");
this.isCreativeMode = nbttagcompound.getBoolean("instabuild");
if (nbttagcompound.hasKey("flySpeed", 99))
{
this.flySpeed = nbttagcompound.getFloat("flySpeed");
this.walkSpeed = nbttagcompound.getFloat("walkSpeed");
}
if (nbttagcompound.hasKey("mayBuild", 1))
{
this.allowEdit = nbttagcompound.getBoolean("mayBuild");
}
}
}
示例7: readEntityFromNBT
import net.minecraft.nbt.NBTTagCompound; //导入方法依赖的package包/类
/**
* (abstract) Protected helper method to read subclass entity data from NBT.
*/
public void readEntityFromNBT(NBTTagCompound tagCompund)
{
this.fireworkAge = tagCompund.getInteger("Life");
this.lifetime = tagCompund.getInteger("LifeTime");
NBTTagCompound nbttagcompound = tagCompund.getCompoundTag("FireworksItem");
if (nbttagcompound != null)
{
ItemStack itemstack = ItemStack.loadItemStackFromNBT(nbttagcompound);
if (itemstack != null)
{
this.dataWatcher.updateObject(8, itemstack);
}
}
}
示例8: renameWorld
import net.minecraft.nbt.NBTTagCompound; //导入方法依赖的package包/类
/**
* Renames the world by storing the new name in level.dat. It does *not* rename the directory containing the world
* data.
*/
public void renameWorld(String dirName, String newName)
{
File file1 = new File(this.savesDirectory, dirName);
if (file1.exists())
{
File file2 = new File(file1, "level.dat");
if (file2.exists())
{
try
{
NBTTagCompound nbttagcompound = CompressedStreamTools.readCompressed(new FileInputStream(file2));
NBTTagCompound nbttagcompound1 = nbttagcompound.getCompoundTag("Data");
nbttagcompound1.setString("LevelName", newName);
CompressedStreamTools.writeCompressed(nbttagcompound, new FileOutputStream(file2));
}
catch (Exception exception)
{
exception.printStackTrace();
}
}
}
}
示例9: readFromNBT
import net.minecraft.nbt.NBTTagCompound; //导入方法依赖的package包/类
@Override
public void readFromNBT(NBTTagCompound compound) {
fluid = CauldronLiquid.getFromName(compound.getString("cauldronType"));
level = compound.getInteger("cauldronLevel");
isActive = compound.getBoolean("isActive");
switchedItem = new ItemStack(compound.getCompoundTag("switchedItemStack"));
super.readFromNBT(compound);
}
示例10: readFromNBT
import net.minecraft.nbt.NBTTagCompound; //导入方法依赖的package包/类
public static Suction readFromNBT(NBTTagCompound tag) {
if (tag.hasKey("Suction", Constants.NBT.TAG_COMPOUND)) {
NBTTagCompound sucTag = tag.getCompoundTag("Suction");
int str = sucTag.getInteger("strength");
float min = sucTag.getFloat("minPurity");
float max = sucTag.getFloat("maxPurity");
return new Suction(str, min, max);
}
return NO_SUCTION;
}
示例11: readEntityFromNBT
import net.minecraft.nbt.NBTTagCompound; //导入方法依赖的package包/类
/**
* (abstract) Protected helper method to read subclass entity data from NBT.
*/
public void readEntityFromNBT(NBTTagCompound tagCompund)
{
this.health = tagCompund.getShort("Health") & 255;
this.age = tagCompund.getShort("Age");
if (tagCompund.hasKey("PickupDelay"))
{
this.delayBeforeCanPickup = tagCompund.getShort("PickupDelay");
}
if (tagCompund.hasKey("Owner"))
{
this.owner = tagCompund.getString("Owner");
}
if (tagCompund.hasKey("Thrower"))
{
this.thrower = tagCompund.getString("Thrower");
}
NBTTagCompound nbttagcompound = tagCompund.getCompoundTag("Item");
this.setEntityItemStack(ItemStack.loadItemStackFromNBT(nbttagcompound));
if (this.getEntityItem() == null)
{
this.setDead();
}
}
示例12: readFromNBT
import net.minecraft.nbt.NBTTagCompound; //导入方法依赖的package包/类
@Override
public void readFromNBT(NBTTagCompound compound) {
super.readFromNBT(compound);
NBTTagCompound randores = compound.getCompoundTag("randores");
this.input.deserializeNBT(randores.getCompoundTag("input"));
this.fuel.deserializeNBT(randores.getCompoundTag("fuel"));
this.output.deserializeNBT(randores.getCompoundTag("output"));
this.furnaceBurnTime = randores.getInteger("burn_time");
this.cookTime = randores.getInteger("cook_time");
this.totalCookTime = randores.getInteger("cook_time_total");
this.divisor = randores.getInteger("furnace_speed");
this.currentItemBurnTime = this.getBurnTime(this.fuel.getStackInSlot(0));
}
示例13: getWorldData
import net.minecraft.nbt.NBTTagCompound; //导入方法依赖的package包/类
@Nullable
public static WorldInfo getWorldData(File p_186353_0_, DataFixer dataFixerIn)
{
try
{
NBTTagCompound nbttagcompound = CompressedStreamTools.readCompressed(new FileInputStream(p_186353_0_));
NBTTagCompound nbttagcompound1 = nbttagcompound.getCompoundTag("Data");
return new WorldInfo(dataFixerIn.process(FixTypes.LEVEL, nbttagcompound1));
}
catch (Exception exception)
{
LOGGER.error("Exception reading {}", new Object[] {p_186353_0_, exception});
return null;
}
}
示例14: readEntityFromNBT
import net.minecraft.nbt.NBTTagCompound; //导入方法依赖的package包/类
/**
* (abstract) Protected helper method to read subclass entity data from NBT.
*/
public void readEntityFromNBT(NBTTagCompound compound)
{
super.readEntityFromNBT(compound);
this.setProfession(compound.getInteger("Profession"));
if (compound.hasKey("ProfessionName"))
{
net.minecraftforge.fml.common.registry.VillagerRegistry.VillagerProfession p =
net.minecraftforge.fml.common.registry.VillagerRegistry.instance().getRegistry().getValue(new net.minecraft.util.ResourceLocation(compound.getString("ProfessionName")));
if (p == null)
p = net.minecraftforge.fml.common.registry.VillagerRegistry.instance().getRegistry().getValue(new net.minecraft.util.ResourceLocation("minecraft:farmer"));
this.setProfession(p);
}
this.wealth = compound.getInteger("Riches");
this.careerId = compound.getInteger("Career");
this.careerLevel = compound.getInteger("CareerLevel");
this.isWillingToMate = compound.getBoolean("Willing");
if (compound.hasKey("Offers", 10))
{
NBTTagCompound nbttagcompound = compound.getCompoundTag("Offers");
this.buyingList = new MerchantRecipeList(nbttagcompound);
}
NBTTagList nbttaglist = compound.getTagList("Inventory", 10);
for (int i = 0; i < nbttaglist.tagCount(); ++i)
{
ItemStack itemstack = ItemStack.loadItemStackFromNBT(nbttaglist.getCompoundTagAt(i));
if (itemstack != null)
{
this.villagerInventory.addItem(itemstack);
}
}
this.setCanPickUpLoot(true);
this.setAdditionalAItasks();
}
示例15: ActionOptions
import net.minecraft.nbt.NBTTagCompound; //导入方法依赖的package包/类
public ActionOptions(NBTTagCompound tagCompound) {
NBTTagList list = tagCompound.getTagList("options", Constants.NBT.TAG_STRING);
actionOptions = new ArrayList<>();
for (int i = 0 ; i < list.tagCount() ; i++) {
actionOptions.add(new MeeCreepActionType(list.getStringTagAt(i)));
}
list = tagCompound.getTagList("maybe", Constants.NBT.TAG_STRING);
maybeActionOptions = new ArrayList<>();
for (int i = 0 ; i < list.tagCount() ; i++) {
maybeActionOptions.add(new MeeCreepActionType(list.getStringTagAt(i)));
}
list = tagCompound.getTagList("drops", Constants.NBT.TAG_COMPOUND);
drops = new ArrayList<>();
for (int i = 0 ; i < list.tagCount() ; i++) {
NBTTagCompound tc = list.getCompoundTagAt(i);
BlockPos p = BlockPos.fromLong(tc.getLong("p"));
NBTTagCompound itemTag = tc.getCompoundTag("i");
ItemStack stack = new ItemStack(itemTag);
drops.add(Pair.of(p, stack));
}
dimension = tagCompound.getInteger("dim");
targetPos = BlockPos.fromLong(tagCompound.getLong("pos"));
targetSide = EnumFacing.VALUES[tagCompound.getByte("targetSide")];
if (tagCompound.hasKey("player")) {
playerId = tagCompound.getUniqueId("player");
} else {
playerId = null;
}
actionId = tagCompound.getInteger("actionId");
timeout = tagCompound.getInteger("timeout");
stage = Stage.getByCode(tagCompound.getString("stage"));
if (tagCompound.hasKey("task")) {
task = new MeeCreepActionType(tagCompound.getString("task"));
}
if (tagCompound.hasKey("fqid")) {
furtherQuestionId = tagCompound.getString("fqid");
} else {
furtherQuestionId = null;
}
paused = tagCompound.getBoolean("paused");
}