本文整理汇总了Java中cn.nukkit.nbt.tag.CompoundTag.contains方法的典型用法代码示例。如果您正苦于以下问题:Java CompoundTag.contains方法的具体用法?Java CompoundTag.contains怎么用?Java CompoundTag.contains使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cn.nukkit.nbt.tag.CompoundTag
的用法示例。
在下文中一共展示了CompoundTag.contains方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: BlockEntityMovingBlock
import cn.nukkit.nbt.tag.CompoundTag; //导入方法依赖的package包/类
public BlockEntityMovingBlock(FullChunk chunk, CompoundTag nbt) {
super(chunk, nbt);
if (nbt.contains("movingBlockData") && nbt.contains("movingBlockId")) {
this.block = Block.get(nbt.getInt("movingBlockId"), nbt.getInt("movingBlockData"));
} else {
this.close();
}
if (nbt.contains("pistonPosX") && nbt.contains("pistonPosY") && nbt.contains("pistonPosZ")) {
this.piston = new BlockVector3(nbt.getInt("pistonPosX"), nbt.getInt("pistonPosY"), nbt.getInt("pistonPosZ"));
} else {
this.close();
}
this.isMovable = nbt.getBoolean("isMovable");
}
示例3: BlockEntitySign
import cn.nukkit.nbt.tag.CompoundTag; //导入方法依赖的package包/类
public BlockEntitySign(FullChunk chunk, CompoundTag nbt) {
super(chunk, nbt);
if (!nbt.contains("Text1")) {
nbt.putString("Text1", "");
}
if (!nbt.contains("Text2")) {
nbt.putString("Text2", "");
}
if (!nbt.contains("Text3")) {
nbt.putString("Text3", "");
}
if (!nbt.contains("Text4")) {
nbt.putString("Text4", "");
}
this.namedTag = nbt;
}
示例4: BlockEntitySign
import cn.nukkit.nbt.tag.CompoundTag; //导入方法依赖的package包/类
public BlockEntitySign(FullChunk chunk, CompoundTag nbt) {
super(chunk, nbt);
if (!nbt.contains("Text")) {
List<String> lines = new ArrayList<>();
for (int i = 1; i <= 4; i++) {
String key = "Text" + i;
if (nbt.contains(key)) {
String line = nbt.getString(key);
lines.add(line);
nbt.remove(key);
}
}
nbt.putString("Text", String.join("\n", lines));
}
}
示例5: 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;
}
示例6: 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;
}
示例7: BlockEntityItemFrame
import cn.nukkit.nbt.tag.CompoundTag; //导入方法依赖的package包/类
public BlockEntityItemFrame(FullChunk chunk, CompoundTag nbt) {
super(chunk, nbt);
if (!nbt.contains("Item")) {
nbt.putCompound("Item", NBTIO.putItemHelper(new ItemBlock(new BlockAir())));
}
if (!nbt.contains("ItemRotation")) {
nbt.putByte("ItemRotation", 0);
}
if (!nbt.contains("ItemDropChance")) {
nbt.putFloat("ItemDropChance", 1.0f);
}
this.level.updateComparatorOutputLevel(this);
}
示例8: 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;
}
示例9: BlockEntitySkull
import cn.nukkit.nbt.tag.CompoundTag; //导入方法依赖的package包/类
public BlockEntitySkull(FullChunk chunk, CompoundTag nbt) {
super(chunk, nbt);
if (!nbt.contains("SkullType")) {
nbt.putByte("SkullType", 0);
}
if (!nbt.contains("Rot")) {
nbt.putByte("Rot", 0);
}
this.namedTag = nbt;
}
示例10: BlockEntityPistonArm
import cn.nukkit.nbt.tag.CompoundTag; //导入方法依赖的package包/类
public BlockEntityPistonArm(FullChunk chunk, CompoundTag nbt) {
super(chunk, nbt);
if (nbt.contains("Progress")) {
this.progress = nbt.getFloat("Progress");
}
if (nbt.contains("LastProgress")) {
this.lastProgress = nbt.getInt("LastProgress");
}
if (nbt.contains("Sticky")) {
this.sticky = nbt.getBoolean("Sticky");
}
if (nbt.contains("Extending")) {
this.extending = nbt.getBoolean("Extending");
}
if (nbt.contains("AttachedBlocks")) {
ListTag<IntTag> blocks = nbt.getList("AttachedBlocks", IntTag.class);
if (blocks != null && blocks.size() > 0) {
this.attachedBlock = new Vector3(blocks.get(0).getData(), blocks.get(1).getData(), blocks.get(2).getData());
}
} else {
nbt.putList(new ListTag<IntTag>("AttachedBlocks"));
}
}
示例11: 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 "";
}
示例12: 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;
}
示例13: BlockEntityPistonArm
import cn.nukkit.nbt.tag.CompoundTag; //导入方法依赖的package包/类
public BlockEntityPistonArm(FullChunk chunk, CompoundTag nbt) {
super(chunk, nbt);
if (nbt.contains("Progress")) {
this.progress = nbt.getFloat("Progress");
}
if (nbt.contains("LastProgress")) {
this.lastProgress = (float) nbt.getInt("LastProgress");
}
if (nbt.contains("Sticky")) {
this.sticky = nbt.getBoolean("Sticky");
}
if (nbt.contains("Extending")) {
this.extending = nbt.getBoolean("Extending");
}
if (nbt.contains("powered")) {
this.powered = nbt.getBoolean("powered");
}
if (nbt.contains("AttachedBlocks")) {
ListTag blocks = nbt.getList("AttachedBlocks", IntTag.class);
if (blocks != null && blocks.size() > 0) {
this.attachedBlock = new Vector3((double) ((IntTag) blocks.get(0)).getData().intValue(), (double) ((IntTag) blocks.get(1)).getData().intValue(), (double) ((IntTag) blocks.get(2)).getData().intValue());
}
} else {
nbt.putList(new ListTag("AttachedBlocks"));
}
}
示例14: BlockEntityComparator
import cn.nukkit.nbt.tag.CompoundTag; //导入方法依赖的package包/类
public BlockEntityComparator(FullChunk chunk, CompoundTag nbt) {
super(chunk, nbt);
if (!nbt.contains("OutputSignal")) {
nbt.putInt("OutputSignal", 0);
}
this.outputSignal = nbt.getInt("OutputSignal");
}
示例15: BlockEntityMobSpawner
import cn.nukkit.nbt.tag.CompoundTag; //导入方法依赖的package包/类
public BlockEntityMobSpawner(FullChunk chunk, CompoundTag nbt) {
super(chunk, nbt);
if (!nbt.contains("EntityId")) {
nbt.putInt("EntityId", 0);
}
if (!nbt.contains("SpawnCount")) {
nbt.putInt("SpawnCount", 4);
}
if (!nbt.contains("SpawnRange")) {
nbt.putInt("SpawnRange", 4);
}
if (!nbt.contains("MinSpawnDelay")) {
nbt.putInt("MinSpawnDelay", 200);
}
if (!nbt.contains("MaxSpawnDelay")) {
nbt.putInt("MaxSpawnDelay", 799);
}
if (!nbt.contains("Delay")) {
nbt.putInt("Delay", NukkitMath.randomRange(new NukkitRandom(), nbt.getInt("MinSpawnDelay"), nbt.getInt("MaxSpawnDelay")));
}
if (this.getNetworkId() > 0) {
this.scheduleUpdate();
}
}