Bring back shapegen, this time as command line tool, update blackhole model
This commit is contained in:
parent
55af4149ff
commit
f3600b1f8f
2
.gitignore
vendored
2
.gitignore
vendored
@ -29,3 +29,5 @@ logs/
|
||||
|
||||
# Files from Forge MDK
|
||||
forge*changelog.txt
|
||||
|
||||
shapegen_output.java
|
||||
|
60
shapegen.js
Normal file
60
shapegen.js
Normal file
@ -0,0 +1,60 @@
|
||||
|
||||
// генерирует код для форм блоков из json моделей
|
||||
|
||||
const fs = require('fs')
|
||||
const root_main = './src/main/resources/assets/overdrive_that_matters/models/block/'
|
||||
const root_datagen = './src/data/resources/assets/overdrive_that_matters/models/block/'
|
||||
|
||||
const handle = fs.openSync('./shapegen_output.java', 'w')
|
||||
const args = process.argv.slice(2)
|
||||
|
||||
if (args.length == 0) {
|
||||
console.error('No model(s) names specified.')
|
||||
process.exit(2)
|
||||
}
|
||||
|
||||
for (const model of args) {
|
||||
fs.writeSync(handle, 'public static final BlockShape ' + model.toUpperCase() + ' = new BlockShape(\n')
|
||||
|
||||
let readData
|
||||
|
||||
try {
|
||||
readData = fs.readFileSync(root_main + model + '.json', {encoding: 'utf-8'})
|
||||
} catch(err1) {
|
||||
try {
|
||||
readData = fs.readFileSync(root_datagen + model + '.json', {encoding: 'utf-8'})
|
||||
} catch(err2) {
|
||||
console.error('Unable to read model file in either of locations')
|
||||
console.error(err1)
|
||||
console.error(err2)
|
||||
process.exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
const obj = JSON.parse(readData)
|
||||
let first = true
|
||||
|
||||
for (const elementID in obj.elements) {
|
||||
const element = obj.elements[elementID]
|
||||
|
||||
if (element.rotation)
|
||||
continue;
|
||||
|
||||
const from = element.from
|
||||
const to = element.to
|
||||
|
||||
if (first) {
|
||||
first = false
|
||||
} else {
|
||||
fs.writeSync(handle, ',\n')
|
||||
}
|
||||
|
||||
fs.writeSync(handle, `\tnew SimpleCuboid(${from[0] / 16}d, ${from[1] / 16}d, ${from[2] / 16}d, ${to[0] / 16}d, ${to[1] / 16}d, ${to[2] / 16}d)`)
|
||||
}
|
||||
|
||||
console.log(`Parsed and generated shape of ${model}.json`)
|
||||
|
||||
fs.writeSync(handle, '\n);\n\n')
|
||||
}
|
||||
|
||||
fs.closeSync(handle)
|
@ -1,7 +1,5 @@
|
||||
package ru.dbotthepony.mc.otm.shapes;
|
||||
|
||||
|
||||
// This file is regenerated on each gradle run. Do not edit it!
|
||||
public class BlockShapes {
|
||||
public static final BlockShape ANDROID_STATION = new BlockShape(
|
||||
new SimpleCuboid(0d, 0.4375d, 0d, 1d, 0.5625d, 1d),
|
||||
@ -30,39 +28,13 @@ public class BlockShapes {
|
||||
);
|
||||
|
||||
public static final BlockShape BLACK_HOLE = new BlockShape(
|
||||
new SimpleCuboid(0.5d, 0.46875d, 0.5d, 0.515625d, 0.484375d, 0.515625d),
|
||||
new SimpleCuboid(0.484375d, 0.484375d, 0.484375d, 0.5d, 0.5d, 0.5d),
|
||||
new SimpleCuboid(0.484375d, 0.484375d, 0.5d, 0.5d, 0.5d, 0.515625d),
|
||||
new SimpleCuboid(0.484375d, 0.484375d, 0.515625d, 0.5d, 0.5d, 0.53125d),
|
||||
new SimpleCuboid(0.5d, 0.484375d, 0.484375d, 0.515625d, 0.5d, 0.5d),
|
||||
new SimpleCuboid(0.5d, 0.484375d, 0.5d, 0.515625d, 0.5d, 0.515625d),
|
||||
new SimpleCuboid(0.5d, 0.484375d, 0.515625d, 0.515625d, 0.5d, 0.53125d),
|
||||
new SimpleCuboid(0.515625d, 0.484375d, 0.484375d, 0.53125d, 0.5d, 0.5d),
|
||||
new SimpleCuboid(0.515625d, 0.484375d, 0.5d, 0.53125d, 0.5d, 0.515625d),
|
||||
new SimpleCuboid(0.515625d, 0.484375d, 0.515625d, 0.53125d, 0.5d, 0.53125d),
|
||||
new SimpleCuboid(0.46875d, 0.5d, 0.5d, 0.484375d, 0.515625d, 0.515625d),
|
||||
new SimpleCuboid(0.484375d, 0.5d, 0.484375d, 0.5d, 0.515625d, 0.5d),
|
||||
new SimpleCuboid(0.484375d, 0.5d, 0.5d, 0.5d, 0.515625d, 0.515625d),
|
||||
new SimpleCuboid(0.484375d, 0.5d, 0.515625d, 0.5d, 0.515625d, 0.53125d),
|
||||
new SimpleCuboid(0.5d, 0.5d, 0.46875d, 0.515625d, 0.515625d, 0.484375d),
|
||||
new SimpleCuboid(0.5d, 0.5d, 0.484375d, 0.515625d, 0.515625d, 0.5d),
|
||||
new SimpleCuboid(0.5d, 0.5d, 0.5d, 0.515625d, 0.515625d, 0.515625d),
|
||||
new SimpleCuboid(0.5d, 0.5d, 0.515625d, 0.515625d, 0.515625d, 0.53125d),
|
||||
new SimpleCuboid(0.5d, 0.5d, 0.53125d, 0.515625d, 0.515625d, 0.546875d),
|
||||
new SimpleCuboid(0.515625d, 0.5d, 0.484375d, 0.53125d, 0.515625d, 0.5d),
|
||||
new SimpleCuboid(0.515625d, 0.5d, 0.5d, 0.53125d, 0.515625d, 0.515625d),
|
||||
new SimpleCuboid(0.515625d, 0.5d, 0.515625d, 0.53125d, 0.515625d, 0.53125d),
|
||||
new SimpleCuboid(0.53125d, 0.5d, 0.5d, 0.546875d, 0.515625d, 0.515625d),
|
||||
new SimpleCuboid(0.484375d, 0.515625d, 0.484375d, 0.5d, 0.53125d, 0.5d),
|
||||
new SimpleCuboid(0.484375d, 0.515625d, 0.5d, 0.5d, 0.53125d, 0.515625d),
|
||||
new SimpleCuboid(0.484375d, 0.515625d, 0.515625d, 0.5d, 0.53125d, 0.53125d),
|
||||
new SimpleCuboid(0.5d, 0.515625d, 0.484375d, 0.515625d, 0.53125d, 0.5d),
|
||||
new SimpleCuboid(0.5d, 0.515625d, 0.5d, 0.515625d, 0.53125d, 0.515625d),
|
||||
new SimpleCuboid(0.5d, 0.515625d, 0.515625d, 0.515625d, 0.53125d, 0.53125d),
|
||||
new SimpleCuboid(0.515625d, 0.515625d, 0.484375d, 0.53125d, 0.53125d, 0.5d),
|
||||
new SimpleCuboid(0.515625d, 0.515625d, 0.5d, 0.53125d, 0.53125d, 0.515625d),
|
||||
new SimpleCuboid(0.515625d, 0.515625d, 0.515625d, 0.53125d, 0.53125d, 0.53125d),
|
||||
new SimpleCuboid(0.5d, 0.53125d, 0.5d, 0.515625d, 0.546875d, 0.515625d)
|
||||
new SimpleCuboid(0.4375d, 0.4375d, 0.375d, 0.625d, 0.625d, 0.5625d),
|
||||
new SimpleCuboid(0.5d, 0.5d, 0.3125d, 0.5625d, 0.5625d, 0.375d),
|
||||
new SimpleCuboid(0.625d, 0.5d, 0.4375d, 0.6875d, 0.5625d, 0.5d),
|
||||
new SimpleCuboid(0.5d, 0.5d, 0.5625d, 0.5625d, 0.5625d, 0.625d),
|
||||
new SimpleCuboid(0.375d, 0.5d, 0.4375d, 0.4375d, 0.5625d, 0.5d),
|
||||
new SimpleCuboid(0.5d, 0.625d, 0.4375d, 0.5625d, 0.6875d, 0.5d),
|
||||
new SimpleCuboid(0.5d, 0.375d, 0.4375d, 0.5625d, 0.4375d, 0.5d)
|
||||
);
|
||||
|
||||
public static final BlockShape MATTER_SCANNER = new BlockShape(
|
||||
@ -197,5 +169,4 @@ public class BlockShapes {
|
||||
new SimpleCuboid(0.875d, 0.125d, 0.8125d, 0.9375d, 0.875d, 0.9375d),
|
||||
new SimpleCuboid(0.875d, 0.125d, 0.5d, 0.9375d, 0.875d, 0.625d)
|
||||
);
|
||||
|
||||
}
|
@ -95,5 +95,5 @@
|
||||
"down": {"uv": [3, 1, 2, 2], "texture": "#black_hole"}
|
||||
}
|
||||
}
|
||||
],
|
||||
]
|
||||
}
|
Loading…
Reference in New Issue
Block a user