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

[ISSUE]: Custom Peripheral Overwritten by Mod's Peripheral #6

Open
Mugiwaxar opened this issue Sep 27, 2024 · 4 comments
Open

[ISSUE]: Custom Peripheral Overwritten by Mod's Peripheral #6

Mugiwaxar opened this issue Sep 27, 2024 · 4 comments
Assignees
Labels
confirmed bug/issue has been confirmed by one of the devs, and was able to reporduce it

Comments

@Mugiwaxar
Copy link

Mugiwaxar commented Sep 27, 2024

Mod Version
KJSCC-2002-1.0.2 for forge 1.20.1

Describe the bug

Hello,

I am trying to add functions to an existing peripheral. Following the tutorial, I attempted to extend the Electric Motor from the "Create Crafts & Additions" mod.

However, it seems that my custom peripheral is being overwritten by the mod's own peripheral. You can see the mod's code on this page:

https://github.com/mrh0/createaddition/blob/1.20.1/src/main/java/com/mrh0/createaddition/compat/computercraft/ElectricMotorPeripheral.java

How can I resolve this issue?

Thank you for your assistance!

To Reproduce
Steps to reproduce the behavior:
1: Add a peripheral and functions
2: Load the game
3: Check with CC:Tweaked computer
4: Peripheral type is still the mod one, no functions added
5: Go to GitHub and post the issus

@wolfieboy09 wolfieboy09 added the needs confirmation One of the devs need to check if it can be re-created label Sep 28, 2024
@wolfieboy09 wolfieboy09 self-assigned this Sep 28, 2024
@wolfieboy09
Copy link
Owner

wolfieboy09 commented Sep 28, 2024

What is the script you are using to add functions so I can test it?

@Mugiwaxar
Copy link
Author

files.zip
Here 3 files:

  • My mods list
  • The KubeJS script
  • The computer lua script

According to the computer's output, the Electric Motor is still identified as 'electric_motor' instead of 'multiperipheral'.

@wolfieboy09 wolfieboy09 added confirmed bug/issue has been confirmed by one of the devs, and was able to reporduce it and removed needs confirmation One of the devs need to check if it can be re-created labels Sep 29, 2024
@wolfieboy09
Copy link
Owner

I changed the code to

ComputerCraftEvents.peripheral(event => {
    event.registerPeripheral("test", "createaddition:electric_motor")
    .mainThreadMethod("aTestFunction", (container) => {
        return "hi!!!"
    })
})

and even kept the "test" part the original, and it was not changing to "multiperipheral" as it should be

@Mugiwaxar
Copy link
Author

I’ve tried several methods and searched through the source code. Apparently, CC: Tweaked prioritizes classes with the IPeripheral interface from mods, and if it doesn’t find anything, it looks at those provided by the API. I had to create a mod and use Mixins to add my own functions to already created peripherals.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
confirmed bug/issue has been confirmed by one of the devs, and was able to reporduce it
Projects
None yet
Development

No branches or pull requests

2 participants