Something went wrong. Try again.
a fabric mods which makes the bow display the correct arrow
Something went wrong. Try again.
real-arrow-tip item-model-generator.py
6.8 kB · 199 lines
Python
at main
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200import osimport json
MODEL_DIR = "./src/main/resources/assets/real_arrow_tip/models/item/"
ARROW_TYPES = [ {"item": "minecraft:spectral_arrow", "name": "spectral", "tint": None}, {"item": "minecraft:tipped_arrow", "name": "tipped", "tint": -13083194},]
def generate_bow_arrow_json(arrow_data): paths = [ f"real_arrow_tip:item/bow_pulling_0_{arrow_data["name"]}", f"real_arrow_tip:item/bow_pulling_1_{arrow_data["name"]}", f"real_arrow_tip:item/bow_pulling_2_{arrow_data["name"]}", ]
range_dispatch = { "type": "minecraft:range_dispatch", "property": "minecraft:use_duration", "scale": 0.05, "entries": [ { "model": { "type": "minecraft:model", "model": paths[1], }, "threshold": 0.65, }, { "model": { "type": "minecraft:model", "model": paths[2], }, "threshold": 0.9, }, ], "fallback": { "type": "minecraft:model", "model": paths[0], }, }
if arrow_data["tint"] is not None: for entry in range_dispatch["entries"]: entry["model"]["tints"] = [{"type": "real_arrow_tip:projectile", "default": arrow_data["tint"]}] range_dispatch["fallback"]["tints"] = [{"type": "real_arrow_tip:projectile", "default": arrow_data["tint"]}]
return { "when": arrow_data["item"], "model": range_dispatch, }
def create_bow(): json_structure = { "model": { "type": "minecraft:condition", "property": "minecraft:using_item", "on_false": { "type": "minecraft:model", "model": "minecraft:item/bow" }, "on_true": { "type": "minecraft:select", "property": "real_arrow_tip:charge_type", "cases": [], "fallback": { "type": "minecraft:range_dispatch", "property": "minecraft:use_duration", "scale": 0.05, "entries": [ { "model": { "type": "minecraft:model", "model": "minecraft:item/bow_pulling_1" }, "threshold": 0.65 }, { "model": { "type": "minecraft:model", "model": "minecraft:item/bow_pulling_2" }, "threshold": 0.9 } ], "fallback": { "type": "minecraft:model", "model": "minecraft:item/bow_pulling_0" }, }, }, } }
for arrow in ARROW_TYPES: arrow_json = generate_bow_arrow_json(arrow) if arrow_json: json_structure["model"]["on_true"]["cases"].append(arrow_json)
output_file = "generated_bow.json" with open(output_file, "w", encoding="utf-8") as f: json.dump(json_structure, f, indent=2)
print(f"created: {output_file}")
def generate_crossbow_arrow_json(arrow_data, namespace, multishot_namespace): model = { "model": { "type": "minecraft:condition", "property": "minecraft:component", "predicate": "minecraft:enchantments", "value": [ { "enchantments": "minecraft:multishot" } ], "on_true": { "type": "minecraft:model", "model": f"{multishot_namespace}:item/crossbow_{arrow_data["name"]}_multishot", }, "on_false": { "type": "minecraft:model", "model": f"{namespace}:item/crossbow_{arrow_data["name"]}", } }, "when": arrow_data["item"] }
if arrow_data["tint"] is not None: model["model"]["on_true"]["tints"] = [{"type": "real_arrow_tip:projectile", "default": arrow_data["tint"]}] model["model"]["on_false"]["tints"] = [{"type": "real_arrow_tip:projectile", "default": arrow_data["tint"]}]
return model
def create_crossbow(): json_structure = { "model": { "type": "minecraft:select", "property": "real_arrow_tip:charge_type", "cases": [], "fallback": { "type": "minecraft:condition", "property": "minecraft:using_item", "on_false": { "type": "minecraft:model", "model": "minecraft:item/crossbow" }, "on_true": { "type": "minecraft:range_dispatch", "entries": [ { "model": { "type": "minecraft:model", "model": "minecraft:item/crossbow_pulling_1" }, "threshold": 0.58 }, { "model": { "type": "minecraft:model", "model": "minecraft:item/crossbow_pulling_2" }, "threshold": 1 } ], "fallback": { "type": "minecraft:model", "model": "minecraft:item/crossbow_pulling_0" }, "property": "minecraft:crossbow/pull" }, }, } }
arrow_json = generate_crossbow_arrow_json({"item": "minecraft:arrow", "name": "arrow", "tint": None}, "minecraft","real_arrow_tip") json_structure["model"]["cases"].append(arrow_json) arrow_json = generate_crossbow_arrow_json({"item": "minecraft:firework_rocket", "name": "firework", "tint": None}, "minecraft","real_arrow_tip") json_structure["model"]["cases"].append(arrow_json)
for arrow in ARROW_TYPES: arrow_json = generate_crossbow_arrow_json(arrow, "real_arrow_tip","real_arrow_tip") if arrow_json: json_structure["model"]["cases"].append(arrow_json)
output_file = "generated_crossbow.json" with open(output_file, "w", encoding="utf-8") as f: json.dump(json_structure, f, indent=2)
print(f"created: {output_file}")
create_bow()create_crossbow()