1414 lines
63 KiB
Java
Executable file
1414 lines
63 KiB
Java
Executable file
package game.world;
|
|
|
|
import java.io.BufferedInputStream;
|
|
import java.io.ByteArrayInputStream;
|
|
import java.io.DataInputStream;
|
|
import java.io.File;
|
|
import java.io.FilenameFilter;
|
|
import java.io.IOException;
|
|
import java.io.RandomAccessFile;
|
|
import java.util.Arrays;
|
|
import java.util.Map;
|
|
import java.util.Map.Entry;
|
|
import java.util.zip.GZIPInputStream;
|
|
import java.util.zip.InflaterInputStream;
|
|
|
|
import com.google.common.collect.Maps;
|
|
|
|
import game.Game;
|
|
import game.biome.Biome;
|
|
import game.block.Block;
|
|
import game.block.BlockCactus;
|
|
import game.block.BlockCarpet;
|
|
import game.block.BlockColored;
|
|
import game.block.BlockDirt;
|
|
import game.block.BlockFire;
|
|
import game.block.BlockFlower;
|
|
import game.block.BlockFlowerPot;
|
|
import game.block.BlockLeaves;
|
|
import game.block.BlockLiquid;
|
|
import game.block.BlockLog;
|
|
import game.block.BlockPistonBase;
|
|
import game.block.BlockPistonHead;
|
|
import game.block.BlockQuartz;
|
|
import game.block.BlockRock;
|
|
import game.block.BlockSand;
|
|
import game.block.BlockSandStone;
|
|
import game.block.BlockSlab;
|
|
import game.block.BlockStainedGlass;
|
|
import game.block.BlockStainedGlassPane;
|
|
import game.block.BlockStoneBrick;
|
|
import game.block.BlockTNT;
|
|
import game.block.BlockTallGrass;
|
|
import game.block.BlockWall;
|
|
import game.block.LeavesType;
|
|
import game.color.DyeColor;
|
|
import game.entity.Entity;
|
|
import game.entity.animal.EntityBat;
|
|
import game.entity.animal.EntityChicken;
|
|
import game.entity.animal.EntityCow;
|
|
import game.entity.animal.EntityHorse;
|
|
import game.entity.animal.EntityMooshroom;
|
|
import game.entity.animal.EntityOcelot;
|
|
import game.entity.animal.EntityPig;
|
|
import game.entity.animal.EntityRabbit;
|
|
import game.entity.animal.EntitySheep;
|
|
import game.entity.animal.EntitySquid;
|
|
import game.entity.animal.EntityWolf;
|
|
import game.entity.item.EntityBoat;
|
|
import game.entity.item.EntityMinecart;
|
|
import game.entity.npc.EntityHuman;
|
|
import game.gui.GuiLoading;
|
|
import game.gui.GuiLoading.Callback;
|
|
import game.gui.world.GuiWorlds;
|
|
import game.init.BlockRegistry;
|
|
import game.init.Blocks;
|
|
import game.init.Config;
|
|
import game.init.EntityRegistry;
|
|
import game.init.TileRegistry;
|
|
import game.init.UniverseRegistry;
|
|
import game.log.Log;
|
|
import game.nbt.NBTLoader;
|
|
import game.nbt.NBTTagCompound;
|
|
import game.nbt.NBTTagList;
|
|
import game.rng.Random;
|
|
import game.tileentity.TileEntity;
|
|
import game.tileentity.TileEntityBanner;
|
|
import game.tileentity.TileEntityBeacon;
|
|
import game.tileentity.TileEntityChest;
|
|
import game.tileentity.TileEntityComparator;
|
|
import game.tileentity.TileEntityDaylightDetector;
|
|
import game.tileentity.TileEntityDispenser;
|
|
import game.tileentity.TileEntityDropper;
|
|
import game.tileentity.TileEntityEnchantmentTable;
|
|
import game.tileentity.TileEntityFurnace;
|
|
import game.tileentity.TileEntityHopper;
|
|
import game.tileentity.TileEntityMobSpawner;
|
|
import game.tileentity.TileEntityNote;
|
|
import game.tileentity.TileEntityPiston;
|
|
import game.tileentity.TileEntitySign;
|
|
import game.tileentity.TileEntitySkull;
|
|
import game.world.Region.FolderInfo;
|
|
|
|
public final class Converter {
|
|
public static enum SaveVersion {
|
|
ALPHA_1_0("Alpha 1.0 - Beta 1.2"),
|
|
BETA_1_3("Beta 1.3 - Release 1.8.9"),
|
|
RELEASE_1_9("Release 1.9 - Release 1.12.2"),
|
|
RELEASE_1_13("Release 1.13 +");
|
|
|
|
private final String name;
|
|
|
|
private SaveVersion(String name) {
|
|
this.name = name;
|
|
}
|
|
|
|
public String toString() {
|
|
return this.name;
|
|
}
|
|
}
|
|
|
|
// public static interface Callback {
|
|
// void postMessage(String msg);
|
|
// void postProgress(int progress);
|
|
// }
|
|
|
|
private static class AnvilRegion {
|
|
private final int[] offsets = new int[1024];
|
|
|
|
private int areas;
|
|
private RandomAccessFile file;
|
|
|
|
public AnvilRegion(File file) {
|
|
if(!file.exists())
|
|
return;
|
|
try {
|
|
this.file = new RandomAccessFile(file, "r");
|
|
this.file.seek(0L);
|
|
if(this.file.length() < 8192L) {
|
|
this.close();
|
|
return;
|
|
}
|
|
for(int i = 0; i < 1024; i++) {
|
|
if((this.offsets[i] = this.file.readInt()) != 0L)
|
|
this.areas |= 1 << (((i & 31) >> 3) + ((i >> 5) >> 3) * 4);
|
|
}
|
|
}
|
|
catch(IOException e) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
|
|
public DataInputStream getInputStream(int x, int z) {
|
|
if(x < 0 || x >= 32 || z < 0 || z >= 32)
|
|
return null;
|
|
try {
|
|
int off = this.offsets[x + z * 32];
|
|
if(off == 0)
|
|
return null;
|
|
int base = off >> 8;
|
|
int len = off & 255;
|
|
if(base + len > (int)this.file.length() / 4096)
|
|
return null;
|
|
this.file.seek((long)(base * 4096));
|
|
int size = this.file.readInt();
|
|
if(size > 4096 * len)
|
|
return null;
|
|
else if(size <= 0)
|
|
return null;
|
|
byte type = this.file.readByte();
|
|
if(type == 1) {
|
|
byte[] data = new byte[size - 1];
|
|
this.file.read(data);
|
|
return new DataInputStream(new BufferedInputStream(new GZIPInputStream(new ByteArrayInputStream(data))));
|
|
}
|
|
else if(type == 2) {
|
|
byte[] data = new byte[size - 1];
|
|
this.file.read(data);
|
|
return new DataInputStream(new BufferedInputStream(new InflaterInputStream(new ByteArrayInputStream(data))));
|
|
}
|
|
return null;
|
|
}
|
|
catch(IOException e) {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
public boolean hasChunk(int x, int z) {
|
|
return this.offsets[x + z * 32] != 0;
|
|
}
|
|
|
|
public boolean hasRegion(int x, int z) {
|
|
return ((this.areas >> (x + z * 4)) & 1) != 0;
|
|
}
|
|
|
|
public void close() throws IOException {
|
|
if(this.file != null) {
|
|
this.file.close();
|
|
this.file = null;
|
|
}
|
|
}
|
|
}
|
|
|
|
private static interface BlockFunction {
|
|
State getState(int id, int data);
|
|
}
|
|
|
|
private Converter() {
|
|
}
|
|
|
|
private long postProgress(long start, int progress) {
|
|
// SKC.info("... " + progress + "%");
|
|
if(System.currentTimeMillis() - start >= 500L) {
|
|
start = System.currentTimeMillis();
|
|
Log.JNI.info("... " + progress + "%");
|
|
}
|
|
return start;
|
|
}
|
|
|
|
private static final Random RANDOM = new Random();
|
|
private static final Map<String, String> ENTITY_MAP = Maps.newHashMap();
|
|
private static final Map<String, String> TILE_MAP = Maps.newHashMap();
|
|
private static final char[] BLOCK_MAP = new char[65536];
|
|
// private static final Map<Character, BlockFunction> BLOCK_FUNCS = Maps.newHashMap();
|
|
private static final Map<String, String> OLD_GAMERULES = Maps.newHashMap();
|
|
|
|
private String action;
|
|
private String task;
|
|
private String file;
|
|
private int totalRegions;
|
|
private int doneRegions;
|
|
private int totalChunks;
|
|
private int doneChunks;
|
|
|
|
private static void mapEntity(Class<? extends Entity> clazz, String ... names) {
|
|
String name = EntityRegistry.getEntityString(clazz);
|
|
for(String oldname : names) {
|
|
ENTITY_MAP.put(oldname, name);
|
|
}
|
|
}
|
|
|
|
private static void mapTile(Class<? extends TileEntity> clazz, String ... names) {
|
|
String name = TileRegistry.classToNameMap.get(clazz);
|
|
for(String oldname : names) {
|
|
TILE_MAP.put(oldname, name);
|
|
}
|
|
}
|
|
|
|
private static void mapBlock(State state, int id, int data) {
|
|
BLOCK_MAP[(id << 4) | data] = (char)BlockRegistry.STATEMAP.get(state);
|
|
}
|
|
|
|
private static void mapBlock(State state, int id) {
|
|
for(int z = 0; z < 16; z++) {
|
|
mapBlock(state, id, z);
|
|
}
|
|
}
|
|
|
|
private static void mapBlock(Block block, int id, int data) {
|
|
mapBlock(block.getState(), id, data);
|
|
}
|
|
|
|
private static void mapBlock(Block block, int id) {
|
|
mapBlock(block.getState(), id);
|
|
}
|
|
|
|
private static void mapBlockData(Block block, int id) {
|
|
for(int z = 0; z < 16; z++) {
|
|
mapBlock(block.getStateFromMeta(z), id, z);
|
|
}
|
|
}
|
|
|
|
private static void mapBlock(BlockFunction func, int id) {
|
|
for(int z = 0; z < 16; z++) {
|
|
mapBlock(func.getState(id, z), id, z);
|
|
}
|
|
}
|
|
|
|
// private static void mapBlockDynamic(BlockFunction func, int id, int data) {
|
|
// BLOCK_MAP[(id << 4) | data] = (char)0x000f;
|
|
// BLOCK_FUNCS.put((char)((id << 4) | data), func);
|
|
// }
|
|
//
|
|
// private static void mapBlockDynamic(BlockFunction func, int id) {
|
|
// for(int z = 0; z < 16; z++) {
|
|
// mapBlockDynamic(func, id, z);
|
|
// }
|
|
// }
|
|
|
|
static {
|
|
OLD_GAMERULES.put("doFireTick", "fireTick");
|
|
OLD_GAMERULES.put("mobGriefing", "mobGriefing");
|
|
OLD_GAMERULES.put("doMobSpawning", "mobSpawning");
|
|
OLD_GAMERULES.put("doMobLoot", "dropLoot");
|
|
OLD_GAMERULES.put("doTileDrops", "dropBlocks");
|
|
OLD_GAMERULES.put("doEntityDrops", "dropObjects");
|
|
OLD_GAMERULES.put("naturalRegeneration", "naturalRegeneration");
|
|
OLD_GAMERULES.put("doDaylightCycle", "daylightCycle");
|
|
OLD_GAMERULES.put("showDeathMessages", "deathMessages");
|
|
OLD_GAMERULES.put("keepInventory", "keepInventory");
|
|
OLD_GAMERULES.put("doWeatherCycle", "weatherChanges");
|
|
OLD_GAMERULES.put("randomTickSpeed", "randomTickSpeed");
|
|
|
|
mapEntity(EntityBoat.class, "Boat", "boat");
|
|
mapEntity(EntityMinecart.class, "Minecart", "MinecartRideable", "minecart");
|
|
mapEntity(EntityBat.class, "Bat", "bat");
|
|
mapEntity(EntityPig.class, "Pig", "pig");
|
|
mapEntity(EntitySheep.class, "Sheep", "sheep");
|
|
mapEntity(EntityCow.class, "Cow", "cow");
|
|
mapEntity(EntityChicken.class, "Chicken", "chicken");
|
|
mapEntity(EntitySquid.class, "Squid", "squid");
|
|
mapEntity(EntityWolf.class, "Wolf", "wolf");
|
|
mapEntity(EntityMooshroom.class, "MushroomCow", "mooshroom");
|
|
mapEntity(EntityOcelot.class, "Ozelot", "ocelot");
|
|
mapEntity(EntityHorse.class, "EntityHorse", "horse");
|
|
mapEntity(EntityRabbit.class, "Rabbit", "rabbit");
|
|
|
|
mapTile(TileEntityFurnace.class, "Furnace", "furnace");
|
|
mapTile(TileEntityChest.class, "Chest", "chest");
|
|
mapTile(TileEntityDispenser.class, "Trap", "dispenser");
|
|
mapTile(TileEntityDropper.class, "Dropper", "dropper");
|
|
mapTile(TileEntitySign.class, "Sign", "sign");
|
|
mapTile(TileEntityMobSpawner.class, "MobSpawner", "mob_spawner");
|
|
mapTile(TileEntityNote.class, "Music", "noteblock");
|
|
mapTile(TileEntityPiston.class, "Piston", "piston");
|
|
mapTile(TileEntityEnchantmentTable.class, "EnchantTable", "enchanting_table");
|
|
mapTile(TileEntityBeacon.class, "Beacon", "beacon");
|
|
mapTile(TileEntitySkull.class, "Skull", "skull");
|
|
mapTile(TileEntityDaylightDetector.class, "DLDetector", "daylight_detector");
|
|
mapTile(TileEntityHopper.class, "Hopper", "hopper");
|
|
mapTile(TileEntityComparator.class, "Comparator", "comparator");
|
|
// mapTile(TileEntityFlowerPot.class, "FlowerPot", "flower_pot");
|
|
mapTile(TileEntityBanner.class, "Banner", "banner");
|
|
|
|
mapBlock(Blocks.stone.getState(), 1);
|
|
mapBlock(Blocks.rock.getState().withProperty(BlockRock.SMOOTH, false), 1, 1);
|
|
mapBlock(Blocks.rock.getState().withProperty(BlockRock.SMOOTH, true), 1, 2);
|
|
mapBlock(Blocks.rock.getState().withProperty(BlockRock.SMOOTH, false), 1, 3);
|
|
mapBlock(Blocks.rock.getState().withProperty(BlockRock.SMOOTH, true), 1, 4);
|
|
mapBlock(Blocks.rock.getState().withProperty(BlockRock.SMOOTH, false), 1, 5);
|
|
mapBlock(Blocks.rock.getState().withProperty(BlockRock.SMOOTH, true), 1, 6);
|
|
mapBlock(Blocks.grass, 2);
|
|
mapBlock(Blocks.dirt.getState().withProperty(BlockDirt.VARIANT, BlockDirt.DirtType.DIRT), 3);
|
|
mapBlock(Blocks.dirt.getState().withProperty(BlockDirt.VARIANT, BlockDirt.DirtType.DIRT), 3, 1);
|
|
mapBlock(Blocks.dirt.getState().withProperty(BlockDirt.VARIANT, BlockDirt.DirtType.DIRT), 3, 2);
|
|
mapBlock(Blocks.cobblestone, 4);
|
|
mapBlock(Blocks.oak_planks, 5);
|
|
mapBlock(Blocks.spruce_planks, 5, 1);
|
|
mapBlock(Blocks.birch_planks, 5, 2);
|
|
mapBlock(Blocks.jungle_planks, 5, 3);
|
|
mapBlock(Blocks.acacia_planks, 5, 4);
|
|
mapBlock(Blocks.dark_oak_planks, 5, 5);
|
|
mapBlock(Blocks.oak_sapling, 6);
|
|
mapBlock(Blocks.spruce_sapling, 6, 1);
|
|
mapBlock(Blocks.birch_sapling, 6, 2);
|
|
mapBlock(Blocks.jungle_sapling, 6, 3);
|
|
mapBlock(Blocks.acacia_sapling, 6, 4);
|
|
mapBlock(Blocks.dark_oak_sapling, 6, 5);
|
|
mapBlock(Blocks.bedrock, 7);
|
|
mapBlock(new BlockFunction() {
|
|
public State getState(int id, int data) {
|
|
return Blocks.flowing_water.getState().withProperty(BlockLiquid.LEVEL, data);
|
|
}
|
|
}, 8);
|
|
mapBlock(new BlockFunction() {
|
|
public State getState(int id, int data) {
|
|
return Blocks.water.getState().withProperty(BlockLiquid.LEVEL, data);
|
|
}
|
|
}, 9);
|
|
mapBlock(new BlockFunction() {
|
|
public State getState(int id, int data) {
|
|
return Blocks.flowing_lava.getState().withProperty(BlockLiquid.LEVEL, data);
|
|
}
|
|
}, 10);
|
|
mapBlock(new BlockFunction() {
|
|
public State getState(int id, int data) {
|
|
return Blocks.lava.getState().withProperty(BlockLiquid.LEVEL, data);
|
|
}
|
|
}, 11);
|
|
mapBlock(Blocks.sand.getState().withProperty(BlockSand.VARIANT, BlockSand.EnumType.SAND), 12);
|
|
mapBlock(Blocks.sand.getState().withProperty(BlockSand.VARIANT, BlockSand.EnumType.RED_SAND), 12, 1);
|
|
mapBlock(Blocks.gravel, 13);
|
|
mapBlock(Blocks.gold_ore, 14);
|
|
mapBlock(Blocks.iron_ore, 15);
|
|
mapBlock(Blocks.coal_ore, 16);
|
|
mapBlock(Blocks.oak_log.getState().withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.Y), 17);
|
|
mapBlock(Blocks.oak_log.getState().withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.X), 17, 4);
|
|
mapBlock(Blocks.oak_log.getState().withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.Z), 17, 8);
|
|
mapBlock(Blocks.oak_log.getState().withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.NONE), 17, 12);
|
|
mapBlock(Blocks.spruce_log.getState().withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.Y), 17, 1);
|
|
mapBlock(Blocks.spruce_log.getState().withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.X), 17, 5);
|
|
mapBlock(Blocks.spruce_log.getState().withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.Z), 17, 9);
|
|
mapBlock(Blocks.spruce_log.getState().withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.NONE), 17, 13);
|
|
mapBlock(Blocks.birch_log.getState().withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.Y), 17, 2);
|
|
mapBlock(Blocks.birch_log.getState().withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.X), 17, 6);
|
|
mapBlock(Blocks.birch_log.getState().withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.Z), 17, 10);
|
|
mapBlock(Blocks.birch_log.getState().withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.NONE), 17, 14);
|
|
mapBlock(Blocks.jungle_log.getState().withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.Y), 17, 3);
|
|
mapBlock(Blocks.jungle_log.getState().withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.X), 17, 7);
|
|
mapBlock(Blocks.jungle_log.getState().withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.Z), 17, 11);
|
|
mapBlock(Blocks.jungle_log.getState().withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.NONE), 17, 15);
|
|
mapBlock(Blocks.oak_leaves.getState().withProperty(BlockLeaves.TYPE, LeavesType.SPRING)
|
|
.withProperty(BlockLeaves.DECAY, false), 18);
|
|
mapBlock(Blocks.oak_leaves.getState().withProperty(BlockLeaves.TYPE, LeavesType.SPRING)
|
|
.withProperty(BlockLeaves.DECAY, false), 18, 4);
|
|
mapBlock(Blocks.oak_leaves.getState().withProperty(BlockLeaves.TYPE, LeavesType.SPRING)
|
|
.withProperty(BlockLeaves.DECAY, true), 18, 8);
|
|
mapBlock(Blocks.oak_leaves.getState().withProperty(BlockLeaves.TYPE, LeavesType.SPRING)
|
|
.withProperty(BlockLeaves.DECAY, true), 18, 12);
|
|
mapBlock(Blocks.spruce_leaves.getState().withProperty(BlockLeaves.TYPE, LeavesType.SPRING)
|
|
.withProperty(BlockLeaves.DECAY, false), 18, 1);
|
|
mapBlock(Blocks.spruce_leaves.getState().withProperty(BlockLeaves.TYPE, LeavesType.SPRING)
|
|
.withProperty(BlockLeaves.DECAY, false), 18, 5);
|
|
mapBlock(Blocks.spruce_leaves.getState().withProperty(BlockLeaves.TYPE, LeavesType.SPRING)
|
|
.withProperty(BlockLeaves.DECAY, true), 18, 9);
|
|
mapBlock(Blocks.spruce_leaves.getState().withProperty(BlockLeaves.TYPE, LeavesType.SPRING)
|
|
.withProperty(BlockLeaves.DECAY, true), 18, 13);
|
|
mapBlock(Blocks.birch_leaves.getState().withProperty(BlockLeaves.TYPE, LeavesType.SPRING)
|
|
.withProperty(BlockLeaves.DECAY, false), 18, 2);
|
|
mapBlock(Blocks.birch_leaves.getState().withProperty(BlockLeaves.TYPE, LeavesType.SPRING)
|
|
.withProperty(BlockLeaves.DECAY, false), 18, 6);
|
|
mapBlock(Blocks.birch_leaves.getState().withProperty(BlockLeaves.TYPE, LeavesType.SPRING)
|
|
.withProperty(BlockLeaves.DECAY, true), 18, 10);
|
|
mapBlock(Blocks.birch_leaves.getState().withProperty(BlockLeaves.TYPE, LeavesType.SPRING)
|
|
.withProperty(BlockLeaves.DECAY, true), 18, 14);
|
|
mapBlock(Blocks.jungle_leaves.getState().withProperty(BlockLeaves.TYPE, LeavesType.SPRING)
|
|
.withProperty(BlockLeaves.DECAY, false), 18, 3);
|
|
mapBlock(Blocks.jungle_leaves.getState().withProperty(BlockLeaves.TYPE, LeavesType.SPRING)
|
|
.withProperty(BlockLeaves.DECAY, false), 18, 7);
|
|
mapBlock(Blocks.jungle_leaves.getState().withProperty(BlockLeaves.TYPE, LeavesType.SPRING)
|
|
.withProperty(BlockLeaves.DECAY, true), 18, 11);
|
|
mapBlock(Blocks.jungle_leaves.getState().withProperty(BlockLeaves.TYPE, LeavesType.SPRING)
|
|
.withProperty(BlockLeaves.DECAY, true), 18, 15);
|
|
mapBlock(Blocks.sponge, 19);
|
|
mapBlock(Blocks.glass, 20);
|
|
mapBlock(Blocks.lapis_ore, 21);
|
|
mapBlock(Blocks.lapis_block, 22);
|
|
mapBlockData(Blocks.dispenser, 23);
|
|
mapBlock(Blocks.sandstone.getState().withProperty(BlockSandStone.TYPE, BlockSandStone.EnumType.DEFAULT), 24);
|
|
mapBlock(Blocks.sandstone.getState().withProperty(BlockSandStone.TYPE, BlockSandStone.EnumType.CHISELED), 24, 1);
|
|
mapBlock(Blocks.sandstone.getState().withProperty(BlockSandStone.TYPE, BlockSandStone.EnumType.SMOOTH), 24, 2);
|
|
mapBlock(Blocks.noteblock, 25);
|
|
mapBlockData(Blocks.red_bed, 26);
|
|
mapBlockData(Blocks.golden_rail, 27);
|
|
mapBlockData(Blocks.detector_rail, 28);
|
|
mapBlockData(Blocks.sticky_piston, 29);
|
|
mapBlock(Blocks.sticky_piston.getState().withProperty(BlockPistonBase.FACING, Facing.UP)
|
|
.withProperty(BlockPistonBase.EXTENDED, false), 29, 6);
|
|
mapBlock(Blocks.sticky_piston.getState().withProperty(BlockPistonBase.FACING, Facing.UP)
|
|
.withProperty(BlockPistonBase.EXTENDED, true), 29, 14);
|
|
mapBlock(Blocks.web, 30);
|
|
mapBlock(Blocks.tallgrass.getState().withProperty(BlockTallGrass.TYPE, BlockTallGrass.EnumType.DEAD_BUSH), 31);
|
|
mapBlock(Blocks.tallgrass.getState().withProperty(BlockTallGrass.TYPE, BlockTallGrass.EnumType.GRASS), 31, 1);
|
|
mapBlock(Blocks.tallgrass.getState().withProperty(BlockTallGrass.TYPE, BlockTallGrass.EnumType.FERN), 31, 2);
|
|
mapBlock(Blocks.deadbush, 32);
|
|
mapBlockData(Blocks.piston, 33);
|
|
mapBlock(Blocks.piston.getState().withProperty(BlockPistonBase.FACING, Facing.UP)
|
|
.withProperty(BlockPistonBase.EXTENDED, false), 33, 6);
|
|
mapBlock(Blocks.piston.getState().withProperty(BlockPistonBase.FACING, Facing.UP)
|
|
.withProperty(BlockPistonBase.EXTENDED, true), 33, 14);
|
|
mapBlockData(Blocks.piston_head, 34);
|
|
mapBlock(Blocks.piston_head.getState().withProperty(BlockPistonHead.FACING, Facing.UP)
|
|
.withProperty(BlockPistonHead.TYPE, BlockPistonHead.EnumPistonType.DEFAULT), 34, 6);
|
|
mapBlock(Blocks.piston_head.getState().withProperty(BlockPistonHead.FACING, Facing.UP)
|
|
.withProperty(BlockPistonHead.TYPE, BlockPistonHead.EnumPistonType.STICKY), 34, 14);
|
|
mapBlock(new BlockFunction() {
|
|
public State getState(int id, int data) {
|
|
return Blocks.wool.getState().withProperty(BlockColored.COLOR, DyeColor.byMetadata(data));
|
|
}
|
|
}, 35);
|
|
mapBlockData(Blocks.piston_extension, 36);
|
|
mapBlock(Blocks.flower.getState().withProperty(Blocks.flower.getTypeProperty(), BlockFlower.EnumFlowerType.DANDELION), 37);
|
|
mapBlock(Blocks.flower.getState().withProperty(Blocks.flower.getTypeProperty(), BlockFlower.EnumFlowerType.POPPY),
|
|
38);
|
|
mapBlock(Blocks.flower.getState().withProperty(Blocks.flower.getTypeProperty(), BlockFlower.EnumFlowerType.BLUE_ORCHID),
|
|
38, 1);
|
|
mapBlock(Blocks.flower.getState().withProperty(Blocks.flower.getTypeProperty(), BlockFlower.EnumFlowerType.ALLIUM),
|
|
38, 2);
|
|
mapBlock(Blocks.flower.getState().withProperty(Blocks.flower.getTypeProperty(), BlockFlower.EnumFlowerType.HOUSTONIA),
|
|
38, 3);
|
|
mapBlock(Blocks.flower.getState().withProperty(Blocks.flower.getTypeProperty(), BlockFlower.EnumFlowerType.RED_TULIP),
|
|
38, 4);
|
|
mapBlock(Blocks.flower.getState().withProperty(Blocks.flower.getTypeProperty(), BlockFlower.EnumFlowerType.ORANGE_TULIP),
|
|
38, 5);
|
|
mapBlock(Blocks.flower.getState().withProperty(Blocks.flower.getTypeProperty(), BlockFlower.EnumFlowerType.WHITE_TULIP),
|
|
38, 6);
|
|
mapBlock(Blocks.flower.getState().withProperty(Blocks.flower.getTypeProperty(), BlockFlower.EnumFlowerType.PINK_TULIP),
|
|
38, 7);
|
|
mapBlock(Blocks.flower.getState().withProperty(Blocks.flower.getTypeProperty(), BlockFlower.EnumFlowerType.OXEYE_DAISY),
|
|
38, 8);
|
|
mapBlock(Blocks.brown_mushroom, 39);
|
|
mapBlock(Blocks.red_mushroom, 40);
|
|
mapBlock(Blocks.gold_block, 41);
|
|
mapBlock(Blocks.iron_block, 42);
|
|
mapBlock(Blocks.stone_slab.getState().withProperty(BlockSlab.DOUBLE, true).withProperty(BlockSlab.SEAMLESS, false),
|
|
43);
|
|
mapBlock(Blocks.sandstone_slab.getState().withProperty(BlockSlab.DOUBLE, true).withProperty(BlockSlab.SEAMLESS, false),
|
|
43, 1);
|
|
mapBlock(Blocks.oak_slab.getState().withProperty(BlockSlab.DOUBLE, true).withProperty(BlockSlab.SEAMLESS, false),
|
|
43, 2);
|
|
mapBlock(Blocks.cobblestone_slab.getState().withProperty(BlockSlab.DOUBLE, true).withProperty(BlockSlab.SEAMLESS, false),
|
|
43, 3);
|
|
mapBlock(Blocks.brick_slab.getState().withProperty(BlockSlab.DOUBLE, true).withProperty(BlockSlab.SEAMLESS, false),
|
|
43, 4);
|
|
mapBlock(Blocks.stonebrick_slab.getState().withProperty(BlockSlab.DOUBLE, true).withProperty(BlockSlab.SEAMLESS, false),
|
|
43, 5);
|
|
mapBlock(Blocks.blood_brick_slab.getState().withProperty(BlockSlab.DOUBLE, true).withProperty(BlockSlab.SEAMLESS, false),
|
|
43, 6);
|
|
mapBlock(Blocks.quartz_slab.getState().withProperty(BlockSlab.DOUBLE, true).withProperty(BlockSlab.SEAMLESS, false),
|
|
43, 7);
|
|
mapBlock(Blocks.stone_slab.getState().withProperty(BlockSlab.DOUBLE, true).withProperty(BlockSlab.SEAMLESS, true),
|
|
43, 8);
|
|
mapBlock(Blocks.sandstone_slab.getState().withProperty(BlockSlab.DOUBLE, true).withProperty(BlockSlab.SEAMLESS, true),
|
|
43, 9);
|
|
mapBlock(Blocks.stone_slab.getState().withProperty(BlockSlab.DOUBLE, false).withProperty(BlockSlab.FACING, Facing.DOWN),
|
|
44);
|
|
mapBlock(Blocks.sandstone_slab.getState().withProperty(BlockSlab.DOUBLE, false).withProperty(BlockSlab.FACING, Facing.DOWN),
|
|
44, 1);
|
|
mapBlock(Blocks.oak_slab.getState().withProperty(BlockSlab.DOUBLE, false).withProperty(BlockSlab.FACING, Facing.DOWN),
|
|
44, 2);
|
|
mapBlock(Blocks.cobblestone_slab.getState().withProperty(BlockSlab.DOUBLE, false).withProperty(BlockSlab.FACING, Facing.DOWN),
|
|
44, 3);
|
|
mapBlock(Blocks.brick_slab.getState().withProperty(BlockSlab.DOUBLE, false).withProperty(BlockSlab.FACING, Facing.DOWN),
|
|
44, 4);
|
|
mapBlock(Blocks.stonebrick_slab.getState().withProperty(BlockSlab.DOUBLE, false).withProperty(BlockSlab.FACING, Facing.DOWN),
|
|
44, 5);
|
|
mapBlock(Blocks.blood_brick_slab.getState().withProperty(BlockSlab.DOUBLE, false).withProperty(BlockSlab.FACING, Facing.DOWN),
|
|
44, 6);
|
|
mapBlock(Blocks.quartz_slab.getState().withProperty(BlockSlab.DOUBLE, false).withProperty(BlockSlab.FACING, Facing.DOWN),
|
|
44, 7);
|
|
mapBlock(Blocks.stone_slab.getState().withProperty(BlockSlab.DOUBLE, false).withProperty(BlockSlab.FACING, Facing.UP),
|
|
44, 8);
|
|
mapBlock(Blocks.sandstone_slab.getState().withProperty(BlockSlab.DOUBLE, false).withProperty(BlockSlab.FACING, Facing.UP),
|
|
44, 9);
|
|
mapBlock(Blocks.oak_slab.getState().withProperty(BlockSlab.DOUBLE, false).withProperty(BlockSlab.FACING, Facing.UP),
|
|
44, 10);
|
|
mapBlock(Blocks.cobblestone_slab.getState().withProperty(BlockSlab.DOUBLE, false).withProperty(BlockSlab.FACING, Facing.UP),
|
|
44, 11);
|
|
mapBlock(Blocks.brick_slab.getState().withProperty(BlockSlab.DOUBLE, false).withProperty(BlockSlab.FACING, Facing.UP),
|
|
44, 12);
|
|
mapBlock(Blocks.stonebrick_slab.getState().withProperty(BlockSlab.DOUBLE, false).withProperty(BlockSlab.FACING, Facing.UP),
|
|
44, 13);
|
|
mapBlock(Blocks.blood_brick_slab.getState().withProperty(BlockSlab.DOUBLE, false).withProperty(BlockSlab.FACING, Facing.UP),
|
|
44, 14);
|
|
mapBlock(Blocks.quartz_slab.getState().withProperty(BlockSlab.DOUBLE, false).withProperty(BlockSlab.FACING, Facing.UP),
|
|
44, 15);
|
|
mapBlock(Blocks.brick_block, 45);
|
|
mapBlock(Blocks.tnt.getState().withProperty(BlockTNT.POWER, 0).withProperty(BlockTNT.EXPLODE, false), 46);
|
|
mapBlock(Blocks.tnt.getState().withProperty(BlockTNT.POWER, 0).withProperty(BlockTNT.EXPLODE, true), 46, 1);
|
|
mapBlock(Blocks.bookshelf, 47);
|
|
mapBlock(Blocks.mossy_cobblestone, 48);
|
|
mapBlock(Blocks.obsidian, 49);
|
|
mapBlock(Blocks.torch, 50);
|
|
mapBlock(new BlockFunction() {
|
|
public State getState(int id, int data) {
|
|
return Blocks.fire.getState().withProperty(BlockFire.AGE, data);
|
|
}
|
|
}, 51);
|
|
mapBlock(Blocks.mob_spawner, 52);
|
|
mapBlockData(Blocks.oak_stairs, 53);
|
|
mapBlockData(Blocks.chest, 54);
|
|
mapBlockData(Blocks.redstone, 55);
|
|
mapBlock(Blocks.diamond_ore, 56);
|
|
mapBlock(Blocks.diamond_block, 57);
|
|
mapBlock(Blocks.crafting_table, 58);
|
|
mapBlockData(Blocks.wheat, 59);
|
|
mapBlockData(Blocks.farmland, 60);
|
|
mapBlockData(Blocks.furnace, 61);
|
|
mapBlockData(Blocks.lit_furnace, 62);
|
|
mapBlockData(Blocks.sign, 63);
|
|
mapBlockData(Blocks.oak_door, 64);
|
|
mapBlockData(Blocks.ladder, 65);
|
|
mapBlockData(Blocks.rail, 66);
|
|
mapBlockData(Blocks.cobblestone_stairs, 67);
|
|
mapBlockData(Blocks.wall_sign, 68);
|
|
mapBlockData(Blocks.lever, 69);
|
|
mapBlockData(Blocks.stone_pressure_plate, 70);
|
|
mapBlockData(Blocks.iron_door, 71);
|
|
mapBlockData(Blocks.wooden_pressure_plate, 72);
|
|
mapBlock(Blocks.redstone_ore, 73);
|
|
mapBlock(Blocks.lit_redstone_ore, 74);
|
|
mapBlockData(Blocks.unlit_redstone_torch, 75);
|
|
mapBlockData(Blocks.redstone_torch, 76);
|
|
mapBlockData(Blocks.stone_button, 77);
|
|
mapBlockData(Blocks.snow_layer, 78);
|
|
mapBlock(Blocks.ice, 79);
|
|
mapBlock(Blocks.snow, 80);
|
|
mapBlock(new BlockFunction() {
|
|
public State getState(int id, int data) {
|
|
return Blocks.cactus.getState().withProperty(BlockCactus.AGE, data);
|
|
}
|
|
}, 81);
|
|
mapBlock(Blocks.clay, 82);
|
|
mapBlockData(Blocks.reeds, 83);
|
|
mapBlock(Blocks.jukebox, 84);
|
|
mapBlockData(Blocks.oak_fence, 85);
|
|
mapBlockData(Blocks.pumpkin, 86);
|
|
mapBlock(Blocks.hellrock, 87);
|
|
mapBlock(Blocks.soul_sand, 88);
|
|
mapBlock(Blocks.glowstone, 89);
|
|
mapBlock(Blocks.stained_glass_pane.getState().withProperty(BlockStainedGlass.COLOR, DyeColor.PURPLE), 90);
|
|
mapBlockData(Blocks.lit_pumpkin, 91);
|
|
mapBlockData(Blocks.cake, 92);
|
|
mapBlockData(Blocks.repeater, 93);
|
|
mapBlockData(Blocks.powered_repeater, 94);
|
|
mapBlock(new BlockFunction() {
|
|
public State getState(int id, int data) {
|
|
return Blocks.stained_glass.getState().withProperty(BlockStainedGlass.COLOR, DyeColor.byMetadata(data));
|
|
}
|
|
}, 95);
|
|
mapBlockData(Blocks.trapdoor, 96);
|
|
mapBlock(Blocks.stone, 97);
|
|
mapBlock(Blocks.cobblestone, 97, 1);
|
|
mapBlock(Blocks.stonebrick.getState().withProperty(BlockStoneBrick.VARIANT, BlockStoneBrick.EnumType.DEFAULT), 97, 2);
|
|
mapBlock(Blocks.stonebrick.getState().withProperty(BlockStoneBrick.VARIANT, BlockStoneBrick.EnumType.MOSSY), 97, 3);
|
|
mapBlock(Blocks.stonebrick.getState().withProperty(BlockStoneBrick.VARIANT, BlockStoneBrick.EnumType.CRACKED), 97, 4);
|
|
mapBlock(Blocks.stonebrick.getState().withProperty(BlockStoneBrick.VARIANT, BlockStoneBrick.EnumType.CHISELED), 97, 5);
|
|
mapBlock(Blocks.stonebrick.getState().withProperty(BlockStoneBrick.VARIANT, BlockStoneBrick.EnumType.DEFAULT), 98);
|
|
mapBlock(Blocks.stonebrick.getState().withProperty(BlockStoneBrick.VARIANT, BlockStoneBrick.EnumType.MOSSY), 98, 1);
|
|
mapBlock(Blocks.stonebrick.getState().withProperty(BlockStoneBrick.VARIANT, BlockStoneBrick.EnumType.CRACKED), 98, 2);
|
|
mapBlock(Blocks.stonebrick.getState().withProperty(BlockStoneBrick.VARIANT, BlockStoneBrick.EnumType.CHISELED), 98, 3);
|
|
mapBlockData(Blocks.brown_mushroom_block, 99);
|
|
mapBlockData(Blocks.red_mushroom_block, 100);
|
|
mapBlock(Blocks.iron_bars, 101);
|
|
mapBlock(Blocks.glass_pane, 102);
|
|
mapBlock(Blocks.melon_block, 103);
|
|
mapBlockData(Blocks.pumpkin_stem, 104);
|
|
mapBlockData(Blocks.melon_stem, 105);
|
|
mapBlockData(Blocks.vine, 106);
|
|
mapBlockData(Blocks.oak_fence_gate, 107);
|
|
mapBlockData(Blocks.brick_stairs, 108);
|
|
mapBlockData(Blocks.stonebrick_stairs, 109);
|
|
mapBlock(Blocks.mycelium, 110);
|
|
mapBlockData(Blocks.waterlily, 111);
|
|
// mapBlockDynamic(new BlockFunction() {
|
|
// public IBlockState getState(int id, int data) {
|
|
// return Blocks.waterlily.getDefaultState().withProperty(BlockDirectional.FACING, Facing.randHorizontal(RANDOM));
|
|
// }
|
|
// }, 111);
|
|
mapBlock(Blocks.blood_brick, 112);
|
|
mapBlockData(Blocks.blood_brick_fence, 113);
|
|
mapBlockData(Blocks.blood_brick_stairs, 114);
|
|
mapBlockData(Blocks.soul_wart, 115);
|
|
mapBlock(Blocks.enchanting_table, 116);
|
|
mapBlockData(Blocks.brewing_stand, 117);
|
|
mapBlockData(Blocks.cauldron, 118);
|
|
mapBlock(Blocks.stained_glass.getState().withProperty(BlockStainedGlass.COLOR, DyeColor.BLACK), 119);
|
|
mapBlock(Blocks.obsidian, 120);
|
|
mapBlock(Blocks.cell_rock, 121);
|
|
mapBlock(Blocks.dragon_egg, 122);
|
|
mapBlock(Blocks.redstone_lamp, 123);
|
|
mapBlock(Blocks.lit_redstone_lamp, 124);
|
|
mapBlock(Blocks.oak_slab.getState().withProperty(BlockSlab.DOUBLE, true).withProperty(BlockSlab.SEAMLESS, false),
|
|
125);
|
|
mapBlock(Blocks.spruce_slab.getState().withProperty(BlockSlab.DOUBLE, true).withProperty(BlockSlab.SEAMLESS, false),
|
|
125, 1);
|
|
mapBlock(Blocks.birch_slab.getState().withProperty(BlockSlab.DOUBLE, true).withProperty(BlockSlab.SEAMLESS, false),
|
|
125, 2);
|
|
mapBlock(Blocks.jungle_slab.getState().withProperty(BlockSlab.DOUBLE, true).withProperty(BlockSlab.SEAMLESS, false),
|
|
125, 3);
|
|
mapBlock(Blocks.acacia_slab.getState().withProperty(BlockSlab.DOUBLE, true).withProperty(BlockSlab.SEAMLESS, false),
|
|
125, 4);
|
|
mapBlock(Blocks.dark_oak_slab.getState().withProperty(BlockSlab.DOUBLE, true).withProperty(BlockSlab.SEAMLESS, false),
|
|
125, 5);
|
|
mapBlock(Blocks.oak_slab.getState().withProperty(BlockSlab.DOUBLE, false).withProperty(BlockSlab.FACING, Facing.DOWN),
|
|
126);
|
|
mapBlock(Blocks.spruce_slab.getState().withProperty(BlockSlab.DOUBLE, false).withProperty(BlockSlab.FACING, Facing.DOWN),
|
|
126, 1);
|
|
mapBlock(Blocks.birch_slab.getState().withProperty(BlockSlab.DOUBLE, false).withProperty(BlockSlab.FACING, Facing.DOWN),
|
|
126, 2);
|
|
mapBlock(Blocks.jungle_slab.getState().withProperty(BlockSlab.DOUBLE, false).withProperty(BlockSlab.FACING, Facing.DOWN),
|
|
126, 3);
|
|
mapBlock(Blocks.acacia_slab.getState().withProperty(BlockSlab.DOUBLE, false).withProperty(BlockSlab.FACING, Facing.DOWN),
|
|
126, 4);
|
|
mapBlock(Blocks.dark_oak_slab.getState().withProperty(BlockSlab.DOUBLE, false).withProperty(BlockSlab.FACING, Facing.DOWN),
|
|
126, 5);
|
|
mapBlock(Blocks.oak_slab.getState().withProperty(BlockSlab.DOUBLE, false).withProperty(BlockSlab.FACING, Facing.UP),
|
|
126, 8);
|
|
mapBlock(Blocks.spruce_slab.getState().withProperty(BlockSlab.DOUBLE, false).withProperty(BlockSlab.FACING, Facing.UP),
|
|
126, 9);
|
|
mapBlock(Blocks.birch_slab.getState().withProperty(BlockSlab.DOUBLE, false).withProperty(BlockSlab.FACING, Facing.UP),
|
|
126, 10);
|
|
mapBlock(Blocks.jungle_slab.getState().withProperty(BlockSlab.DOUBLE, false).withProperty(BlockSlab.FACING, Facing.UP),
|
|
126, 11);
|
|
mapBlock(Blocks.acacia_slab.getState().withProperty(BlockSlab.DOUBLE, false).withProperty(BlockSlab.FACING, Facing.UP),
|
|
126, 12);
|
|
mapBlock(Blocks.dark_oak_slab.getState().withProperty(BlockSlab.DOUBLE, false).withProperty(BlockSlab.FACING, Facing.UP),
|
|
126, 13);
|
|
mapBlockData(Blocks.cocoa, 127);
|
|
mapBlockData(Blocks.sandstone_stairs, 128);
|
|
mapBlock(Blocks.emerald_ore, 129);
|
|
mapBlockData(Blocks.warp_chest, 130);
|
|
mapBlockData(Blocks.tripwire_hook, 131);
|
|
mapBlockData(Blocks.string, 132);
|
|
mapBlock(Blocks.emerald_block, 133);
|
|
mapBlockData(Blocks.spruce_stairs, 134);
|
|
mapBlockData(Blocks.spruce_stairs, 135);
|
|
mapBlockData(Blocks.spruce_stairs, 136);
|
|
mapBlock(Blocks.obsidian, 137);
|
|
mapBlock(Blocks.beacon, 138);
|
|
mapBlock(Blocks.cobblestone_wall.getState().withProperty(BlockWall.VARIANT, BlockWall.EnumType.NORMAL), 139);
|
|
mapBlock(Blocks.cobblestone_wall.getState().withProperty(BlockWall.VARIANT, BlockWall.EnumType.MOSSY), 139, 1);
|
|
mapBlock(Blocks.flower_pot.getState().withProperty(BlockFlowerPot.CONTENTS, 0), 140);
|
|
mapBlockData(Blocks.carrot, 141);
|
|
mapBlockData(Blocks.potato, 142);
|
|
mapBlockData(Blocks.wooden_button, 143);
|
|
mapBlockData(Blocks.skull, 144); // -NODROP
|
|
mapBlockData(Blocks.anvil, 145);
|
|
mapBlockData(Blocks.trapped_chest, 146);
|
|
mapBlockData(Blocks.light_weighted_pressure_plate, 147);
|
|
mapBlockData(Blocks.heavy_weighted_pressure_plate, 148);
|
|
mapBlockData(Blocks.comparator, 149);
|
|
mapBlockData(Blocks.powered_comparator, 150);
|
|
mapBlockData(Blocks.daylight_detector, 151);
|
|
mapBlock(Blocks.redstone_block, 152);
|
|
mapBlock(Blocks.quartz_ore, 153);
|
|
mapBlockData(Blocks.hopper, 154);
|
|
mapBlock(Blocks.quartz_block.getState().withProperty(BlockQuartz.VARIANT, BlockQuartz.EnumType.DEFAULT), 155);
|
|
mapBlock(Blocks.quartz_block.getState().withProperty(BlockQuartz.VARIANT, BlockQuartz.EnumType.CHISELED), 155, 1);
|
|
mapBlock(Blocks.quartz_block.getState().withProperty(BlockQuartz.VARIANT, BlockQuartz.EnumType.LINES_Y), 155, 2);
|
|
mapBlock(Blocks.quartz_block.getState().withProperty(BlockQuartz.VARIANT, BlockQuartz.EnumType.LINES_X), 155, 3);
|
|
mapBlock(Blocks.quartz_block.getState().withProperty(BlockQuartz.VARIANT, BlockQuartz.EnumType.LINES_Z), 155, 4);
|
|
mapBlockData(Blocks.quartz_stairs, 156);
|
|
mapBlockData(Blocks.activator_rail, 157);
|
|
mapBlockData(Blocks.dropper, 158);
|
|
mapBlock(new BlockFunction() {
|
|
public State getState(int id, int data) {
|
|
return Blocks.stained_hardened_clay.getState().withProperty(BlockColored.COLOR, DyeColor.byMetadata(data));
|
|
}
|
|
}, 159);
|
|
mapBlock(new BlockFunction() {
|
|
public State getState(int id, int data) {
|
|
return Blocks.stained_glass_pane.getState().withProperty(BlockStainedGlassPane.COLOR, DyeColor.byMetadata(data));
|
|
}
|
|
}, 160);
|
|
mapBlock(Blocks.acacia_leaves.getState().withProperty(BlockLeaves.TYPE, LeavesType.SPRING)
|
|
.withProperty(BlockLeaves.DECAY, false), 161);
|
|
mapBlock(Blocks.acacia_leaves.getState().withProperty(BlockLeaves.TYPE, LeavesType.SPRING)
|
|
.withProperty(BlockLeaves.DECAY, false), 161, 4);
|
|
mapBlock(Blocks.acacia_leaves.getState().withProperty(BlockLeaves.TYPE, LeavesType.SPRING)
|
|
.withProperty(BlockLeaves.DECAY, true), 161, 8);
|
|
mapBlock(Blocks.acacia_leaves.getState().withProperty(BlockLeaves.TYPE, LeavesType.SPRING)
|
|
.withProperty(BlockLeaves.DECAY, true), 161, 12);
|
|
mapBlock(Blocks.dark_oak_leaves.getState().withProperty(BlockLeaves.TYPE, LeavesType.SPRING)
|
|
.withProperty(BlockLeaves.DECAY, false), 161, 1);
|
|
mapBlock(Blocks.dark_oak_leaves.getState().withProperty(BlockLeaves.TYPE, LeavesType.SPRING)
|
|
.withProperty(BlockLeaves.DECAY, false), 161, 5);
|
|
mapBlock(Blocks.dark_oak_leaves.getState().withProperty(BlockLeaves.TYPE, LeavesType.SPRING)
|
|
.withProperty(BlockLeaves.DECAY, true), 161, 9);
|
|
mapBlock(Blocks.dark_oak_leaves.getState().withProperty(BlockLeaves.TYPE, LeavesType.SPRING)
|
|
.withProperty(BlockLeaves.DECAY, true), 161, 13);
|
|
mapBlock(Blocks.acacia_log.getState().withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.Y), 162);
|
|
mapBlock(Blocks.acacia_log.getState().withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.X), 162, 4);
|
|
mapBlock(Blocks.acacia_log.getState().withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.Z), 162, 8);
|
|
mapBlock(Blocks.acacia_log.getState().withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.NONE), 162, 12);
|
|
mapBlock(Blocks.dark_oak_log.getState().withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.Y), 162, 1);
|
|
mapBlock(Blocks.dark_oak_log.getState().withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.X), 162, 5);
|
|
mapBlock(Blocks.dark_oak_log.getState().withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.Z), 162, 9);
|
|
mapBlock(Blocks.dark_oak_log.getState().withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.NONE), 162, 13);
|
|
mapBlockData(Blocks.acacia_stairs, 163);
|
|
mapBlockData(Blocks.dark_oak_stairs, 164);
|
|
mapBlock(Blocks.slime_block, 165);
|
|
mapBlock(Blocks.glass, 166);
|
|
mapBlockData(Blocks.iron_trapdoor, 167);
|
|
mapBlock(Blocks.stonebrick.getState().withProperty(BlockStoneBrick.VARIANT, BlockStoneBrick.EnumType.DEFAULT), 168);
|
|
mapBlock(Blocks.rock.getState().withProperty(BlockRock.SMOOTH, true), 168, 1);
|
|
mapBlock(Blocks.black_brick, 168, 2);
|
|
mapBlock(Blocks.lamp, 169);
|
|
mapBlockData(Blocks.hay_block, 170);
|
|
mapBlock(new BlockFunction() {
|
|
public State getState(int id, int data) {
|
|
return Blocks.carpet.getState().withProperty(BlockCarpet.COLOR, DyeColor.byMetadata(data));
|
|
}
|
|
}, 171);
|
|
mapBlock(Blocks.hardened_clay, 172);
|
|
mapBlock(Blocks.coal_block, 173);
|
|
mapBlock(Blocks.packed_ice, 174);
|
|
mapBlockData(Blocks.double_plant, 175);
|
|
mapBlockData(Blocks.banner, 176);
|
|
mapBlockData(Blocks.wall_banner, 177);
|
|
mapBlockData(Blocks.daylight_detector_inverted, 178);
|
|
mapBlock(Blocks.sandstone.getState().withProperty(BlockSandStone.TYPE, BlockSandStone.EnumType.DEFAULT), 179);
|
|
mapBlock(Blocks.sandstone.getState().withProperty(BlockSandStone.TYPE, BlockSandStone.EnumType.CHISELED), 179, 1);
|
|
mapBlock(Blocks.sandstone.getState().withProperty(BlockSandStone.TYPE, BlockSandStone.EnumType.SMOOTH), 179, 2);
|
|
mapBlockData(Blocks.sandstone_stairs, 180);
|
|
mapBlock(Blocks.sandstone_slab.getState().withProperty(BlockSlab.DOUBLE, true).withProperty(BlockSlab.SEAMLESS, false),
|
|
181);
|
|
mapBlock(Blocks.sandstone_slab.getState().withProperty(BlockSlab.DOUBLE, false).withProperty(BlockSlab.FACING,
|
|
Facing.DOWN), 182);
|
|
mapBlock(Blocks.sandstone_slab.getState().withProperty(BlockSlab.DOUBLE, false).withProperty(BlockSlab.FACING,
|
|
Facing.UP), 182, 8);
|
|
mapBlockData(Blocks.spruce_fence_gate, 183);
|
|
mapBlockData(Blocks.birch_fence_gate, 184);
|
|
mapBlockData(Blocks.jungle_fence_gate, 185);
|
|
mapBlockData(Blocks.dark_oak_fence_gate, 186);
|
|
mapBlockData(Blocks.acacia_fence_gate, 187);
|
|
mapBlockData(Blocks.spruce_fence, 188);
|
|
mapBlockData(Blocks.birch_fence, 189);
|
|
mapBlockData(Blocks.jungle_fence, 190);
|
|
mapBlockData(Blocks.dark_oak_fence, 191);
|
|
mapBlockData(Blocks.acacia_fence, 192);
|
|
mapBlockData(Blocks.spruce_door, 193);
|
|
mapBlockData(Blocks.birch_door, 194);
|
|
mapBlockData(Blocks.jungle_door, 195);
|
|
mapBlockData(Blocks.acacia_door, 196);
|
|
mapBlockData(Blocks.dark_oak_door, 197);
|
|
|
|
mapBlock(Blocks.iron_bars, 198);
|
|
mapBlock(Blocks.glass_pane, 199);
|
|
mapBlock(Blocks.glass_pane, 200);
|
|
mapBlock(Blocks.quartz_block.getState().withProperty(BlockQuartz.VARIANT, BlockQuartz.EnumType.DEFAULT), 201);
|
|
mapBlock(Blocks.quartz_block.getState().withProperty(BlockQuartz.VARIANT, BlockQuartz.EnumType.LINES_Y), 202);
|
|
mapBlockData(Blocks.quartz_stairs, 203);
|
|
mapBlock(Blocks.quartz_slab.getState().withProperty(BlockSlab.DOUBLE, true).withProperty(BlockSlab.SEAMLESS, false), 204);
|
|
mapBlock(Blocks.quartz_slab.getState().withProperty(BlockSlab.DOUBLE, false).withProperty(BlockSlab.FACING, Facing.DOWN),
|
|
205);
|
|
mapBlock(Blocks.quartz_slab.getState().withProperty(BlockSlab.DOUBLE, false).withProperty(BlockSlab.FACING, Facing.UP),
|
|
205, 8);
|
|
mapBlock(Blocks.stonebrick.getState().withProperty(BlockStoneBrick.VARIANT, BlockStoneBrick.EnumType.DEFAULT), 206);
|
|
mapBlockData(Blocks.potato, 207);
|
|
mapBlock(Blocks.farmland, 208);
|
|
mapBlock(Blocks.stained_glass.getState().withProperty(BlockStainedGlass.COLOR, DyeColor.BLACK), 209);
|
|
mapBlock(Blocks.obsidian, 210);
|
|
mapBlock(Blocks.obsidian, 211);
|
|
mapBlock(Blocks.ice, 212);
|
|
mapBlock(Blocks.hellrock, 213);
|
|
mapBlock(Blocks.red_mushroom_block, 214);
|
|
mapBlock(Blocks.blood_brick, 215);
|
|
mapBlock(Blocks.quartz_block.getState().withProperty(BlockQuartz.VARIANT, BlockQuartz.EnumType.DEFAULT), 216);
|
|
mapBlock(Blocks.glass, 217);
|
|
mapBlockData(Blocks.dropper, 218);
|
|
for(int id = 219; id <= 234; id++) {
|
|
mapBlock(Blocks.wool.getState().withProperty(BlockColored.COLOR, DyeColor.byMetadata(id - 219)), id);
|
|
}
|
|
for(int id = 235; id <= 250; id++) {
|
|
mapBlock(Blocks.stained_hardened_clay.getState().withProperty(BlockColored.COLOR, DyeColor.byMetadata(id - 235)), id);
|
|
}
|
|
mapBlock(new BlockFunction() {
|
|
public State getState(int id, int data) {
|
|
return Blocks.stained_hardened_clay.getState().withProperty(BlockColored.COLOR, DyeColor.byMetadata(data));
|
|
}
|
|
}, 251);
|
|
mapBlock(new BlockFunction() {
|
|
public State getState(int id, int data) {
|
|
return Blocks.stained_hardened_clay.getState().withProperty(BlockColored.COLOR, DyeColor.byMetadata(data));
|
|
}
|
|
}, 252);
|
|
// 253, 254
|
|
mapBlock(Blocks.obsidian, 255);
|
|
|
|
// addBlock(137, 49); // Command Block
|
|
// addBlock(166, 0); // Barrier
|
|
// addBlock(168, 98); // Prismarine
|
|
// // addBlock(169, 169); // Sea Lantern --> Lamp
|
|
// addBlock(179, 24); // Red Sandstone
|
|
// addBlock(180, 128); // Red Sandstone Stairs
|
|
// addBlock(181, 43, 1); // Red Sandstone Double Slab
|
|
//
|
|
// addBlock(198, 101); // End Rod
|
|
// addBlock(199, 102); // Chorus Plant
|
|
// addBlock(200, 102); // Chorus Flower
|
|
// addBlock(201, 155); // Purpur Block
|
|
// addBlock(203, 156); // Purpur Stairs
|
|
// addBlock(206, 98); // End Stone Bricks
|
|
// addBlock(207, 142); // Beetroot Block
|
|
// addBlock(208, 60); // Grass Path
|
|
// addBlock(209, 20); // End Gateway
|
|
// addBlock(210, 137); // Repeating Command Block
|
|
// addBlock(211, 137); // Chain Command Block
|
|
// addBlock(212, 79); // Frosted Ice
|
|
// addBlock(213, 87); // Magma Block
|
|
// addBlock(214, 100); // Nether Wart Block
|
|
// addBlock(215, 112); // Red Nether Brick
|
|
// addBlock(216, 155); // Bone Block
|
|
// addBlock(217, 20); // Structure Void
|
|
// addBlock(218, 158); // Observer
|
|
// addBlock(255, 49); // Structure Block
|
|
// addBlock(202, 155, 2); // Purpur Pillar
|
|
// addBlock(204, 43, 7); // Purpur Double Slab
|
|
|
|
// if(block > 197 && adddata != null)
|
|
// adddata.set(cx, cy, cz, 0);
|
|
// if(block == 1 || block == 19) { // Stone, Sponge
|
|
// data.set(cx, cy, cz, 0);
|
|
// }
|
|
// else if(block == 29 || block == 33 || block == 34) { // Piston, Sticky Piston, Piston Head
|
|
// int dt = data.get(cx, cy, cz);
|
|
// if((dt & 7) == 6)
|
|
// data.set(cx, cy, cz, (dt & 8) | 1);
|
|
// }
|
|
// else if(block == 97) { // Monster Egg
|
|
// int dt = data.get(cx, cy, cz);
|
|
// switch(dt) {
|
|
// case 0:
|
|
// default:
|
|
// blocks[c] = (byte)1;
|
|
// data.set(cx, cy, cz, 0);
|
|
// break;
|
|
// case 1:
|
|
// blocks[c] = (byte)4;
|
|
// data.set(cx, cy, cz, 0);
|
|
// break;
|
|
// case 2:
|
|
// case 3:
|
|
// case 4:
|
|
// case 5:
|
|
// blocks[c] = (byte)98;
|
|
// data.set(cx, cy, cz, dt - 2);
|
|
// break;
|
|
// }
|
|
// }
|
|
// mapBlock(new BlockFunction() {
|
|
// public IBlockState getState(int id, int data) {
|
|
// return Blocks.waterlily.getDefaultState().withProperty(BlockDirectional.FACING, Facing.randHorizontal(RANDOM));
|
|
// }
|
|
// }, 111);
|
|
// else if(block == 111) { // Water Lily
|
|
// data.set(cx, cy, cz, RANDOM.zrange(4));
|
|
// }
|
|
// else if(block == 251 || block == 252) { // Concrete, Concrete Powder
|
|
// blocks[c] = (byte)159;
|
|
// }
|
|
// else if(block >= 235 && block <= 250) { // Glazed Terracotta
|
|
// blocks[c] = (byte)159;
|
|
// data.set(cx, cy, cz, block - 235);
|
|
// }
|
|
// else if(block >= 219 && block <= 234) { // Shulker Box
|
|
// blocks[c] = (byte)35;
|
|
// data.set(cx, cy, cz, block - 219);
|
|
// }
|
|
// else if(block == 205) { // Purpur Slab
|
|
// blocks[c] = (byte)44;
|
|
// data.set(cx, cy, cz, (data.get(cx, cy, cz) & 8) == 8 ? 15 : 7);
|
|
// }
|
|
// else if(block == 182) { // Red Sandstone Slab
|
|
// blocks[c] = (byte)44;
|
|
// data.set(cx, cy, cz, (data.get(cx, cy, cz) & 8) == 8 ? 9 : 1);
|
|
// }
|
|
}
|
|
|
|
private static void convertTile(NBTTagCompound ent) {
|
|
if("Sign".equals(ent.getString("id"))) {
|
|
// Log.debug("Konvertiere Schild bei "
|
|
// + ent.getInteger("x") + "," + ent.getInteger("y") + "," + ent.getInteger("z") + " ...");
|
|
String[] signText = new String[4];
|
|
for(int i = 0; i < 4; ++i) {
|
|
signText[i] = ent.getString("Text" + (i + 1));
|
|
}
|
|
byte newComp = 0;
|
|
byte quotes = 0;
|
|
String[] old = new String[4];
|
|
for(int i = 0; i < 4; ++i) {
|
|
old[i] = signText[i];
|
|
// if(ChatFormat.hasLegacy(this.signText[i])) {
|
|
signText[i] = signText[i].indexOf('\u00A7') != -1 ? /* TextColor.replaceCodes( */
|
|
signText[i].replaceAll("\u00A7[0-9a-fA-Fk-oK-O]", "") /* .replace("\u00A7", "$$")) */ :
|
|
signText[i];
|
|
// }
|
|
if(signText[i].startsWith("{") && signText[i].endsWith("}")) {
|
|
try {
|
|
// TextComponent comp = TextSerializer.toComponent(signText[i]);
|
|
signText[i] = "<JSON>"; // comp.getFormattedText();
|
|
newComp++;
|
|
}
|
|
catch(Throwable e) {
|
|
}
|
|
}
|
|
else if(signText[i].startsWith("\"") && signText[i].endsWith("\"")) {
|
|
newComp++;
|
|
quotes |= 1 << i;
|
|
}
|
|
}
|
|
for(int i = 0; i < 4; ++i) {
|
|
if(newComp == 4 && (quotes & (1 << i)) != 0) {
|
|
signText[i] = signText[i].substring(1, signText[i].length() - 1);
|
|
}
|
|
// if(old[i] != signText[i]) {
|
|
// Log.debug("Zeile " + (i + 1) + ": '" + TextColor.stripCodes(signText[i]) + "'");
|
|
// }
|
|
}
|
|
for(int i = 0; i < 4; ++i) {
|
|
ent.setString("Text" + (i + 1), signText[i]);
|
|
}
|
|
}
|
|
}
|
|
|
|
private static int getNibble(byte[] data, int x, int y, int z) {
|
|
int off = x << 11 | z << 7 | y;
|
|
return (off & 1) == 0 ? data[off >> 1] & 15 : data[off >> 1] >> 4 & 15;
|
|
}
|
|
|
|
private static String trimColon(String name) {
|
|
int idx = name.indexOf(':');
|
|
return idx >= 0 ? name.substring(idx + 1) : name; // save compat
|
|
}
|
|
|
|
private static NBTTagCompound convertChunkData(NBTTagCompound tag, boolean legacy) {
|
|
tag = tag.getCompoundTag("Level");
|
|
if(legacy) {
|
|
if(tag.hasKey("LastUpdate", 3))
|
|
tag.setLong("LastUpdate", (long)tag.getInteger("LastUpdate"));
|
|
byte[] oldheight = tag.getByteArray("HeightMap");
|
|
int[] height = new int[oldheight.length];
|
|
for(int i = 0; i < oldheight.length; ++i) {
|
|
height[i] = oldheight[i];
|
|
}
|
|
tag.setIntArray("HeightMap", height);
|
|
byte[] oldblks = tag.getByteArray("Blocks");
|
|
byte[] olddata = tag.getByteArray("Data");
|
|
byte[] oldsky = tag.getByteArray("SkyLight");
|
|
byte[] oldlight = tag.getByteArray("BlockLight");
|
|
NBTTagList sections = new NBTTagList();
|
|
for(int n = 0; n < 8; ++n) {
|
|
boolean empty = true;
|
|
for(int x = 0; x < 16 && empty; ++x) {
|
|
for(int y = 0; y < 16 && empty; ++y) {
|
|
for(int z = 0; z < 16; ++z) {
|
|
int pos = x << 11 | z << 7 | y + (n << 4);
|
|
int blk = oldblks[pos];
|
|
if(blk != 0) {
|
|
empty = false;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if(!empty) {
|
|
byte[] blocks = new byte[4096];
|
|
NibbleArray data = new NibbleArray();
|
|
NibbleArray sky = new NibbleArray();
|
|
NibbleArray light = new NibbleArray();
|
|
for(int x = 0; x < 16; ++x) {
|
|
for(int y = 0; y < 16; ++y) {
|
|
for(int z = 0; z < 16; ++z) {
|
|
int pos = x << 11 | z << 7 | y + (n << 4);
|
|
int blk = oldblks[pos];
|
|
blocks[y << 8 | z << 4 | x] = (byte)(blk & 255);
|
|
data.set(x, y, z, getNibble(olddata, x, y + (n << 4), z));
|
|
sky.set(x, y, z, getNibble(oldsky, x, y + (n << 4), z));
|
|
light.set(x, y, z, getNibble(oldlight, x, y + (n << 4), z));
|
|
}
|
|
}
|
|
}
|
|
NBTTagCompound section = new NBTTagCompound();
|
|
section.setByte("Y", (byte)(n & 255));
|
|
section.setByteArray("Blocks", blocks);
|
|
section.setByteArray("Data", data.getData());
|
|
section.setByteArray("SkyLight", sky.getData());
|
|
section.setByteArray("BlockLight", light.getData());
|
|
sections.appendTag(section);
|
|
}
|
|
}
|
|
tag.setTag("Sections", sections);
|
|
byte[] biomes = new byte[256];
|
|
Arrays.fill(biomes, (byte)(Biome.DEF_BIOME.id & 255));
|
|
tag.setByteArray("Biomes", biomes);
|
|
}
|
|
NBTTagList ents = tag.getTagList("Entities", 10);
|
|
NBTTagList entities = new NBTTagList();
|
|
for(int z = 0; z < ents.tagCount(); z++) {
|
|
NBTTagCompound ent = ents.getCompoundTagAt(z);
|
|
String mapped = ENTITY_MAP.get(trimColon(ent.getString("id")));
|
|
if(mapped != null) {
|
|
NBTTagList pos = ent.getTagList("Pos", 6);
|
|
NBTTagList motion = ent.getTagList("Motion", 6);
|
|
NBTTagList rotation = ent.getTagList("Rotation", 5);
|
|
boolean ground = ent.getBoolean("OnGround");
|
|
ent.getKeySet().clear();
|
|
ent.setTag("Pos", pos);
|
|
ent.setTag("Motion", motion);
|
|
ent.setTag("Rotation", rotation);
|
|
ent.setBoolean("OnGround", ground);
|
|
ent.setInteger("Dimension", 1);
|
|
ent.setString("id", mapped);
|
|
entities.appendTag(ent);
|
|
}
|
|
}
|
|
tag.setTag("Entities", entities);
|
|
|
|
ents = tag.getTagList("TileEntities", 10);
|
|
entities = new NBTTagList();
|
|
for(int z = 0; z < ents.tagCount(); z++) {
|
|
NBTTagCompound ent = ents.getCompoundTagAt(z);
|
|
String mapped = TILE_MAP.get(trimColon(ent.getString("id")));
|
|
if(mapped != null) {
|
|
ent.setString("id", mapped);
|
|
convertTile(ent);
|
|
entities.appendTag(ent);
|
|
}
|
|
}
|
|
tag.setTag("TileEntities", entities);
|
|
|
|
tag.removeTag("TileTicks");
|
|
|
|
NBTTagList sects = tag.getTagList("Sections", 10);
|
|
for(int n = 0; n < sects.tagCount(); ++n) {
|
|
NBTTagCompound sect = sects.getCompoundTagAt(n);
|
|
byte[] blocks = sect.getByteArray("Blocks");
|
|
NibbleArray data = new NibbleArray(sect.getByteArray("Data"));
|
|
NibbleArray adddata = sect.hasKey("Add", 7) ? new NibbleArray(sect.getByteArray("Add")) : null;
|
|
for(int c = 0; c < blocks.length; ++c) {
|
|
int cx = c & 15;
|
|
int cy = c >> 8 & 15;
|
|
int cz = c >> 4 & 15;
|
|
int ca = adddata != null ? adddata.get(cx, cy, cz) : 0;
|
|
char block = (char)((ca << 8) | (blocks[c] & 255));
|
|
// if(block == 0)
|
|
// continue;
|
|
//// else if(block <= 197) {
|
|
//// if((blocks[c] = BLOCK_MAP[block]) != (byte)block)
|
|
//// data.set(cx, cy, cz, DATA_MAP[block]);
|
|
//// }
|
|
if(block >= 256) {
|
|
blocks[c] = (byte)1;
|
|
data.set(cx, cy, cz, 0);
|
|
}
|
|
else if(block > 0) {
|
|
int dt = block == 111 ? RANDOM.zrange(4) : data.get(cx, cy, cz);
|
|
char cd = BLOCK_MAP[(block << 4) | dt];
|
|
// if(cd == (char)0x000f)
|
|
// cd = (char)BlockRegistry.STATEMAP.get(BLOCK_FUNCS.get((char)((block << 4) | dt)).getState(block, dt));
|
|
if(cd >> 12 != 0) {
|
|
if(adddata == null)
|
|
adddata = new NibbleArray();
|
|
adddata.set(cx, cy, cz, cd >> 12);
|
|
}
|
|
blocks[c] = (byte)(cd >> 4 & 255);
|
|
data.set(cx, cy, cz, cd & 15);
|
|
}
|
|
}
|
|
sect.setByteArray("Blocks", blocks);
|
|
sect.setByteArray("Data", data.getData());
|
|
if(adddata != null)
|
|
sect.setByteArray("Add", adddata.getData());
|
|
}
|
|
return tag;
|
|
}
|
|
|
|
private long convertChunks(File dir, File file, long start, int progress, int total) {
|
|
String name = file.getName();
|
|
this.file = name;
|
|
this.totalChunks = 1024;
|
|
boolean legacy = name.endsWith(".mcr");
|
|
int rx, rz;
|
|
String[] reg = name.split("\\.");
|
|
if(reg.length != 4) {
|
|
Log.JNI.warn("Unbekannte Region " + file);
|
|
this.doneChunks = 0;
|
|
this.file = null;
|
|
return start;
|
|
}
|
|
try {
|
|
rx = Integer.parseInt(reg[1]);
|
|
rz = Integer.parseInt(reg[2]);
|
|
}
|
|
catch(NumberFormatException e) {
|
|
Log.JNI.warn("Unbekannte Region " + file);
|
|
this.doneChunks = 0;
|
|
this.file = null;
|
|
return start;
|
|
}
|
|
try {
|
|
File sdir;
|
|
File dest;
|
|
int areas = 0;
|
|
int chunks = 0;
|
|
AnvilRegion oldreg = new AnvilRegion(file);
|
|
Region newreg;
|
|
for(int bx = 0; bx < 4; bx++) {
|
|
for(int bz = 0; bz < 4; bz++) {
|
|
if(!oldreg.hasRegion(bx, bz)) {
|
|
this.doneChunks += 64;
|
|
continue;
|
|
}
|
|
areas++;
|
|
newreg = new Region(dir, rx * 4 + bx, rz * 4 + bz);
|
|
Log.JNI.info("Konvertiere " + file + " zu " + newreg.getFile() + " ...");
|
|
for(int nx = 0; nx < 8; nx++) {
|
|
for(int nz = 0; nz < 8; nz++) {
|
|
int x = bx << 3 | nx;
|
|
int z = bz << 3 | nz;
|
|
if(oldreg.hasChunk(x, z) && newreg.getTimestamp(nx, nz) == 0L) {
|
|
chunks++;
|
|
DataInputStream in = oldreg.getInputStream(x, z);
|
|
if(in == null) {
|
|
Log.JNI.warn("Konnte " + file.getPath() + "@" + x + "," + z + " nicht lesen");
|
|
this.doneChunks += 1;
|
|
continue;
|
|
}
|
|
NBTTagCompound tag = NBTLoader.read(in);
|
|
in.close();
|
|
tag = convertChunkData(tag, legacy);
|
|
// DataOutputStream out = newreg.getOutputStream(nx, nz);
|
|
// CompressedStreamTools.write(tag, out);
|
|
// out.close();
|
|
newreg.writeTag(nx, nz, tag);
|
|
}
|
|
this.doneChunks += 1;
|
|
}
|
|
}
|
|
newreg.close(false);
|
|
int prev = (int)Math.round(100.0D * (double)(progress * 1024) / (double)(total * 1024));
|
|
int percent = (int)Math.round(100.0D * (double)(((bx * 4 + bz) * 2 + 1) * 32 + progress * 1024) / (double)(total * 1024));
|
|
if(percent > prev) {
|
|
start = postProgress(start, percent);
|
|
}
|
|
// this.doneChunks += 1;
|
|
}
|
|
}
|
|
oldreg.close();
|
|
Log.JNI.info(file + ": " + areas + " Regionen, " + chunks + " Chunks");
|
|
}
|
|
catch(IOException e) {
|
|
e.printStackTrace();
|
|
}
|
|
this.doneChunks = 0;
|
|
this.file = null;
|
|
return start;
|
|
}
|
|
|
|
public static FolderInfo convertMapFormat(File dir, String user) {
|
|
long cur = System.currentTimeMillis();
|
|
if(user != null)
|
|
Log.JNI.info("Welt '" + dir + "' wird konvertiert");
|
|
if(new File(dir, "level.nbt").exists()) {
|
|
if(user != null)
|
|
Log.JNI.error("Datei level.nbt existiert bereits");
|
|
return null;
|
|
}
|
|
File ldat = new File(dir, "level.dat");
|
|
if(!ldat.exists())
|
|
ldat = new File(dir, "level.dat_old");
|
|
if(!ldat.exists()) {
|
|
if(user != null)
|
|
Log.JNI.error("Datei level.dat und level.dat_old nicht gefunden");
|
|
return null;
|
|
}
|
|
NBTTagCompound nbt;
|
|
try {
|
|
nbt = NBTLoader.readGZip(ldat);
|
|
}
|
|
catch(Exception e) {
|
|
if(user != null)
|
|
Log.JNI.error(e, "Fehler beim Lesen von level.dat");
|
|
return null;
|
|
}
|
|
nbt = nbt.getCompoundTag("Data");
|
|
int version = nbt.getInteger("version");
|
|
int data = nbt.getInteger("DataVersion");
|
|
// nbt.setBoolean("incompatible", data >= 1400);
|
|
SaveVersion ver = data >= 1400 ? SaveVersion.RELEASE_1_13 : (data >= 100 ? SaveVersion.RELEASE_1_9 : (version == 19132 || version == 19133 ? SaveVersion.BETA_1_3 : (version == 0 ? SaveVersion.ALPHA_1_0 : null)));
|
|
if(ver == null) {
|
|
if(user != null)
|
|
Log.IO.error("Version %d ist unbekannt", version);
|
|
return null;
|
|
}
|
|
long wtime = nbt.getLong(nbt.hasKey("DayTime", 99) ? "DayTime" : "Time") + World.START_TIME;
|
|
if(user == null)
|
|
return new FolderInfo(wtime, null, nbt.getLong("LastPlayed"), ver, null);
|
|
// nbt.setString("verdesc", ver);
|
|
// NBTTagCompound nbt = getLegacyWorldInfo(dir);
|
|
// if(nbt == null)
|
|
// return false;
|
|
final Converter conv = new Converter();
|
|
Game.getGame().displayGuiScreen(new GuiLoading("Konvertiere Welt ...", new Callback() {
|
|
public void poll(Game gm, GuiLoading gui) {
|
|
if(conv.totalRegions > 0) {
|
|
gui.setBar(conv.task, "Regionen", conv.totalRegions);
|
|
gui.setProgress(conv.doneRegions);
|
|
}
|
|
else {
|
|
gui.resetBar();
|
|
}
|
|
if(conv.totalChunks > 0) {
|
|
gui.setSub(conv.file, "Chunks", conv.totalChunks);
|
|
gui.setSubProgress(conv.doneChunks);
|
|
}
|
|
else {
|
|
gui.resetSub();
|
|
}
|
|
gui.setTask(conv.action);
|
|
}
|
|
}));
|
|
final NBTTagCompound tag = nbt;
|
|
new Thread(new Runnable() {
|
|
public void run() {
|
|
Log.IO.info("Version: %s", ver);
|
|
if(ver != SaveVersion.RELEASE_1_13) {
|
|
conv.action = "Suche nach Chunk-Daten";
|
|
Log.JNI.info("Konvertiere Chunk-Daten von region/*.mca,*.mcr");
|
|
File regionDir = new File(dir, "region");
|
|
if(regionDir.exists()) {
|
|
File chunkDir = new File(new File(dir, "chunk"), "terra");
|
|
Log.JNI.info("Konvertiere Welt nach '" + chunkDir + "' ...");
|
|
Log.JNI.info("Durchsuche Ordner unter '" + regionDir + "' nach .mca- und .mcr-Dateien ...");
|
|
File[] files = regionDir.listFiles(new FilenameFilter() {
|
|
public boolean accept(File file, String name) {
|
|
return name.endsWith(".mca") || name.endsWith(".mcr");
|
|
}
|
|
});
|
|
if(files.length == 0) {
|
|
Log.JNI.info("Keine .mca- oder .mcr-Dateien gefunden.");
|
|
}
|
|
else {
|
|
conv.task = "Konvertiere Chunkdaten";
|
|
conv.totalRegions = files.length;
|
|
Log.JNI.info("Ingesamt wurden " + files.length + " .mca-Dateien und .mcr-Dateien gefunden, konvertiere ...");
|
|
if(ver == SaveVersion.RELEASE_1_9)
|
|
Log.JNI.info("Konvertiere von neuerer Version, dies wird Blöcke entfernen ...");
|
|
chunkDir.mkdirs();
|
|
int progress = 0;
|
|
long time = System.currentTimeMillis();
|
|
long start = conv.postProgress(time, 0);
|
|
for(File file : files) {
|
|
int percent = (int)Math.round(100.0D * (double)progress / (double)files.length);
|
|
Log.JNI.info("Konvertiere Chunk-Daten: " + file.getName() + " (" + progress + "/" + files.length + ")");
|
|
start = conv.convertChunks(chunkDir, file, start, progress, files.length);
|
|
++progress;
|
|
start = conv.postProgress(start, percent);
|
|
conv.doneRegions += 1;
|
|
}
|
|
time = System.currentTimeMillis() - time;
|
|
Log.JNI.info("Fertig. Konversion dauerte " + ((time / 60000L) > 0 ? ((time / 60000L) + " Minuten und ") : "") + ((time / 1000L) % 60L) + " Sekunden.");
|
|
}
|
|
}
|
|
}
|
|
else {
|
|
Log.JNI.warn("Konvertiere keine Chunk-Daten, da Version zu neu");
|
|
}
|
|
conv.doneRegions = 0;
|
|
conv.task = null;
|
|
conv.action = "Konvertiere level.dat";
|
|
Log.JNI.info("Konvertiere Daten von level.dat");
|
|
Config.clear();
|
|
UniverseRegistry.clear();
|
|
if(tag.hasKey("GameRules", 10)) {
|
|
NBTTagCompound rules = tag.getCompoundTag("GameRules");
|
|
for(Entry<String, String> rule : OLD_GAMERULES.entrySet()) {
|
|
if(rules.hasKey(rule.getKey(), 8))
|
|
Config.set(rule.getValue(), rules.getString(rule.getKey()), null);
|
|
}
|
|
}
|
|
// Config.setVar("noRespawn", "" + nbt.getBoolean("hardcore"), false);
|
|
// int id = nbt.getInteger("GameType");
|
|
// Config.set("defaultNoCreative", "" + (id == 2 || id == 0), false);
|
|
Config.set("spawnX", "" + tag.getInteger("SpawnX"), null);
|
|
Config.set("spawnY", "" + tag.getInteger("SpawnY"), null);
|
|
Config.set("spawnZ", "" + tag.getInteger("SpawnZ"), null);
|
|
Config.set("spawnDim", "" + 1, null);
|
|
Log.JNI.info("Speichere neue level.nbt ...");
|
|
Region.saveWorldInfo(dir, wtime, user);
|
|
if(tag.hasKey("Player", 10)) {
|
|
conv.action = "Konvertiere Spielerdaten";
|
|
NBTTagCompound player = tag.getCompoundTag("Player");
|
|
NBTTagList pos = player.getTagList("Pos", 6);
|
|
NBTTagList motion = player.getTagList("Motion", 6);
|
|
NBTTagList rotation = player.getTagList("Rotation", 5);
|
|
boolean ground = player.getBoolean("OnGround");
|
|
BlockPos spawn = null;
|
|
// boolean force = player.getBoolean("OnGround");
|
|
// int mode = -1;
|
|
// if(player.hasKey("playerGameType", 99)) {
|
|
// mode = player.getInteger("playerGameType");
|
|
// mode = mode == 0 || mode == 2 ? 0 : (mode == 1 || mode == 3 ? 1 : -1);
|
|
// }
|
|
if(player.hasKey("SpawnX", 99) && player.hasKey("SpawnY", 99) && player.hasKey("SpawnZ", 99)) {
|
|
spawn = new BlockPos(player.getInteger("SpawnX"), player.getInteger("SpawnY"),
|
|
player.getInteger("SpawnZ"));
|
|
// force = player.getBoolean("SpawnForced");
|
|
}
|
|
player.getKeySet().clear();
|
|
player.setTag("Pos", pos);
|
|
player.setTag("Motion", motion);
|
|
player.setTag("Rotation", rotation);
|
|
player.setBoolean("OnGround", ground);
|
|
player.setInteger("Dimension", 1);
|
|
player.setString("id", EntityRegistry.getEntityString(EntityHuman.class));
|
|
if(spawn != null) {
|
|
player.setInteger("SpawnX", spawn.getX());
|
|
player.setInteger("SpawnY", spawn.getY());
|
|
player.setInteger("SpawnZ", spawn.getZ());
|
|
player.setInteger("SpawnDim", 1);
|
|
// player.setBoolean("SpawnForced", force);
|
|
}
|
|
// if(mode >= 0)
|
|
// player.setBoolean("creative", mode == 1);
|
|
Log.JNI.info("Speichere neue Spielerdaten " + user.toLowerCase() + ".nbt ...");
|
|
File pdat = new File(new File(dir, "players"), user.toLowerCase() + ".nbt");
|
|
try {
|
|
pdat.getParentFile().mkdirs();
|
|
NBTLoader.writeGZip(player, pdat);
|
|
}
|
|
catch(Exception e) {
|
|
Log.JNI.error(e, "Fehler beim Schreiben von " + pdat);
|
|
}
|
|
}
|
|
Weather weather = tag.getBoolean("thundering") ? Weather.THUNDER : (tag.getBoolean("raining") ? Weather.RAIN : Weather.CLEAR);
|
|
if(weather != Weather.CLEAR) {
|
|
conv.action = "Konvertiere Dimensionsdaten";
|
|
NBTTagCompound dataTag = new NBTTagCompound();
|
|
dataTag.setString("Weather", weather.getName());
|
|
Log.JNI.info("Speichere neue data.nbt ...");
|
|
File dataFile = new File(new File(new File(dir, "chunk"), "terra"), "data.nbt");
|
|
try {
|
|
NBTLoader.writeGZip(dataTag, dataFile);
|
|
}
|
|
catch(Exception e) {
|
|
Log.JNI.error(e, "Konnte Weltdaten nicht speichern");
|
|
}
|
|
}
|
|
Log.IO.info("Welt '" + dir + "' wurde in %d Sekunden konvertiert", (System.currentTimeMillis() - cur) / 1000L);
|
|
Game.getGame().schedule(new Runnable() {
|
|
public void run() {
|
|
Game.getGame().displayGuiScreen(GuiWorlds.INSTANCE);
|
|
}
|
|
});
|
|
}
|
|
}, "Converter Thread").start();
|
|
return new FolderInfo(wtime, user, System.currentTimeMillis(), null, Config.VERSION);
|
|
}
|
|
|
|
// public static NBTTagCompound getLegacyWorldInfo(File worldDir) {
|
|
// return nbt;
|
|
// }
|
|
}
|