Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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: 2 months ago
JSON representation

A library containing Jython for use within minecraft mods

Awesome Lists containing this project

README

        

[![downloads](https://img.shields.io/modrinth/dt/jythonmc?color=00AF5C&label=modrinth%20downloads&style=flat-square&logo=modrinth)](https://modrinth.com/mod/jythonmc/versions)
[![followers](https://img.shields.io/modrinth/followers/jythonmc?color=00AF5C&label=modrinth%20followers&style=flat-square&logo=modrinth)](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
```