Add .terrain-export 🧌
This commit is contained in:
@@ -45,8 +45,9 @@ public class MeteorRejectsAddon extends MeteorAddon {
|
|||||||
commands.add(new AntiAntiXrayCommand());
|
commands.add(new AntiAntiXrayCommand());
|
||||||
commands.add(new BookDupeCommand());
|
commands.add(new BookDupeCommand());
|
||||||
commands.add(new GiveCommand());
|
commands.add(new GiveCommand());
|
||||||
commands.add(new SpectateCommand());
|
|
||||||
commands.add(new SaveSkinCommand());
|
commands.add(new SaveSkinCommand());
|
||||||
|
commands.add(new SpectateCommand());
|
||||||
|
commands.add(new TerrainExport());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
69
src/main/java/cloudburst/rejects/commands/TerrainExport.java
Normal file
69
src/main/java/cloudburst/rejects/commands/TerrainExport.java
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
package cloudburst.rejects.commands;
|
||||||
|
|
||||||
|
import com.mojang.brigadier.arguments.IntegerArgumentType;
|
||||||
|
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||||
|
import minegame159.meteorclient.systems.commands.Command;
|
||||||
|
|
||||||
|
import net.minecraft.command.CommandSource;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
|
||||||
|
import org.lwjgl.BufferUtils;
|
||||||
|
import org.lwjgl.PointerBuffer;
|
||||||
|
import org.lwjgl.system.MemoryUtil;
|
||||||
|
import org.lwjgl.util.tinyfd.TinyFileDialogs;
|
||||||
|
|
||||||
|
import java.io.FileWriter;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.ByteBuffer;
|
||||||
|
|
||||||
|
import static com.mojang.brigadier.Command.SINGLE_SUCCESS;
|
||||||
|
|
||||||
|
public class TerrainExport extends Command {
|
||||||
|
|
||||||
|
private final PointerBuffer filters;
|
||||||
|
|
||||||
|
public TerrainExport() {
|
||||||
|
super("terrain-export", "Export an area to the c++ terrain finder format (very popbob command).");
|
||||||
|
|
||||||
|
filters = BufferUtils.createPointerBuffer(1);
|
||||||
|
|
||||||
|
ByteBuffer txtFilter = MemoryUtil.memASCII("*.txt");
|
||||||
|
|
||||||
|
filters.put(txtFilter);
|
||||||
|
filters.rewind();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void build(LiteralArgumentBuilder<CommandSource> builder) {
|
||||||
|
builder.then(argument("distance", IntegerArgumentType.integer(1)).executes(context -> {
|
||||||
|
int distance = IntegerArgumentType.getInteger(context, "distance");
|
||||||
|
|
||||||
|
StringBuilder stringBuilder = new StringBuilder();
|
||||||
|
for (int x = -distance; x <= distance; x++) {
|
||||||
|
for (int z = -distance; z <= distance; z++) {
|
||||||
|
for (int y = distance; y >= -distance; y--) {
|
||||||
|
BlockPos pos = mc.player.getBlockPos().add(x, y, z);
|
||||||
|
if (mc.world.getBlockState(pos).isFullCube(mc.world, pos)) {
|
||||||
|
stringBuilder.append(String.format("%d, %d, %d\n", x + distance, y + distance, z + distance));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String path = TinyFileDialogs.tinyfd_saveFileDialog("Save data", null, filters, null);
|
||||||
|
if (path == null)
|
||||||
|
return SINGLE_SUCCESS;
|
||||||
|
if (!path.endsWith(".txt"))
|
||||||
|
path += ".txt";
|
||||||
|
try {
|
||||||
|
FileWriter file = new FileWriter(path);
|
||||||
|
file.write(stringBuilder.toString().trim());
|
||||||
|
file.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
error("IOException");
|
||||||
|
}
|
||||||
|
|
||||||
|
return SINGLE_SUCCESS;
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user