Solved Barges plugin throws Cannot convert type 'BaseEntity' to 'Oxide.Plugins.ChickenCoop'

magnumk

Patron
Supporter
I get this error when ChickenCoop is loaded before Barges. If they load the other way around there is no problem.
Barges:
Failed to compile: Cannot convert type 'BaseEntity' to 'Oxide.Plugins.ChickenCoop' via a reference conversion, boxing conversion, unboxing conversion, wrapping conversion, or null type conversion | Line: 2918, Pos: 47

Code on line 2918:
C#:
                   ChickenCoop chickenCoop = baseEntity as ChickenCoop;
                    if (chickenCoop != null)
                    {
                        for (int j = 0; j < chickenCoop.children.Count; j++)
                        {
                            FarmableAnimal farmableAnimal = chickenCoop.children[j] as FarmableAnimal;
                            if (farmableAnimal == null)
                                continue;
                            farmableAnimal.CancelInvoke(farmableAnimal.GetPrivateAction("MoveToNewLocation"));
                        }
                        continue;
                    }


Is this a Barges problem or ChickenCoop?

https://codefling.com/plugins/barges
 
It worked, thanks. I'll post to Barges developer and see what he says.
It's happening because the plugin name is the same as Facepunch's internal class name for their chicken coop. He just needs to apply the edit I showed you to address it

And if he says I need to rename my plugin, nope, not happening, mine was around before Facepunch even added their chicken coop 😆
 
Last edited:
Hm I was to quick..

Got new errors with CopyPaste


C#:
CopyPaste - Failed to compile: An expression of type 'BaseEntity' cannot be handled by a pattern of type 'ChickenCoop'. | Line: 986, Pos: 27

Code on 986, CopyPaste

C#:
if (entity is ChickenCoop chickenCoop && chickenCoop.IsValid() && !chickenCoop.IsDestroyed)
 
Hm I was to quick..

Got new errors with CopyPaste


C#:
CopyPaste - Failed to compile: An expression of type 'BaseEntity' cannot be handled by a pattern of type 'ChickenCoop'. | Line: 986, Pos: 27

Code on 986, CopyPaste

C#:
if (entity is ChickenCoop chickenCoop && chickenCoop.IsValid() && !chickenCoop.IsDestroyed)
Fuck 🫠
 
Back
Top
This plugin uses Oxide's permission system. Grant or revoke permissions using oxide.grant and oxide.revoke. You can assign them to individual players or groups using their Steam id or group name.
Chat commands start with a /, while console commands can be entered directly in the F1 console or server console. Use find <keyword> in console to search for available commands related to the plugin.
Settings are stored in the config file found under the config/ directory. You can edit this file manually, then reload the plugin to apply your changes.
Persistent data is saved in the data/ directory. This includes things like saved settings, usage stats, or player progress depending on the plugin. Deleting a data file will reset stored progress or customizations.
Language files are located in the lang/ folder. To translate messages, copy the en.json file into your target language folder (e.g. fr, de) and edit the values. Reload the plugin after changes to apply new messages.
This section lists public methods exposed by the plugin for use in other plugins. You can call these via the CallHook method. Make sure the plugin is loaded before calling its API to avoid null reference errors.
These are custom hooks that other plugins can listen for. Simply define a method with the same name and expected parameters in your plugin to handle the event. Hooks are triggered at key moments and are useful for extending or reacting to plugin behavior.
These hooks are injected into the game's code using Harmony. They let the plugin run code at key points in the game's internal logic. You can return values to block or modify behavior. Use with caution — these are powerful and can affect core mechanics.
Cart