https://github.com/enderzombi102/jythonmc
A library containing Jython for use within minecraft mods
https://github.com/enderzombi102/jythonmc
fabricmc jython library python
Last synced: 12 months ago
JSON representation
A library containing Jython for use within minecraft mods
- Host: GitHub
- URL: https://github.com/enderzombi102/jythonmc
- Owner: ENDERZOMBI102
- License: mit
- Created: 2021-06-14T20:30:04.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2024-06-21T16:30:50.000Z (almost 2 years ago)
- Last Synced: 2025-04-12T09:11:44.134Z (12 months ago)
- Topics: fabricmc, jython, library, python
- Language: Java
- Homepage:
- Size: 4.18 MB
- Stars: 6
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://modrinth.com/mod/jythonmc/versions)
[](https://modrinth.com/mod/jythonmc)
_DISCLAIMER! THIS LIBRARY DOES NOT LET YOU CREATE MODS IN PYTHON!_
# JythonMC
A library providing Jython for use within minecraft mods.
# Use
There's two methods to initialize the python system:
1) Add `"jythonmc:use" : true` to `custom` in your `fabric.mod.json`
this will automatically start the python system when JythonMC is loaded
3) Call `com.enderzombi102.jythonmc.Jython.initSystem()`
this will initialize the python system, but if its already initialized it'll do nothing
After the system is initialized, you can use the python interpreter liek this:
```java
try ( PythonInterpreter python = new PythonInterpreter() ) {
python.setErr(System.err); // to set python's stderr
python.setOut(System.out); // to set python's stdout
python.exec(CODE); // executes the code in the string CODE
} catch (Exception e) {
e.printStackTrace(); // python exceptions are translated to java ones if nothing catch them
}
```
# Install
build.gradle
```gradle
repositories {
mavenCentral()
maven {
url 'https://repo.repsy.io/mvn/enderzombi102/mc/'
}
}
dependencies {
modImplementation "com.enderzombi102:JythonMC:$jythonmc_version"
}
```
gradle.properties
```properties
jythonmc_version=1.0.2
```