本文整理汇总了Java中cn.nukkit.nbt.tag.CompoundTag.get方法的典型用法代码示例。如果您正苦于以下问题:Java CompoundTag.get方法的具体用法?Java CompoundTag.get怎么用?Java CompoundTag.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cn.nukkit.nbt.tag.CompoundTag
的用法示例。
在下文中一共展示了CompoundTag.get方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCustomBlockData
import cn.nukkit.nbt.tag.CompoundTag; //导入方法依赖的package包/类
public CompoundTag getCustomBlockData() {
if (!this.hasCompoundTag()) {
return null;
}
CompoundTag tag = this.getNamedTag();
if (tag.contains("BlockEntityTag")) {
Tag bet = tag.get("BlockEntityTag");
if (bet instanceof CompoundTag) {
return (CompoundTag) bet;
}
}
return null;
}
示例2: clearCustomName
import cn.nukkit.nbt.tag.CompoundTag; //导入方法依赖的package包/类
public Item clearCustomName() {
if (!this.hasCompoundTag()) {
return this;
}
CompoundTag tag = this.getNamedTag();
if (tag.contains("display") && tag.get("display") instanceof CompoundTag) {
tag.getCompound("display").remove("Name");
if (tag.getCompound("display").isEmpty()) {
tag.remove("display");
}
this.setNamedTag(tag);
}
return this;
}
示例3: hasEnchantments
import cn.nukkit.nbt.tag.CompoundTag; //导入方法依赖的package包/类
public boolean hasEnchantments() {
if (!this.hasCompoundTag()) {
return false;
}
CompoundTag tag = this.getNamedTag();
if (tag.contains("ench")) {
Tag enchTag = tag.get("ench");
if (enchTag instanceof ListTag) {
return true;
}
}
return false;
}
示例4: BaseLevelProvider
import cn.nukkit.nbt.tag.CompoundTag; //导入方法依赖的package包/类
public BaseLevelProvider(Level level, String path) throws IOException {
this.level = level;
this.path = path;
File file_path = new File(this.path);
if (!file_path.exists()) {
file_path.mkdirs();
}
CompoundTag levelData = NBTIO.readCompressed(new FileInputStream(new File(this.getPath() + "level.dat")), ByteOrder.BIG_ENDIAN);
if (levelData.get("Data") instanceof CompoundTag) {
this.levelData = levelData.getCompound("Data");
} else {
throw new LevelException("Invalid level.dat");
}
if (!this.levelData.contains("generatorName")) {
this.levelData.putString("generatorName", Generator.getGenerator("DEFAULT").getSimpleName().toLowerCase());
}
if (!this.levelData.contains("generatorOptions")) {
this.levelData.putString("generatorOptions", "");
}
}
示例5: clearCustomBlockData
import cn.nukkit.nbt.tag.CompoundTag; //导入方法依赖的package包/类
public Item clearCustomBlockData() {
if (!this.hasCompoundTag()) {
return this;
}
CompoundTag tag = this.getNamedTag();
if (tag.contains("BlockEntityTag") && tag.get("BlockEntityTag") instanceof CompoundTag) {
tag.remove("BlockEntityTag");
this.setNamedTag(tag);
}
return this;
}
示例6: fromBinary
import cn.nukkit.nbt.tag.CompoundTag; //导入方法依赖的package包/类
public static Chunk fromBinary(byte[] data, LevelProvider provider) {
try {
CompoundTag chunk = NBTIO.read(new ByteArrayInputStream(Zlib.inflate(data)), ByteOrder.BIG_ENDIAN);
if (!chunk.contains("Level") || !(chunk.get("Level") instanceof CompoundTag)) {
return null;
}
return new Chunk(provider != null ? provider : McRegion.class.newInstance(), chunk.getCompound("Level"));
} catch (Exception e) {
return null;
}
}
示例7: getCustomName
import cn.nukkit.nbt.tag.CompoundTag; //导入方法依赖的package包/类
public String getCustomName() {
if (!this.hasCompoundTag()) {
return "";
}
CompoundTag tag = this.getNamedTag();
if (tag.contains("display")) {
Tag tag1 = tag.get("display");
if (tag1 instanceof CompoundTag && ((CompoundTag) tag1).contains("Name") && ((CompoundTag) tag1).get("Name") instanceof StringTag) {
return ((CompoundTag) tag1).getString("Name");
}
}
return "";
}
示例8: getItemHelper
import cn.nukkit.nbt.tag.CompoundTag; //导入方法依赖的package包/类
public static Item getItemHelper(CompoundTag tag) {
if (!tag.contains("id") || !tag.contains("Count")) {
return Item.get(0);
}
Item item = Item.get(tag.getShort("id"), !tag.contains("Damage") ? 0 : tag.getShort("Damage"), tag.getByte("Count"));
if (tag.contains("tag") && tag.get("tag") instanceof CompoundTag) {
item.setNamedTag(tag.getCompound("tag"));
}
return item;
}
示例9: hasCustomName
import cn.nukkit.nbt.tag.CompoundTag; //导入方法依赖的package包/类
public boolean hasCustomName() {
if (!this.hasCompoundTag()) {
return false;
}
CompoundTag tag = this.getNamedTag();
if (tag.contains("display")) {
Tag tag1 = tag.get("display");
if (tag1 instanceof CompoundTag && ((CompoundTag) tag1).contains("Name") && ((CompoundTag) tag1).get("Name") instanceof StringTag) {
return true;
}
}
return false;
}
示例10: getNamedTagEntry
import cn.nukkit.nbt.tag.CompoundTag; //导入方法依赖的package包/类
public Tag getNamedTagEntry(String name) {
CompoundTag tag = this.getNamedTag();
if (tag != null) {
return tag.contains(name) ? tag.get(name) : null;
}
return null;
}
示例11: hasCustomBlockData
import cn.nukkit.nbt.tag.CompoundTag; //导入方法依赖的package包/类
public boolean hasCustomBlockData() {
if (!this.hasCompoundTag()) {
return false;
}
CompoundTag tag = this.getNamedTag();
return tag.contains("BlockEntityTag") && tag.get("BlockEntityTag") instanceof CompoundTag;
}