Skip to content

Commit

Permalink
complete Block translation + version checking of definition files
Browse files Browse the repository at this point in the history
+ completet translation of all Block IDs up to 1.12.2
+ add version compare of internal stored definition to force an overwrite
  • Loading branch information
EtlamGit committed Aug 11, 2018
1 parent 8b69321 commit 9e2107b
Show file tree
Hide file tree
Showing 3 changed files with 131 additions and 6 deletions.
26 changes: 25 additions & 1 deletion definitionmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ DefinitionManager::DefinitionManager(QWidget *parent) :
table->setHorizontalHeaderLabels(labels);
table->horizontalHeader()->setSectionResizeMode(
QHeaderView::ResizeToContents);
table->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch);
table->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
table->horizontalHeader()->setHighlightSections(false);
table->verticalHeader()->hide();
table->setShowGrid(false);
Expand Down Expand Up @@ -229,8 +229,32 @@ void DefinitionManager::installJson(QString path, bool overwrite,
}

QString key = def->at("name")->asString() + def->at("type")->asString();
QString exeversion = def->at("version")->asString();
delete def;
QString dest = destdir + "/" + QString("%1").arg(qHash(key)) + ".json";

// check if build in version is newer than version on disk
if (QFile::exists(dest)) {
QFile f(dest);
f.open(QIODevice::ReadOnly);
try {
def = JSON::parse(f.readAll());
f.close();
} catch (JSONParseException e) {
f.close();
return;
}
QString fileversion = def->at("version")->asString();
delete def;
if (exeversion.compare(fileversion, Qt::CaseInsensitive) > 0) {
// force overwriting outdated local copy
QFile::remove(dest);
QFile::copy(path, dest);
QFile::setPermissions(dest, QFile::ReadOwner|QFile::WriteOwner);
}
}

// import new definition (if file is not present)
if (!QFile::exists(dest) || overwrite) {
if (QFile::exists(dest) && install)
removeDefinition(dest);
Expand Down
95 changes: 94 additions & 1 deletion definitions/vanilla_blocks.json
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,30 @@
"name": "minecraft:dark_oak_wood",
"color": "#5d4931"
},
{
"name": "minecraft:stripped_oak_log",
"color": "#665130"
},
{
"name": "minecraft:stripped_spruce_log",
"color": "#2e1d0a"
},
{
"name": "minecraft:stripped_birch_log",
"color": "#d6dad6"
},
{
"name": "minecraft:stripped_jungle_log",
"color": "#584219"
},
{
"name": "minecraft:stripped_acacia_log",
"color": "#b25b3b"
},
{
"name": "minecraft:stripped_dark_oak_log",
"color": "#5d4931"
},
{
"name": "minecraft:stripped_oak_wood",
"color": "#665130"
Expand Down Expand Up @@ -1266,6 +1290,11 @@
"color": "#505050",
"transparent": true
},
{
"name": "minecraft:mossy_cobblestone_wall",
"color": "#508050",
"transparent": true
},
{
"name": "minecraft:flower_pot",
"color": "#7c4536",
Expand Down Expand Up @@ -1371,7 +1400,67 @@
"canprovidepower": true
},
{
"name": "minecraft:skull",
"name": "minecraft:mob_head",
"color": "#1a1a1a",
"transparent": true
},
{
"name": "minecraft:skeleton_skull",
"color": "#1a1a1a",
"transparent": true
},
{
"name": "minecraft:skeleton_wall_skull",
"color": "#1a1a1a",
"transparent": true
},
{
"name": "minecraft:wither_skeleton_skull",
"color": "#1a1a1a",
"transparent": true
},
{
"name": "minecraft:wither_skeleton_wall_skull",
"color": "#1a1a1a",
"transparent": true
},
{
"name": "minecraft:zombie_head",
"color": "#1a1a1a",
"transparent": true
},
{
"name": "minecraft:zombie_wall_head",
"color": "#1a1a1a",
"transparent": true
},
{
"name": "minecraft:player_head",
"color": "#1a1a1a",
"transparent": true
},
{
"name": "minecraft:player_wall_head",
"color": "#1a1a1a",
"transparent": true
},
{
"name": "minecraft:creeper_head",
"color": "#1a1a1a",
"transparent": true
},
{
"name": "minecraft:creeper_wall_head",
"color": "#1a1a1a",
"transparent": true
},
{
"name": "minecraft:dragon_head",
"color": "#1a1a1a",
"transparent": true
},
{
"name": "minecraft:dragon_wall_head",
"color": "#1a1a1a",
"transparent": true
},
Expand Down Expand Up @@ -1449,6 +1538,10 @@
"name": "minecraft:quartz_pillar",
"color": "#e1dcd3"
},
{
"name": "minecraft:smooth_quartz",
"color": "#edebe5"
},
{
"name": "minecraft:quartz_stairs",
"color": "#dfdacf",
Expand Down
16 changes: 12 additions & 4 deletions definitions/vanilla_ids.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "Vanilla Flattening Converter",
"name": "Vanilla",
"type": "block",
"version": "1.12.17w13a",
"version": "1.12.18w32",
"data": [
{
"id": 0,
Expand Down Expand Up @@ -159,6 +159,7 @@
{
"id": 8,
"name": "Water (flowing)",
"flatname": "minecraft:flowing_water",
"color": "#1f55ff",
"alpha": 0.53,
"transparent": true,
Expand All @@ -175,6 +176,7 @@
{
"id": 10,
"name": "Lava (flowing)",
"flatname": "minecraft:flowing_lava",
"color": "#fc5700",
"transparent": true,
"liquid": true
Expand Down Expand Up @@ -628,7 +630,7 @@
{
"data": 7,
"name": "Double Quartz Slab",
"flatname": "minecraft:quartz_slab",
"flatname": "minecraft:smooth_quartz",
"color": "#f0eee8"
},
{
Expand Down Expand Up @@ -659,7 +661,7 @@
{
"data": 2,
"name": "Wooden Slab",
"flatname": "minecraft:oak_slab",
"flatname": "minecraft:oak_slab",
"color": "#b4905a"
},
{
Expand Down Expand Up @@ -1929,26 +1931,31 @@
{
"id": 155,
"name": "Quartz Block",
"flatname": "minecraft:quartz_block",
"color": "#edebe5",
"variants": [
{
"data": 1,
"name": "Chiseled Quartz Block",
"flatname": "minecraft:chiseled_quartz_block",
"color": "#e3dfd5"
},
{
"data": 2,
"name": "Pillar Quartz Block",
"flatname": "minecraft:quartz_pillar",
"color": "#e1dcd3"
},
{
"data": 3,
"name": "Pillar Quartz Block",
"flatname": "minecraft:quartz_pillar",
"color": "#e1dcd3"
},
{
"data": 4,
"name": "Pillar Quartz Block",
"flatname": "minecraft:quartz_pillar",
"color": "#e1dcd3"
}
]
Expand Down Expand Up @@ -2630,6 +2637,7 @@
{
"id": 209,
"name": "End Gateway Block",
"flatname": "minecraft:end_gateway",
"color": "#000000"
},
{
Expand Down

0 comments on commit 9e2107b

Please sign in to comment.