Sorry, this is abandoned and archived now.
Jython still only supports Python 2 which is hopelessly outdated these days.
AFAICS this was the state:
- It was able to run Python scripts under Minecraft/Forge 1.11 (but I cannot remember, so I might err)
- Each Python script runs in an independent Thread
- It was probably able to read all Minecraft objects and elements. I only tried a few things.
- I doubt it can alter things in Minecraft due to the threading (this would lead to crashes!)
- I do not think it even is portable to newer Minecraft releases
Minecraft Forge module to run Python scripts
This is under development, so not all features are implemented for now!
- Locate the
.minecraftfolder. Everything needs to be put below that:- Mac:
~/Library/Application Support/minecraft(use Finder :: Go :: Folder) - Unix:
$HOME/.minecraft - Windows:
%APPDATA%\.minecraft
- Mac:
- Download suitable
pymcfo*.jarfrom "build" branch (or compile it yourself, it's inbuild/libs/then) - Place the
pymcfo*.jarinto dirmods - Run Minecraft once. This creates directory
pymcfowith following subdirs:iniwhen Minecraft is started (before entering world)srvon the Minecraft server sideusron the Minecraft client siderunfor chat (or server console)/pycommandlibwhere Jython and optional additional libs can be placed
- Download Jython from jython.org
- Put
jython*.jarin dirmods. Put(Does not work for unknown reason)jython*.jarin dirlibbelowpymcfo.- The copy I use is on "libs" branch
- Put
- Download (or write) Python scripts. Those scripts are text files and end on
.py - Place Python scripts into the proper directory (
ini/srv/usr/run) - As always: Be careful, as insecure scripts (those from unknown sources) can harm your data, as scripts can access everything on your computer.
Then:
- Launch Minecraft with Forge
- Module
pymcforeads all files at the proper stages - Please keep in mind, each script runs in it's own thread, so they all run in parallel.
- See
examples/folder for examples
On OS-X, you probably need some Linux command compatibility:
git clone --recursive https://github.com/hilbix/macshim.git cd macshim make make installMake sure,
$HOME/bin/is in yourPATH.
This should do, under Linux, OS-X and Ubuntu/Windows (Windows 10 creators update and above):
git clone --recursive https://github.com/hilbix/pymcfo.git
cd pymcfo
make
And I think this already is much too complex.
What I would like to see is just a link which can be clicked to build everything.
- No complex questions asked except, perhaps, a local target folder.
- No additional installations or updates of your environment needed.
- No additional configuration needed, as everything is readily configured.
- No additional explanations needed, as it just works.
- And this must support, at least, Linux, Windows and OS-X.
Notes:
- After
make, the module source is linked to ../pymcfo.jar - The module needs the corresponding Forge version to run.
Update Forge?
-
I did not find any better solution than that yet:
- Go to https://files.minecraftforge.net/
- Find the Forge version you want to use
- Hover over to "MCP" and click the
(i)button. - Open the ZIP with 7-zip or similar.
- Find the file
build.gradlein the ZIP - Show it as text (in 7-zip just press
F4) - Scroll down to the
minecraft {block. - Open your local project file
build.gradle. - Update the
minecraft {block of your local file accordingly - Be sure to replace
versionandmappings, as they belong together!
Afterwards run Gradle task
SetupDecompWorkspaceand follow the yellow brick road. Or just run:make
Why?
- Because I was unable to find Python for Forge.
Why Forge?
- Because Forge runs on Servers as well as on standalone Clients.
Why Python?
- Jython easily integrates into Java.
- It is scripting and easy to change interactively.
- So no need to restart Minecraft while changing scripts.
Why no other Language?
- Forge includes Scala already, but I am not used to Scala, sorry.
- I like Python, everything is readily available and was easy to integrate.
Jython?
- This is a Python interpreter written in Java.
PyMcFo?
-
Sorry, I did not find a catchy name.
If you have a better idea, and allow me to use this freely (see License), I am all ears.
Logo?
-
Sorry, I am not into graphics.
If you have a nice logo (please SVG), and allow me to use this freely (see License), I am all ears.
git submodules?
-
Some people think,
git submoduleis evil. Many alternatives were developed, likegitslave,git subtree,git subrepoandgit monorepo. However, git submodules offer one unique feature: You can support rewriting of history without breaking it!Thanks to this unique feature, you can work against the problem of ever growing
gitrepo data.For example, in future I can remove old builds or old variants of the big
libs/jython-*.jarwithout trouble.3 And I can split thegitrepo into a small main repo an a big overwhelming archive repo. You then cangit fetchthe archive into your local repo to bring back archived SHAs temporarily. The main repo still stays fully functional and operable, without any holes nor any broken parts.Without
git submoduleyou need to rewrite history by rebasing to be able to remove files from commits.
License?
-
For all the license files please have a look into directory
license/. -
For everything written by me (directories
src/andexamples/), following License applies:This Works is placed under the terms of the Copyright Less License, see file COPYRIGHT.CLL. USE AT OWN RISK, ABSOLUTELY NO WARRANTY.`The CLL is a free license, with free as in free beer and free speech and free baby.
Contact?
- As I do not read mails, open an issue on Github or send a pull request.
- Sorry, my pager https://hydra.geht.net/pager.php is currently down. But as soon as it is up again you can use it, of course.
- more examples
- Telnet type service for interactive Python
- way to safely alter Minecraft objects from within Python
- Java wrappers for Python, such that this all can be done from Python
- start python scripts from server console
- start python scripts from chat
Perhaps somebody else can enlighten me with Gradle:
- How to edit Gradle such, that build copies
examples/subdirectories torun/output (probably only in IntelliJ Idea? Currently I add build artifacts for that manually which is not nice.) - How to edit Gradle such, that build creates the empty directory
run/. As if it is missing (git clean -x -f -d) build fails in IntelliJ. - A short, really easy to understand, comprehensive manual of Gradle which a complete coverage of all the gory details I might want to know about (like the previous points).