-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathcheck-world
executable file
·66 lines (52 loc) · 1.17 KB
/
check-world
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/env perl
use Data::Dumper;
use FindBin;
use lib "$FindBin::Bin/lib";
use Minecraft;
use Getopt::Long;
my $worldname;
my $command;
my $help;
# Load every region in a world just to check it loads
BEGIN {
sub help
{
print "$0 <world-name> <perl-code>\n";
}
if( !GetOptions (
"help" => \$help,
)) {
print STDERR ("Error in command line arguments\n");
help();
exit( 1 );
}
($worldname, $command) = @ARGV;
}
use strict;
use warnings;
if( $help )
{
help();
exit( 0 );
}
if( !defined $worldname )
{
die "No worldname given";
}
if(! -e "$FindBin::Bin/saves/$worldname" )
{
die "Can't find world $worldname";
}
my $mc = new Minecraft( "$FindBin::Bin/saves" );
my $world = $mc->world( $worldname );
my @regions = $world->regions;
for( my $reg_i=0;$reg_i<scalar @regions; $reg_i++ ) {
my $r_pos = $regions[$reg_i];
my $region= $world->region( $r_pos->[0], $r_pos->[1] );
my $r_x = $region->{opts}->{r_x};
my $r_z = $region->{opts}->{r_z};
print "Region ".($reg_i+1)." of ".(scalar @regions)." [".$r_pos->[0].",".$r_pos->[1]."] (".($r_pos->[0]*512).",".($r_pos->[1]*512).")\n";
delete $world->{regions}->{$r_z}->{$r_x};
}
print "DONE\n";
exit;