mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 00:33:59 +00:00
resource packs: added new option remove_client_resources, fixed client packs being removed when forcing resource pack download
This commit is contained in:
parent
ee08286eca
commit
06ec8b8397
@ -2118,7 +2118,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
$pk = new ResourcePackStackPacket();
|
||||
$manager = $this->server->getResourcePackManager();
|
||||
$pk->resourcePackStack = $manager->getResourceStack();
|
||||
$pk->mustAccept = $manager->resourcePacksRequired();
|
||||
$pk->removeClientResourcePacks = $manager->removeClientResourcePacks();
|
||||
$this->dataPacket($pk);
|
||||
break;
|
||||
case ResourcePackClientResponsePacket::STATUS_COMPLETED:
|
||||
|
@ -35,7 +35,7 @@ class ResourcePackStackPacket extends DataPacket{
|
||||
public const NETWORK_ID = ProtocolInfo::RESOURCE_PACK_STACK_PACKET;
|
||||
|
||||
/** @var bool */
|
||||
public $mustAccept = false;
|
||||
public $removeClientResourcePacks = false;
|
||||
|
||||
/** @var ResourcePack[] */
|
||||
public $behaviorPackStack = [];
|
||||
@ -48,7 +48,7 @@ class ResourcePackStackPacket extends DataPacket{
|
||||
public $baseGameVersion = ProtocolInfo::MINECRAFT_VERSION_NETWORK;
|
||||
|
||||
protected function decodePayload(){
|
||||
$this->mustAccept = $this->getBool();
|
||||
$this->removeClientResourcePacks = $this->getBool();
|
||||
$behaviorPackCount = $this->getUnsignedVarInt();
|
||||
while($behaviorPackCount-- > 0){
|
||||
$this->getString();
|
||||
@ -68,7 +68,7 @@ class ResourcePackStackPacket extends DataPacket{
|
||||
}
|
||||
|
||||
protected function encodePayload(){
|
||||
$this->putBool($this->mustAccept);
|
||||
$this->putBool($this->removeClientResourcePacks);
|
||||
|
||||
$this->putUnsignedVarInt(count($this->behaviorPackStack));
|
||||
foreach($this->behaviorPackStack as $entry){
|
||||
|
@ -43,6 +43,8 @@ class ResourcePackManager{
|
||||
|
||||
/** @var bool */
|
||||
private $serverForceResources = false;
|
||||
/** @var bool */
|
||||
private $removeClientResourcePacks = false;
|
||||
|
||||
/** @var ResourcePack[] */
|
||||
private $resourcePacks = [];
|
||||
@ -71,6 +73,7 @@ class ResourcePackManager{
|
||||
$resourcePacksConfig = new Config($this->path . "resource_packs.yml", Config::YAML, []);
|
||||
|
||||
$this->serverForceResources = (bool) $resourcePacksConfig->get("force_resources", false);
|
||||
$this->removeClientResourcePacks = (bool) $resourcePacksConfig->get("remove_client_resources", false);
|
||||
|
||||
$logger->info("Loading resource packs...");
|
||||
|
||||
@ -136,6 +139,16 @@ class ResourcePackManager{
|
||||
return $this->serverForceResources;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether client-sided global resources will be removed.
|
||||
* Useful if you want to force vanilla resources.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function removeClientResourcePacks() : bool{
|
||||
return $this->removeClientResourcePacks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of resource packs in use, sorted in order of priority.
|
||||
* @return ResourcePack[]
|
||||
|
@ -3,6 +3,13 @@
|
||||
#Choose whether players must use your chosen resource packs to join the server.
|
||||
#NOTE: This will do nothing if there are no resource packs in the stack below.
|
||||
force_resources: false
|
||||
|
||||
#Choose whether players are allowed to use their own client-side packs in addition to the server ones.
|
||||
#If false, server packs will apply on top of client global packs.
|
||||
#If true, server packs will apply directly on top of vanilla and client packs will be removed.
|
||||
#You can use this with an empty resource stack to force vanilla-only textures.
|
||||
remove_client_resources: false
|
||||
|
||||
resource_stack:
|
||||
#Resource packs here are applied from bottom to top. This means that resources in higher packs will override those in lower packs.
|
||||
#Entries here must indicate the filename of the resource pack.
|
||||
|
Loading…
x
Reference in New Issue
Block a user