Skip to content

Commit

Permalink
First strike at MCEdit file format
Browse files Browse the repository at this point in the history
Thanks to WorldEdit source code for some of this code.
  • Loading branch information
mcmonkey4eva committed Jan 16, 2015
1 parent 523936d commit 1a2ac2f
Show file tree
Hide file tree
Showing 24 changed files with 2,730 additions and 28 deletions.
17 changes: 8 additions & 9 deletions src/main/java/net/aufdemrand/denizen/objects/dCuboid.java
Expand Up @@ -428,8 +428,8 @@ public List<dLocation> getBlocks_internal(List<dMaterial> materials) {
int x_distance = pair.x_distance;

for (int x = 0; x != x_distance + 1; x++) {
for (int z = 0; z != z_distance + 1; z++) {
for (int y = 0; y != y_distance + 1; y++) {
for (int y = 0; y != y_distance + 1; y++) {
for (int z = 0; z != z_distance + 1; z++) {
loc = new dLocation(loc_1.clone().add(x, y, z));
if (!filter.isEmpty() && loc.getY() >= 0 && loc.getY() < 256) {
// Check filter
Expand Down Expand Up @@ -469,8 +469,8 @@ public void setBlocks_internal(List<BlockData> materials) {
int x_distance = pair.x_distance;

for (int x = 0; x != x_distance + 1; x++) {
for (int z = 0; z != z_distance + 1; z++) {
for (int y = 0; y != y_distance + 1; y++) {
for (int y = 0; y != y_distance + 1; y++) {
for (int z = 0; z != z_distance + 1; z++) {
if (loc_1.getY() + y >= 0 && loc_1.getY() + y < 256) {
materials.get(index).setBlock(loc_1.clone().add(x, y, z).getBlock());
}
Expand All @@ -492,8 +492,8 @@ public BlockData getBlockAt(double nX, double nY, double nZ, List<BlockData> mat
int x_distance = pair.x_distance;

for (int x = 0; x != x_distance + 1; x++) {
for (int z = 0; z != z_distance + 1; z++) {
for (int y = 0; y != y_distance + 1; y++) {
for (int y = 0; y != y_distance + 1; y++) {
for (int z = 0; z != z_distance + 1; z++) {
if (x == nX && nY == y && z == nZ) {
return materials.get(index);
}
Expand Down Expand Up @@ -571,9 +571,8 @@ public dList getSpawnableBlocks(List<dMaterial> mats) {
int x_distance = pair.x_distance;

for (int x = 0; x != x_distance + 1; x++) {
for (int z = 0; z != z_distance + 1; z++) {
for (int y = 0; y != y_distance; y++) {

for (int y = 0; y != y_distance + 1; y++) {
for (int z = 0; z != z_distance + 1; z++) {
loc = new dLocation(loc_1.clone()
.add(x, y, z));

Expand Down
Expand Up @@ -135,7 +135,8 @@ public void execute(ScriptEntry scriptEntry) throws CommandExecutionException {
return;
}
InputStream fs = new FileInputStream(f);
set = CuboidBlockSet.fromCompressedString(ScriptHelper.convertStreamToString(fs));
//set = CuboidBlockSet.fromCompressedString(ScriptHelper.convertStreamToString(fs));
set = CuboidBlockSet.fromMCEditStream(fs);
fs.close();
schematics.put(name.asString().toUpperCase(), set);
}
Expand Down Expand Up @@ -191,12 +192,13 @@ public void execute(ScriptEntry scriptEntry) throws CommandExecutionException {
set = schematics.get(name.asString().toUpperCase());
String directory = URLDecoder.decode(System.getProperty("user.dir"));
File f = new File(directory + "/plugins/Denizen/schematics/" + name.asString() + ".schematic");
String output = set.toCompressedFormat();
//String output = set.toCompressedFormat();
FileOutputStream fs = new FileOutputStream(f);
OutputStreamWriter osw = new OutputStreamWriter(fs);
set.saveMCEditFormatToStream(fs);
/*OutputStreamWriter osw = new OutputStreamWriter(fs);
osw.write(output);
osw.flush();
osw.close();
osw.close();*/
fs.flush();
fs.close();
}
Expand Down
@@ -1,5 +1,6 @@
package net.aufdemrand.denizen.utilities.blocks;

import net.aufdemrand.denizen.utilities.jnbt.CompoundTag;
import net.aufdemrand.denizencore.utilities.CoreUtilities;
import org.bukkit.Material;
import org.bukkit.block.Block;
Expand All @@ -14,6 +15,11 @@ public class BlockData {
public BlockData() {
}

public BlockData(short mat, byte dat) {
material = Material.getMaterial(mat);
data = dat;
}

public BlockData(Block block) {
material = block.getType();
data = block.getData();
Expand All @@ -38,4 +44,12 @@ public static BlockData fromCompressedString(String str) {
}
return data;
}

public CompoundTag getNBTTag() {
return null;
}

public void setNBTTag(CompoundTag tag) {
return;
}
}

0 comments on commit 1a2ac2f

Please sign in to comment.