本文整理汇总了Java中net.minecraft.server.NBTTagCompound类的典型用法代码示例。如果您正苦于以下问题:Java NBTTagCompound类的具体用法?Java NBTTagCompound怎么用?Java NBTTagCompound使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NBTTagCompound类属于net.minecraft.server包,在下文中一共展示了NBTTagCompound类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: checkStoredChunks
import net.minecraft.server.NBTTagCompound; //导入依赖的package包/类
/**
* Not really a test.
*/
@Test
public void checkStoredChunks() throws Exception {
Jedis jedis = new Jedis("localhost");
Set<String> keys = jedis.keys("world:*");
for (String key : keys) {
byte[] bytes = jedis.get(key.getBytes(UTF_8));
DataInputStream dataStream = new DataInputStream(new InflaterInputStream(new ByteArrayInputStream(bytes)));
try {
NBTTagCompound a = NBTCompressedStreamTools.a(dataStream);
} catch (Exception e) {
System.out.println("bad chunk at " + key + " (" + bytes.length + " bytes) : " + e);
}
}
}
开发者ID:jonathanperret,项目名称:redismine,代码行数:21,代码来源:RedisCheckChunks.java
示例2: getEnchantments
import net.minecraft.server.NBTTagCompound; //导入依赖的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
示例3: buildEnchantments
import net.minecraft.server.NBTTagCompound; //导入依赖的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
示例4: applyToItem
import net.minecraft.server.NBTTagCompound; //导入依赖的package包/类
@Overridden
void applyToItem(NBTTagCompound itemTag) {
if (hasDisplayName()) {
setDisplayTag(itemTag, NAME.NBT, new NBTTagString(displayName));
}
if (hasLore()) {
setDisplayTag(itemTag, LORE.NBT, createStringList(lore));
}
applyEnchantments(enchantments, itemTag, ENCHANTMENTS);
if (hasRepairCost()) {
itemTag.setInt(REPAIR.NBT, repairCost);
}
if (attributes != null) {
itemTag.set(ATTRIBUTES.NBT, attributes);
}
}
开发者ID:OvercastNetwork,项目名称:CraftBukkit,代码行数:21,代码来源:CraftMetaItem.java
示例5: applyEnchantments
import net.minecraft.server.NBTTagCompound; //导入依赖的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
示例6: CraftMetaFirework
import net.minecraft.server.NBTTagCompound; //导入依赖的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
示例7: getExplosion
import net.minecraft.server.NBTTagCompound; //导入依赖的package包/类
static NBTTagCompound getExplosion(FireworkEffect effect) {
NBTTagCompound explosion = new NBTTagCompound();
if (effect.hasFlicker()) {
explosion.setBoolean(EXPLOSION_FLICKER.NBT, true);
}
if (effect.hasTrail()) {
explosion.setBoolean(EXPLOSION_TRAIL.NBT, true);
}
addColors(explosion, EXPLOSION_COLORS, effect.getColors());
addColors(explosion, EXPLOSION_FADE, effect.getFadeColors());
explosion.setByte(EXPLOSION_TYPE.NBT, (byte) getNBT(effect.getType()));
return explosion;
}
开发者ID:OvercastNetwork,项目名称:CraftBukkit,代码行数:19,代码来源:CraftMetaFirework.java
示例8: applyToItem
import net.minecraft.server.NBTTagCompound; //导入依赖的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
示例9: CraftMetaBook
import net.minecraft.server.NBTTagCompound; //导入依赖的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
示例10: applyToItem
import net.minecraft.server.NBTTagCompound; //导入依赖的package包/类
@Override
void applyToItem(NBTTagCompound itemData) {
super.applyToItem(itemData);
if (hasTitle()) {
itemData.setString(BOOK_TITLE.NBT, this.title);
}
if (hasAuthor()) {
itemData.setString(BOOK_AUTHOR.NBT, this.author);
}
if (hasPages()) {
itemData.set(BOOK_PAGES.NBT, createStringList(pages));
}
}
开发者ID:OvercastNetwork,项目名称:CraftBukkit,代码行数:17,代码来源:CraftMetaBook.java
示例11: CraftMetaPotion
import net.minecraft.server.NBTTagCompound; //导入依赖的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
示例12: applyToItem
import net.minecraft.server.NBTTagCompound; //导入依赖的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
示例13: getName
import net.minecraft.server.NBTTagCompound; //导入依赖的package包/类
public String getName() {
Player player = getPlayer();
if (player != null) {
return player.getName();
}
// This might not match lastKnownName but if not it should be more correct
if (profile.getName() != null) {
return profile.getName();
}
NBTTagCompound data = getBukkitData();
if (data != null) {
if (data.hasKey("lastKnownName")) {
return data.getString("lastKnownName");
}
}
return null;
}
开发者ID:OvercastNetwork,项目名称:CraftBukkit,代码行数:22,代码来源:CraftOfflinePlayer.java
示例14: getFirstPlayed
import net.minecraft.server.NBTTagCompound; //导入依赖的package包/类
public long getFirstPlayed() {
Player player = getPlayer();
if (player != null) return player.getFirstPlayed();
NBTTagCompound data = getBukkitData();
if (data != null) {
if (data.hasKey("firstPlayed")) {
return data.getLong("firstPlayed");
} else {
File file = getDataFile();
return file.lastModified();
}
} else {
return 0;
}
}
开发者ID:OvercastNetwork,项目名称:CraftBukkit,代码行数:18,代码来源:CraftOfflinePlayer.java
示例15: getLastPlayed
import net.minecraft.server.NBTTagCompound; //导入依赖的package包/类
public long getLastPlayed() {
Player player = getPlayer();
if (player != null) return player.getLastPlayed();
NBTTagCompound data = getBukkitData();
if (data != null) {
if (data.hasKey("lastPlayed")) {
return data.getLong("lastPlayed");
} else {
File file = getDataFile();
return file.lastModified();
}
} else {
return 0;
}
}
开发者ID:OvercastNetwork,项目名称:CraftBukkit,代码行数:18,代码来源:CraftOfflinePlayer.java
示例16: update
import net.minecraft.server.NBTTagCompound; //导入依赖的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
示例17: setItemMeta
import net.minecraft.server.NBTTagCompound; //导入依赖的package包/类
public static boolean setItemMeta(net.minecraft.server.ItemStack item, ItemMeta itemMeta) {
if (item == null) {
return false;
}
if (CraftItemFactory.instance().equals(itemMeta, null)) {
item.setTag(null);
return true;
}
if (!CraftItemFactory.instance().isApplicable(itemMeta, getType(item))) {
return false;
}
itemMeta = CraftItemFactory.instance().asMetaFor(itemMeta, getType(item));
if (itemMeta == null) return true;
NBTTagCompound tag = new NBTTagCompound();
item.setTag(tag);
((CraftMetaItem) itemMeta).applyToItem(tag);
return true;
}
开发者ID:tgnmc,项目名称:Craftbukkit,代码行数:23,代码来源:CraftItemStack.java
示例18: CraftMetaBookSigned
import net.minecraft.server.NBTTagCompound; //导入依赖的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
示例19: applyToItem
import net.minecraft.server.NBTTagCompound; //导入依赖的package包/类
@Overridden
void applyToItem(NBTTagCompound itemTag) {
if (hasDisplayName()) {
setDisplayTag(itemTag, NAME.NBT, new NBTTagString(displayName));
}
if (hasLore()) {
setDisplayTag(itemTag, LORE.NBT, createStringList(lore));
}
if (hideFlag != 0) {
itemTag.setInt(HIDEFLAGS.NBT, hideFlag);
}
applyEnchantments(enchantments, itemTag, ENCHANTMENTS);
if (hasRepairCost()) {
itemTag.setInt(REPAIR.NBT, repairCost);
}
for (Map.Entry<String, NBTBase> e : unhandledTags.entrySet()) {
itemTag.set(e.getKey(), e.getValue());
}
}
开发者ID:tgnmc,项目名称:Craftbukkit,代码行数:25,代码来源:CraftMetaItem.java
示例20: CraftMetaBanner
import net.minecraft.server.NBTTagCompound; //导入依赖的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
注:本文中的net.minecraft.server.NBTTagCompound类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论