block_entity_renderers_converter.py 677 B

123456789101112131415161718
  1. rendererLineStart = ".renderer(() -> "
  2. allTileEntities = "../src/main/java/com/simibubi/create/AllTileEntities.java"
  3. lines = []
  4. file = open(allTileEntities)
  5. for line in file:
  6. if rendererLineStart in line:
  7. if "//" in line:
  8. lines.append(line)
  9. continue
  10. toReplace = line.split(rendererLineStart)[1].split(")")[0]
  11. rendererClass = toReplace.split("::")[0]
  12. newLine = line.replace(toReplace, "ctx -> new %s(ctx.getBlockEntityRenderDispatcher())" % rendererClass)
  13. lines.append(newLine)
  14. else: lines.append(line)
  15. out = open("../src/main/java/com/simibubi/create/AllTileEntitiesNew.java", "a")
  16. out.writelines(lines)