Example #1
0
func esPlayerModelRemove(p *playerModelComponent) {
	if p.skin != "" {
		render.FreeSkin(p.skin)
	}
	if p.cape != "" {
		render.FreeSkin(p.cape)
	}
	if p.heldModel != nil {
		p.heldModel.Free()
	}
}
Example #2
0
func (p *playerListUI) free() {
	p.set(false)
	for _, pl := range p.info {
		if pl.skinHash != "" {
			render.FreeSkin(pl.skinHash)
		}
		if pl.capeHash != "" {
			render.FreeSkin(pl.capeHash)
		}
	}
}
Example #3
0
func (s *skullComponent) free() {
	if s.model != nil {
		s.model.Free()
		s.model = nil
	}
	if s.Owner != "" && s.OwnerSkin != nil {
		s.OwnerSkin = nil
		render.FreeSkin(s.Owner)
	}
}
Example #4
0
func (handler) PlayerListInfo(p *protocol.PlayerInfo) {
	playerList := Client.playerList.info
	for _, pl := range p.Players {
		if _, ok := playerList[pl.UUID]; (!ok && p.Action != 0) || (ok && p.Action == 0) {
			continue
		}
		switch p.Action {
		case 0: // Add
			i := &playerInfo{
				name:        pl.Name,
				uuid:        pl.UUID,
				displayName: pl.DisplayName,
				gameMode:    gameMode(pl.GameMode),
				ping:        int(pl.Ping),
			}
			for _, prop := range pl.Properties {
				if prop.Name == "textures" {
					if !prop.IsSigned {
						Client.network.SignalClose(errors.New("Missing signature from textures"))
						return
					}
					data, err := base64.StdEncoding.DecodeString(prop.Value)
					if err != nil {
						Client.network.SignalClose(err)
						continue
					}

					sig, err := base64.StdEncoding.DecodeString(prop.Signature)
					if err != nil {
						Client.network.SignalClose(err)
						continue
					}

					if err := verifySkinSignature([]byte(prop.Value), sig); err != nil {
						Client.network.SignalClose(err)
						return
					}

					var blob skinBlob
					err = json.Unmarshal(data, &blob)
					if err != nil {
						Client.network.SignalClose(err)
						continue
					}
					url := blob.Textures.Skin.Url
					if strings.HasPrefix(url, "http://textures.minecraft.net/texture/") {
						i.skinHash = url[len("http://textures.minecraft.net/texture/"):]
						render.RefSkin(i.skinHash)
						i.skin = render.Skin(i.skinHash)
					}
					url = blob.Textures.Cape.Url
					if strings.HasPrefix(url, "http://textures.minecraft.net/texture/") {
						i.capeHash = url[len("http://textures.minecraft.net/texture/"):]
						render.RefSkin(i.capeHash)
						i.cape = render.Skin(i.capeHash)
					}
				}
			}
			if i.skin == nil {
				i.skin = render.GetTexture("entity/steve")
			}
			i.skin = render.RelativeTexture(i.skin, 64, 64)
			playerList[pl.UUID] = i

			// Special case for self
			if !Client.entityAdded && i.uuid == Client.entity.UUID() {
				Client.entities.container.AddEntity(Client.entity)
				Client.entityAdded = true
			}
		case 1: // Update gamemode
			playerList[pl.UUID].gameMode = gameMode(pl.GameMode)
		case 2: // Update ping
			playerList[pl.UUID].ping = int(pl.Ping)
		case 3: // Update display name
			playerList[pl.UUID].displayName = pl.DisplayName
		case 4: // Remove
			i := playerList[pl.UUID]
			if i.skinHash != "" {
				render.FreeSkin(i.skinHash)
			}
			delete(playerList, pl.UUID)
		}
	}
}