本文整理汇总了Java中net.minecraft.nbt.NBTTagCompound.setShort方法的典型用法代码示例。如果您正苦于以下问题:Java NBTTagCompound.setShort方法的具体用法?Java NBTTagCompound.setShort怎么用?Java NBTTagCompound.setShort使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.nbt.NBTTagCompound
的用法示例。
在下文中一共展示了NBTTagCompound.setShort方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: writeToNBT
import net.minecraft.nbt.NBTTagCompound; //导入方法依赖的package包/类
public void writeToNBT(NBTTagCompound compound)
{
super.writeToNBT(compound);
compound.setShort("BrewTime", (short)this.brewTime);
NBTTagList nbttaglist = new NBTTagList();
for (int i = 0; i < this.brewingItemStacks.length; ++i)
{
if (this.brewingItemStacks[i] != null)
{
NBTTagCompound nbttagcompound = new NBTTagCompound();
nbttagcompound.setByte("Slot", (byte)i);
this.brewingItemStacks[i].writeToNBT(nbttagcompound);
nbttaglist.appendTag(nbttagcompound);
}
}
compound.setTag("Items", nbttaglist);
if (this.hasCustomName())
{
compound.setString("CustomName", this.customName);
}
}
示例2: addEnchantment
import net.minecraft.nbt.NBTTagCompound; //导入方法依赖的package包/类
/**
* Adds an enchantment with a desired level on the ItemStack.
*/
public void addEnchantment(Enchantment ench, int level)
{
if (this.stackTagCompound == null)
{
this.setTagCompound(new NBTTagCompound());
}
if (!this.stackTagCompound.hasKey("ench", 9))
{
this.stackTagCompound.setTag("ench", new NBTTagList());
}
NBTTagList nbttaglist = this.stackTagCompound.getTagList("ench", 10);
NBTTagCompound nbttagcompound = new NBTTagCompound();
nbttagcompound.setShort("id", (short)ench.effectId);
nbttagcompound.setShort("lvl", (short)((byte)level));
nbttaglist.appendTag(nbttagcompound);
}
示例3: writeToNBT
import net.minecraft.nbt.NBTTagCompound; //导入方法依赖的package包/类
public void writeToNBT(NBTTagCompound tagCompound) {
super.tileEntityWriteToNBT(tagCompound);
tagCompound.setShort("CurrentEnergy", (short) currentEnergy);
NBTTagList tagList = new NBTTagList();
for(int i = 0; i < machineItemStacks.length; ++i) {
if(machineItemStacks[i] != null) {
NBTTagCompound tagCompound1 = new NBTTagCompound();
tagCompound1.setByte("Slot", (byte) i);
machineItemStacks[i].writeToNBT(tagCompound1);
tagList.appendTag(tagCompound1);
}
}
tagCompound.setTag("Items", tagList);
if(hasCustomInventoryName())
tagCompound.setString("CustomName", machineName);
}
示例4: writeEntityToNBT
import net.minecraft.nbt.NBTTagCompound; //导入方法依赖的package包/类
/**
* (abstract) Protected helper method to write subclass entity data to NBT.
*/
public void writeEntityToNBT(NBTTagCompound tagCompound)
{
tagCompound.setShort("Health", (short)((byte)this.health));
tagCompound.setShort("Age", (short)this.age);
tagCompound.setShort("PickupDelay", (short)this.delayBeforeCanPickup);
if (this.getThrower() != null)
{
tagCompound.setString("Thrower", this.thrower);
}
if (this.getOwner() != null)
{
tagCompound.setString("Owner", this.owner);
}
if (this.getEntityItem() != null)
{
tagCompound.setTag("Item", this.getEntityItem().writeToNBT(new NBTTagCompound()));
}
}
示例5: writeEntityToNBT
import net.minecraft.nbt.NBTTagCompound; //导入方法依赖的package包/类
@Override
public void writeEntityToNBT(NBTTagCompound nbt) {
super.writeEntityToNBT(nbt);
nbt.setBoolean("Hidden", this.hidden);
if(hidden){
nbt.setIntArray("HiddenPos", new int[]{this.hiddenBlock.getX(),this.hiddenBlock.getY(),this.hiddenBlock.getZ()});
NBTTagList list=new NBTTagList();
nbt.setTag("Props", list);
for(BlockPos pos:this.usedPos)
list.appendTag(new NBTTagIntArray(new int[]{pos.getX(),pos.getY(),pos.getZ()}));
}
nbt.setShort("Begin", (short)this.begin);
nbt.setShort("Teleport", (short)this.teleportCooldown);
nbt.setShort("BombCooldown", (short)this.bombCooldown);
nbt.setShort("BombDuration", (short)this.bombDuration);
nbt.setShort("TopBlock", (short)this.topBlock);
nbt.setByte("HideCount", (byte)this.hideCount);
nbt.setBoolean("Bomb", this.isBombSpell());
}
示例6: onHackFinished
import net.minecraft.nbt.NBTTagCompound; //导入方法依赖的package包/类
@Override
public void onHackFinished(World world, BlockPos pos, EntityPlayer player) {
if (!world.isRemote) {
NBTTagCompound tag = new NBTTagCompound();
TileEntity te = world.getTileEntity(pos);
if (te != null) {
te.writeToNBT(tag);
tag.setShort("RequiredPlayerRange", (short) 0);
te.readFromNBT(tag);
IBlockState state = world.getBlockState(pos);
world.notifyBlockUpdate(pos, state, state, 3);
}
}
}
示例7: saveFlags
import net.minecraft.nbt.NBTTagCompound; //导入方法依赖的package包/类
/**
* Save flags to file
* @throws IOException If flags failed to save
*/
private void saveFlags() throws IOException {
NBTTagCompound tag = new NBTTagCompound();
tag.setInteger("Version", VERSION);
tag.setShort("Width", (short)getWidth());
tag.setShort("Height", (short)getHeight());
tag.setShort("Length", (short)getLength());
tag.setLong("SchemaLen", getSchemaLen());
tag.setInteger("Lift", getLift());
tag.setInteger("Method", getMethod().getValue());
tag.setInteger("Biome", getBiomus().getValue());
Utils.writeTags(getFileFlag(), tag);
}
示例8: writeEntityToNBT
import net.minecraft.nbt.NBTTagCompound; //导入方法依赖的package包/类
/**
* (abstract) Protected helper method to write subclass entity data to NBT.
*/
public void writeEntityToNBT(NBTTagCompound tagCompound)
{
tagCompound.setShort("xTile", (short)this.xTile);
tagCompound.setShort("yTile", (short)this.yTile);
tagCompound.setShort("zTile", (short)this.zTile);
ResourceLocation resourcelocation = (ResourceLocation)Block.blockRegistry.getNameForObject(this.inTile);
tagCompound.setString("inTile", resourcelocation == null ? "" : resourcelocation.toString());
tagCompound.setByte("shake", (byte)this.shake);
tagCompound.setByte("inGround", (byte)(this.inGround ? 1 : 0));
}
示例9: setEnchantments
import net.minecraft.nbt.NBTTagCompound; //导入方法依赖的package包/类
/**
* Set the enchantments for the specified stack.
*/
public static void setEnchantments(Map<Enchantment, Integer> enchMap, ItemStack stack)
{
NBTTagList nbttaglist = new NBTTagList();
for (Entry<Enchantment, Integer> entry : enchMap.entrySet())
{
Enchantment enchantment = (Enchantment)entry.getKey();
if (enchantment != null)
{
int i = ((Integer)entry.getValue()).intValue();
NBTTagCompound nbttagcompound = new NBTTagCompound();
nbttagcompound.setShort("id", (short)Enchantment.getEnchantmentID(enchantment));
nbttagcompound.setShort("lvl", (short)i);
nbttaglist.appendTag(nbttagcompound);
if (stack.getItem() == Items.ENCHANTED_BOOK)
{
Items.ENCHANTED_BOOK.addEnchantment(stack, new EnchantmentData(enchantment, i));
}
}
}
if (nbttaglist.hasNoTags())
{
if (stack.hasTagCompound())
{
stack.getTagCompound().removeTag("ench");
}
}
else if (stack.getItem() != Items.ENCHANTED_BOOK)
{
stack.setTagInfo("ench", nbttaglist);
}
}
示例10: writeToNBT
import net.minecraft.nbt.NBTTagCompound; //导入方法依赖的package包/类
/**
* Write the stack fields to a NBT object. Return the new NBT object.
*/
public NBTTagCompound writeToNBT(NBTTagCompound nbt)
{
ResourceLocation resourcelocation = (ResourceLocation)Item.itemRegistry.getNameForObject(this.item);
nbt.setString("id", resourcelocation == null ? "minecraft:air" : resourcelocation.toString());
nbt.setByte("Count", (byte)this.stackSize);
nbt.setShort("Damage", (short)this.itemDamage);
if (this.stackTagCompound != null)
{
nbt.setTag("tag", this.stackTagCompound);
}
return nbt;
}
示例11: writeEntityToNBT
import net.minecraft.nbt.NBTTagCompound; //导入方法依赖的package包/类
/**
* (abstract) Protected helper method to write subclass entity data to NBT.
*/
public void writeEntityToNBT(NBTTagCompound tagCompound)
{
tagCompound.setFloat("HealF", this.getHealth());
tagCompound.setShort("Health", (short)((int)Math.ceil((double)this.getHealth())));
tagCompound.setShort("HurtTime", (short)this.hurtTime);
tagCompound.setInteger("HurtByTimestamp", this.revengeTimer);
tagCompound.setShort("DeathTime", (short)this.deathTime);
tagCompound.setFloat("AbsorptionAmount", this.getAbsorptionAmount());
for (ItemStack itemstack : this.getInventory())
{
if (itemstack != null)
{
this.attributeMap.removeAttributeModifiers(itemstack.getAttributeModifiers());
}
}
tagCompound.setTag("Attributes", SharedMonsterAttributes.writeBaseAttributeMapToNBT(this.getAttributeMap()));
for (ItemStack itemstack1 : this.getInventory())
{
if (itemstack1 != null)
{
this.attributeMap.applyAttributeModifiers(itemstack1.getAttributeModifiers());
}
}
if (!this.activePotionsMap.isEmpty())
{
NBTTagList nbttaglist = new NBTTagList();
for (PotionEffect potioneffect : this.activePotionsMap.values())
{
nbttaglist.appendTag(potioneffect.writeCustomPotionEffectToNBT(new NBTTagCompound()));
}
tagCompound.setTag("ActiveEffects", nbttaglist);
}
}
示例12: writeToFixedNBT
import net.minecraft.nbt.NBTTagCompound; //导入方法依赖的package包/类
@Override
protected NBTTagCompound writeToFixedNBT (NBTTagCompound tag) {
tag = super.writeToFixedNBT(tag);
tag.setShort("BurnTime", (short)furnaceBurnTime);
tag.setShort("CookTime", (short)cookTime);
tag.setShort("CookTimeTotal", (short)totalCookTime);
ItemStackHelper.saveAllItems(tag, furnaceItemStacks);
return tag;
}
示例13: writeEntityToNBT
import net.minecraft.nbt.NBTTagCompound; //导入方法依赖的package包/类
/**
* (abstract) Protected helper method to write subclass entity data to NBT.
*/
public void writeEntityToNBT(NBTTagCompound compound)
{
super.writeEntityToNBT(compound);
compound.setShort("Anger", (short)this.angerLevel);
if (this.angerTargetUUID != null)
{
compound.setString("HurtBy", this.angerTargetUUID.toString());
}
else
{
compound.setString("HurtBy", "");
}
}
示例14: fixTagCompound
import net.minecraft.nbt.NBTTagCompound; //导入方法依赖的package包/类
public NBTTagCompound fixTagCompound(NBTTagCompound compound)
{
if ("minecraft:banner".equals(compound.getString("id")) && compound.hasKey("tag", 10))
{
NBTTagCompound nbttagcompound = compound.getCompoundTag("tag");
if (nbttagcompound.hasKey("BlockEntityTag", 10))
{
NBTTagCompound nbttagcompound1 = nbttagcompound.getCompoundTag("BlockEntityTag");
if (nbttagcompound1.hasKey("Base", 99))
{
compound.setShort("Damage", (short)(nbttagcompound1.getShort("Base") & 15));
if (nbttagcompound.hasKey("display", 10))
{
NBTTagCompound nbttagcompound2 = nbttagcompound.getCompoundTag("display");
if (nbttagcompound2.hasKey("Lore", 9))
{
NBTTagList nbttaglist = nbttagcompound2.getTagList("Lore", 8);
if (nbttaglist.tagCount() == 1 && "(+NBT)".equals(nbttaglist.getStringTagAt(0)))
{
return compound;
}
}
}
nbttagcompound1.removeTag("Base");
if (nbttagcompound1.hasNoTags())
{
nbttagcompound.removeTag("BlockEntityTag");
}
if (nbttagcompound.hasNoTags())
{
compound.removeTag("tag");
}
}
}
}
return compound;
}
示例15: writeEntityToNBT
import net.minecraft.nbt.NBTTagCompound; //导入方法依赖的package包/类
@Override
public void writeEntityToNBT(NBTTagCompound compound)
{
super.writeEntityToNBT(compound);
compound.setShort("Suspension", (short)suspension);
}