Page 1 of 1

Help with JSON files

Posted: Wed May 20, 2015 5:09 pm
by meloetta_344
So I have been working on my resource pack recently, and I found a way to give blocks different images for their different sides even if those blocks don't naturally have multi textured sides! My first block to have it is the Command Block:
Spoiler:
Code: Select all
{
    "parent": "block/cube",
    "textures": {
        "particle": "blocks/command_block",
        "down": "blocks/command_block",
        "up": "cp/command_block_top",
        "north": "blocks/command_block",
        "east": "blocks/command_block",
        "south": "blocks/command_block",
        "west": "blocks/command_block"
    }
}
New Image of the top (up) of Command Blocks:
Image
To do this, I simply copied the Crafting Table's JSON file contents to the Command Block's JSON file and changed what need to be changed. After this worked, I wanted to take it a step further and tried my luck at getting what I wanted Sea Lanterns to look like, and it worked, sort of. Here is the info of Sea Lanterns:
Spoiler:
Code: Select all
{
    "ambientocclusion": false,
    "textures": {
        "particle": "blocks/glass",
        "glass": "blocks/glass",
        "sea_lantern": "blocks/sea_lantern"
    },
    "elements": [
        {   "__comment": "Glass shell",
            "from": [ 0, 0, 0 ],
            "to": [ 16, 16, 16 ],
            "faces": {
                "down":  { "uv": [ 0, 0, 16, 16 ], "texture": "#glass" },
                "up":    { "uv": [ 0, 0, 16, 16 ], "texture": "#glass" },
                "north": { "uv": [ 0, 0, 16, 16 ], "texture": "#glass" },
                "south": { "uv": [ 0, 0, 16, 16 ], "texture": "#glass" },
                "west":  { "uv": [ 0, 0, 16, 16 ], "texture": "#glass" },
                "east":  { "uv": [ 0, 0, 16, 16 ], "texture": "#glass" }
            }
        },
        {   "__comment": "Inner sea_lantern texture",
            "from": [ 3, 3, 3 ],
            "to": [ 13, 14, 13 ],
            "faces": {
                "down":  { "uv": [ 3, 3, 13, 13 ], "texture": "#sea_lantern" },
                "up":    { "uv": [ 3, 3, 13, 13 ], "texture": "#sea_lantern" },
                "north": { "uv": [ 3, 2, 13, 13 ], "texture": "#sea_lantern" },
                "south": { "uv": [ 3, 2, 13, 13 ], "texture": "#sea_lantern" },
                "west":  { "uv": [ 3, 2, 13, 13 ], "texture": "#sea_lantern" },
                "east":  { "uv": [ 3, 2, 13, 13 ], "texture": "#sea_lantern" }
            }
        }
	]
}
Here is what the item looks like:
Image

As you can tell, it worked. It looks exactly like how I wanted it to, but only in your hand and as an item:
Image
This image shows what it looks like placed as a block. The code above is from the "minecraft/models/block" path, and the "minecraft/models/item" path is a child directory to the previous path. So Minecraft recognizes the change, just not for the block itself.
There is nothing in the Game Output that would suggest a rendering crash. So what I ask is if anybody could help me figure out: a) If the center part of a beacon is hard coded or can be changed using the JSON files, and b) How so?

Any help would be great as I used the Game Output to help me fix errors in the JSON file, and since there is nothing to indicate any errors, I have no idea on how to fix it.

Re: Help with JSON files

Posted: Thu May 21, 2015 5:15 am
by eah
I notice the beacon texture is 16x16 (to be used for each face), while the sea lantern texture is 16x80 (different texture for each face). Maybe that has something to do with it.

If you've drawn your own sea lantern texture, make it 16x16 only.

EDIT: Figured out the sea lantern texture is larger because it's animated.

Re: Help with JSON files

Posted: Thu May 21, 2015 7:49 am
by meloetta_344
The animated file for Sea Lanterns did not work with it so I had to shrink the file down to 16x16 to at least get it to show.

Re: Help with JSON files

Posted: Thu May 21, 2015 4:33 pm
by meloetta_344
Well, it appears that the way beacons are rendered in Minecraft is hard coded into the game :( . I tried using a model maker for Minecraft and took off the glass shell only to get it to render the way I wanted it to, but the area that did not have anything became invisible. So that won't work, bummer. Looks like the only way to get it to work is to find a mod, or make one, that will give blocks transparency similar to glass and then try it again.

Re: Help with JSON files

Posted: Wed May 27, 2015 12:32 pm
by Puged
JSON and iOS CoreData are ruining my happiness at the moment...
Spoiler:
DataManager.getCoursesFromProfsquireWithSuccess { (coursesData) -> Void in
let startTime = CFAbsoluteTimeGetCurrent()

let json = JSON(data: coursesData)
for index in 0...json.count-1 {

var newDeptItem: Department!
if let data = json[index]["department"].string {
let fetchRequest = NSFetchRequest(entityName: "Department")
let predicate = NSPredicate(format: "title == %@", data)
fetchRequest.predicate = predicate
if let fetchResults: [Department]? = managedObjectContext!.executeFetchRequest(fetchRequest, error: nil) as? [Department] {
newDeptItem = fetchResults![0]
} else {
newDeptItem = NSEntityDescription.insertNewObjectForEntityForName("Department", inManagedObjectContext: managedObjectContext!) as! Department
newDeptItem.title = data
}
}

let newGDItem = NSEntityDescription.insertNewObjectForEntityForName("GradeDistribution", inManagedObjectContext: managedObjectContext!) as! GradeDistribution
if let a = json[index]["a"].number {
newGDItem.a = a
}
if let b = json[index]["b"].number {
newGDItem.b = b
}
if let c = json[index]["c"].number {
newGDItem.c = c
}
if let d = json[index]["d"].number {
newGDItem.d = d
}
if let f = json[index]["f"].number {
newGDItem.f = f
}
if let w = json[index]["w"].number {
newGDItem.w = w
}
newGDItem.total = Int(newGDItem.a) + Int(newGDItem.b) + Int(newGDItem.c) + Int(newGDItem.d) + Int(newGDItem.f)


let newCrsItem = NSEntityDescription.insertNewObjectForEntityForName("Course", inManagedObjectContext: managedObjectContext!) as! Course
newCrsItem.department = newDeptItem
newCrsItem.grade_distribution = newGDItem
if let prof_id = json[index]["professor_id"].number {
let fetchRequest = NSFetchRequest(entityName: "Professor")
let predicate = NSPredicate(format: "id == %@", prof_id)
fetchRequest.predicate = predicate
if let fetchResults = managedObjectContext!.executeFetchRequest(fetchRequest, error: nil) as? [Professor] {
if fetchResults.count != 0 {
newCrsItem.professor = fetchResults[0]
} else {
println("Couldn't find professor with id \(prof_id)")
}
}
}
if let crs_id = json[index]["id"].number {
newCrsItem.id = crs_id
}
if let course_name = json[index]["course"].string {
newCrsItem.title = course_name
}
if let semester = json[index]["semester"].string {
newCrsItem.semester = semester
}
if let yr = json[index]["year"].number {
newCrsItem.year = yr
}
if let section = json[index]["section"].number {
newCrsItem.section = section
}
}
println("Course data parsing and storing took \(CFAbsoluteTimeGetCurrent() - startTime) s.")
...just thought I'd share my current JSON frustrations :}