Jump to content

AddPrefabPostInit removes sounds from mobs


Recommended Posts

For example using this mod disables sounds of mobs if you are not the host.

Any way to fix this?

Here is the code:

function AddMap(prefab)
        table.insert(Assets, Asset("IMAGE", "images/" .. prefab .. ".tex"))
        table.insert(Assets, Asset("ATLAS", "images/" .. prefab .. ".xml"))
        AddMinimapAtlas("images/" .. prefab .. ".xml")
        AddPrefabPostInit(prefab, function(inst)
            inst.entity:AddMiniMapEntity()
            inst.MiniMapEntity:SetIcon(prefab .. ".tex")
        end)
end

 

Link to comment
Share on other sites

@DarkXero, do you know why adding a MinimapEntity component to an entity only on client (or only on the server) affects SoundEmitter? Is there some hidden network synchonization issue? Does this apply to other components as well, e.g. Light)?

Link to comment
Share on other sites

2 hours ago, Maris said:

Probably you should check if MiniMapEntity already exists before adding another one.

Yes, but I tested it with beefalo only. They didn't have sounds. And they don't start with a MiniMapEntity already.

8 hours ago, Muche said:

do you know why adding a MinimapEntity component to an entity only on client (or only on the server) affects SoundEmitter? Is there some hidden network synchonization issue?

No, and yes.

Despite what it looks like, MiniMapEntity has some networking. Make a server, enter it, and input something like:

Remote: c_find("multiplayer_portal").MiniMapEntity:SetIcon("glommer.png")

You will see that the change propagates to your client minimap.

8 hours ago, Muche said:

Does this apply to other components as well, e.g. Light)?

Light doesn't have any networking that breaks sounds, as far as I know.

Which is why you can have lights on your side, but still get hit by Charlie in the server.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
  • Create New...