[Google trad]
Hello. with this code I get the orientation of the blocks. I save like this:
final List<BlockState> Blocksmeta = new ArrayList<>();
int i = 1;
for (int x = x1; x <= x2; x++) {
for (int y = y1; y <= y2; y++) {
for (int z = z1; z <= z2; z++) {
Location<World> location = new Location<World>(player.getWorld(), x, y, z);
Blocksmeta.add(location.getBlock());
i++;
}
}
}
FileConfig.getConfig().getNode("conf", "Blocs", nom_zone, "blocs").setValue(Blocksmeta.toString());
FileConfig.save();
FileConfig.load();
Résultat:
conf {
Blocs {
Test {
blocs="[minecraft:quartz_block[variant=lines_x], minecraft:lit_pumpkin[facing=west], minecraft:sandstone_stairs[facing=south,half=top,shape=straight], minecraft:lit_pumpkin[facing=south], minecraft:quartz_block[variant=lines_y], minecraft:wool[color=blue], minecraft:chest[facing=north], minecraft:air, minecraft:quartz_block[variant=lines_x], minecraft:wool[color=red], minecraft:air, minecraft:air]"
zone {
"coin_1" {
x1=65
y1=4
z1=30
}
"coin_2" {
x2=67
y2=5
z2=31
}
}
}
}
}
Doing:
CommentedConfigurationNode t = FileConfigAnimatedMagic.getConfig().getNode("conf", "Blocs", nom_zone);
Sponge.getLogger().debug("" + t.getNode("blocs").getValue());
Give me:
[minecraft:quartz_block[variant=lines_x], minecraft:lit_pumpkin[facing=west], minecraft:sandstone_stairs[facing=south,half=top,shape=straight], minecraft:lit_pumpkin[facing=south], minecraft:quartz_block[variant=lines_y], minecraft:wool[color=blue], minecraft:chest[facing=north], minecraft:air, minecraft:quartz_block[variant=lines_x], minecraft:wool[color=red], minecraft:air, minecraft:air]
But how to buckle on? I can not do it
This code gives nothing:
Sponge.getLogger().debug(“” + t.getNode(“blocs”).getChildrenList().stream().map(ConfigurationNode::getString).collect(Collectors.toList()).size());
[FR]
Bonjour. avec ce code je récupère l’orientation des blocs. Je sauvegarde comme ceci:
final List<BlockState> Blocksmeta = new ArrayList<>();
int i = 1;
for (int x = x1; x <= x2; x++) {
for (int y = y1; y <= y2; y++) {
for (int z = z1; z <= z2; z++) {
Location<World> location = new Location<World>(player.getWorld(), x, y, z);
Blocksmeta.add(location.getBlock());
i++;
}
}
}
FileConfig.getConfig().getNode("conf", "Blocs", nom_zone, "blocs").setValue(Blocksmeta.toString());
FileConfig.save();
FileConfig.load();
Résultat:
conf {
Blocs {
Test {
blocs="[minecraft:quartz_block[variant=lines_x], minecraft:lit_pumpkin[facing=west], minecraft:sandstone_stairs[facing=south,half=top,shape=straight], minecraft:lit_pumpkin[facing=south], minecraft:quartz_block[variant=lines_y], minecraft:wool[color=blue], minecraft:chest[facing=north], minecraft:air, minecraft:quartz_block[variant=lines_x], minecraft:wool[color=red], minecraft:air, minecraft:air]"
zone {
"coin_1" {
x1=65
y1=4
z1=30
}
"coin_2" {
x2=67
y2=5
z2=31
}
}
}
}
}
En faisant:
CommentedConfigurationNode t = FileConfigAnimatedMagic.getConfig().getNode("conf", "Blocs", nom_zone);
Sponge.getLogger().debug("" + t.getNode("blocs").getValue());
Me donne:
[minecraft:quartz_block[variant=lines_x], minecraft:lit_pumpkin[facing=west], minecraft:sandstone_stairs[facing=south,half=top,shape=straight], minecraft:lit_pumpkin[facing=south], minecraft:quartz_block[variant=lines_y], minecraft:wool[color=blue], minecraft:chest[facing=north], minecraft:air, minecraft:quartz_block[variant=lines_x], minecraft:wool[color=red], minecraft:air, minecraft:air]
Mais comment boucler dessus ? Je n’y arrive pas
Ce code donne rien:
Sponge.getLogger().debug(“” + t.getNode(“blocs”).getChildrenList().stream().map(ConfigurationNode::getString).collect(Collectors.toList()).size());