本文整理汇总了Java中cn.nukkit.utils.LevelException类的典型用法代码示例。如果您正苦于以下问题:Java LevelException类的具体用法?Java LevelException怎么用?Java LevelException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LevelException类属于cn.nukkit.utils包,在下文中一共展示了LevelException类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: BaseLevelProvider
import cn.nukkit.utils.LevelException; //导入依赖的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", "");
}
}
示例2: removeEntity
import cn.nukkit.utils.LevelException; //导入依赖的package包/类
public void removeEntity(Entity entity) {
if (entity.getLevel() != this) {
throw new LevelException("Invalid Entity level");
}
if (entity instanceof Player) {
this.players.remove(entity.getId());
this.checkSleep();
} else {
entity.close();
}
this.entities.remove(entity.getId());
this.updateEntities.remove(entity.getId());
}
示例3: addEntity
import cn.nukkit.utils.LevelException; //导入依赖的package包/类
public void addEntity(Entity entity) {
if (entity.getLevel() != this) {
throw new LevelException("Invalid Entity level");
}
if (entity instanceof Player) {
this.players.put(entity.getId(), (Player) entity);
}
this.entities.put(entity.getId(), entity);
}
示例4: addBlockEntity
import cn.nukkit.utils.LevelException; //导入依赖的package包/类
public void addBlockEntity(BlockEntity blockEntity) {
if (blockEntity.getLevel() != this) {
throw new LevelException("Invalid Block Entity level");
}
blockEntities.put(blockEntity.getId(), blockEntity);
this.clearChunkCache((int) blockEntity.getX() >> 4, (int) blockEntity.getZ() >> 4);
}
示例5: removeBlockEntity
import cn.nukkit.utils.LevelException; //导入依赖的package包/类
public void removeBlockEntity(BlockEntity blockEntity) {
if (blockEntity.getLevel() != this) {
throw new LevelException("Invalid Block Entity level");
}
blockEntities.remove(blockEntity.getId());
updateBlockEntities.remove(blockEntity.getId());
this.clearChunkCache((int) blockEntity.getX() >> 4, (int) blockEntity.getZ() >> 4);
}
示例6: getSide
import cn.nukkit.utils.LevelException; //导入依赖的package包/类
public Position getSide(BlockFace face, int step) {
if (!this.isValid()) {
throw new LevelException("Undefined Level reference");
}
return Position.fromObject(super.getSide(face, step), this.level);
}
示例7: getLevelBlock
import cn.nukkit.utils.LevelException; //导入依赖的package包/类
public Block getLevelBlock() {
if (this.isValid()) return this.level.getBlock(this);
else throw new LevelException("Undefined Level reference");
}
示例8: getLocation
import cn.nukkit.utils.LevelException; //导入依赖的package包/类
public Location getLocation() {
if (this.isValid()) return new Location(this.x, this.y, this.z, 0, 0, this.level);
else throw new LevelException("Undefined Level reference");
}
示例9: getLocation
import cn.nukkit.utils.LevelException; //导入依赖的package包/类
@Override
public Location getLocation() {
if (this.isValid()) return new Location(this.x, this.y, this.z, this.yaw, this.pitch, this.level);
else throw new LevelException("Undefined Level reference");
}
示例10: recalculateBoundingBox
import cn.nukkit.utils.LevelException; //导入依赖的package包/类
protected AxisAlignedBB recalculateBoundingBox() {
double f = 0.4375;
double f1 = 0.5625;
double f2 = 0.4375;
double f3 = 0.5625;
try {
boolean flag = this.canConnect(this.north());
boolean flag1 = this.canConnect(this.south());
boolean flag2 = this.canConnect(this.west());
boolean flag3 = this.canConnect(this.east());
if ((!flag2 || !flag3) && (flag2 || flag3 || flag || flag1)) {
if (flag2) {
f = 0;
} else if (flag3) {
f1 = 1;
}
} else {
f = 0;
f1 = 1;
}
if ((!flag || !flag1) && (flag2 || flag3 || flag || flag1)) {
if (flag) {
f2 = 0;
} else if (flag1) {
f3 = 1;
}
} else {
f2 = 0;
f3 = 1;
}
} catch (LevelException ignore) {
//null sucks
}
return new AxisAlignedBB(
this.x + f,
this.y,
this.z + f2,
this.x + f1,
this.y + 1,
this.z + f3
);
}
示例11: getSide
import cn.nukkit.utils.LevelException; //导入依赖的package包/类
public Position getSide(int side, int step) {
if (!this.isValid()) {
throw new LevelException("Undefined Level reference");
}
return Position.fromObject(super.getSide(side, step), this.level);
}
示例12: recalculateBoundingBox
import cn.nukkit.utils.LevelException; //导入依赖的package包/类
protected AxisAlignedBB recalculateBoundingBox() {
double f = 0.4375;
double f1 = 0.5625;
double f2 = 0.4375;
double f3 = 0.5625;
try {
boolean flag = this.canConnect(this.getSide(2));
boolean flag1 = this.canConnect(this.getSide(3));
boolean flag2 = this.canConnect(this.getSide(4));
boolean flag3 = this.canConnect(this.getSide(5));
if ((!flag2 || !flag3) && (flag2 || flag3 || flag || flag1)) {
if (flag2) {
f = 0;
} else if (flag3) {
f1 = 1;
}
} else {
f = 0;
f1 = 1;
}
if ((!flag || !flag1) && (flag2 || flag3 || flag || flag1)) {
if (flag) {
f2 = 0;
} else if (flag1) {
f3 = 1;
}
} else {
f2 = 0;
f3 = 1;
}
} catch (LevelException ignore) {
//null sucks
}
return new AxisAlignedBB(
this.x + f,
this.y,
this.z + f2,
this.x + f1,
this.y + 1,
this.z + f3
);
}