Skip to content

ResourcePackFile

Namespace Mc.Scripting.Content · Kind class (sealed)

public sealed class ResourcePackFile

A built resource pack: the zip, its SHA-1 and the id clients know it by.

Member Description
byte[] Bytes { get; } The zip.
Uuid Id { get; } The pack id (derived from the name: a pack of the same name replaces the older one on the client).
string Name { get; } The pack name.
string Sha1 { get; } The SHA-1 of the zip (40 lower-case hex characters).
int Size { get; } The size of the zip in bytes.
public byte[] Bytes { get; }

The zip.

public Uuid Id { get; }

The pack id (derived from the name: a pack of the same name replaces the older one on the client).

public string Name { get; }

The pack name.

public string Sha1 { get; }

The SHA-1 of the zip (40 lower-case hex characters).

public int Size { get; }

The size of the zip in bytes.

Member Description
ResourcePack Publish(bool required = false, Component? prompt = null) Hosts the zip with ResourcePackHost and returns the description a client needs.
void SendTo(Player player, bool required = false, Component? prompt = null) Hosts the pack (see ResourcePackFile.Publish) and asks a player to download it.
ResourcePack ToResourcePack(string url, bool required = false, Component? prompt = null) The pack as the packet a client needs, for a URL you host yourself.
void WriteTo(string path) Writes the zip to a file.
public ResourcePack Publish(bool required = false, Component? prompt = null)

Hosts the zip with ResourcePackHost and returns the description a client needs.

Parameters

Name Type Description
required bool = false Whether the player must accept it.
prompt Component? = null Text shown in the download prompt.

Returns ResourcePack: The resource pack description.

Throws

  • System.InvalidOperationException: The built-in host is off (content.pack_host_port is 0 and ResourcePackHost.Start was not called).
public void SendTo(Player player, bool required = false, Component? prompt = null)

Hosts the pack (see ResourcePackFile.Publish) and asks a player to download it.

Parameters

Name Type Description
player Player The player.
required bool = false Whether he must accept it.
prompt Component? = null Text shown in the download prompt.
public ResourcePack ToResourcePack(string url, bool required = false, Component? prompt = null)

The pack as the packet a client needs, for a URL you host yourself.

Parameters

Name Type Description
url string Where the zip is downloadable.
required bool = false Whether the player must accept it (declining kicks him).
prompt Component? = null Text shown in the download prompt.

Returns ResourcePack: The resource pack description.

public void WriteTo(string path)

Writes the zip to a file.

Parameters

Name Type Description
path string The file path.

Component · Player · ResourcePack · Uuid