Skip to content

Commit

Permalink
Implement case handling for assets
Browse files Browse the repository at this point in the history
Specified per #316 to change settings forcibly when the asset would be known to not work well with the default. Entirely driven by the json to avoid hardcoding, but only based on asset display names (so could clash with custom installed assets potentially)
  • Loading branch information
TheDuckCow committed Aug 2, 2022
1 parent 6d16dce commit 075a7c9
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 2 deletions.
11 changes: 10 additions & 1 deletion MCprep_addon/MCprep_resources/mcprep_data_update.json
Original file line number Diff line number Diff line change
Expand Up @@ -3941,5 +3941,14 @@
"water_overlay",
"water_still"
]
}
},
"mob_skip_prep": [
"Frog",
"Simple Villager (2.8+)",
"Glow Squid",
"Strider",
"Warden"
],
"make_real": ["chest", "chest_double"]

}
17 changes: 17 additions & 0 deletions MCprep_addon/mcprep_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ def draw(self, context):
ops = layout.operator("mcprep.mob_spawner", text=mob.name)
ops.mcmob_type = mob.mcmob_type

# Skip prep materials in case of unique shader.
if conf.json_data and mob.name in conf.json_data.get("mob_skip_prep", []):
ops.prep_materials = False


class MCPREP_MT_meshswap_place(bpy.types.Menu):
"""Menu for all the meshswap objects"""
Expand All @@ -112,6 +116,10 @@ def draw(self, context):
opr.block = blockset[0]
opr.location = util.get_cuser_location(context)

# Ensure meshswap with rigs is made real, so the rigs can be used.
if conf.json_data and blockset[1] in conf.json_data.get("make_real", []):
opr.make_real = True


class MCPREP_MT_item_spawn(bpy.types.Menu):
"""Menu for loaded item spawners"""
Expand Down Expand Up @@ -1060,6 +1068,11 @@ def mob_spawner(self, context):
p = row.operator("mcprep.mob_spawner", text="Spawn " + name)
if mcmob_type:
p.mcmob_type = mcmob_type

# Skip prep materials in case of unique shader.
if conf.json_data and name in conf.json_data.get("mob_skip_prep", []):
p.prep_materials = False

p = col.operator("mcprep.mob_install_menu")
p.mob_category = scn_props.spawn_rig_category

Expand Down Expand Up @@ -1162,6 +1175,10 @@ def meshswap_spawner(self, context):
p.block = block
p.method = method
p.location = util.get_cuser_location(context)
# Ensure meshswap with rigs is made real, so the rigs can be used.
if conf.json_data and block in conf.json_data.get("make_real", []):
p.make_real = True

else:
row.operator("mcprep.meshswap_spawner", text="Place block")
# something to directly open meshswap file??
Expand Down
1 change: 1 addition & 0 deletions MCprep_addon/spawner/spawn_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,7 @@ class MCPREP_OT_reload_spawners(bpy.types.Operator):

@tracking.report_error
def execute(self, context):
_ = util.load_mcprep_json() # For cases when to prep/make real.
bpy.ops.mcprep.reload_meshswap()
bpy.ops.mcprep.reload_mobs()
bpy.ops.mcprep.reload_items()
Expand Down
4 changes: 3 additions & 1 deletion MCprep_addon/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,9 @@ def load_mcprep_json():
"block_mapping_jmc": {},
"block_mapping_mineways": {},
"canon_mapping_block": {}
}
},
"mob_skip_prep": [],
"make_real": []
}
if not os.path.isfile(path):
conf.log("Error, json file does not exist: " + path)
Expand Down

0 comments on commit 075a7c9

Please sign in to comment.