tested making block displays smaller

This commit is contained in:
Lars Neuhaus 2024-07-05 20:01:43 +02:00
parent 44adb56903
commit 69f8a05bed

View File

@ -6,42 +6,51 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.BlockDisplay;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.util.Transformation;
import org.jetbrains.annotations.NotNull;
public class ChessCommand implements CommandExecutor {
@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
if(sender instanceof Player p) {
Location playerLocation = p.getLocation();
Location playerLocation = p.getLocation().toBlockLocation();
double scale = (double) 1/16;
for (int i = 0; i < 8; i++) {
for (int i = 0; i < 16; i++) {
int finalI = i+1;
for (int j = 0; j < 8; j++) {
for (int j = 0; j < 16; j++) {
int finalJ = j+1;
p.getWorld().spawn(
new Location(p.getWorld(),
playerLocation.x()+i,
playerLocation.y(),
playerLocation.z()+j),
BlockDisplay.class, blockDisplay -> {
if(finalI % 2 == 0 && finalJ % 2 == 0) {
blockDisplay.setBlock(Material.BLACK_CONCRETE.createBlockData());
} else if(finalI % 2 != 0 && finalJ % 2 != 0) {
blockDisplay.setBlock(Material.BLACK_CONCRETE.createBlockData());
} else {
blockDisplay.setBlock(Material.WHITE_CONCRETE.createBlockData());
}
blockDisplay.setDisplayHeight(0.5f);
blockDisplay.setDisplayWidth(0.5f);
}
double blockPositionX = playerLocation.x()+i*scale;
double blockPositionY = playerLocation.y();
double blockPositionZ = playerLocation.z()+j*scale;
BlockDisplay bd;
bd = (BlockDisplay) p.getWorld().spawnEntity(
new Location(p.getWorld(), blockPositionX, blockPositionY, blockPositionZ),
EntityType.BLOCK_DISPLAY
);
if(finalI % 2 == 0 && finalJ % 2 == 0) {
bd.setBlock(Material.BLACK_CONCRETE.createBlockData());
} else if(finalI % 2 != 0 && finalJ % 2 != 0) {
bd.setBlock(Material.BLACK_CONCRETE.createBlockData());
} else {
bd.setBlock(Material.WHITE_CONCRETE.createBlockData());
}
Transformation transform = bd.getTransformation();
transform.getScale().set(scale);
bd.setTransformation(transform);
}
}
} else {
return(true);
sender.sendMessage("This command is only for real Players!");
}
return true;
return(true);
}
}