本文整理汇总了Java中cn.nukkit.level.Position类的典型用法代码示例。如果您正苦于以下问题:Java Position类的具体用法?Java Position怎么用?Java Position使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Position类属于cn.nukkit.level包,在下文中一共展示了Position类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setPosition
import cn.nukkit.level.Position; //导入依赖的package包/类
public boolean setPosition(Vector3 pos) {
if (this.closed) {
return false;
}
if (pos instanceof Position && ((Position) pos).level != null && ((Position) pos).level != this.level) {
if (!this.switchLevel(((Position) pos).getLevel())) {
return false;
}
}
this.x = pos.x;
this.y = pos.y;
this.z = pos.z;
double radius = this.getWidth() / 2d;
this.boundingBox.setBounds(pos.x - radius, pos.y, pos.z - radius, pos.x + radius, pos.y + (this.getHeight() * this.scale), pos.z
+ radius);
this.checkChunks();
return true;
}
示例2: setPosition
import cn.nukkit.level.Position; //导入依赖的package包/类
public boolean setPosition(Vector3 pos) {
if (this.closed) {
return false;
}
if (pos instanceof Position && ((Position) pos).level != null && ((Position) pos).level != this.level) {
if (!this.switchLevel(((Position) pos).getLevel())) {
return false;
}
}
this.x = pos.x;
this.y = pos.y;
this.z = pos.z;
double radius = this.getWidth() / 2d;
this.boundingBox.setBounds(pos.x - radius, pos.y, pos.z - radius, pos.x + radius, pos.y + (this.getHeight() * this.scale), pos.z +
radius);
this.checkChunks();
return true;
}
示例3: get
import cn.nukkit.level.Position; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public static Block get(int id, Integer meta, Position pos) {
Block block;
try {
Class c = list[id];
if (c != null) {
Constructor constructor = c.getDeclaredConstructor(int.class);
constructor.setAccessible(true);
block = (Block) constructor.newInstance(meta);
} else {
block = new BlockUnknown(id, meta);
}
} catch (Exception e) {
block = new BlockUnknown(id, meta);
}
if (pos != null) {
block.x = pos.x;
block.y = pos.y;
block.z = pos.z;
block.level = pos.level;
}
return block;
}
示例4: setSpawn
import cn.nukkit.level.Position; //导入依赖的package包/类
/**
* プレイヤーのスポーン地点を設定します。
* @param pos 設定する座標
* @return void
* @see "Vector3"
* @see Vector3
*/
public void setSpawn(Vector3 pos) {
Level level;
if (!(pos instanceof Position)) {
level = this.level;
} else {
level = ((Position) pos).getLevel();
}
this.spawnPosition = new Position(pos.x, pos.y, pos.z, level);
SetSpawnPositionPacket pk = new SetSpawnPositionPacket();
pk.spawnType = SetSpawnPositionPacket.TYPE_PLAYER_SPAWN;
pk.x = (int) this.spawnPosition.x;
pk.y = (int) this.spawnPosition.y;
pk.z = (int) this.spawnPosition.z;
this.dataPacket(pk);
}
示例5: run
import cn.nukkit.level.Position; //导入依赖的package包/类
public void run(){
while (true){
try{
for (Player player : Server.getInstance().getOnlinePlayers().values()){
if (positionHashMap.containsKey(player.getName())){
Position from = positionHashMap.get(player.getName());
Position to = player.getPosition();
float move = ((float) Math.sqrt(Math.pow(from.x - to.x,2)+Math.pow(from.z - to.z,2)));
putMove(player.getName(),move);
positionHashMap.put(player.getName(),player.getPosition());
} else {
putMove(player.getName(),0F);
positionHashMap.put(player.getName(),player.getPosition());
}
}
thread.sleep(50);
}catch (Exception e){
e.printStackTrace();
}
}
}
示例6: wtBlock
import cn.nukkit.level.Position; //导入依赖的package包/类
public static void wtBlock(HashMap<Integer, HashMap<Integer, Position>> line, Level level) {
int c = 1;
for(Map.Entry<Integer, HashMap<Integer, Position>> entry:line.entrySet()){
for(Map.Entry<Integer,Position> entry1:entry.getValue().entrySet()){
if(c % 2 == 0){
level.setBlock(entry1.getValue(),Block.get(35));
}else{
level.setBlock(entry1.getValue(),Block.get(35,15));
}
c++;
}
c++;
}
/*for (int i = 0; i < 5; i++) {
for (int n = 0; n < 4; n++) {
Vector3 pos = new Vector3(line.get(i).get(n).x, line.get(i).get(n).y, line.get(i).get(n).z);
if (c % 2 == 0) {
line.get(i).get(n).getLevel().setBlock(pos, Block.get(35));
} else {
line.get(i).get(n).getLevel().setBlock(pos, Block.get(35, 15));
}
c++;
}
c++;
}*/
}
示例7: wtLine
import cn.nukkit.level.Position; //导入依赖的package包/类
private HashMap<Integer, HashMap<Integer, Position>> wtLine(int x1, int y1, int z1, Level level, Boolean type) {
HashMap<Integer, HashMap<Integer, Position>> line = new HashMap<>();
for (int i = 0; i < 5; i++) {
HashMap<Integer, Position> in = new HashMap<>();
for (int n = 0; n < 4; n++) {
if (type) {
in.put(n, new Position(x1, y1 + i, z1 + n, level));
} else {
in.put(n, new Position(x1 + n, y1 + i, z1, level));
}
//plugin.getLogger().notice(i+"|"+n+"|"+in);
}
line.put(i, in);
}
return line;
}
示例8: position
import cn.nukkit.level.Position; //导入依赖的package包/类
final public void position(Position v) {
this.x = (int) v.x;
this.y = (int) v.y;
this.z = (int) v.z;
this.level = v.level;
this.boundingBox = null;
}
示例9: getSpawn
import cn.nukkit.level.Position; //导入依赖的package包/类
public Position getSpawn() {
if (this.spawnPosition != null && this.spawnPosition.getLevel() != null) {
return this.spawnPosition;
} else {
return this.server.getDefaultLevel().getSafeSpawn();
}
}
示例10: setSpawn
import cn.nukkit.level.Position; //导入依赖的package包/类
public void setSpawn(Vector3 pos) {
Level level;
if (!(pos instanceof Position)) {
level = this.level;
} else {
level = ((Position) pos).getLevel();
}
this.spawnPosition = new Position(pos.x, pos.y, pos.z, level);
SetSpawnPositionPacket pk = new SetSpawnPositionPacket();
pk.spawnType = SetSpawnPositionPacket.TYPE_PLAYER_SPAWN;
pk.x = (int) this.spawnPosition.x;
pk.y = (int) this.spawnPosition.y;
pk.z = (int) this.spawnPosition.z;
this.dataPacket(pk);
}
示例11: teleportImmediate
import cn.nukkit.level.Position; //导入依赖的package包/类
public void teleportImmediate(Location location, TeleportCause cause) {
Location from = this.getLocation();
if (super.teleport(location, cause)) {
for (Inventory window : new ArrayList<>(this.windowIndex.values())) {
if (window == this.inventory) {
continue;
}
this.removeWindow(window);
}
if (from.getLevel().getId() != location.getLevel().getId()) { //Different level, update compass position
SetSpawnPositionPacket pk = new SetSpawnPositionPacket();
pk.spawnType = SetSpawnPositionPacket.TYPE_WORLD_SPAWN;
Position spawn = location.getLevel().getSpawnLocation();
pk.x = spawn.getFloorX();
pk.y = spawn.getFloorY();
pk.z = spawn.getFloorZ();
dataPacket(pk);
}
this.forceMovement = new Vector3(this.x, this.y, this.z);
this.sendPosition(this, this.yaw, this.pitch, MovePlayerPacket.MODE_RESET);
this.resetFallDistance();
this.orderChunks();
this.nextChunkOrderRun = 0;
this.newPosition = null;
//Weather
this.getLevel().sendWeather(this);
//Update time
this.getLevel().sendTime(this);
}
}
示例12: PlayerInteractEvent
import cn.nukkit.level.Position; //导入依赖的package包/类
public PlayerInteractEvent(Player player, Item item, Vector3 block, BlockFace face, Action action) {
if (block instanceof Block) {
this.blockTouched = (Block) block;
this.touchVector = new Vector3(0, 0, 0);
} else {
this.touchVector = block;
this.blockTouched = Block.get(Block.AIR, 0, new Position(0, 0, 0, player.level));
}
this.player = player;
this.item = item;
this.blockFace = face;
this.action = action;
}
示例13: teleportImmediate
import cn.nukkit.level.Position; //导入依赖的package包/类
public void teleportImmediate(Location location, TeleportCause cause) {
Location from = this.getLocation();
if (super.teleport(location, cause)) {
for (Inventory window : new ArrayList<>(this.windowIndex.values())) {
if (window == this.inventory) {
continue;
}
this.removeWindow(window);
}
if (from.getLevel().getId() != location.getLevel().getId()) {
SetSpawnPositionPacket pk = new SetSpawnPositionPacket();
pk.spawnType = SetSpawnPositionPacket.TYPE_WORLD_SPAWN;
Position spawn = location.getLevel().getSpawnLocation();
pk.x = spawn.getFloorX();
pk.y = spawn.getFloorY();
pk.z = spawn.getFloorZ();
dataPacket(pk);
}
this.forceMovement = new Vector3(this.x, this.y, this.z);
this.sendPosition(this, this.yaw, this.pitch, MovePlayerPacket.MODE_RESET);
this.resetFallDistance();
this.orderChunks();
this.nextChunkOrderRun = 0;
this.newPosition = null;
//Weather
this.getLevel().sendWeather(this);
//Update time
this.getLevel().sendTime(this);
}
}
示例14: execute
import cn.nukkit.level.Position; //导入依赖的package包/类
@Override
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
if (!this.testPermission(sender)) {
return true;
}
if (sender instanceof ConsoleCommandSender) {
sender.sendMessage(new TranslationContainer("commands.generic.ingame"));
return true;
}
if (args.length < 2) {
sender.sendMessage(new TranslationContainer("commands.generic.usage", this.usageMessage));
return false;
}
Position pos = new Position(Double.parseDouble(args[1]), Double.parseDouble(args[2]), Double.parseDouble(args[3]), ((Player) sender).getLevel());
CompoundTag nbt = new CompoundTag()
.putList(new ListTag<DoubleTag>("Pos")
.add(new DoubleTag("", pos.getX() + 0.5))
.add(new DoubleTag("", pos.getY()))
.add(new DoubleTag("", pos.getZ() + 0.5)))
.putList(new ListTag<DoubleTag>("Motion")
.add(new DoubleTag("", 0))
.add(new DoubleTag("", 0))
.add(new DoubleTag("", 0)))
.putList(new ListTag<FloatTag>("Rotation")
.add(new FloatTag("", new Random().nextFloat() * 360))
.add(new FloatTag("", 0)));
Entity entity = Entity.createEntity(args[0], pos.getLevel().getChunk((int) pos.getX() >> 4, (int) pos.getZ() >> 4, true), nbt);
entity.spawnToAll();
return true;
}
示例15: saveData
import cn.nukkit.level.Position; //导入依赖的package包/类
public void saveData(){
/*ConfigSection map = new ConfigSection();
map.put("status",status);
map.put("top",top.x+":"+top.y+":"+top.z+":"+top.level.getFolderName());
map.put("start",start.x+":"+start.y+":"+start.z+":"+start.level.getFolderName());
map.put("line",line);
map.put("first",first);
//LinkedHashMap<String,Object> l = new LinkedHashMap<>();
//l.putAll(map);
config.setAll(map);*/
if(status != 0) {
config.set("status", status);
config.set("top", top.x + ":" + top.y + ":" + top.z + ":" + top.level.getFolderName());
config.set("top2", top2.x + ":" + top2.y + ":" + top2.z + ":" + top2.level.getFolderName());
config.set("top3", top3.x + ":" + top3.y + ":" + top3.z + ":" + top3.level.getFolderName());
config.set("start", start.x + ":" + start.y + ":" + start.z + ":" + start.level.getFolderName());
String l = "";
for (Map.Entry<Integer, HashMap<Integer, Position>> entry : line.entrySet()) {
l += entry.getKey() + "=>";
for (Map.Entry<Integer, Position> entry1 : entry.getValue().entrySet()) {
l += entry1.getKey() + "->" + entry1.getValue().x + ":" + entry1.getValue().y + ":" + entry1.getValue().z + ":" + entry1.getValue().level.getFolderName() + "@";
}
l = l.substring(0, l.length() - 1);
l += "|";
}
l = l.substring(0, l.length() - 1);
config.set("line", l);
config.set("first", first);
config.set("second", second);
config.set("third", third);
config.save();
}
}