Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add initial computercraft support. #2792

Open
wants to merge 1 commit into
base: 1.20.1
Choose a base branch
from

Conversation

tomprince
Copy link
Contributor

@tomprince tomprince commented Jan 27, 2025

What

This add computercraft support to some energy containers.
See #806.

Outcome

EU energy containers (including power substations) now can be queried for their stored energy and energy capacity.

Additional Information

image

Potential Compatibility Issues

The names and ids defined for peripherals are exposed to lua code, so changing them in the future will cause compatibility issues.

@tomprince tomprince changed the title WIP: Add computercraft support. Add initial computercraft support. Jan 27, 2025
@tomprince tomprince marked this pull request as ready for review January 27, 2025 07:47
@tomprince tomprince requested a review from a team as a code owner January 27, 2025 07:47
@tomprince
Copy link
Contributor Author

I think this is ready for review. It is definitely very minimal, but is usable as-is. It also partly covers a gap in the KubeJS implementation, as the support for energy containers does not support the power substation.

@Ghostipedia Ghostipedia added the type: feature New feature or request label Jan 28, 2025
@omergunr100
Copy link
Contributor

Resolve the merge conflicts and ping me on discord if I don't notice


private static BigInteger MAX_LONG = BigInteger.valueOf(Long.MAX_VALUE);

private static MethodResult toResult(BigInteger val) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lua treats all numbers as doubles, so there's no advantage to special-casing small values.
In CC:Tweaked specifically, values are converted by calling java.lang.Number#doubleValue(), so you can just pass the BigInteger into MethodResult.of() directly.
https://github.com/cc-tweaked/CC-Tweaked/blob/mc-1.20.x/projects/core/src/main/java/dan200/computercraft/core/lua/CobaltLuaMachine.java#L177

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants