wolfieboy09 / KubeJS-CC-Tweaked

Add ComputerCraft support from KubeJS for Forge and Fabric [Uploaded on CurseForge and Modrinth]
https://modrinth.com/mod/kubejs+cc-tweaked
GNU Lesser General Public License v2.1
7 stars 2 forks source link

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

Open Mugiwaxar opened 2 months ago

Mugiwaxar commented 2 months ago

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 commented 1 month ago

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

Mugiwaxar commented 1 month ago

files.zip Here 3 files:

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

wolfieboy09 commented 1 month ago

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 commented 1 month ago

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.