- Katılım
- 14 Kasım 2021
- Mesajlar
- 18
- Elmaslar
- 10
- Puanlar
- 370
- Yaş
- 16
- Minecraft
- ordu34
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;
}
}
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;
}
}