Çözüldü Kodladığım eklenti çalışmıyor(konsolda hata yok kodlama yanlışı var) yardım edebilir misiniz?

ordu34

Somon Balığı Selam Vermeye Geldi
Katılım
14 Kasım 2021
Mesajlar
18
Elmaslar
10
Puan
370
Yaş
18
Minecraft
ordu34

Discord:

ordu34#1869

Oyunda "/satranc olustur" yazdığımda her bir karesi 25 bloktan oluşan bir satranç arenası inşaa etmesi gereken kod, ben bu kodu yazdığımda sadece 1 blok oluşturuyor veya hiç oluşturmuyor

kod aşağıda





package satranc.arena;

import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class Komut implements CommandExecutor{

@Override
public boolean onCommand(CommandSender arg0, Command arg1, String arg2, String[] arg3) {
Player oyuncu = (Player) arg0;
if(arg0 instanceof Player) {
if(oyuncu.isOp() || oyuncu.hasPermission("satranc.hersey")) {
if(arg3[0].equalsIgnoreCase("olustur")) {
World dunya = Bukkit.getWorld("world");
Block blok = dunya.getBlockAt(oyuncu.getLocation());
int k;
for(k = 1; k< 40; k++) {
//k değişkeni z eksenindeki 5'lik blokları kontrol eder
if(k%10 > 5) {
int i;
for(i = 1; i<40; i++) {
//i değişkeni x eksenindeki 5'lik blokları kontrol eder
if(i%5 <= 5) {
Location lokasyon = new Location(dunya,oyuncu.getLocation().getBlockX() + 1,oyuncu.getLocation().getBlockY(),oyuncu.getLocation().getBlockZ());
blok = dunya.getBlockAt(lokasyon);
blok.setType(Material.WHITE_WOOL);
}else{
Location lokasyon = new Location(dunya,oyuncu.getLocation().getBlockX() + 1,oyuncu.getLocation().getBlockY(),oyuncu.getLocation().getBlockZ());
blok = dunya.getBlockAt(lokasyon);
blok.setType(Material.BLACK_WOOL);
}
}
if(i == 39) {
Location lokasyon = new Location(dunya,oyuncu.getLocation().getBlockX(),oyuncu.getLocation().getBlockY(),oyuncu.getLocation().getBlockZ()+1);
blok = dunya.getBlockAt(lokasyon);
}
}
else {
int i;
for(i = 1; i<40; i++) {
if(i%5 <= 5) {
Location lokasyon = new Location(dunya,oyuncu.getLocation().getBlockX() + 1,oyuncu.getLocation().getBlockY(),oyuncu.getLocation().getBlockZ());
blok = dunya.getBlockAt(lokasyon);
blok.setType(Material.WHITE_WOOL);
}else{
Location lokasyon = new Location(dunya,oyuncu.getLocation().getBlockX() + 1,oyuncu.getLocation().getBlockY(),oyuncu.getLocation().getBlockZ());
blok = dunya.getBlockAt(lokasyon);
blok.setType(Material.BLACK_WOOL);
}
}
if(i == 39) {
Location lokasyon = new Location(dunya,oyuncu.getLocation().getBlockX(),oyuncu.getLocation().getBlockY(),oyuncu.getLocation().getBlockZ()+1);
blok = dunya.getBlockAt(lokasyon);
}
}

}
}
}
}
return true;
}
}
 
Java:
Location lokasyon = new Location(dunya,oyuncu.getLocation().getBlockX() + 1,oyuncu.getLocation().getBlockY(),oyuncu.getLocation().getBlockZ());
Şu satırlarda oyuncunun x lokasyonuna sadece 1 ekliyorsunuz bu yüzden değişen blok sürekli aynı.
Ve Z lokasyonuna ekleme yapmıyorsunuz.
Çözüm:
Java:
Location lokasyon = new Location(dunya,oyuncu.getLocation().getBlockX() + i,oyuncu.getLocation().getBlockY(),oyuncu.getLocation().getBlockZ()+k);

Java:
for(i = 1; i<40; i++) {
for looplarınız sadece 39 kere çağrılıyor. Her karenin 5 blok olması için 40 kere çağrılması gerek.
Çözüm: < yerine <= kullanın.
 
Son düzenleme:

Hala Discord sunucumuza katılmadın mı?

Büyük bir topluluğun parçası ol, etkinliklere katıl ve özel hediyeler kazanma şansı yakala!

Şimdi Katıl
Üst