Следуйте инструкциям в видео ниже, чтобы узнать, как установить наш сайт как веб-приложение на главный экран вашего устройства.
Примечание: Эта функция может быть недоступна в некоторых браузерах.
Не работает.Цикл for(for(for()))
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
Player p = (Player) sender;
if(command.getName().equalsIgnoreCase("hello")) {
for(for(for()));
}
return false;
}
ОрНе работает.
Код:@Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { Player p = (Player) sender; if(command.getName().equalsIgnoreCase("hello")) { for(for(for())); } return false; }
int x1 = 100; //Изменяй на твои значения.
int y1 = 100;
int z1 = 100;
int x2 = 200;
int y2 = 200;
int z2 = 200;
List<Block> blocks = new ArrayList<Block>(); //Лист блоков между 2 блоков
for(int i = x1; i <= x2; i++){
for(int i1 = y1; i1 <= y2; i1++){
for(int i2 = z1; i2 <= z2; i2++){
Block block = Bukkit.getWorld("world").getBlockAt(i, i1, i2);
if(block != null) blocks.add(block);
}
}
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
List<ItemStack> blocks = null;
Player p = (Player) sender;
if(command.getName().equalsIgnoreCase("hello")) {
Location loc1 = new Location(sender.getLocation().getWorld(), x1, y1,z1);
Location loc2 = new Location(sender.getLocation().getWorld(), x2, y2,z2);
for (double d1 = x1; d1 < x2; d1++) {
for (double d2 = y1; d2 < y2; d2++) {
for (double d3 = z1; d3 < z2; d3++) {
blocks.add(блок на d1, d2, d3);
}
}
}
}
return false;
}
1) blocks у тебя хранит значения с типом ItemStack, а не BlockУгараешь?
Код:@Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { List<ItemStack> blocks = null; Player p = (Player) sender; if(command.getName().equalsIgnoreCase("hello")) { Location loc1 = new Location(sender.getLocation().getWorld(), x1, y1,z1); Location loc2 = new Location(sender.getLocation().getWorld(), x2, y2,z2); for (double d1 = x1; d1 < x2; d1++) { for (double d2 = y1; d2 < y2; d2++) { for (double d3 = z1; d3 < z2; d3++) { blocks.add(блок на d1, d2, d3); } } } } return false; }
Он разве может быть null? Баккит что-то, да и вернёт.block != null
Если блока нету, то вернет null. (По идеи, не проверял.)Он разве может быть null? Баккит что-то, да и вернёт.
Берёшь итемстак блока = профит1) blocks у тебя хранит значения с типом ItemStack, а не Block
2) blocks равен null, +ошибка в консоль
Можно в принципе понять код, но для него лучше точь в точь писать. ;P
Нахрена ему ItemStack блока, если, например, ему надо будет получить локацию одного из них?Берёшь итемстак блока = профит
инициализирую blocks нормально = профит2
Он вернёт блок воздуха.Если блока нету, то вернет null. (По идеи, не проверял.)
Хз, я не спрашивал, что ему надо.Нахрена ему ItemStack блока, если, например, ему надо будет получить локацию одного из них?
List<ItemStack> blocks = null норма?
Иногда не заносит ничего в лист. Например когда x1 = 397, y1 = 74, z1 = -361 и x2 = 398, y2 = 73, y3 = -363Ор
Код:int x1 = 100; //Изменяй на твои значения. int y1 = 100; int z1 = 100; int x2 = 200; int y2 = 200; int z2 = 200; List<Block> blocks = new ArrayList<Block>(); //Лист блоков между 2 блоков for(int i = x1; i <= x2; i++){ for(int i1 = y1; i1 <= y2; i1++){ for(int i2 = z1; i2 <= z2; i2++){ Block block = Bukkit.getWorld("world").getBlockAt(i, i1, i2); if(block != null) blocks.add(block); } } }
Попробуй на x1, y1 и z1 указывать ту локацию у которой y (высота) меньшеИногда не заносит ничего в лист. Например когда x1 = 397, y1 = 74, z1 = -361 и x2 = 398, y2 = 73, y3 = -363
Иногда не заносит ничего в лист. Например когда x1 = 397, y1 = 74, z1 = -361 и x2 = 398, y2 = 73, y3 = -363
private void normalize(long x1, long y1, long z1, long x2, long y2, long z2) {
this.xMin = Math.min(x1, x2);
this.xMax = Math.max(x1, x2);
this.yMin = Math.min(y1, y2);
this.yMax = Math.max(y1, y2);
this.zMin = Math.min(z1, z2);
this.zMax = Math.max(z1, z2);
}
Спасибо. работает.Код:private void normalize(long x1, long y1, long z1, long x2, long y2, long z2) { this.xMin = Math.min(x1, x2); this.xMax = Math.max(x1, x2); this.yMin = Math.min(y1, y2); this.yMax = Math.max(y1, y2); this.zMin = Math.min(z1, z2); this.zMax = Math.max(z1, z2); }