Jump to content

Recommended Posts

Posted

Is there anything special that needs to be done to get a client-side patch to work in multiplayer?

My patch:

[
    {
        "file": "game:blocktypes/stone/cobble/cobbleslab.json",
        "op": "replace",
        "path": "/textures",
        "value": {
		horizontals: { base: "block/stone/cobblestoneslab/{rock}" },
		up: { base: "block/stone/cobblestoneslabtop/{rock}*" },
		down: { base: "block/stone/cobblestone/{rock}*" }
        }
    }
]

 

Posted
5 hours ago, The Insanity God said:

The `Side` should be set to `Client` inside the modinfo.json (and possibly also in the patch itself) and well if the server is using fairplay guardian (mod for restricting client mods on a server) you might need to get it whitelisted

The modinfo does have it set to client, dunno how I'd set that in the patch (not seen it on the wiki), and server doesn’t have that mod (it's my server).

Posted (edited)
3 minutes ago, Diff said:

It works in single player though? How are you installing the mod? Are you just putting it in your client mod folder?

Yes to both.
It's in my "AppData\Roaming\VintagestoryData\Mods" folder, and works fine in single-player.
I'll also state, that's it's only the patches of this texture mod that's not working in multi-player, every thing non-patch related loads fine.

Edited by Slye_Fox
Posted
17 hours ago, Slye_Fox said:

The modinfo does have it set to client, dunno how I'd set that in the patch (not seen it on the wiki), and server doesn’t have that mod (it's my server).

Essentially the same way as you'd do in the ModInfo, though if the mod is already marked as client side then this will only enforce that the patch happens during the client side code and not during the server side code when possible.

[
  {
    "file": "game:blocktypes/stone/cobble/cobbleslab.json",
    "op": "replace",
    "path": "/textures",
    "value": {
      "horizontals": { "base": "block/stone/cobblestoneslab/{rock}" },
      "up": { "base": "block/stone/cobblestoneslabtop/{rock}*" },
      "down": { "base": "block/stone/cobblestone/{rock}*" }
    },
    "side": "Client"
  }
]
Posted
50 minutes ago, The Insanity God said:

Essentially the same way as you'd do in the ModInfo, though if the mod is already marked as client side then this will only enforce that the patch happens during the client side code and not during the server side code when possible.

[
  {
    "file": "game:blocktypes/stone/cobble/cobbleslab.json",
    "op": "replace",
    "path": "/textures",
    "value": {
      "horizontals": { "base": "block/stone/cobblestoneslab/{rock}" },
      "up": { "base": "block/stone/cobblestoneslabtop/{rock}*" },
      "down": { "base": "block/stone/cobblestone/{rock}*" }
    },
    "side": "Client"
  }
]

Oddly, adding the "side" line to the patch actually stops it working in single-player too.

Posted

Long shot, but I believe it may need to be lower case "client". The examples on the wiki and the majority of examples I can scrape together on GitHub are client: "server" rather than client: "Server". The few on GitHub that are client side patches do use a lower case "client".

Posted
16 minutes ago, Slye_Fox said:

Oddly, adding the "side" line to the patch actually stops it working in single-player too.

Huh, maybe this kinda patch just somehow doesn't work when run client side and because you added the "side" line it now enforces the patch happen during client side logic (instead of happening earlier) it stopped working 🤔
 

2 minutes ago, Diff said:

Long shot, but I believe it may need to be lower case "client". The examples on the wiki and the majority of examples I can scrape together on GitHub are client: "server" rather than client: "Server". The few on GitHub that are client side patches do use a lower case "client".

It's case insensitive, in the code It's actually capitalized so if it wasn't then lowercase would likely fail :P

image.png.ba231876a3614c166161fa8c0dfa459a.png

  • Thanks 1
Posted
46 minutes ago, Diff said:

Long shot, but I believe it may need to be lower case "client". The examples on the wiki and the majority of examples I can scrape together on GitHub are client: "server" rather than client: "Server". The few on GitHub that are client side patches do use a lower case "client".

It didn't work with either case.

Posted

Changing textures need to be done server side, because all the information of how a block/item etc should render, is transmitted from the server to the client in a multiplayer setting.

The reason it works in singleplayer is simple, you ARE the server, as well as the client.

Change it to "Universal", and it should be fine.

Posted
1 minute ago, xXx_Ape_xXx said:

Changing textures need to be done server side, because all the information of how a block/item etc should render, is transmitted from the server to the client in a multiplayer setting.

The reason it works in singleplayer is simple, you ARE the server, as well as the client.

Change it to "Universal", and it should be fine.

Does that mean that there's no way to have it so only the client needs the mod?

Posted (edited)
15 minutes ago, Slye_Fox said:

Does that mean that there's no way to have it so only the client needs the mod?

Yes there is a way.

If all your mod does is to change textures for various blocks/items, you don't need to patch anything.
Set the side to "client" in your modinfo.json.

 

All you need to do, is to create your custom textures and name them exactly the same as the textures you're trying to replace. Then place them inside the "game" name space in your mod asset folder, with the exact same placement as the texture has in vanilla game. And this is important, the path and the names must match what you're trying to replace.

To clarify, here's a picture of the file structure of a mod that will replace the textures for granite cobblestone:

image.png.73797381ee145a031bba8491496a9c46.png

It does not matter if the texture you want to replace is located in the creative,game or survival folders in the vanilla game, they are all referenced with the "game" prefix when targeting them in mods. This method uses the compability layer of the API.

For more information about how compaility "patching" works, you can read about it here in the wiki: Wiki: CompatibilityLib

 

If anything is unclear, just ping me and I'll take a look.

 

Edited by xXx_Ape_xXx
  • Thanks 1
Posted

It doesn’t just replace the textures, it changes it to use a different set of textures on certain sides.
This is also not the only patch In the mod, just the first I grabbed.

Another patch example is for the Polished Slabs;

[
    {
        "file": "game:blocktypes/stone/polished/polishedrockslab.json",
        "op": "replace",
        "path": "/texturesByType",
        "value": {
		"*-up-free": {
			horizontals: { base: "block/stone/polishedrockslab/{rock}" },
			verticals: { base: "block/stone/polishedrock/{rock}" }
		},
		"*-down-free": {
			horizontals: { base: "block/stone/polishedrockslab/{rock}" },
			verticals: { base: "block/stone/polishedrock/{rock}" }
		},
		"*-north-free": {
			"verticals": { base: "block/stone/polishedrockslab/{rock}" },
			"east": { base: "block/stone/polishedrockslab/{rock}", rotation: 90 },
			"west": { base: "block/stone/polishedrockslab/{rock}", rotation: 90 },
			"north": { base: "block/stone/polishedrock/{rock}" },
			"south": { base: "block/stone/polishedrock/{rock}" }
		},
		"*-south-free": {
			"verticals": { base: "block/stone/polishedrockslab/{rock}" },
			"east": { base: "block/stone/polishedrockslab/{rock}", rotation: 90 },
			"west": { base: "block/stone/polishedrockslab/{rock}", rotation: 90 },
			"north": { base: "block/stone/polishedrock/{rock}" },
			"south": { base: "block/stone/polishedrock/{rock}" }
		},
		"*-east-free": {
			"verticals": { base: "block/stone/polishedrockslab/{rock}", rotation: 90 },
			"east": { base: "block/stone/polishedrock/{rock}" },
			"west": { base: "block/stone/polishedrock/{rock}" },
			"north": { base: "block/stone/polishedrockslab/{rock}", rotation: 90 },
			"south": { base: "block/stone/polishedrockslab/{rock}", rotation: 90 }
		},
		"*-west-free": {
			"verticals": { base: "block/stone/polishedrockslab/{rock}", rotation: 90 },
			"east": { base: "block/stone/polishedrock/{rock}" },
			"west": { base: "block/stone/polishedrock/{rock}" },
			"north": { base: "block/stone/polishedrockslab/{rock}", rotation: 90 },
			"south": { base: "block/stone/polishedrockslab/{rock}", rotation: 90 }
		}
        }
    }
]

 

Posted
1 hour ago, xXx_Ape_xXx said:

Changing textures need to be done server side, because all the information of how a block/item etc should render, is transmitted from the server to the client in a multiplayer setting.

The reason it works in singleplayer is simple, you ARE the server, as well as the client.

Change it to "Universal", and it should be fine.

Wait, I just realised something.
You say that this mod only works as a 'both' type mod.
But there are already client side only mods that do work in multiplayer, eg; Reforged Tools.

Posted

Yes, that mod uses the exact method I described above, by replacing the shape files with its own versions. So when the server tells the client to render a tool, it sends info to the client of what file to look up, and since the mod have replaced the shape with its own, the client then looks up the new shape file provided by the mod for all its info. 

Posted (edited)
16 hours ago, xXx_Ape_xXx said:

Yes, that mod uses the exact method I described above, by replacing the shape files with its own versions. So when the server tells the client to render a tool, it sends info to the client of what file to look up, and since the mod have replaced the shape with its own, the client then looks up the new shape file provided by the mod for all its info. 

Okay, then is it possible to make these blocks use a custom shape file instead of the default one, or are the blocks hardcoded to use those shapes?

 

The reason I'm trying to get this to work is that I'm not just replacing textures, but also fixing some errors.
For example:

image.thumb.png.4b0355bf3562171195d60863eb9cbc8c.png

Edited by Slye_Fox
Posted (edited)

Yes, just make your own shape file and name it the same as the shape you want to replace, then place it within the "game" namespace, aka a folder inside your mods asset folder called game, at the same location you would find the vanilla shape you want to replace.

So if the file is called "slab-up.json" and is located in "your-game-install-dir/assets/survival/shapes/block/basic/slab/",
then you create your shape, name it exactly the same, and place it in the folder "assets/game/shapes/block/basic/slab/" within your mod.

When the game loads, the Compability Lib will look for these files and replace any it finds that match vanilla files, with your version provided in your mod.
This same method can, to some extent, also be used to swap files in other mods, though patching is usually the safer way to go in these circumstances.

 

Edit: They are not hardcoded per se, as they are defined in the blocktype/itemtype json files, and can easily be patched if need be. But then it's no longer a client only mod, as only the server reads the blocktype/itemtype files in a multiplayer setting.

Edited by xXx_Ape_xXx
Posted
14 minutes ago, xXx_Ape_xXx said:

Yes, just make your own shape file and name it the same as the shape you want to replace, then place it within the "game" namespace, aka a folder inside your mods asset folder called game, at the same location you would find the vanilla shape you want to replace.

So if the file is called "slab-up.json" and is located in "your-game-install-dir/assets/survival/shapes/block/basic/slab/",
then you create your shape, name it exactly the same, and place it in the folder "assets/game/shapes/block/basic/slab/" within your mod.

When the game loads, the Compability Lib will look for these files and replace any it finds that match vanilla files, with your version provided in your mod.
This same method can, to some extent, also be used to swap files in other mods, though patching is usually the safer way to go in these circumstances.

So, if I'm understanding right;
While I can change the shape file, it would affect all the blocks that use it, not just the ones I want to change.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.