Metadata-Version: 2.4
Name: minescript
Version: 1.1.4
Summary: Python helper module for the local Minescript Fabric bridge
Keywords: minecraft,fabric,automation,minescript
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Games/Entertainment
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.9
Description-Content-Type: text/markdown

# MinePyScript

Installable Python package for the Minescript client bridge.

## Install

```text
py -m pip install .
```

## Build

```text
py -m build
```

## Notes

- This package talks to a local Minescript Fabric bridge over HTTP.
- It requires the Minecraft mod to be installed and running.
- Set `MINESCRIPT_PORT` if the bridge is not using the default port `47641`.

## Example

```python
import minescript

print(minescript.methods())
print(minescript.getplayerpos())
minescript.sendchat("Hello from Python")
minescript.closecurrentmenu()
```

## Litematica Compatibility

If your installed Minescript mod exposes Litematica or schematic-placement bridge methods, the package now provides nearby-placement helpers:

```python
import minescript

print(minescript.litematicamethods())
print(minescript.getnearestschematicplacement(radius=24))
print(minescript.getnearbyschematicplacements(radius=48, limit=8))
```

`litematicamethods()` returns the related runtime bridge methods advertised by the connected mod.
The nearby helpers resolve the best matching bridge method dynamically so they can work across compatible mod versions that use slightly different RPC names.

## Timed Use Helpers

Use the timed helpers when you want to hold left or right item use for a duration:

```python
import minescript

minescript.useitemfor(2.0)
minescript.useitemrightfor(1.5)
minescript.useitemleftfor(0.75)
```

`useitemfor()` and `useitemrightfor()` hold the use-item input.
`useitemleftfor()` holds the attack input for mining or attacking.

## Menu Close Fallback

If your running Minescript mod does not expose `closecurrentmenu` or `closemenu`, `minescript.closemenu()` uses fallback behavior automatically:

```python
import minescript

minescript.closemenu()
```

On Windows, it sends a native `Esc` keypress.

On other runners, the default stdout control payload is:

```python
{"command": "close_menu"}
```

Set `MINESCRIPT_MENU_CLOSE_COMMAND` if your Java runner expects a different command name.

If you want full Python-side control, you can still register a custom fallback and route it to your own Java injection path:

```python
import minescript

def close_menu_via_java():
    minescript.emitcontrol({"command": "close_menu_via_java"})

minescript.set_menu_close_handler(close_menu_via_java)
minescript.closemenu()
```

`emitcontrol()` sends a custom control payload to the Java runner over stdout.
`set_menu_close_handler()` overrides the built-in fallback when the HTTP bridge does not advertise a native menu-close method.
