本文整理汇总了Java中net.minecraft.server.NBTTagList类的典型用法代码示例。如果您正苦于以下问题:Java NBTTagList类的具体用法?Java NBTTagList怎么用?Java NBTTagList使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NBTTagList类属于net.minecraft.server包,在下文中一共展示了NBTTagList类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getEnchantments
import net.minecraft.server.NBTTagList; //导入依赖的package包/类
static Map<Enchantment, Integer> getEnchantments(net.minecraft.server.ItemStack item) {
NBTTagList list = (item != null && item.hasEnchantments()) ? item.getEnchantments() : null;
if (list == null || list.size() == 0) {
return ImmutableMap.of();
}
ImmutableMap.Builder<Enchantment, Integer> result = ImmutableMap.builder();
for (int i = 0; i < list.size(); i++) {
int id = 0xffff & ((NBTTagCompound) list.get(i)).getShort(ENCHANTMENTS_ID.NBT);
int level = 0xffff & ((NBTTagCompound) list.get(i)).getShort(ENCHANTMENTS_LVL.NBT);
result.put(Enchantment.getById(id), level);
}
return result.build();
}
开发者ID:OvercastNetwork,项目名称:CraftBukkit,代码行数:19,代码来源:CraftItemStack.java
示例2: buildEnchantments
import net.minecraft.server.NBTTagList; //导入依赖的package包/类
static Map<Enchantment, Integer> buildEnchantments(NBTTagCompound tag, ItemMetaKey key) {
if (!tag.hasKey(key.NBT)) {
return null;
}
NBTTagList ench = tag.getList(key.NBT, 10);
Map<Enchantment, Integer> enchantments = new HashMap<Enchantment, Integer>(ench.size());
for (int i = 0; i < ench.size(); i++) {
int id = 0xffff & ((NBTTagCompound) ench.get(i)).getShort(ENCHANTMENTS_ID.NBT);
int level = 0xffff & ((NBTTagCompound) ench.get(i)).getShort(ENCHANTMENTS_LVL.NBT);
enchantments.put(Enchantment.getById(id), level);
}
return enchantments;
}
开发者ID:OvercastNetwork,项目名称:CraftBukkit,代码行数:18,代码来源:CraftMetaItem.java
示例3: applyEnchantments
import net.minecraft.server.NBTTagList; //导入依赖的package包/类
static void applyEnchantments(Map<Enchantment, Integer> enchantments, NBTTagCompound tag, ItemMetaKey key) {
if (enchantments == null || enchantments.size() == 0) {
return;
}
NBTTagList list = new NBTTagList();
for (Map.Entry<Enchantment, Integer> entry : enchantments.entrySet()) {
NBTTagCompound subtag = new NBTTagCompound();
subtag.setShort(ENCHANTMENTS_ID.NBT, (short) entry.getKey().getId());
subtag.setShort(ENCHANTMENTS_LVL.NBT, entry.getValue().shortValue());
list.add(subtag);
}
tag.set(key.NBT, list);
}
开发者ID:OvercastNetwork,项目名称:CraftBukkit,代码行数:19,代码来源:CraftMetaItem.java
示例4: CraftMetaFirework
import net.minecraft.server.NBTTagList; //导入依赖的package包/类
CraftMetaFirework(NBTTagCompound tag) {
super(tag);
if (!tag.hasKey(FIREWORKS.NBT)) {
return;
}
NBTTagCompound fireworks = tag.getCompound(FIREWORKS.NBT);
power = 0xff & fireworks.getByte(FLIGHT.NBT);
if (!fireworks.hasKey(EXPLOSIONS.NBT)) {
return;
}
NBTTagList fireworkEffects = fireworks.getList(EXPLOSIONS.NBT, 10);
List<FireworkEffect> effects = this.effects = new ArrayList<FireworkEffect>(fireworkEffects.size());
for (int i = 0; i < fireworkEffects.size(); i++) {
effects.add(getEffect((NBTTagCompound) fireworkEffects.get(i)));
}
}
开发者ID:OvercastNetwork,项目名称:CraftBukkit,代码行数:23,代码来源:CraftMetaFirework.java
示例5: applyToItem
import net.minecraft.server.NBTTagList; //导入依赖的package包/类
@Override
void applyToItem(NBTTagCompound itemTag) {
super.applyToItem(itemTag);
if (isFireworkEmpty()) {
return;
}
NBTTagCompound fireworks = itemTag.getCompound(FIREWORKS.NBT);
itemTag.set(FIREWORKS.NBT, fireworks);
if (hasEffects()) {
NBTTagList effects = new NBTTagList();
for (FireworkEffect effect : this.effects) {
effects.add(getExplosion(effect));
}
if (effects.size() > 0) {
fireworks.set(EXPLOSIONS.NBT, effects);
}
}
if (hasPower()) {
fireworks.setByte(FLIGHT.NBT, (byte) power);
}
}
开发者ID:OvercastNetwork,项目名称:CraftBukkit,代码行数:26,代码来源:CraftMetaFirework.java
示例6: CraftMetaBook
import net.minecraft.server.NBTTagList; //导入依赖的package包/类
CraftMetaBook(NBTTagCompound tag) {
super(tag);
if (tag.hasKey(BOOK_TITLE.NBT)) {
this.title = tag.getString(BOOK_TITLE.NBT);
}
if (tag.hasKey(BOOK_AUTHOR.NBT)) {
this.author = tag.getString(BOOK_AUTHOR.NBT);
}
if (tag.hasKey(BOOK_PAGES.NBT)) {
NBTTagList pages = tag.getList(BOOK_PAGES.NBT, 8);
String[] pageArray = new String[pages.size()];
for (int i = 0; i < pages.size(); i++) {
String page = pages.getString(i);
pageArray[i] = page;
}
addPage(pageArray);
}
}
开发者ID:OvercastNetwork,项目名称:CraftBukkit,代码行数:24,代码来源:CraftMetaBook.java
示例7: CraftMetaPotion
import net.minecraft.server.NBTTagList; //导入依赖的package包/类
CraftMetaPotion(NBTTagCompound tag) {
super(tag);
if (tag.hasKey(POTION_EFFECTS.NBT)) {
NBTTagList list = tag.getList(POTION_EFFECTS.NBT, 10);
int length = list.size();
if (length > 0) {
customEffects = new ArrayList<PotionEffect>(length);
for (int i = 0; i < length; i++) {
NBTTagCompound effect = list.get(i);
PotionEffectType type = PotionEffectType.getById(effect.getByte(ID.NBT));
int amp = effect.getByte(AMPLIFIER.NBT);
int duration = effect.getInt(DURATION.NBT);
boolean ambient = effect.getBoolean(AMBIENT.NBT);
customEffects.add(new PotionEffect(type, duration, amp, ambient));
}
}
}
}
开发者ID:OvercastNetwork,项目名称:CraftBukkit,代码行数:21,代码来源:CraftMetaPotion.java
示例8: applyToItem
import net.minecraft.server.NBTTagList; //导入依赖的package包/类
@Override
void applyToItem(NBTTagCompound tag) {
super.applyToItem(tag);
if (hasCustomEffects()) {
NBTTagList effectList = new NBTTagList();
tag.set(POTION_EFFECTS.NBT, effectList);
for (PotionEffect effect : customEffects) {
NBTTagCompound effectData = new NBTTagCompound();
effectData.setByte(ID.NBT, (byte) effect.getType().getId());
effectData.setByte(AMPLIFIER.NBT, (byte) effect.getAmplifier());
effectData.setInt(DURATION.NBT, effect.getDuration());
effectData.setBoolean(AMBIENT.NBT, effect.isAmbient());
effectList.add(effectData);
}
}
}
开发者ID:OvercastNetwork,项目名称:CraftBukkit,代码行数:18,代码来源:CraftMetaPotion.java
示例9: update
import net.minecraft.server.NBTTagList; //导入依赖的package包/类
@Override
public boolean update(boolean force, boolean applyPhysics) {
boolean result = super.update(force, applyPhysics);
if (result) {
banner.color = base.getDyeData();
NBTTagList newPatterns = new NBTTagList();
for (Pattern p : patterns) {
NBTTagCompound compound = new NBTTagCompound();
compound.setInt("Color", p.getColor().getDyeData());
compound.setString("Pattern", p.getPattern().getIdentifier());
newPatterns.add(compound);
}
banner.patterns = newPatterns;
banner.update();
}
return result;
}
开发者ID:tgnmc,项目名称:Craftbukkit,代码行数:24,代码来源:CraftBanner.java
示例10: CraftMetaBookSigned
import net.minecraft.server.NBTTagList; //导入依赖的package包/类
CraftMetaBookSigned(NBTTagCompound tag) {
super(tag, false);
boolean resolved = true;
if (tag.hasKey(RESOLVED.NBT)) {
resolved = tag.getBoolean(RESOLVED.NBT);
}
if (tag.hasKey(BOOK_PAGES.NBT)) {
NBTTagList pages = tag.getList(BOOK_PAGES.NBT, 8);
for (int i = 0; i < pages.size(); i++) {
String page = pages.getString(i);
if (resolved) {
try {
this.pages.add(ChatSerializer.a(page));
continue;
} catch (Exception e) {
// Ignore and treat as an old book
}
}
addPage(page);
}
}
}
开发者ID:tgnmc,项目名称:Craftbukkit,代码行数:26,代码来源:CraftMetaBookSigned.java
示例11: CraftMetaBanner
import net.minecraft.server.NBTTagList; //导入依赖的package包/类
CraftMetaBanner(NBTTagCompound tag) {
super(tag);
if (!tag.hasKey("BlockEntityTag")) {
return;
}
NBTTagCompound entityTag = tag.getCompound("BlockEntityTag");
base = entityTag.hasKey(BASE.NBT) ? DyeColor.getByDyeData((byte) entityTag.getInt(BASE.NBT)) : null;
if (entityTag.hasKey(PATTERNS.NBT)) {
NBTTagList patterns = entityTag.getList(PATTERNS.NBT, 10);
for (int i = 0; i < Math.min(patterns.size(), 20); i++) {
NBTTagCompound p = patterns.get(i);
this.patterns.add(new Pattern(DyeColor.getByDyeData((byte) p.getInt(COLOR.NBT)), PatternType.getByIdentifier(p.getString(PATTERN.NBT))));
}
}
}
开发者ID:tgnmc,项目名称:Craftbukkit,代码行数:20,代码来源:CraftMetaBanner.java
示例12: applyToItem
import net.minecraft.server.NBTTagList; //导入依赖的package包/类
@Override
void applyToItem(NBTTagCompound tag) {
super.applyToItem(tag);
NBTTagCompound entityTag = new NBTTagCompound();
if (base != null) {
entityTag.setInt(BASE.NBT, base.getDyeData());
}
NBTTagList newPatterns = new NBTTagList();
for (Pattern p : patterns) {
NBTTagCompound compound = new NBTTagCompound();
compound.setInt(COLOR.NBT, p.getColor().getDyeData());
compound.setString(PATTERN.NBT, p.getPattern().getIdentifier());
newPatterns.add(compound);
}
entityTag.set(PATTERNS.NBT, newPatterns);
tag.set("BlockEntityTag", entityTag);
}
开发者ID:tgnmc,项目名称:Craftbukkit,代码行数:22,代码来源:CraftMetaBanner.java
示例13: CraftMetaPotion
import net.minecraft.server.NBTTagList; //导入依赖的package包/类
CraftMetaPotion(NBTTagCompound tag) {
super(tag);
if (tag.hasKey(POTION_EFFECTS.NBT)) {
NBTTagList list = tag.getList(POTION_EFFECTS.NBT, 10);
int length = list.size();
customEffects = new ArrayList<PotionEffect>(length);
for (int i = 0; i < length; i++) {
NBTTagCompound effect = list.get(i);
PotionEffectType type = PotionEffectType.getById(effect.getByte(ID.NBT));
int amp = effect.getByte(AMPLIFIER.NBT);
int duration = effect.getInt(DURATION.NBT);
boolean ambient = effect.getBoolean(AMBIENT.NBT);
boolean particles = effect.getBoolean(SHOW_PARTICLES.NBT);
customEffects.add(new PotionEffect(type, duration, amp, ambient, particles));
}
}
}
开发者ID:tgnmc,项目名称:Craftbukkit,代码行数:20,代码来源:CraftMetaPotion.java
示例14: applyToItem
import net.minecraft.server.NBTTagList; //导入依赖的package包/类
@Override
void applyToItem(NBTTagCompound tag) {
super.applyToItem(tag);
if (customEffects != null) {
NBTTagList effectList = new NBTTagList();
tag.set(POTION_EFFECTS.NBT, effectList);
for (PotionEffect effect : customEffects) {
NBTTagCompound effectData = new NBTTagCompound();
effectData.setByte(ID.NBT, (byte) effect.getType().getId());
effectData.setByte(AMPLIFIER.NBT, (byte) effect.getAmplifier());
effectData.setInt(DURATION.NBT, effect.getDuration());
effectData.setBoolean(AMBIENT.NBT, effect.isAmbient());
effectData.setBoolean(SHOW_PARTICLES.NBT, effect.hasParticles());
effectList.add(effectData);
}
}
}
开发者ID:tgnmc,项目名称:Craftbukkit,代码行数:19,代码来源:CraftMetaPotion.java
示例15: getEnchantments
import net.minecraft.server.NBTTagList; //导入依赖的package包/类
static Map<Enchantment, Integer> getEnchantments(net.minecraft.server.ItemStack item) {
ImmutableMap.Builder<Enchantment, Integer> result = ImmutableMap.builder();
NBTTagList list = (item == null) ? null : item.getEnchantments();
if (list == null) {
return result.build();
}
for (int i = 0; i < list.size(); i++) {
int id = 0xffff & ((NBTTagCompound) list.get(i)).getShort(ENCHANTMENTS_ID.NBT);
int level = 0xffff & ((NBTTagCompound) list.get(i)).getShort(ENCHANTMENTS_LVL.NBT);
result.put(Enchantment.getById(id), level);
}
return result.build();
}
开发者ID:AlmuraDev,项目名称:Almura-Server,代码行数:18,代码来源:CraftItemStack.java
示例16: buildEnchantments
import net.minecraft.server.NBTTagList; //导入依赖的package包/类
static Map<Enchantment, Integer> buildEnchantments(NBTTagCompound tag, ItemMetaKey key) {
if (!tag.hasKey(key.NBT)) {
return null;
}
NBTTagList ench = tag.getList(key.NBT);
Map<Enchantment, Integer> enchantments = new HashMap<Enchantment, Integer>(ench.size());
for (int i = 0; i < ench.size(); i++) {
int id = 0xffff & ((NBTTagCompound) ench.get(i)).getShort(ENCHANTMENTS_ID.NBT);
int level = 0xffff & ((NBTTagCompound) ench.get(i)).getShort(ENCHANTMENTS_LVL.NBT);
enchantments.put(Enchantment.getById(id), level);
}
return enchantments;
}
开发者ID:AlmuraDev,项目名称:Almura-Server,代码行数:18,代码来源:CraftMetaItem.java
示例17: applyEnchantments
import net.minecraft.server.NBTTagList; //导入依赖的package包/类
static void applyEnchantments(Map<Enchantment, Integer> enchantments, NBTTagCompound tag, ItemMetaKey key) {
if (enchantments == null || enchantments.size() == 0) {
return;
}
NBTTagList list = new NBTTagList(key.NBT);
for (Map.Entry<Enchantment, Integer> entry : enchantments.entrySet()) {
NBTTagCompound subtag = new NBTTagCompound();
subtag.setShort(ENCHANTMENTS_ID.NBT, (short) entry.getKey().getId());
subtag.setShort(ENCHANTMENTS_LVL.NBT, entry.getValue().shortValue());
list.add(subtag);
}
tag.set(key.NBT, list);
}
开发者ID:AlmuraDev,项目名称:Almura-Server,代码行数:19,代码来源:CraftMetaItem.java
示例18: CraftMetaFirework
import net.minecraft.server.NBTTagList; //导入依赖的package包/类
CraftMetaFirework(NBTTagCompound tag) {
super(tag);
if (!tag.hasKey(FIREWORKS.NBT)) {
return;
}
NBTTagCompound fireworks = tag.getCompound(FIREWORKS.NBT);
power = 0xff & fireworks.getByte(FLIGHT.NBT);
if (!fireworks.hasKey(EXPLOSIONS.NBT)) {
return;
}
NBTTagList fireworkEffects = fireworks.getList(EXPLOSIONS.NBT);
List<FireworkEffect> effects = this.effects = new ArrayList<FireworkEffect>(fireworkEffects.size());
for (int i = 0; i < fireworkEffects.size(); i++) {
effects.add(getEffect((NBTTagCompound) fireworkEffects.get(i)));
}
}
开发者ID:AlmuraDev,项目名称:Almura-Server,代码行数:23,代码来源:CraftMetaFirework.java
示例19: applyToItem
import net.minecraft.server.NBTTagList; //导入依赖的package包/类
@Override
void applyToItem(NBTTagCompound itemTag) {
super.applyToItem(itemTag);
if (isFireworkEmpty()) {
return;
}
NBTTagCompound fireworks = itemTag.getCompound(FIREWORKS.NBT);
itemTag.setCompound(FIREWORKS.NBT, fireworks);
if (hasEffects()) {
NBTTagList effects = new NBTTagList(EXPLOSIONS.NBT);
for (FireworkEffect effect : this.effects) {
effects.add(getExplosion(effect));
}
if (effects.size() > 0) {
fireworks.set(EXPLOSIONS.NBT, effects);
}
}
if (hasPower()) {
fireworks.setByte(FLIGHT.NBT, (byte) power);
}
}
开发者ID:AlmuraDev,项目名称:Almura-Server,代码行数:26,代码来源:CraftMetaFirework.java
示例20: CraftMetaBook
import net.minecraft.server.NBTTagList; //导入依赖的package包/类
CraftMetaBook(NBTTagCompound tag) {
super(tag);
if (tag.hasKey(BOOK_TITLE.NBT)) {
this.title = tag.getString(BOOK_TITLE.NBT);
}
if (tag.hasKey(BOOK_AUTHOR.NBT)) {
this.author = tag.getString(BOOK_AUTHOR.NBT);
}
if (tag.hasKey(BOOK_PAGES.NBT)) {
NBTTagList pages = tag.getList(BOOK_PAGES.NBT);
String[] pageArray = new String[pages.size()];
for (int i = 0; i < pages.size(); i++) {
String page = ((NBTTagString) pages.get(i)).data;
pageArray[i] = page;
}
addPage(pageArray);
}
}
开发者ID:AlmuraDev,项目名称:Almura-Server,代码行数:24,代码来源:CraftMetaBook.java
注:本文中的net.minecraft.server.NBTTagList类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论