From 075a7c99fa63dee5bfcd9185eeafe06fa24ad70a Mon Sep 17 00:00:00 2001 From: "Patrick W. Crawford" Date: Tue, 2 Aug 2022 00:49:34 -0700 Subject: [PATCH] Implement case handling for assets Specified per https://github.com/TheDuckCow/MCprep/issues/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) --- .../MCprep_resources/mcprep_data_update.json | 11 ++++++++++- MCprep_addon/mcprep_ui.py | 17 +++++++++++++++++ MCprep_addon/spawner/spawn_util.py | 1 + MCprep_addon/util.py | 4 +++- 4 files changed, 31 insertions(+), 2 deletions(-) diff --git a/MCprep_addon/MCprep_resources/mcprep_data_update.json b/MCprep_addon/MCprep_resources/mcprep_data_update.json index e653b6f2..d8978bd2 100644 --- a/MCprep_addon/MCprep_resources/mcprep_data_update.json +++ b/MCprep_addon/MCprep_resources/mcprep_data_update.json @@ -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"] + } \ No newline at end of file diff --git a/MCprep_addon/mcprep_ui.py b/MCprep_addon/mcprep_ui.py index 7a95988b..52209390 100755 --- a/MCprep_addon/mcprep_ui.py +++ b/MCprep_addon/mcprep_ui.py @@ -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""" @@ -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""" @@ -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 @@ -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?? diff --git a/MCprep_addon/spawner/spawn_util.py b/MCprep_addon/spawner/spawn_util.py index 87d4b24b..9f0aff38 100755 --- a/MCprep_addon/spawner/spawn_util.py +++ b/MCprep_addon/spawner/spawn_util.py @@ -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() diff --git a/MCprep_addon/util.py b/MCprep_addon/util.py index 8e4c6a4c..296f6071 100755 --- a/MCprep_addon/util.py +++ b/MCprep_addon/util.py @@ -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)